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