Eclipse 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-2019 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 // ===========================================================================
37  // default values from
38  // Kurczveil, T., López, P.Á., & Schnieder, E. (2014). Implementation of an Energy Model and a Charging Infrastructure in SUMO.
50 }
51 
52 
53 double
54 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 {
55  if (e != PollutantsInterface::ELEC) {
56  return 0.;
57  }
58  if (param == nullptr) {
59  param = &myDefaultParameter;
60  }
61  //@ToDo: All formulas below work with the logic of the euler update (refs #860).
62  // Approximation order could be improved. Refs. #2592.
63 
64  const double lastV = v - ACCEL2SPEED(a);
65  const double mass = param->find(SUMO_ATTR_VEHICLEMASS)->second;
66 
67  // calculate potential energy difference
68  double energyDiff = mass * 9.81 * sin(DEG2RAD(slope)) * SPEED2DIST(v);
69 
70  // kinetic energy difference of vehicle
71  energyDiff += 0.5 * mass * (v * v - lastV * lastV);
72 
73  // add rotational energy diff of internal rotating elements
74  energyDiff += param->find(SUMO_ATTR_INTERNALMOMENTOFINERTIA)->second * (v * v - lastV * lastV);
75 
76  // Energy loss through Air resistance [Ws]
77  // Calculate energy losses:
78  // EnergyLoss,Air = 1/2 * rho_air [kg/m^3] * myFrontSurfaceArea [m^2] * myAirDragCoefficient [-] * v_Veh^2 [m/s] * s [m]
79  // ... with rho_air [kg/m^3] = 1,2041 kg/m^3 (at T = 20C)
80  // ... with s [m] = v_Veh [m/s] * TS [s]
81  energyDiff += 0.5 * 1.2041 * param->find(SUMO_ATTR_FRONTSURFACEAREA)->second * param->find(SUMO_ATTR_AIRDRAGCOEFFICIENT)->second * v * v * SPEED2DIST(v);
82 
83  // Energy loss through Roll resistance [Ws]
84  // ... (fabs(veh.getSpeed())>=0.01) = 0, if vehicle isn't moving
85  // EnergyLoss,Tire = c_R [-] * F_N [N] * s [m]
86  // ... with c_R = ~0.012 (car tire on asphalt)
87  // ... with F_N [N] = myMass [kg] * g [m/s^2]
88  energyDiff += param->find(SUMO_ATTR_ROLLDRAGCOEFFICIENT)->second * 9.81 * mass * SPEED2DIST(v);
89 
90  // Energy loss through friction by radial force [Ws]
91  // If angle of vehicle was changed
92  const double angleDiff = param->find(SUMO_ATTR_ANGLE)->second;
93  if (angleDiff != 0.) {
94  // Compute new radio
95  double radius = SPEED2DIST(v) / fabs(angleDiff);
96 
97  // Check if radius is in the interval [0.0001 - 10000] (To avoid overflow and division by zero)
98  if (radius < 0.0001) {
99  radius = 0.0001;
100  } else if (radius > 10000) {
101  radius = 10000;
102  }
103  // EnergyLoss,internalFrictionRadialForce = c [m] * F_rad [N];
104  // Energy loss through friction by radial force [Ws]
105  energyDiff += param->find(SUMO_ATTR_RADIALDRAGCOEFFICIENT)->second * mass * v * v / radius;
106  }
107 
108  // EnergyLoss,constantConsumers
109  // Energy loss through constant loads (e.g. A/C) [Ws]
110  energyDiff += param->find(SUMO_ATTR_CONSTANTPOWERINTAKE)->second;
111 
112  //E_Bat = E_kin_pot + EnergyLoss;
113  if (energyDiff > 0) {
114  // Assumption: Efficiency of myPropulsionEfficiency when accelerating
115  energyDiff /= param->find(SUMO_ATTR_PROPULSIONEFFICIENCY)->second;
116  } else {
117  // Assumption: Efficiency of myRecuperationEfficiency when recuperating
118  energyDiff *= param->find(SUMO_ATTR_RECUPERATIONEFFICIENCY)->second;
119  if (a != 0) {
120  // Fiori, Chiara & Ahn, Kyoungho & Rakha, Hesham. (2016).
121  // Power-based electric vehicle energy consumption model: Model
122  // development and validation. Applied Energy. 168. 257-268.
123  // 10.1016/j.apenergy.2016.01.097.
124  energyDiff *= (1 / exp(param->find(SUMO_ATTR_RECUPERATIONEFFICIENCY_BY_DECELERATION)->second / fabs(a)));
125  }
126  }
127 
128  // convert from [Ws] to [Wh] (3600s / 1h):
129  return energyDiff / 3600.;
130 }
131 
132 
133 /****************************************************************************/
SUMO_ATTR_ANGLE
Definition: SUMOXMLDefinitions.h:791
SPEED2DIST
#define SPEED2DIST(x)
Definition: SUMOTime.h:47
ToString.h
HelpersEnergy::HelpersEnergy
HelpersEnergy()
Constructor (initializes myEmissionClassStrings)
Definition: HelpersEnergy.cpp:34
SUMO_ATTR_PROPULSIONEFFICIENCY
Propulsion efficiency.
Definition: SUMOXMLDefinitions.h:501
SUMO_ATTR_VEHICLEMASS
Vehicle mass.
Definition: SUMOXMLDefinitions.h:487
SUMOTime.h
HelpersEnergy::compute
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.
Definition: HelpersEnergy.cpp:54
HelpersEnergy::myDefaultParameter
std::map< int, double > myDefaultParameter
The default parameter.
Definition: HelpersEnergy.h:72
PollutantsInterface::EmissionType
EmissionType
Enumerating all emission types, including fuel.
Definition: PollutantsInterface.h:56
ACCEL2SPEED
#define ACCEL2SPEED(x)
Definition: SUMOTime.h:53
SUMO_ATTR_CONSTANTPOWERINTAKE
Constant Power Intake.
Definition: SUMOXMLDefinitions.h:499
HelpersEnergy.h
SUMOEmissionClass
int SUMOEmissionClass
Definition: SUMOVehicleClass.h:232
HelpersEnergy::ENERGY_BASE
static const int ENERGY_BASE
Definition: HelpersEnergy.h:45
SUMO_ATTR_RECUPERATIONEFFICIENCY
Recuperation efficiency (constant)
Definition: SUMOXMLDefinitions.h:503
StringBijection::insert
void insert(const std::string str, const T key, bool checkDuplicates=true)
Definition: StringBijection.h:72
SUMO_ATTR_ROLLDRAGCOEFFICIENT
Roll Drag coefficient.
Definition: SUMOXMLDefinitions.h:497
PollutantsInterface::ELEC
Definition: PollutantsInterface.h:56
DEG2RAD
#define DEG2RAD(x)
Definition: GeomHelper.h:38
PollutantsInterface::ZERO_EMISSIONS
static const int ZERO_EMISSIONS
the first class in each model representing a zero emission vehicle
Definition: PollutantsInterface.h:262
PollutantsInterface::Helper::myEmissionClassStrings
StringBijection< SUMOEmissionClass > myEmissionClassStrings
Mapping between emission class names and integer representations.
Definition: PollutantsInterface.h:254
SUMO_ATTR_INTERNALMOMENTOFINERTIA
Internal moment of inertia.
Definition: SUMOXMLDefinitions.h:493
config.h
PollutantsInterface
Helper methods for PHEMlight-based emission computation.
Definition: PollutantsInterface.h:52
SUMO_ATTR_AIRDRAGCOEFFICIENT
Air drag coefficient.
Definition: SUMOXMLDefinitions.h:491
SUMO_ATTR_RADIALDRAGCOEFFICIENT
Radial drag coefficient.
Definition: SUMOXMLDefinitions.h:495
SUMO_ATTR_RECUPERATIONEFFICIENCY_BY_DECELERATION
Recuperation efficiency (by deceleration)
Definition: SUMOXMLDefinitions.h:505
SUMO_ATTR_FRONTSURFACEAREA
Front surface area.
Definition: SUMOXMLDefinitions.h:489