67 double actualBatteryCapacity = 0;
70 const std::string abc = vehicleParams.
getParameter(attrName,
"-1");
74 WRITE_WARNING(
"Invalid value '" + abc +
"'for vehicle parameter '" + attrName +
"'. Using the default of " + std::to_string(actualBatteryCapacity));
78 const std::string abc = typeParams.
getParameter(attrName,
"-1");
81 WRITE_WARNING(
"Vehicle '" + v.
getID() +
"' does not provide vehicle parameter '" + attrName +
"'. Using the vehicle type value of " + std::to_string(actualBatteryCapacity));
83 WRITE_WARNING(
"Invalid value '" + abc +
"'for vehicle type parameter '" + attrName +
"'. Using the default of " + std::to_string(actualBatteryCapacity));
86 WRITE_WARNING(
"Vehicle '" + v.
getID() +
"' does not provide vehicle or vehicle type parameter '" + attrName +
"'. Using the default of " + std::to_string(actualBatteryCapacity));
91 double maximumBatteryCapacity = 0;
94 const std::string mbc = typeParams.
getParameter(attrName,
"-1");
98 WRITE_WARNING(
"Invalid value '" + mbc +
"'for vType parameter '" + attrName +
"'");
101 WRITE_WARNING(
"Vehicle '" + v.
getID() +
"' is missing the vType parameter '" + attrName +
"'. Using the default of " + std::to_string(maximumBatteryCapacity));
105 double overheadWireChargingPower = 0;
108 const std::string ocp = typeParams.
getParameter(attrName,
"-1");
112 WRITE_WARNING(
"Invalid value '" + ocp +
"'for vType parameter '" + attrName +
"'");
115 WRITE_WARNING(
"Vehicle '" + v.
getID() +
"' is missing the vType parameter '" + attrName +
"'. Using the default of " + std::to_string(overheadWireChargingPower));
121 std::map<int, double> param;
137 actualBatteryCapacity, maximumBatteryCapacity, overheadWireChargingPower, param);
140 into.push_back(device);
149 const double actualBatteryCapacity,
const double maximumBatteryCapacity,
const double overheadWireChargingPower,
const std::map<int, double>& param) :
151 myActualBatteryCapacity(0),
152 myMaximumBatteryCapacity(0),
153 myOverheadWireChargingPower(0),
157 myBatteryDischargedLogic(false),
160 myCircuitCurrent(NAN),
161 myCircuitVoltage(NAN),
162 myMaxBatteryPower(NAN),
163 myMinBatteryPower(NAN),
164 myTotalPowerConsumed(0),
165 myTotalPowerRegenerated(0),
166 myTotalPowerWasted(0),
169 myActOverheadWireSegment(nullptr),
170 myPreviousOverheadWireSegment(nullptr),
172 veh_pos_tail_elem(nullptr),
173 pos_veh_node(nullptr) {
174 if (maximumBatteryCapacity < 0) {
180 if (actualBatteryCapacity > maximumBatteryCapacity) {
187 if (overheadWireChargingPower < 0) {
236 std::vector<std::pair<SUMOTime, double> > speedTimeLine;
242 speedTimeLine.push_back(
246 speedTimeLine.push_back(
251 static_cast<MSVehicle*
>(&veh)->getInfluencer().setSpeedTimeLine(speedTimeLine);
270 double powerWasted = 0.0;
272 if (overheadWireSegmentID !=
"") {
296 if (actualSubstation !=
nullptr) {
313 if (actualSubstation !=
nullptr) {
324 WRITE_WARNING(
"pos_veh_node or neg_veh_node or veh_elem is not NULL (and they shoud be at the beginning of adding elecHybrid to the circuit)");
334 Element::ElementType::CURRENT_SOURCE_traction_wire);
350 double relativeComplementaryPosOnSegment =
357 if (strncmp(element_pos->
getName().c_str(),
"pos_tail_", 9) != 0) {
375 resistance, node_pos,
pos_veh_node, Element::ElementType::RESISTOR_traction_wire);
378 WRITE_WARNING(
"The resistivity of overhead wire segment connected to vehicle " + veh.
getID() +
" is < 0. Set to 1e-6.");
404 if (voltage < 10 || voltage > 1500 ||
ISNAN(voltage)) {
429 WRITE_ERROR(
"Overhead wire solver is on, but the Eigen library has not been compiled in!")
437 double voltage = 0.0;
438 if (actualSubstation !=
nullptr) {
458 if (powerWanted < 0.0) {
459 powerWasted = -powerWanted;
509 WRITE_ERROR(
"Overhead wire solver is on, but the Eigen library has not been compiled in!")
556 const double frontOnLane,
557 const double timeOnLane,
558 const double meanSpeedFrontOnLane,
559 const double meanSpeedVehicleOnLane,
560 const double travelledDistanceFrontOnLane,
561 const double travelledDistanceVehicleOnLane,
562 const double meanLengthOnLane) {
579 WRITE_ERROR(
"During deleting vehicle '" + veh.
getID() +
"' from circuit some init previous Nodes or Elements was not assigned.");
583 WRITE_ERROR(
"During deleting vehicle '" + veh.
getID() +
"' from circuit the size of element-vector of pNode or nNode was not 3. It should be 3 by Jakub's opinion.");
595 WRITE_ERROR(
"During deleting vehicle '" + veh.
getID() +
"' from circuit the size of element-vector of pNode or nNode was not 1. It should be 1 by Jakub's opinion.");
620 if (node_last !=
nullptr) {
624 if (elem_last !=
nullptr) {
627 WRITE_ERROR(
"The element or node with the last Id was not found in the circuit!");
646 #ifdef ELECHYBRID_MESOSCOPIC_DEBUG
648 std::cout <<
"device '" <<
getID() <<
"' notifyEnter: reason=" << reason <<
" currentEdge=" << veh.
getEdge()->
getID() <<
"\n";
664 #ifdef ELECHYBRID_MESOSCOPIC_DEBUG
666 std::cout <<
"device '" <<
getID() <<
"' notifyLeave: reason=" << reason <<
" currentEdge=" << veh.
getEdge()->
getID() <<
"\n";
670 std::cout <<
"***************** MESO - notifyLeave*** START ****************** '" << v.
getID() <<
"' \n";
672 std::cout <<
"getSpeed: '" << v.
getSpeed() <<
"' | getAverageSpeed: '" << v.
getAverageSpeed() <<
"' | getStoptime: '" << v.getStoptime(v.
getSegment(), 0) <<
"' \n";
675 std::cout <<
"***************** MESO - notifyLeave*** END ****************** '" << v.
getID() <<
"' \n";
692 WRITE_ERROR(
"Overhead wire solver is on, but the Eigen library has not been compiled in!")
699 if (prevSubstation !=
nullptr) {
712 const double upper) {
714 myParam.find(paramKey)->second < lower ||
715 myParam.find(paramKey)->second > upper) {
724 if (tripinfoOut !=
nullptr) {
726 tripinfoOut->
openTag(
"elechybrid");
803 if (owc !=
nullptr) {
807 WRITE_ERROR(
"Overhead wire solver is on, but the Eigen library has not been compiled in!")
868 if (actualBatteryCapacity < 0.0) {
const double WIRE_RESISTIVITY
#define WRITE_WARNING(msg)
@ SUMO_TAG_OVERHEAD_WIRE_SEGMENT
An overhead wire segment.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_MAXIMUMPOWER
Maximum Power.
@ SUMO_ATTR_ENERGYCONSUMED
Energy consumed.
@ SUMO_ATTR_SUBSTATIONID
id of a traction substation substation
@ SUMO_ATTR_MAXIMUMBATTERYCAPACITY
Maxium battery capacity.
@ SUMO_ATTR_ROLLDRAGCOEFFICIENT
Roll Drag coefficient.
@ SUMO_ATTR_CONSTANTPOWERINTAKE
Constant Power Intake.
@ SUMO_ATTR_RECUPERATIONEFFICIENCY_BY_DECELERATION
Recuperation efficiency (by deceleration)
@ SUMO_ATTR_RECUPERATIONEFFICIENCY
Recuperation efficiency (constant)
@ SUMO_ATTR_AIRDRAGCOEFFICIENT
Air drag coefficient.
@ SUMO_ATTR_ACTUALBATTERYCAPACITY
@ SUMO_ATTR_VEHICLEMASS
Vehicle mass.
@ SUMO_ATTR_RADIALDRAGCOEFFICIENT
Radial drag coefficient.
@ SUMO_ATTR_ENERGYCHARGED
tgotal of Energy charged
@ SUMO_ATTR_OVERHEADWIREID
@ SUMO_ATTR_PROPULSIONEFFICIENCY
Propulsion efficiency.
@ SUMO_ATTR_INTERNALMOMENTOFINERTIA
Internal moment of inertia.
@ SUMO_ATTR_FRONTSURFACEAREA
Front surface area.
@ SUMO_ATTR_OVERHEADWIRECHARGINGPOWER
#define UNUSED_PARAMETER(x)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Element * addElement(string name, double value, Node *pNode, Node *nNode, Element::ElementType et)
void eraseNode(Node *node)
Node * getNode(string name)
Element * getVoltageSource(int id)
Element * getElement(string name)
double alphaBest
Best alpha scaling value.
Node * addNode(string name)
void eraseElement(Element *element)
void setCurrent(double current)
void setPosNode(Node *node)
void setResistance(double resistance)
void setPowerWanted(double powerWanted)
static double angleDiff(const double angle1, const double angle2)
Returns the difference of the second angle to the first angle in radiants.
Helper methods for energy-based electricity consumption computation based on the battery device.
double compute(const SUMOEmissionClass c, const PollutantsInterface::EmissionType e, const double v, const double a, const double slope, const std::map< int, double > *param) const
Computes the emitted pollutant amount using the given speed and acceleration.
double acceleration(const SUMOEmissionClass c, const PollutantsInterface::EmissionType e, const double v, const double P, const double slope, const std::map< int, double > *param) const
Computes the achievable acceleration using the given speed and amount of consumed electric power.
double getDefaultParam(int paramKey) const
A vehicle from the mesoscopic point of view.
double getLastEntryTimeSeconds() const
Returns the entry time for the current segment.
double getBlockTimeSeconds() const
Returns the time at which the vehicle was blocked on the current segment.
double getAverageSpeed() const
Returns the vehicle's estimated average speed on the segment assuming no further delays.
SUMOTime getAccumulatedWaitingTime() const
Returns the duration for which the vehicle was blocked.
SUMOTime getLastEntryTime() const
Returns the time the vehicle entered the current segment.
MESegment * getSegment() const
Returns the current segment the vehicle is on.
SUMOTime getWaitingTime() const
Returns the duration for which the vehicle was blocked.
double getSpeed() const
Returns the vehicle's estimated speed assuming no delays.
A device which collects info on the vehicle trip (mainly on departure and arrival)
void setEnergyCharged(double energyCharged)
bool myCharging
Parameter, Flag: Vehicle is charging (by default is false)
void setCurrentFromOverheadWire(double current)
double myMaximumBatteryCapacity
Parameter, The total vehicles's Battery Capacity in Wh, [myMaximumBatteryCapacity >= 0].
std::map< int, double > myParam
Parameter collection.
double getCircuitAlpha() const
MSOverheadWire * myPreviousOverheadWireSegment
Parameter, Pointer to the act overhead wire segment in previous step (by default is nullptr),...
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
void deleteVehicleFromCircuit(SUMOVehicle &veh)
double getVoltageOfOverheadWire() const
Get actual voltage on the overhead wire segment.
double myEnergyCharged
Energy flowing into (+) or from (-) the battery pack in the given timestep.
bool notifyLeave(SUMOTrafficObject &tObject, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves arrival info.
double mySOCMax
Maximal SOC of the battery pack, battery will not be charged above this level. (But the buffer may st...
double getMaximumBatteryCapacity() const
Get the total vehicle's Battery Capacity in kWh.
double consumption(SUMOVehicle &veh, double a, double newSpeed)
double getParameterDouble(const std::string &key) const
double getPowerWanted() const
void setConsum(const double consumption)
bool isBatteryDischarged() const
Get consum.
void generateOutput(OutputDevice *tripinfoOut) const
Called on writing tripinfo output.
double myConsum
Parameter, Vehicle consumption during a time step (by default is 0.)
void setActualBatteryCapacity(const double actualBatteryCapacity)
Set actual vehicle's Battery Capacity in kWh.
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key
double acceleration(SUMOVehicle &veh, double power, double oldSpeed)
double myLastAngle
Parameter, Vehicle's last angle.
double getCurrentFromOverheadWire() const
Get actual current in the overhead wire segment.
bool myBatteryDischargedLogic
Parameter, Flag: Battery of Vehicle is fully discharged (by default is false)
const std::string deviceName() const
return the name for this type of device
bool notifyMove(SUMOTrafficObject &tObject, double oldPos, double newPos, double newSpeed)
Checks for waiting steps when the vehicle moves.
void checkParam(const SumoXMLAttr paramKey, const double lower=0., const double upper=std::numeric_limits< double >::infinity())
double myOverheadWireChargingPower
Parameter, overhead wire charging power to battery, if the battery SoC is not full (in Watt)
void setVoltageOfOverheadWire(double voltage)
double myTotalPowerWasted
Energy that could not be stored back to the battery or traction station and was wasted on resistors....
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_ElecHybrid-options.
~MSDevice_ElecHybrid()
Destructor.
MSOverheadWire * myActOverheadWireSegment
Parameter, Pointer to the actual overhead wire segment in which vehicle is placed (by default is null...
double myActualBatteryCapacity
Parameter, The actual vehicles's Battery Capacity in Wh, [myActualBatteryCapacity <= myMaximumBattery...
double getEnergyCharged() const
Get charged energy.
std::string getTractionSubstationID() const
Get actual traction substationn ID.
virtual void notifyMoveInternal(const SUMOTrafficObject &tObject, const double frontOnLane, const double timeOnLane, const double meanSpeedFrontOnLane, const double meanSpeedVehicleOnLane, const double travelledDistanceFrontOnLane, const double travelledDistanceVehicleOnLane, const double meanLengthOnLane)
Internal notification about the vehicle moves.
double myTotalPowerConsumed
bool notifyEnter(SUMOTrafficObject &tObject, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves departure info on insertion.
double myTotalPowerRegenerated
MSDevice_ElecHybrid(SUMOVehicle &holder, const std::string &id, const double actualBatteryCapacity, const double maximumBatteryCapacity, const double overheadWireChargingPower, const std::map< int, double > ¶m)
Constructor.
double getActualBatteryCapacity() const
Get the actual vehicle's Battery Capacity in kWh.
double getConsum() const
Get consum.
Element * veh_pos_tail_elem
double myCircuitCurrent
Parameter, Current wanted at overhead wire in next timestep.
std::string getOverheadWireSegmentID() const
Get actual overhead wire segment ID.
void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this device. Throw exception for unsupported key
static void insertDefaultAssignmentOptions(const std::string &deviceName, const std::string &optionsTopic, OptionsCont &oc, const bool isPerson=false)
Adds common command options that allow to assign devices to vehicles.
static bool equippedByDefaultAssignmentOptions(const OptionsCont &oc, const std::string &deviceName, DEVICEHOLDER &v, bool outputOptionSet, const bool isPerson=false)
Determines whether a vehicle should get a certain device.
MSLane * leftLane(const MSLane *const lane) const
Returns the lane left to the one given, 0 if the given lane is leftmost.
MSLane * rightLane(const MSLane *const lane) const
Returns the lane right to the one given, 0 if the given lane is rightmost.
static bool gOverheadWireSolver
Representation of a lane in the micro simulation.
double getLength() const
Returns the lane's length.
Notification
Definition of a vehicle state.
@ NOTIFICATION_TELEPORT
The vehicle is being teleported.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
std::string getStoppingPlaceID(const MSLane *lane, const double pos, const SumoXMLTag category) const
Returns the stop of the given category close to the given position.
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
Definition of overhead wire segment.
Circuit * getCircuit() const
void addChargeValueForOutput(double WCharged, MSDevice_ElecHybrid *elecHybrid, bool ischarging=1)
add charge value for output
MSTractionSubstation * getTractionSubstation() const
void eraseVehicle(SUMOVehicle &veh)
void addVehicle(SUMOVehicle &veh)
const MSLane & getLane() const
Returns the lane this stop is located at.
void decreaseElecHybridCount()
void eraseVehicle(MSDevice_ElecHybrid *elecHybrid)
double getSubstationVoltage() const
void addSolvingCirucitToEndOfTimestepEvents()
void increaseElecHybridCount()
void addVehicle(MSDevice_ElecHybrid *elecHybrid)
Abstract in-vehicle device.
Representation of a vehicle in the micro simulation.
const SUMOVTypeParameter & getParameter() const
const std::string & getID() const
Returns the id.
vector< Element * > * getElements()
void addElement(Element *element)
void eraseElement(Element *element)
A storage for options typed value containers)
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
double getDouble(const std::string &key, const double defaultValue) const
Returns the value for a given key converted to a double.
const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
bool knowsParameter(const std::string &key) const
Returns whether the parameter is known.
static const HelpersEnergy & getEnergyHelper()
get energy helper
Representation of a vehicle, person, or container.
virtual bool isVehicle() const
Whether it is a vehicle.
virtual double getSlope() const =0
Returns the slope of the road at object's position in degrees.
virtual double getSpeed() const =0
Returns the object's current speed.
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
virtual const MSLane * getLane() const =0
Returns the lane the object is currently at.
virtual const MSEdge * getEdge() const =0
Returns the edge the object is currently at.
virtual double getPositionOnLane() const =0
Get the object's position along the lane.
Structure representing possible vehicle parameter.
Representation of a vehicle.
virtual double getAngle() const =0
Get the vehicle's angle.
Structure representing possible vehicle parameter.
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter