38#define IDLE_SPEED (10 / 3.6)
50 for (
const auto& cep :
myCEPs) {
58 if (eClass ==
"unknown" && !myEmissionClassStrings.hasString(
"unknown")) {
59 myEmissionClassStrings.addAlias(
"unknown",
getClassByName(
"PC_G_EU4", vc));
61 if (eClass ==
"default" && !myEmissionClassStrings.hasString(
"default")) {
62 myEmissionClassStrings.addAlias(
"default",
getClassByName(
"PC_G_EU4", vc));
64 if (myEmissionClassStrings.hasString(eClass)) {
65 return myEmissionClassStrings.get(eClass);
67 if (eClass.size() < 6) {
71 const std::string type = eClass.substr(0, 3);
72 if (type ==
"HDV" || type ==
"LB_" || type ==
"RB_" || type ==
"LSZ" || eClass.find(
"LKW") != std::string::npos) {
73 index |= PollutantsInterface::HEAVY_BIT;
75 myEmissionClassStrings.insert(eClass, index);
80 std::vector<std::string> phemPath;
82 if (getenv(
"PHEMLIGHT_PATH") !=
nullptr) {
83 phemPath.push_back(std::string(getenv(
"PHEMLIGHT_PATH")) +
"/");
85 if (getenv(
"SUMO_HOME") !=
nullptr) {
86 phemPath.push_back(std::string(getenv(
"SUMO_HOME")) +
"/data/emissions/PHEMlight/");
92 myEmissionClassStrings.remove(eClass, index);
107 std::string eClassOffset =
"0";
108 if (eClass.length() == 5 && eClass.substr(0, 4) ==
"Euro") {
109 if (eClass[4] >=
'0' && eClass[4] <=
'6') {
110 eClassOffset = eClass.substr(4, 1);
114 if (vClass ==
"Passenger") {
116 if (fuel ==
"Gasoline") {
118 }
else if (fuel ==
"Diesel") {
120 }
else if (fuel ==
"HybridGasoline") {
121 desc =
"H_" + desc +
"G_";
122 }
else if (fuel ==
"HybridDiesel") {
123 desc =
"H_" + desc +
"G_";
125 desc +=
"EU" + eClassOffset;
126 }
else if (vClass ==
"Moped") {
127 desc =
"KKR_G_EU" + eClassOffset;
128 }
else if (vClass ==
"Motorcycle") {
129 desc =
"MR_G_EU" + eClassOffset;
130 if (fuel ==
"Gasoline2S") {
135 }
else if (vClass ==
"Delivery") {
137 if (fuel ==
"Gasoline") {
139 }
else if (fuel ==
"Diesel") {
142 desc +=
"EU" + eClassOffset +
"_I";
143 if (weight > 1305.) {
145 if (weight > 1760.) {
149 }
else if (vClass ==
"UrbanBus") {
150 desc =
"LB_D_EU" + eClassOffset;
151 }
else if (vClass ==
"Coach") {
152 desc =
"RB_D_EU" + eClassOffset;
153 }
else if (vClass ==
"Truck") {
154 desc =
"Solo_LKW_D_EU" + eClassOffset +
"_I";
155 if (weight > 1305.) {
158 }
else if (vClass ==
"Trailer") {
159 desc =
"LSZ_D_EU" + eClassOffset;
161 if (myEmissionClassStrings.hasString(desc)) {
162 return myEmissionClassStrings.get(desc);
170 const std::string name = myEmissionClassStrings.getString(c);
171 if (name.find(
"KKR_") != std::string::npos) {
173 }
else if (name.find(
"RB_") != std::string::npos) {
175 }
else if (name.find(
"LB_") != std::string::npos) {
177 }
else if (name.find(
"LNF_") != std::string::npos) {
179 }
else if (name.find(
"LSZ_") != std::string::npos) {
181 }
else if (name.find(
"MR_") != std::string::npos) {
183 }
else if (name.find(
"LKW_") != std::string::npos) {
192 const std::string name = myEmissionClassStrings.getString(c);
193 std::string fuel =
"Gasoline";
194 if (name.find(
"_D_") != std::string::npos) {
197 if (name.find(
"H_") != std::string::npos) {
198 fuel =
"Hybrid" + fuel;
206 const std::string name = myEmissionClassStrings.getString(c);
207 if (name.find(
"_EU1") != std::string::npos) {
209 }
else if (name.find(
"_EU2") != std::string::npos) {
211 }
else if (name.find(
"_EU3") != std::string::npos) {
213 }
else if (name.find(
"_EU4") != std::string::npos) {
215 }
else if (name.find(
"_EU5") != std::string::npos) {
217 }
else if (name.find(
"_EU6") != std::string::npos) {
226 const std::string name = myEmissionClassStrings.getString(c);
227 if (name.find(
"LNF_") != std::string::npos) {
228 if (name.find(
"_III") != std::string::npos) {
230 }
else if (name.find(
"_II") != std::string::npos) {
232 }
else if (name.find(
"_I") != std::string::npos) {
236 if (name.find(
"Solo_LKW_") != std::string::npos) {
237 if (name.find(
"_II") != std::string::npos) {
239 }
else if (name.find(
"_I") != std::string::npos) {
249 if (oldCep !=
nullptr) {
250 return oldCep->GetEmission(e, p, v);
259 if (currCep !=
nullptr) {
268 return myCEPs.count(c) == 0 ? 0. :
myCEPs.find(c)->second->GetDecelCoast(v, a, slope);
277 const double corrSpeed =
MAX2(0.0, v);
281 if (oldCep !=
nullptr) {
282 if (v >
IDLE_SPEED && a < oldCep->GetDecelCoast(corrSpeed, a, slope, 0)) {
287 power = oldCep->CalcPower(corrSpeed, a, slope);
290 const PHEMCEP*
const oldCep = 0;
293 if (currCep !=
nullptr) {
296 corrAcc < currCep->GetDecelCoast(corrSpeed, corrAcc, slope) &&
301 power = currCep->
CalcPower(corrSpeed, corrAcc, slope);
303 const std::string& fuelType = oldCep !=
nullptr ? oldCep->GetVehicleFuelType() : currCep->
getFuelType();
305 case PollutantsInterface::CO:
307 case PollutantsInterface::CO2:
308 if (oldCep !=
nullptr) {
312 getEmission(
nullptr, currCep,
"CO", power, corrSpeed),
314 case PollutantsInterface::HC:
316 case PollutantsInterface::NO_X:
318 case PollutantsInterface::PM_X:
320 case PollutantsInterface::FUEL: {
332 case PollutantsInterface::ELEC:
const double SECONDS_PER_HOUR
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
An upper class for objects with additional parameters.
bool isEngineOff() const
Returns the state of the engine when the vehicle is not moving.
double getEmission(const PHEMCEP *oldCep, PHEMlightdll::CEP *currCep, const std::string &e, const double p, const double v) const
Returns the amount of emitted pollutant given the vehicle type and state (in mg/s or in ml/s for fuel...
std::map< SUMOEmissionClass, PHEMlightdll::CEP * > myCEPs
SUMOEmissionClass getClass(const SUMOEmissionClass base, const std::string &vClass, const std::string &fuel, const std::string &eClass, const double weight) const
Returns the emission class described by the given parameters.
std::string getFuel(const SUMOEmissionClass c) const
Returns the fuel type described by this emission class as described in the Amitran interface (Gasolin...
PHEMlightdll::Helpers myHelper
virtual double compute(const SUMOEmissionClass c, const PollutantsInterface::EmissionType e, const double v, const double a, const double slope, const EnergyParams *param) const
Returns the amount of emitted pollutant given the vehicle type and state (in mg/s or in ml/s for fuel...
HelpersPHEMlight()
Constructor.
virtual double getModifiedAccel(const SUMOEmissionClass c, const double v, const double a, const double slope, const EnergyParams *param) const
Returns the adapted acceleration value, useful for comparing with external PHEMlight references.
virtual double getCoastingDecel(const SUMOEmissionClass c, const double v, const double a, const double slope, const EnergyParams *param) const
Returns the maximum deceleration value (as a negative number), which can still be considered as non-b...
int getEuroClass(const SUMOEmissionClass c) const
Returns the Euro emission class described by this emission class as described in the Amitran interfac...
virtual ~HelpersPHEMlight()
Destructor.
virtual SUMOEmissionClass getClassByName(const std::string &eClass, const SUMOVehicleClass vc)
Checks whether the string describes a known vehicle class.
double getWeight(const SUMOEmissionClass c) const
Returns a reference weight in kg described by this emission class as described in the Amitran interfa...
PHEMlightdll::CEPHandler myCEPHandler
int myIndex
the index of the next class
std::string getAmitranVehicleClass(const SUMOEmissionClass c) const
Returns the vehicle class described by this emission class as described in the Amitran interface (Pas...
static const int PHEMLIGHT_BASE
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool).
static OptionsCont & getOptions()
Retrieves the options.
static PHEMCEPHandler & getHandlerInstance()
Implementatio of Singelton pattern.
PHEMCEP * GetCep(SUMOEmissionClass emissionClass)
Returns the CEP data for a PHEM emission class.
Data Handler for a single CEP emission data set.
double GetMaxAccel(double speed, double gradient)
double GetEmission(const std::string &pollutant, double power, double speed, Helpers *VehicleClass)
double CalcPower(double speed, double acc, double gradient)
const std::string & getFuelType() const
double GetCO2Emission(double _FC, double _CO, double _HC, Helpers *VehicleClass)
static const std::string strBEV
static const double ZERO_SPEED_ACCURACY
static const std::string strDiesel
static const std::string strGasoline
Helper methods for PHEMlight-based emission computation.
static std::string to_lower_case(const std::string &str)
Transfers the content to lower case.