NeTrainSim 0.1.1 beta
The Open-Source Network Trains Simulator
 
Loading...
Searching...
No Matches
locomotive.h
Go to the documentation of this file.
1//
2// Created by Ahmed Aredah
3// Version 0.0.1
4//
5
6#ifndef NeTrainSim_Locomotive_h
7#define NeTrainSim_Locomotive_h
8
9#include <functional>
10#include <string>
11#include <iostream>
12#include "../util/vector.h"
13#include "traintypes.h"
14#include "energyconsumption.h"
15#include "traincomponent.h"
16
17using namespace std;
18
37 /***********************************************
38 * variables declaration *
39 ************************************************/
40private:
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;
56
57private:
59 double maxTractiveForce = 0.0;
60public:
62 double maxPower;
72 double maxSpeed;
73
75 bool isLocOn = true;
77 int Nmax = 8;
80 int maxLocNotch = 0;
93 const double g = 9.8067;
94
95 double usedPowerPortion = 0.0;
96
97
141 Locomotive(double locomotiveMaxPower_kw,
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(), // NAN value should be resolved latter
158 double batteryInitialCharge_perc =
159 std::numeric_limits<double>::quiet_NaN(), // NAN value should be resolved latter
160 double tankMaxCapacity_kg =
161 EC::DefaultLocomotiveTankMaxCapacityDiesel,
162 double tankInitialCapacity_perc =
163 EC::DefaultLocomotiveTankInitialCapacity,
164 double batteryCRate =
165 EC::DefaultLocomotiveBatteryCRate,
166 TrainTypes::LocomotivePowerMethod theHybridMethod =
168
169
179
191
208 double getHyperbolicThrottleCoef(double &trainSpeed);
209
228 double getlamdaDiscretized(double &lamda);
229
245 double getDiscretizedThrottleCoef(double& trainSpeed);
246
266 double getThrottleLevel(double &trainSpeed, bool &optimize,
267 double &optimumThrottleLevel);
268
279 double getResistance(double trainSpeed) override;
280
297 double getTractiveForce(double &frictionCoef, double &trainSpeed,
298 bool &optimize, double &optimumThrottleLevel);
299
314 double getNetForce(double &frictionCoef, double &trainAcceleration,
315 bool &optimize, double &optimumThrottleLevel);
316
338 double getSharedVirtualTractivePower(double& trainSpeed,
339 double& trainAcceleration,
340 double& sharedWeight,
341 double& sharedResistance);
342
354 double getRegenerativeEffeciency(double &LocomotiveVirtualTractivePower,
355 double &trainAcceleration,
356 double &trainSpeed);
357
370 double getEnergyConsumptionAtDCBus(double &LocomotiveVirtualTractivePower,
371 double &trainAcceleration,
372 double &trainSpeed, double &timeStep);
373
385 double getEnergyConsumptionAtTank(double &LocomotiveVirtualTractivePower,
386 double &trainSpeed,
387 double EnergyConsumptionAtDCBus);
404 double getEnergyConsumption(double& LocomotiveVirtualTractivePower,
405 double& acceleration, double& speed,
406 double& timeStep);
407
408
409
442 std::pair<bool,double> consumeFuel(double timeStep, double trainSpeed,
443 double EC_kwh,
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;
458
472 double getMaxRechargeEnergy(double timeStep, double trainSpeed,
473 double LocomotiveVirtualTractivePower);
474
481 double getUsedPowerPortion(double trainSpeed,
482 double LocomotiveVirtualTractivePower);
483
484 void rechargeBatteryByMaxFlow(double timeStep, double trainSpeed,
485 double powerPortion,
486 double fuelConversionFactor,
487 double fuelDensity,
488 double LocomotiveVirtualTractivePower,
489 std::function<std::pair<bool, double>(
490 double, double, double)>
491 ConsumeFuelFunc);
492
493 std::pair<bool, double> consumeEnergyFromHybridTechnology(
494 double timeStep,
495 double trainSpeed,
496 double powerPortion,
497 double EC_kwh,
498 double fuelConversionFactor,
499 double fuelDensity,
500 double LocomotiveVirtualTractivePower,
501 std::function<std::pair<bool, double>(
502 double, double, double)>
503 ConsumeFuelFunc);
504
514
523 void updateLocNotch(double &trainSpeed);
524
535 void reducePower(double &reductionFactor);
536
544
550 double getMaxProvidedEnergy(double &timeStep);
551
558 double canProvideEnergy(double &EC, double &timeStep);
559
571 friend ostream& operator<<(ostream& ostr, Locomotive& stud);
572};
573
574
575
576#endif // !NeTrainSim_Locomotive_h
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