SUMO - Simulation of Urban MObility
HelpersEnergy.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // Helper methods for HBEFA-based emission computation
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include <utils/common/SUMOTime.h>
33 #include <utils/common/ToString.h>
34 #include "HelpersEnergy.h"
35 
36 
37 // ===========================================================================
38 // method definitions
39 // ===========================================================================
53 }
54 
55 
56 double
57 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 {
58  if (e != PollutantsInterface::ELEC) {
59  return 0.;
60  }
61  if (param == 0) {
62  param = &myDefaultParameter;
63  }
64  //@ToDo: All formulas below work with the logic of the euler update (refs #860).
65  // Approximation order could be improved. Refs. #2592.
66 
67  const double lastV = v - ACCEL2SPEED(a);
68  const double mass = param->find(SUMO_ATTR_VEHICLEMASS)->second;
69 
70  // calculate potential energy difference
71  double energyDiff = mass * 9.81 * sin(DEG2RAD(slope)) * SPEED2DIST(v);
72 
73  // kinetic energy difference of vehicle
74  energyDiff += 0.5 * mass * (v * v - lastV * lastV);
75 
76  // add rotational energy diff of internal rotating elements
77  energyDiff += param->find(SUMO_ATTR_INTERNALMOMENTOFINERTIA)->second * (v * v - lastV * lastV);
78 
79  // Energy loss through Air resistance [Ws]
80  // Calculate energy losses:
81  // EnergyLoss,Air = 1/2 * rho_air [kg/m^3] * myFrontSurfaceArea [m^2] * myAirDragCoefficient [-] * v_Veh^2 [m/s] * s [m]
82  // ... with rho_air [kg/m^3] = 1,2041 kg/m^3 (at T = 20C)
83  // ... with s [m] = v_Veh [m/s] * TS [s]
84  energyDiff += 0.5 * 1.2041 * param->find(SUMO_ATTR_FRONTSURFACEAREA)->second * param->find(SUMO_ATTR_AIRDRAGCOEFFICIENT)->second * v * v * SPEED2DIST(v);
85 
86  // Energy loss through Roll resistance [Ws]
87  // ... (fabs(veh.getSpeed())>=0.01) = 0, if vehicle isn't moving
88  // EnergyLoss,Tire = c_R [-] * F_N [N] * s [m]
89  // ... with c_R = ~0.012 (car tire on asphalt)
90  // ... with F_N [N] = myMass [kg] * g [m/s^2]
91  energyDiff += param->find(SUMO_ATTR_ROLLDRAGCOEFFICIENT)->second * 9.81 * mass * SPEED2DIST(v);
92 
93  // Energy loss through friction by radial force [Ws]
94  // If angle of vehicle was changed
95  const double angleDiff = param->find(SUMO_ATTR_ANGLE)->second;
96  if (angleDiff != 0.) {
97  // Compute new radio
98  double radius = SPEED2DIST(v) / fabs(angleDiff);
99 
100  // Check if radius is in the interval [0.0001 - 10000] (To avoid overflow and division by zero)
101  if (radius < 0.0001) {
102  radius = 0.0001;
103  } else if (radius > 10000) {
104  radius = 10000;
105  }
106  // EnergyLoss,internalFrictionRadialForce = c [m] * F_rad [N];
107  // Energy loss through friction by radial force [Ws]
108  energyDiff += param->find(SUMO_ATTR_RADIALDRAGCOEFFICIENT)->second * mass * v * v / radius;
109  }
110 
111  // EnergyLoss,constantConsumers
112  // Energy loss through constant loads (e.g. A/C) [Ws]
113  energyDiff += param->find(SUMO_ATTR_CONSTANTPOWERINTAKE)->second;
114 
115  //E_Bat = E_kin_pot + EnergyLoss;
116  if (energyDiff > 0) {
117  // Assumption: Efficiency of myPropulsionEfficiency when accelerating
118  energyDiff /= param->find(SUMO_ATTR_PROPULSIONEFFICIENCY)->second;
119  } else {
120  // Assumption: Efficiency of myRecuperationEfficiency when recuperating
121  energyDiff *= param->find(SUMO_ATTR_RECUPERATIONEFFICIENCY)->second;
122  }
123 
124  // convert from [Ws] to [Wh] (3600s / 1h):
125  return energyDiff / 3600.;
126 }
127 
128 
129 /****************************************************************************/
static const int ENERGY_BASE
Definition: HelpersEnergy.h:51
Internal moment of inertia.
#define SPEED2DIST(x)
Definition: SUMOTime.h:54
#define ACCEL2SPEED(x)
Definition: SUMOTime.h:60
EmissionType
Enumerating all emission types, including fuel.
HelpersEnergy()
Constructor (initializes myEmissionClassStrings)
C++ TraCI client API implementation.
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:78
void insert(const std::string str, const T key, bool checkDuplicates=true)
int SUMOEmissionClass
#define DEG2RAD(x)
Definition: GeomHelper.h:44
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.