SUMO - Simulation of Urban MObility
HelpersEnergy.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // Helper methods for HBEFA-based emission computation
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <utils/common/SUMOTime.h>
34 #include <utils/common/ToString.h>
35 #include "HelpersEnergy.h"
36 
37 
38 // ===========================================================================
39 // method definitions
40 // ===========================================================================
54 }
55 
56 
57 double
58 HelpersEnergy::compute(const SUMOEmissionClass /* c */, const PollutantsInterface::EmissionType e, const double v, const double a, const double slope, const std::map<int, double>* param) const {
59  if (e != PollutantsInterface::ELEC) {
60  return 0.;
61  }
62  if (param == 0) {
63  param = &myDefaultParameter;
64  }
65  //@ToDo: All formulas below work with the logic of the euler update (refs #860).
66  // Approximation order could be improved. Refs. #2592.
67 
68  const double lastV = v - ACCEL2SPEED(a);
69  const double mass = param->find(SUMO_ATTR_VEHICLEMASS)->second;
70 
71  // calculate potential energy difference
72  double energyDiff = mass * 9.81 * slope * SPEED2DIST(v);
73 
74  // kinetic energy difference of vehicle
75  energyDiff += 0.5 * mass * (v * v - lastV * lastV);
76 
77  // add rotational energy diff of internal rotating elements
78  energyDiff += param->find(SUMO_ATTR_INTERNALMOMENTOFINERTIA)->second * (v * v - lastV * lastV);
79 
80  // Energy loss through Air resistance [Ws]
81  // Calculate energy losses:
82  // EnergyLoss,Air = 1/2 * rho_air [kg/m^3] * myFrontSurfaceArea [m^2] * myAirDragCoefficient [-] * v_Veh^2 [m/s] * s [m]
83  // ... with rho_air [kg/m^3] = 1,2041 kg/m^3 (at T = 20C)
84  // ... with s [m] = v_Veh [m/s] * TS [s]
85  energyDiff += 0.5 * 1.2041 * param->find(SUMO_ATTR_FRONTSURFACEAREA)->second * param->find(SUMO_ATTR_AIRDRAGCOEFFICIENT)->second * v * v * SPEED2DIST(v);
86 
87  // Energy loss through Roll resistance [Ws]
88  // ... (fabs(veh.getSpeed())>=0.01) = 0, if vehicle isn't moving
89  // EnergyLoss,Tire = c_R [-] * F_N [N] * s [m]
90  // ... with c_R = ~0.012 (car tire on asphalt)
91  // ... with F_N [N] = myMass [kg] * g [m/s^2]
92  energyDiff += param->find(SUMO_ATTR_ROLLDRAGCOEFFICIENT)->second * 9.81 * mass * SPEED2DIST(v);
93 
94  // Energy loss through friction by radial force [Ws]
95  // If angle of vehicle was changed
96  const double angleDiff = param->find(SUMO_ATTR_ANGLE)->second;
97  if (angleDiff != 0.) {
98  // Compute new radio
99  double radius = SPEED2DIST(v) / fabs(angleDiff);
100 
101  // Check if radius is in the interval [0.0001 - 10000] (To avoid overflow and division by zero)
102  if (radius < 0.0001) {
103  radius = 0.0001;
104  } else if (radius > 10000) {
105  radius = 10000;
106  }
107  // EnergyLoss,internalFrictionRadialForce = c [m] * F_rad [N];
108  // Energy loss through friction by radial force [Ws]
109  energyDiff += param->find(SUMO_ATTR_RADIALDRAGCOEFFICIENT)->second * mass * v * v / radius;
110  }
111 
112  // EnergyLoss,constantConsumers
113  // Energy loss through constant loads (e.g. A/C) [Ws]
114  energyDiff += param->find(SUMO_ATTR_CONSTANTPOWERINTAKE)->second;
115 
116  //E_Bat = E_kin_pot + EnergyLoss;
117  if (energyDiff > 0) {
118  // Assumption: Efficiency of myPropulsionEfficiency when accelerating
119  energyDiff /= param->find(SUMO_ATTR_PROPULSIONEFFICIENCY)->second;
120  } else {
121  // Assumption: Efficiency of myRecuperationEfficiency when recuperating
122  energyDiff *= param->find(SUMO_ATTR_RECUPERATIONEFFICIENCY)->second;
123  }
124 
125  // convert from [Ws] to [Wh] (3600s / 1h):
126  return energyDiff / 3600.;
127 }
128 
129 
130 /****************************************************************************/
static const int ENERGY_BASE
Definition: HelpersEnergy.h:52
Internal moment of inertia.
#define SPEED2DIST(x)
Definition: SUMOTime.h:55
#define ACCEL2SPEED(x)
Definition: SUMOTime.h:61
EmissionType
Enumerating all emission types, including fuel.
HelpersEnergy()
Constructor (initializes myEmissionClassStrings)
static const int ZERO_EMISSIONS
the first class in each model representing a zero emission vehicle
Radial drag coefficient.
std::map< int, double > myDefaultParameter
The default parameter.
Definition: HelpersEnergy.h:79
void insert(const std::string str, const T key, bool checkDuplicates=true)
int SUMOEmissionClass
StringBijection< SUMOEmissionClass > myEmissionClassStrings
Mapping between emission class names and integer representations.
double compute(const SUMOEmissionClass c, const PollutantsInterface::EmissionType e, const double v, const double a, const double slope, const std::map< int, double > *param) const
Computes the emitted pollutant amount using the given speed and acceleration.
Helper methods for PHEMlight-based emission computation.