Skip to content

Commit

Permalink
more aggressive trains
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedAredah committed Dec 6, 2023
1 parent 3ce883b commit 2da8bd0
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/NeTrainSim/traindefinition/locomotive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <algorithm>
#include "../util/vector.h"
#include "energyconsumption.h"
#include "qdebug.h"
#include "traintypes.h"
#include <cstdlib>
#include "../util/utils.h"
Expand Down Expand Up @@ -220,13 +221,13 @@ Locomotive::Locomotive(double locomotiveMaxPower_kw,

double Locomotive::getHyperbolicThrottleCoef(double & trainSpeed)
{
double dv, um;
double dv = 0.0, um;


// ratio of current train speed by the max loco speed
dv = trainSpeed / this->maxSpeed;
dv = trainSpeed / this->maxSpeed;
double lambda = (double)1.0 / (1.0 + exp(-7.82605 * (dv - 0.42606)));

//double lambda = 1.0 - (1.0 / (-2.5576+(3.5637/(1.0-dv))-3.7146*dv));

if (lambda < 0.0){
return 0.0;
}
Expand All @@ -236,6 +237,19 @@ double Locomotive::getHyperbolicThrottleCoef(double & trainSpeed)

return lambda;


// um = 0.05 * this->maxSpeed;
// if (dv >= 1.0) {
// return 1.0;
// }

// if (trainSpeed <= um )
// {
// return abs((dv)/((0.001)+(0.05/(1-dv))+(0.030*(dv))));
// }
// else {
// return 1.0;
// }
};

double Locomotive::getlamdaDiscretized(double &lamda)
Expand Down Expand Up @@ -330,8 +344,9 @@ void Locomotive::reducePower(double &reductionFactor)
// the max power supplied/ current demand power
this->locPowerReductionFactor = reductionFactor;
//restrict the reduction to the lower notch only.
int lowerNotch = this->currentLocNotch - 1;
double lowerNotchLambda = this->discritizedLamda[lowerNotch];
int lowerNotch = this->currentLocNotch - 2; // get index of previous notch
lowerNotch = max(lowerNotch, 0);
double lowerNotchLambda = this->throttleLevels[lowerNotch];
if (lowerNotchLambda > this->locPowerReductionFactor) {
this->locPowerReductionFactor = lowerNotchLambda;
}
Expand Down Expand Up @@ -372,6 +387,7 @@ double Locomotive::getTractiveForce(double &frictionCoef,
return f1;
}
else {

f = min((this->locPowerReductionFactor * 1000.0 *
this->transmissionEfficiency *
this->getThrottleLevel(trainSpeed, optimize,
Expand Down

0 comments on commit 2da8bd0

Please sign in to comment.