Skip to content

Commit

Permalink
fix #13055
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Feb 26, 2024
1 parent 5e42d66 commit 5e7055b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/microsim/MSVehicleType.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
10 changes: 7 additions & 3 deletions src/microsim/cfmodels/MSCFModel_Rail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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
}
}

Expand All @@ -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.);
Expand Down
17 changes: 6 additions & 11 deletions src/microsim/cfmodels/MSCFModel_Rail.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,20 @@ class MSCFModel_Rail : public MSCFModel {
typedef std::map<double, double> 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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 5e7055b

Please sign in to comment.