From 5e7055baf5371aa3366f5f06560a439474ab1729 Mon Sep 17 00:00:00 2001 From: namdre Date: Mon, 26 Feb 2024 14:58:50 +0100 Subject: [PATCH] fix #13055 --- src/microsim/MSVehicleType.h | 2 +- src/microsim/cfmodels/MSCFModel_Rail.cpp | 10 +++++++--- src/microsim/cfmodels/MSCFModel_Rail.h | 17 ++++++----------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/microsim/MSVehicleType.h b/src/microsim/MSVehicleType.h index ce75bf873e26..33de2bda178e 100644 --- a/src/microsim/MSVehicleType.h +++ b/src/microsim/MSVehicleType.h @@ -77,7 +77,7 @@ class MSVehicleType { * @param[in] what The parameter which one asks for * @return Whether the given parameter was set */ - bool wasSet(int what) const { + bool wasSet(long long int what) const { return (myParameter.parametersSet & what) != 0; } diff --git a/src/microsim/cfmodels/MSCFModel_Rail.cpp b/src/microsim/cfmodels/MSCFModel_Rail.cpp index 80846a34cdac..127bf92663a4 100644 --- a/src/microsim/cfmodels/MSCFModel_Rail.cpp +++ b/src/microsim/cfmodels/MSCFModel_Rail.cpp @@ -61,6 +61,10 @@ MSCFModel_Rail::MSCFModel_Rail(const MSVehicleType* vtype) : if (vtype->wasSet(VTYPEPARS_LENGTH_SET)) { myTrainParams.length = vtype->getLength(); } + if (vtype->wasSet(VTYPEPARS_MASS_SET)) { + // kg to tons + myTrainParams.weight = vtype->getMass() / 1000; + } myTrainParams.decl = vtype->getParameter().getCFParam(SUMO_ATTR_DECEL, myTrainParams.decl); setMaxDecel(myTrainParams.decl); setEmergencyDecel(vtype->getParameter().getCFParam(SUMO_ATTR_EMERGENCYDECEL, myTrainParams.decl + 0.3)); @@ -127,11 +131,11 @@ double MSCFModel_Rail::maxNextSpeed(double speed, const MSVehicle* const veh) co double a; if (speed < targetSpeed) { - a = (trac - totalRes) / myTrainParams.rotWeight; //kN/t == N/kg + a = (trac - totalRes) / myTrainParams.getRotWeight(); //kN/t == N/kg } else { a = 0.; if (totalRes > trac) { - a = (trac - totalRes) / myTrainParams.rotWeight; //kN/t == N/kg + a = (trac - totalRes) / myTrainParams.getRotWeight(); //kN/t == N/kg } } @@ -148,7 +152,7 @@ double MSCFModel_Rail::minNextSpeed(double speed, const MSVehicle* const veh) co const double gr = myTrainParams.weight * GRAVITY * sin(DEG2RAD(slope)); //kN const double res = getInterpolatedValueFromLookUpMap(speed, &(myTrainParams.resistance)); // kN const double totalRes = res + gr; //kN - const double a = myTrainParams.decl + totalRes / myTrainParams.rotWeight; + const double a = myTrainParams.decl + totalRes / myTrainParams.getRotWeight(); const double vMin = speed - ACCEL2SPEED(a); if (MSGlobals::gSemiImplicitEulerUpdate) { return MAX2(vMin, 0.); diff --git a/src/microsim/cfmodels/MSCFModel_Rail.h b/src/microsim/cfmodels/MSCFModel_Rail.h index 6483b05057c2..4cfade1b1fc1 100644 --- a/src/microsim/cfmodels/MSCFModel_Rail.h +++ b/src/microsim/cfmodels/MSCFModel_Rail.h @@ -70,15 +70,20 @@ class MSCFModel_Rail : public MSCFModel { typedef std::map LookUpMap; struct TrainParams { + // the vehicle mass in tons double weight; + // the mass factor double mf; double length; double decl; double vmax; double recovery; - double rotWeight; LookUpMap traction; LookUpMap resistance; + + double getRotWeight() const { + return weight * mf; + } }; double getInterpolatedValueFromLookUpMap(double speed, const LookUpMap* lookUpMap) const; @@ -231,7 +236,6 @@ class MSCFModel_Rail : public MSCFModel { params.decl = 0.9; params.vmax = 500 / 3.6; params.recovery = 0.6; - params.rotWeight = params.weight * params.mf; params.traction = initNGT400Traction(); params.resistance = initNGT400Resistance(); return params; @@ -351,7 +355,6 @@ class MSCFModel_Rail : public MSCFModel { params.decl = 0.9; params.vmax = 430 / 3.6; params.recovery = 0.6; - params.rotWeight = params.weight * params.mf; params.traction = initNGT400_16Traction(); params.resistance = initNGT400_16Resistance(); return params; @@ -427,7 +430,6 @@ class MSCFModel_Rail : public MSCFModel { params.decl = 0.5; params.vmax = 250 / 3.6; params.recovery = 0.1; - params.rotWeight = params.weight * params.mf; params.traction = initICE1Traction(); params.resistance = initICE1Resistance(); return params; @@ -441,7 +443,6 @@ class MSCFModel_Rail : public MSCFModel { params.decl = 0.5; params.vmax = 300 / 3.6; params.recovery = 0.6; - params.rotWeight = params.weight * params.mf; params.traction = initICE3Traction(); params.resistance = initICE3Resistance(); return params; @@ -527,7 +528,6 @@ class MSCFModel_Rail : public MSCFModel { params.decl = 0.5; params.vmax = 160 / 3.6; params.recovery = 0.1; - params.rotWeight = params.weight * params.mf; params.traction = initREDosto7Traction(); params.resistance = initREDosto7Resistance(); return params; @@ -585,7 +585,6 @@ class MSCFModel_Rail : public MSCFModel { params.decl = 0.5; params.vmax = 120 / 3.6; params.recovery = 0; - params.rotWeight = params.weight * params.mf; params.traction = initRB628Traction(); params.resistance = initRB628Resistance(); return params; @@ -635,7 +634,6 @@ class MSCFModel_Rail : public MSCFModel { params.decl = 0.3; params.vmax = 120 / 3.6; params.recovery = 0.05; - params.rotWeight = params.weight * params.mf; params.traction = initFreightTraction(); params.resistance = initFreightResistance(); return params; @@ -728,7 +726,6 @@ class MSCFModel_Rail : public MSCFModel { params.decl = 1.0; params.vmax = 160 / 3.6; params.recovery = 0.6; - params.rotWeight = params.weight * params.mf; params.traction = initRB425Traction(); params.resistance = initRB425Resistance(); return params; @@ -787,7 +784,6 @@ class MSCFModel_Rail : public MSCFModel { params.decl = 1.1; params.vmax = 160 / 3.6; params.recovery = 0.3; - params.rotWeight = params.weight * params.mf; params.traction = initMireoPlusB2TTraction(); params.resistance = initMireoPlusB2TResistance(); return params; @@ -846,7 +842,6 @@ class MSCFModel_Rail : public MSCFModel { params.decl = 1.1; params.vmax = 160 / 3.6; params.recovery = 0.3; - params.rotWeight = params.weight * params.mf; params.traction = initMireoPlusH2TTraction(); params.resistance = initMireoPlusH2TResistance(); return params;