Skip to content

Commit

Permalink
making wheel radius and rolling resistance configurable #14285
Browse files Browse the repository at this point in the history
  • Loading branch information
behrisch committed Feb 20, 2024
1 parent 7ddfc6d commit 938cc26
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 29 deletions.
20 changes: 2 additions & 18 deletions src/foreign/PHEMlight/V5/cpp/CEP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ namespace PHEMlightdllV5 {
return true;
}

double CEP::getFMot(const double speed, const double ratedPower) {
double CEP::getFMot(const double speed, const double ratedPower, const double wheelRadius) {
if (speed < 10e-2) {
return 0.;
}
Expand All @@ -380,29 +380,13 @@ namespace PHEMlightdllV5 {

double iTot = iGear * _axleRatio;

double n = (30 * speed * iTot) / ((_effectiveWheelDiameter / 2) * M_PI);
double n = (30 * speed * iTot) / (wheelRadius * M_PI);
double nNorm = (n - _engineIdlingSpeed) / (_engineRatedSpeed - _engineIdlingSpeed);

FindLowerUpperInPattern(lowerIndex, upperIndex, _nNormTable, nNorm);
return (-Interpolate(nNorm, _nNormTable[lowerIndex], _nNormTable[upperIndex], _dragNormTable[lowerIndex], _dragNormTable[upperIndex]) * ratedPower * 1000 / speed) / Constants::getDRIVE_TRAIN_EFFICIENCY();
}

double CEP::GetDecelCoast(double speed, double acc, double gradient, const double ratedPower) {

if (speed < Constants::SPEED_DCEL_MIN) {
return speed / Constants::SPEED_DCEL_MIN * GetDecelCoast(Constants::SPEED_DCEL_MIN, acc, gradient, ratedPower);
}
double fMot = getFMot(speed, ratedPower);
double rotCoeff = GetRotationalCoeffecient(speed);
double fRoll = (_resistanceF0 + _resistanceF1 * speed + std::pow(_resistanceF2 * speed, 2) + std::pow(_resistanceF3 * speed, 3) + std::pow(_resistanceF4 * speed, 4)) * (_massVehicle + _vehicleLoading) * Constants::GRAVITY_CONST;

double fAir = _cWValue * _crossSectionalArea * Constants::AIR_DENSITY_CONST * 0.5 * std::pow(speed, 2);

double fGrad = (_massVehicle + _vehicleLoading) * Constants::GRAVITY_CONST * gradient / 100;

return -(fMot + fRoll + fAir + fGrad) / ((_massVehicle + _vehicleLoading) * rotCoeff);
}

double CEP::GetRotationalCoeffecient(double speed) {
//Declaration
int upperIndex;
Expand Down
17 changes: 9 additions & 8 deletions src/foreign/PHEMlight/V5/cpp/CEP.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,16 @@ namespace PHEMlightdllV5 {
double getCWValue() const {
return _cWValue;
}
double getResistance(const double speed, const bool full=false) const {
if (full) {
return _resistanceF0 + _resistanceF1 * speed + std::pow(_resistanceF2 * speed, 2) + std::pow(_resistanceF3 * speed, 3) + std::pow(_resistanceF4 * speed, 4);
}
return _resistanceF0 + _resistanceF1 * speed + _resistanceF4 * std::pow(speed, 4);
double getWheelRadius() const {
return _effectiveWheelDiameter / 2.;
}
double getFMot(const double speed, const double ratedPower);
double getResistanceF0() const {
return _resistanceF0;
}
double getResistance(const double speed, const double f0) const {
return f0 + _resistanceF1 * speed + _resistanceF2 * std::pow(speed, 2) + _resistanceF3 * std::pow(speed, 3) + _resistanceF4 * std::pow(speed, 4);
}
double getFMot(const double speed, const double ratedPower, const double wheelRadius);

protected:
double _massVehicle;
Expand Down Expand Up @@ -142,8 +145,6 @@ namespace PHEMlightdllV5 {
bool GetfcVals(const std::string& _fuelTypex, double& _fCBr, double& _fCHC, double& _fCCO, double& _fCCO2, Helpers* VehicleClass);

public:
double GetDecelCoast(double speed, double acc, double gradient, const double ratedPower);

double GetRotationalCoeffecient(double speed);


Expand Down
2 changes: 2 additions & 0 deletions src/utils/emissions/EnergyParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ EnergyParams::EnergyParams(const SUMOEmissionClass c) {
myMap[SUMO_ATTR_FRONTSURFACEAREA] = INVALID_DOUBLE;
myMap[SUMO_ATTR_AIRDRAGCOEFFICIENT] = INVALID_DOUBLE;
myMap[SUMO_ATTR_CONSTANTPOWERINTAKE] = INVALID_DOUBLE;
myMap[SUMO_ATTR_WHEELRADIUS] = INVALID_DOUBLE;
myMap[SUMO_ATTR_ROLLDRAGCOEFFICIENT] = INVALID_DOUBLE;
return;
}
const SUMOVTypeParameter::VClassDefaultValues defaultValues(SVC_PASSENGER);
Expand Down
9 changes: 6 additions & 3 deletions src/utils/emissions/HelpersPHEMlight5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ HelpersPHEMlight5::calcWheelPower(PHEMlightdllV5::CEP* currCep, const double v,
const double massRot = currCep->getVehicleMassRot();
const double load = param->getDoubleOptional(SUMO_ATTR_LOADING, currCep->getVehicleLoading());
const double cw = param->getDoubleOptional(SUMO_ATTR_FRONTSURFACEAREA, currCep->getCrossSectionalArea()) * param->getDoubleOptional(SUMO_ATTR_AIRDRAGCOEFFICIENT, currCep->getCWValue());
const double rf0 = param->getDoubleOptional(SUMO_ATTR_ROLLDRAGCOEFFICIENT, currCep->getResistanceF0());

double power = (mass + load) * PHEMlightdllV5::Constants::GRAVITY_CONST * currCep->getResistance(v) * v;
double power = (mass + load) * PHEMlightdllV5::Constants::GRAVITY_CONST * currCep->getResistance(v, rf0) * v;
power += (cw * PHEMlightdllV5::Constants::AIR_DENSITY_CONST / 2) * std::pow(v, 3);
power += (mass * rotFactor + massRot + load) * a * v;
power += (mass + load) * PHEMlightdllV5::Constants::GRAVITY_CONST * slope * 0.01 * v;
Expand Down Expand Up @@ -193,12 +194,14 @@ HelpersPHEMlight5::getCoastingDecel(const SUMOEmissionClass c, const double v, c
const double load = param->getDoubleOptional(SUMO_ATTR_LOADING, currCep->getVehicleLoading());
const double cw = param->getDoubleOptional(SUMO_ATTR_FRONTSURFACEAREA, currCep->getCrossSectionalArea()) * param->getDoubleOptional(SUMO_ATTR_AIRDRAGCOEFFICIENT, currCep->getCWValue());
const double ratedPower = param->getDoubleOptional(SUMO_ATTR_MAXIMUMPOWER, currCep->getRatedPower());
const double wheelRadius = param->getDoubleOptional(SUMO_ATTR_WHEELRADIUS, currCep->getWheelRadius());
const double rf0 = param->getDoubleOptional(SUMO_ATTR_ROLLDRAGCOEFFICIENT, currCep->getResistanceF0());

const double fRoll = currCep->getResistance(v, true) * (mass + load) * PHEMlightdllV5::Constants::GRAVITY_CONST;
const double fRoll = currCep->getResistance(v, rf0) * (mass + load) * PHEMlightdllV5::Constants::GRAVITY_CONST;
const double fAir = cw * PHEMlightdllV5::Constants::AIR_DENSITY_CONST * 0.5 * std::pow(v, 2);
const double fGrad = (mass + load) * PHEMlightdllV5::Constants::GRAVITY_CONST * slope / 100;

return -(currCep->getFMot(v, ratedPower) + fRoll + fAir + fGrad) / ((mass + load) * rotFactor);
return -(currCep->getFMot(v, ratedPower, wheelRadius) + fRoll + fAir + fGrad) / ((mass + load) * rotFactor);
}


Expand Down

0 comments on commit 938cc26

Please sign in to comment.