40 myIndex(PHEMLIGHT5_BASE) {
45 for (
const auto& cep :
myCEPs) {
62 if (eClass.size() < 6) {
67 std::vector<std::string> phemPath;
68 phemPath.push_back(oc.
getString(
"phemlight-path") +
"/");
69 if (getenv(
"PHEMLIGHT_PATH") !=
nullptr) {
70 phemPath.push_back(std::string(getenv(
"PHEMLIGHT_PATH")) +
"/");
72 if (getenv(
"SUMO_HOME") !=
nullptr) {
73 phemPath.push_back(std::string(getenv(
"SUMO_HOME")) +
"/data/emissions/PHEMlight5/");
81 throw InvalidArgument(
"Error reading PHEMlight5 deterioration data.\n" + err);
85 if (!oc.
isDefault(
"phemlight-temperature")) {
89 throw InvalidArgument(
"Error reading PHEMlight5 deterioration data.\n" + err);
115 std::string fuel =
"Gasoline";
116 if (name.find(
"_D_") != std::string::npos) {
119 if (name.find(
"_BEV_") != std::string::npos) {
120 fuel =
"Electricity";
122 if (name.find(
"_HEV") != std::string::npos) {
123 fuel =
"Hybrid" + fuel;
131 return myCEPs.find(c)->second->getVehicleMass();
164 power += (mass * rotFactor + massRot + load) * a * v;
166 return power / 1000.;
173 if (currCep !=
nullptr) {
183 const double pMaxForAcc = currCep->
GetPMaxNorm(v) * ratedPower -
calcPower(currCep, v, 0, slope, param);
184 const double maxAcc = (pMaxForAcc * 1000) / ((mass * rotFactor + massRot + load) * v);
185 return MIN2(a, maxAcc);
210 return -(currCep->
getFMot(v, ratedPower, wheelRadius) + fRoll + fAir + fGrad) / ((mass + load) * rotFactor);
219 const double corrSpeed =
MAX2(0.0, v);
220 assert(
myCEPs.count(c) == 1);
225 const double power_raw =
calcPower(currCep, corrSpeed, corrAcc, slope, param);
227 const double power = isHybrid ?
calcWheelPower(currCep, corrSpeed, corrAcc, slope, param) : currCep->
CalcEngPower(power_raw, ratedPower);
229 if (!isBEV && corrAcc <
getCoastingDecel(c, corrSpeed, corrAcc, slope, param) &&
240 getEmission(currCep,
"CO", power, corrSpeed, drivingPower, ratedPower),
const double SECONDS_PER_HOUR
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SUMO_ATTR_MAXIMUMPOWER
Maximum Power.
@ SUMO_ATTR_ROLLDRAGCOEFFICIENT
Roll Drag coefficient.
@ SUMO_ATTR_CONSTANTPOWERINTAKE
Constant Power Intake.
@ SUMO_ATTR_LOADING
additional mass loaded on the vehicle
@ SUMO_ATTR_AIRDRAGCOEFFICIENT
Air drag coefficient.
@ SUMO_ATTR_ROTATINGMASS
Mass equivalent of rotating elements.
@ SUMO_ATTR_FRONTSURFACEAREA
Front surface area.
An upper class for objects with additional parameters.
double getDoubleOptional(SumoXMLAttr attr, const double def) const
Returns the value for a given key with an optional default. SUMO_ATTR_MASS and SUMO_ATTR_FRONTSURFACE...
bool isEngineOff() const
Returns the state of the engine when the vehicle is not moving.
double getTransportableMass() const
Returns the mass of all transportables in the vehicle.
int myIndex
the index of the next class
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.
double calcWheelPower(PHEMlightdllV5::CEP *currCep, const double v, const double a, const double slope, const EnergyParams *param) const
Returns the power without auxiliaries.
HelpersPHEMlight5()
Constructor.
double calcPower(PHEMlightdllV5::CEP *currCep, const double v, const double a, const double slope, const EnergyParams *param) const
Returns the total power needed.
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...
std::string getFuel(const SUMOEmissionClass c) const
Returns the fuel type described by this emission class as described in the Amitran interface (Gasolin...
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...
double getEmission(PHEMlightdllV5::CEP *currCep, const std::string &e, const double p, const double v, const double drivingPower, const double ratedPower) const
Returns the amount of emitted pollutant given the vehicle type and state (in mg/s or in ml/s for fuel...
PHEMlightdllV5::CEPHandler myCEPHandler
std::map< SUMOEmissionClass, PHEMlightdllV5::CEP * > myCEPs
PHEMlightdllV5::Correction * myCorrection
SUMOEmissionClass getClassByName(const std::string &eClass, const SUMOVehicleClass vc)
Checks whether the string describes a known vehicle class.
virtual ~HelpersPHEMlight5()
Destructor.
double getWeight(const SUMOEmissionClass c) const
Returns a reference weight in kg described by this emission class This implementation returns the val...
PHEMlightdllV5::Helpers myHelper
Helper methods for PHEMlight-based emission computation.
A storage for options typed value containers)
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
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.
const std::map< std::string, CEP * > & getCEPS() const
bool GetCEP(std::vector< std::string > &DataPath, Helpers *Helper, Correction *DataCor)
double getWheelRadius() const
double getVehicleMassRot() const
double GetRotationalCoeffecient(double speed)
const double & getRatedPower() const
double getCWValue() const
double getResistanceF0() const
double getFMot(const double speed, const double ratedPower, const double wheelRadius)
double getVehicleLoading() const
double getResistance(const double speed, const double f0) const
double getCrossSectionalArea() const
const bool & getHeavyVehicle() const
const std::string & getCalcType() const
double GetPMaxNorm(double speed)
double getVehicleMass() const
const std::string & getFuelType() const
double getAuxPower() const
double GetEmission(const std::string &pollutant, double power, double speed, Helpers *VehicleClass, const double drivingPower, const double ratedPower)
double GetCO2Emission(double _FC, double _CO, double _HC, Helpers *VehicleClass)
double CalcEngPower(double power, const double ratedPower)
static const std::string strBEV
static const double NORMALIZING_ACCELARATION
static const double NORMALIZING_SPEED
static const double SPEED_DCEL_MIN
static const double ZERO_SPEED_ACCURACY
static const double AIR_DENSITY_CONST
static const std::string strHybrid
static const std::string strGasoline
static const std::string strDiesel
static const double GRAVITY_CONST
static double _DRIVE_TRAIN_EFFICIENCY
void setAmbTemp(const double &value)
bool ReadDet(std::string &ErrMSG)
bool ReadTNOx(std::string &ErrMSG)
void setYear(const int &value)
void setUseTNOx(const bool &value)
void setUseDet(const bool &value)
void setPHEMDataV(const std::string &value)
bool setclass(const std::string &VEH)
const std::string & getgClass() const
void setCommentPrefix(const std::string &value)
const std::string & getErrMsg() const
bool myVolumetricFuel
return fuel consumption in l instead of mg
StringBijection< SUMOEmissionClass > myEmissionClassStrings
Mapping between emission class names and integer representations.
EmissionType
Enumerating all emission types, including fuel.
static const int HEAVY_BIT
the bit to set for denoting heavy vehicles
const std::string & getString(const T key) const
bool hasString(const std::string &str) const
void addAlias(const std::string str, const T key)
T get(const std::string &str) const
void insert(const std::string str, const T key, bool checkDuplicates=true)
static std::string to_lower_case(const std::string &str)
Transfers the content to lower case.