Eclipse SUMO - Simulation of Urban MObility
MSDevice_ElecHybrid.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2002-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
19 // A device which stands as an implementation ElecHybrid and which outputs movereminder calls
20 /****************************************************************************/
21 #pragma once
22 #include <config.h>
23 
25 #include <microsim/MSVehicle.h>
27 #include <utils/common/SUMOTime.h>
29 
30 // ===========================================================================
31 // class declarations
32 // ===========================================================================
33 class SUMOVehicle;
34 
35 
36 // ===========================================================================
37 // class definitions
38 // ===========================================================================
48 public:
52  static void insertOptions(OptionsCont& oc);
53 
54 
65  static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
66 
69 
70 
71 
74 
84  bool notifyMove(SUMOTrafficObject& tObject, double oldPos, double newPos, double newSpeed);
85 
94  bool notifyEnter(SUMOTrafficObject& tObject, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
95 
96 
105  bool notifyLeave(SUMOTrafficObject& tObject, double lastPos, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
106 
110  virtual void notifyMoveInternal(
111  const SUMOTrafficObject& tObject,
112  const double frontOnLane,
113  const double timeOnLane,
114  const double meanSpeedFrontOnLane,
115  const double meanSpeedVehicleOnLane,
116  const double travelledDistanceFrontOnLane,
117  const double travelledDistanceVehicleOnLane,
118  const double meanLengthOnLane);
120 
122  const std::string deviceName() const {
123  return "elecHybrid";
124  }
125 
127  std::string getParameter(const std::string& key) const;
128 
129  double getParameterDouble(const std::string& key) const;
130 
132  void setParameter(const std::string& key, const std::string& value);
133 
140  void generateOutput(OutputDevice* tripinfoOut) const;
141 
143  double getActualBatteryCapacity() const;
144 
146  double getMaximumBatteryCapacity() const;
147 
149  std::string getOverheadWireSegmentID() const;
150 
152  std::string getTractionSubstationID() const;
153 
155  double getEnergyCharged() const;
156 
157  void setEnergyCharged(double energyCharged);
158 
159  double getCircuitAlpha() const;
160 
161  double getPowerWanted() const;
162 
164  double getCurrentFromOverheadWire() const;
165 
166  void setCurrentFromOverheadWire(double current);
167 
169  double getVoltageOfOverheadWire() const;
170 
171  void setVoltageOfOverheadWire(double voltage);
172 
174  double getConsum() const;
175 
176  double getDistance() const {
177  return myDistance;
178  }
179 
181  bool isBatteryDischarged() const;
182 
184  void setActualBatteryCapacity(const double actualBatteryCapacity);
185 
187  double storeEnergyToBattery(const double energy);
188 
190  void updateTotalEnergyWasted(const double energyWasted);
191 
192  void setConsum(const double consumption);
193 
194  double acceleration(SUMOVehicle& veh, double power, double oldSpeed);
195 
197  double consumption(SUMOVehicle& veh, double a, double newSpeed);
198 
200  double computeChargedEnergy(double energyIn);
201 
204  };
205 
207  return veh_elem;
208  }
209 
211  const EnergyParams& getEnergyParams() const {
212  return myParam;
213  }
214 
215 private:
221  MSDevice_ElecHybrid(SUMOVehicle& holder, const std::string& id,
222  const double actualBatteryCapacity, const double maximumBatteryCapacity, const double overheadWireChargingPower, const EnergyParams& param);
223 
224  void checkParam(const SumoXMLAttr paramKey, const double lower = 0., const double upper = std::numeric_limits<double>::infinity());
225 
226 protected:
229 
232 
235 
238 
240  double myLastAngle;
241 
243  double myConsum;
244 
247 
250 
253 
256 
258 
265 
271 
275  double mySOCMin;
278  double mySOCMax;
280 
283 
286 
287  double myDistance;
288 
289  //circuit element of elecHybrid device
290  // ----|veh_pos_tail_elem|---------|pos_veh_node|--------
291  // |
292  // |
293  // |veh_elem|
294  // |
295  // |
296  // ----------------------------------|ground|------------
300 
302 
303 
304 private:
307 
310 
311 
312 };
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
An upper class for objects with additional parameters.
Definition: EnergyParams.h:41
A device which collects info on the vehicle trip (mainly on departure and arrival)
void setEnergyCharged(double energyCharged)
const EnergyParams & getEnergyParams() const
retrieve parameters for the energy consumption model
bool myCharging
Parameter, Flag: Vehicle is charging (by default is false)
MSDevice_ElecHybrid & operator=(const MSDevice_ElecHybrid &)
Invalidated assignment operator.
EnergyParams myParam
Parameter collection.
MSOverheadWire * getActOverheadWireSegment()
void setCurrentFromOverheadWire(double current)
double myMaximumBatteryCapacity
Parameter, The total vehicles's Battery Capacity in Wh, [myMaximumBatteryCapacity >= 0].
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)
return energy consumption in Wh (power multiplied by TS)
double getDistance() const
double computeChargedEnergy(double energyIn)
compute charged energy properly considering recuperation and propulsion efficiency during charging ba...
double getParameterDouble(const std::string &key) const
double myTotalEnergyWasted
Energy that could not be stored back to the battery or traction station and was wasted on resistors....
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 storeEnergyToBattery(const double energy)
Attempt to store energy into battery pack and return the energy that could not be accomodated due to ...
void updateTotalEnergyWasted(const double energyWasted)
Add energyWasted to the total sum myTotalEnergyWasted.
double myLastAngle
Parameter, Vehicle's last angle.
double getCurrentFromOverheadWire() const
Get actual current in the overhead wire segment.
MSDevice_ElecHybrid(const MSDevice_ElecHybrid &)
Invalidated copy constructor.
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)
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_ElecHybrid-options.
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.
bool notifyEnter(SUMOTrafficObject &tObject, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves departure info on insertion.
MSDevice_ElecHybrid(SUMOVehicle &holder, const std::string &id, const double actualBatteryCapacity, const double maximumBatteryCapacity, const double overheadWireChargingPower, const EnergyParams &param)
Constructor.
double getActualBatteryCapacity() const
Get the actual vehicle's Battery Capacity in kWh.
double getConsum() const
Get consum.
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
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
Notification
Definition of a vehicle state.
Definition of overhead wire segment.
Abstract in-vehicle device.
Definition: Node.h:39
A storage for options typed value containers)
Definition: OptionsCont.h:89
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
Representation of a vehicle, person, or container.
Representation of a vehicle.
Definition: SUMOVehicle.h:60