6#ifndef NeTrainSim_Locomotive_h
7#define NeTrainSim_Locomotive_h
12#include "../util/vector.h"
42 inline static const string DefaultLocomotiveName =
"locomotive";
44 static constexpr double DefaultLocomotiveMaxSpeed = 100.0 / 3.0;
46 static constexpr double DefaultLocomotiveMaxAcheivableNotch = 0;
48 static const int DefaultLocomotiveNoOfNotches = 8;
50 static const int DefaultLocomotiveNoOfAxiles = 6;
53 static const int DefaultLocomotiveType = 0;
55 static constexpr double DefaultLocomotiveEmptyWeight = 180;
59 double maxTractiveForce = 0.0;
93 const double g = 9.8067;
142 double locomotiveTransmissionEfficiency,
143 double locomotiveLength_m,
144 double locomotiveDragCoef,
145 double locomotiveFrontalArea_sqm,
146 double locomotiveWeight_t,
147 int locomotiveNoOfAxiles = DefaultLocomotiveNoOfAxiles,
148 int locomotivePowerType = DefaultLocomotiveType,
149 double locomotiveMaxSpeed_mps = DefaultLocomotiveMaxSpeed,
150 int totalNotches = DefaultLocomotiveNoOfNotches,
151 int locomotiveMaxAchievableNotch =
152 DefaultLocomotiveMaxAcheivableNotch,
153 double locomotiveAuxiliaryPower_kw =
154 EC::DefaultLocomotiveAuxiliaryPower,
155 string locomotiveName = DefaultLocomotiveName,
156 double batteryMaxCharge_kwh =
157 std::numeric_limits<double>::quiet_NaN(),
158 double batteryInitialCharge_perc =
159 std::numeric_limits<double>::quiet_NaN(),
160 double tankMaxCapacity_kg =
161 EC::DefaultLocomotiveTankMaxCapacityDiesel,
162 double tankInitialCapacity_perc =
163 EC::DefaultLocomotiveTankInitialCapacity,
164 double batteryCRate =
165 EC::DefaultLocomotiveBatteryCRate,
267 double &optimumThrottleLevel);
298 bool &optimize,
double &optimumThrottleLevel);
314 double getNetForce(
double &frictionCoef,
double &trainAcceleration,
315 bool &optimize,
double &optimumThrottleLevel);
339 double& trainAcceleration,
340 double& sharedWeight,
341 double& sharedResistance);
355 double &trainAcceleration,
371 double &trainAcceleration,
372 double &trainSpeed,
double &timeStep);
387 double EnergyConsumptionAtDCBus);
405 double& acceleration,
double& speed,
442 std::pair<bool,double>
consumeFuel(
double timeStep,
double trainSpeed,
444 double LocomotiveVirtualTractivePower =
445 std::numeric_limits<double>::quiet_NaN(),
446 double dieselConversionFactor =
447 EC::DefaultDieselConversionFactor,
448 double bioDieselConversionFactor =
449 EC::DefaultBiodieselConversionFactor,
450 double hydrogenConversionFactor =
451 EC::DefaultHydrogenConversionFactor,
452 double dieselDensity =
453 EC::DefaultDieselDensity,
454 double bioDieselDensity =
455 EC::DefaultBioDieselDensity,
456 double hydrogenDensity =
457 EC::DefaultHydrogenDensity)
override;
473 double LocomotiveVirtualTractivePower);
482 double LocomotiveVirtualTractivePower);
486 double fuelConversionFactor,
488 double LocomotiveVirtualTractivePower,
489 std::function<std::pair<bool, double>(
490 double,
double,
double)>
498 double fuelConversionFactor,
500 double LocomotiveVirtualTractivePower,
501 std::function<std::pair<bool, double>(
502 double,
double,
double)>
defines a rail locomotive.
Definition locomotive.h:36
double canProvideEnergy(double &EC, double &timeStep)
check if the locomotive can provide required energy
Definition locomotive.cpp:888
double getMaxProvidedEnergy(double &timeStep)
getMaxProvidedEnergy
Definition locomotive.cpp:863
double getNetForce(double &frictionCoef, double &trainAcceleration, bool &optimize, double &optimumThrottleLevel)
Gets net force.
Definition locomotive.cpp:854
double usedPowerPortion
Definition locomotive.h:95
void resetPowerRestriction()
reset lower power restriction on the locomotive.
Definition locomotive.cpp:340
double transmissionEfficiency
Transmission effeciency of the locomotive.
Definition locomotive.h:66
double getSharedVirtualTractivePower(double &trainSpeed, double &trainAcceleration, double &sharedWeight, double &sharedResistance)
Gets shared virtual tractive power.
Definition locomotive.cpp:386
double getDiscretizedThrottleCoef(double &trainSpeed)
Gets discretized throttle coef.
Definition locomotive.cpp:261
double getThrottleLevel(double &trainSpeed, bool &optimize, double &optimumThrottleLevel)
Gets the throttle level the locomotive should move by.
Definition locomotive.cpp:290
Vector< double > defineThrottleLevels()
Define throttle levels.
Definition locomotive.cpp:345
Vector< double > discritizedLamda
The discretized throttlelevels.
Definition locomotive.h:87
double getTractiveForce(double &frictionCoef, double &trainSpeed, bool &optimize, double &optimumThrottleLevel)
Gets tractive force that this locomotive can generate by the current speed and notch level.
Definition locomotive.cpp:360
void rechargeBatteryByMaxFlow(double timeStep, double trainSpeed, double powerPortion, double fuelConversionFactor, double fuelDensity, double LocomotiveVirtualTractivePower, std::function< std::pair< bool, double >(double, double, double)> ConsumeFuelFunc)
Definition locomotive.cpp:575
double getMaxRechargeEnergy(double timeStep, double trainSpeed, double LocomotiveVirtualTractivePower)
Get the max energy the locomotive can regenerate.
Definition locomotive.cpp:555
double getUsedPowerPortion(double trainSpeed, double LocomotiveVirtualTractivePower)
getUsedPowerPortion
Definition locomotive.cpp:544
void reducePower(double &reductionFactor)
reduce the power that the locomotive is producing by reducing the notch position to a lower position.
Definition locomotive.cpp:327
TrainTypes::PowerType getPowerTypeEnum(string powertype)
Gets power type as an enum.
double getResistance(double trainSpeed) override
Gets the resistance this locomotive is contributing to the whole train.
Definition locomotive.cpp:835
double getlamdaDiscretized(double &lamda)
Get lamda discretized.
Definition locomotive.cpp:241
std::pair< bool, double > consumeFuel(double timeStep, double trainSpeed, double EC_kwh, double LocomotiveVirtualTractivePower=std::numeric_limits< double >::quiet_NaN(), double dieselConversionFactor=EC::DefaultDieselConversionFactor, double bioDieselConversionFactor=EC::DefaultBiodieselConversionFactor, double hydrogenConversionFactor=EC::DefaultHydrogenConversionFactor, double dieselDensity=EC::DefaultDieselDensity, double bioDieselDensity=EC::DefaultBioDieselDensity, double hydrogenDensity=EC::DefaultHydrogenDensity) override
Consume the locomotive fuel.
Definition locomotive.cpp:724
double currentTractiveForce
The tractive forces of this time step.
Definition locomotive.h:64
const double g
(Immutable) the gravitation acceleration
Definition locomotive.h:93
int maxLocNotch
The max notch the locomotive is allowed to achieve, if zero, then use all notches.
Definition locomotive.h:80
friend ostream & operator<<(ostream &ostr, Locomotive &stud)
Stream insertion operator.
string getPowerTypeString()
Gets power type as a string.
std::pair< bool, double > consumeEnergyFromHybridTechnology(double timeStep, double trainSpeed, double powerPortion, double EC_kwh, double fuelConversionFactor, double fuelDensity, double LocomotiveVirtualTractivePower, std::function< std::pair< bool, double >(double, double, double)> ConsumeFuelFunc)
Definition locomotive.cpp:617
bool isLocOn
Decide if the locomotive is adding power to the train.
Definition locomotive.h:75
TrainTypes::PowerType powerType
The type of the car.
Definition locomotive.h:68
double getEnergyConsumptionAtTank(double &LocomotiveVirtualTractivePower, double &trainSpeed, double EnergyConsumptionAtDCBus)
get the Energy Consumption At Tank
Definition locomotive.cpp:472
double getEnergyConsumptionAtDCBus(double &LocomotiveVirtualTractivePower, double &trainAcceleration, double &trainSpeed, double &timeStep)
get the Energy Consumption At DC Bus
Definition locomotive.cpp:435
double throttleLevel
The current throttle level based on the current notch.
Definition locomotive.h:89
double maxPower
The max power of the locomotive in kw.
Definition locomotive.h:62
Vector< double > throttleLevels
The throttle levels.
Definition locomotive.h:91
int currentLocNotch
The current notch the locomotive is going by.
Definition locomotive.h:82
double locPowerReductionFactor
The forced lower power factor to the locomotive in case lower energy consumption is required.
Definition locomotive.h:85
void updateLocNotch(double &trainSpeed)
Updates the location notch described by trainSpeed.
Definition locomotive.cpp:309
double getHyperbolicThrottleCoef(double &trainSpeed)
Gets hyperbolic throttle coef.
Definition locomotive.cpp:221
double maxSpeed
Current used notch max speed.
Definition locomotive.h:72
TrainTypes::LocomotivePowerMethod hybridMethod
the hybrid technology whether it is series or paralletl.
Definition locomotive.h:70
double getEnergyConsumption(double &LocomotiveVirtualTractivePower, double &acceleration, double &speed, double &timeStep)
Gets energy consumption of this locomotive.
Definition locomotive.cpp:497
double getRegenerativeEffeciency(double &LocomotiveVirtualTractivePower, double &trainAcceleration, double &trainSpeed)
get the regenerative effeciency at that speed when decelerating
Definition locomotive.cpp:398
int Nmax
Number of notches the locomotives have.
Definition locomotive.h:77
Defines a train component base class.
Definition traincomponent.h:24
A vector.
Definition vector.h:24
Definition energyconsumption.cpp:6
_LocomotivePowerMethod
Values that represent power types.
Definition traintypes.h:337
_PowerType
Values that represent power types.
Definition traintypes.h:168