Skip to content

Commit

Permalink
fixing parameter parsing #14285
Browse files Browse the repository at this point in the history
  • Loading branch information
behrisch committed Feb 2, 2024
1 parent b365dbf commit 4fe225b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/utils/emissions/EnergyParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ EnergyParams::EnergyParams(const SUMOEmissionClass c) {
myMap[SUMO_ATTR_WAITINGTIME] = -1.;

if (c != EMISSION_CLASS_UNSPECIFIED && StringUtils::startsWith(PollutantsInterface::getName(c), "PHEMlight5/")) {
myMap[SUMO_ATTR_VEHICLEMASS] = INVALID_DOUBLE;
myMap[SUMO_ATTR_FRONTSURFACEAREA] = INVALID_DOUBLE;
myMap[SUMO_ATTR_AIRDRAGCOEFFICIENT] = INVALID_DOUBLE;
myMap[SUMO_ATTR_CONSTANTPOWERINTAKE] = INVALID_DOUBLE;
return;
}
// default values from
Expand Down Expand Up @@ -130,7 +134,7 @@ EnergyParams::getDouble(SumoXMLAttr attr) const {
double
EnergyParams::getDoubleOptional(SumoXMLAttr attr, const double def) const {
auto it = myMap.find(attr);
if (it != myMap.end()) {
if (it != myMap.end() && it->second != INVALID_DOUBLE) {
return it->second;
}
if (mySecondaryParams != nullptr) {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/emissions/HelpersPHEMlight5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ HelpersPHEMlight5::calcPower(PHEMlightdllV5::CEP* currCep, const double v, const
// copy of CEP::CalcPower
const double power = calcWheelPower(currCep, v, a, slope, param) / PHEMlightdllV5::Constants::_DRIVE_TRAIN_EFFICIENCY;
if (!(currCep->getCalcType() == "HEV" || currCep->getCalcType() == "BEV")) {
return power + param->getDoubleOptional(SUMO_ATTR_CONSTANTPOWERINTAKE, currCep->getAuxPower());
return power + param->getDoubleOptional(SUMO_ATTR_CONSTANTPOWERINTAKE, currCep->getAuxPower() * 1000.) / 1000.;
}
return power;
}
Expand Down Expand Up @@ -247,7 +247,7 @@ HelpersPHEMlight5::compute(const SUMOEmissionClass c, const PollutantsInterface:
}
case PollutantsInterface::ELEC:
if (isBEV) {
const double auxPower = param->getDoubleOptional(SUMO_ATTR_CONSTANTPOWERINTAKE, currCep->getAuxPower());
const double auxPower = param->getDoubleOptional(SUMO_ATTR_CONSTANTPOWERINTAKE, currCep->getAuxPower() * 1000.) / 1000.;
return (getEmission(currCep, "FC_el", power, corrSpeed, drivingPower) + auxPower) / SECONDS_PER_HOUR * 1000.;
}
return 0;
Expand Down

0 comments on commit 4fe225b

Please sign in to comment.