Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2002-2024 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 : /****************************************************************************/
14 : /// @file MSDevice_ElecHybrid.h
15 : /// @author Jakub Sevcik (RICE)
16 : /// @author Jan Prikryl (RICE)
17 : /// @date 2019-12-15
18 : ///
19 : // A device which stands as an implementation ElecHybrid and which outputs movereminder calls
20 : /****************************************************************************/
21 : #pragma once
22 : #include <config.h>
23 :
24 : #include <microsim/devices/MSVehicleDevice.h>
25 : #include <microsim/MSVehicle.h>
26 : #include <microsim/trigger/MSOverheadWire.h>
27 : #include <utils/common/SUMOTime.h>
28 : #include <utils/emissions/EnergyParams.h>
29 :
30 : // ===========================================================================
31 : // class declarations
32 : // ===========================================================================
33 : class SUMOVehicle;
34 : class MSDevice_Emissions;
35 :
36 :
37 : // ===========================================================================
38 : // class definitions
39 : // ===========================================================================
40 : /**
41 : * @class MSDevice_ElecHybrid
42 : * @brief A device which collects info on the vehicle trip (mainly on departure and arrival)
43 : *
44 : * Each device collects departure time, lane and speed and the same for arrival.
45 : *
46 : * @see MSDevice
47 : */
48 : class MSDevice_ElecHybrid : public MSVehicleDevice {
49 : public:
50 : /** @brief Inserts MSDevice_ElecHybrid-options
51 : * @param[filled] oc The options container to add the options to
52 : */
53 : static void insertOptions(OptionsCont& oc);
54 :
55 :
56 : /** @brief Build devices for the given vehicle, if needed
57 : *
58 : * The options are read and evaluated whether a ElecHybrid-device shall be built
59 : * for the given vehicle.
60 : *
61 : * The built device is stored in the given vector.
62 : *
63 : * @param[in] v The vehicle for which a device may be built
64 : * @param[filled] into The vector to store the built device in
65 : */
66 : static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
67 :
68 : /// @brief Destructor.
69 : ~MSDevice_ElecHybrid();
70 :
71 :
72 :
73 : /// @name Methods called on vehicle movement / state change, overwriting MSDevice
74 : /// @{
75 :
76 : /** @brief Checks for waiting steps when the vehicle moves
77 : *
78 : * @param[in] veh Vehicle that asks this reminder.
79 : * @param[in] oldPos Position before move.
80 : * @param[in] newPos Position after move with newSpeed.
81 : * @param[in] newSpeed Moving speed.
82 : *
83 : * @return True (always).
84 : */
85 : bool notifyMove(SUMOTrafficObject& tObject, double oldPos, double newPos, double newSpeed);
86 :
87 : /** @brief Saves departure info on insertion
88 : *
89 : * @param[in] veh The entering vehicle.
90 : * @param[in] reason how the vehicle enters the lane
91 : * @return Always true
92 : * @see MSMoveReminder::notifyEnter
93 : * @see MSMoveReminder::Notification
94 : */
95 : bool notifyEnter(SUMOTrafficObject& tObject, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
96 :
97 :
98 : /** @brief Saves arrival info
99 : *
100 : * @param[in] veh The leaving vehicle.
101 : * @param[in] lastPos Position on the lane when leaving.
102 : * @param[in] isArrival whether the vehicle arrived at its destination
103 : * @param[in] isLaneChange whether the vehicle changed from the lane
104 : * @return True if it did not leave the net.
105 : */
106 : bool notifyLeave(SUMOTrafficObject& tObject, double lastPos, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
107 :
108 : /** @brief Internal notification about the vehicle moves
109 : * @see MSMoveReminder::notifyMoveInternal()
110 : */
111 : virtual void notifyMoveInternal(
112 : const SUMOTrafficObject& tObject,
113 : const double frontOnLane,
114 : const double timeOnLane,
115 : const double meanSpeedFrontOnLane,
116 : const double meanSpeedVehicleOnLane,
117 : const double travelledDistanceFrontOnLane,
118 : const double travelledDistanceVehicleOnLane,
119 : const double meanLengthOnLane);
120 : /// @}
121 :
122 : /// @brief return the name for this type of device
123 0 : const std::string deviceName() const {
124 0 : return "elecHybrid";
125 : }
126 :
127 : /// @brief try to retrieve the given parameter from this device. Throw exception for unsupported key
128 : std::string getParameter(const std::string& key) const;
129 :
130 : double getParameterDouble(const std::string& key) const;
131 :
132 : /// @brief try to set the given parameter for this device. Throw exception for unsupported key
133 : void setParameter(const std::string& key, const std::string& value);
134 :
135 : /** @brief Called on writing tripinfo output
136 : *
137 : * @param[in] tripinfoOut The output device to write the information into
138 : * @exception IOError not yet implemented
139 : * @see MSDevice::tripInfoOutput
140 : */
141 : void generateOutput(OutputDevice* tripinfoOut) const;
142 :
143 : /// @brief Get the actual vehicle's Battery Capacity in kWh
144 : double getActualBatteryCapacity() const;
145 :
146 : /// @brief Get the total vehicle's Battery Capacity in kWh
147 : double getMaximumBatteryCapacity() const;
148 :
149 : /// @brief Get actual overhead wire segment ID
150 : std::string getOverheadWireSegmentID() const;
151 :
152 : /// @brief Get actual traction substation ID
153 : std::string getTractionSubstationID() const;
154 :
155 : /// @brief Get charged energy
156 : double getEnergyCharged() const;
157 :
158 : void setEnergyCharged(double energyCharged);
159 :
160 : double getCircuitAlpha() const;
161 :
162 : double getPowerWanted() const;
163 :
164 : /// @brief Get actual current in the overhead wire segment
165 : double getCurrentFromOverheadWire() const;
166 :
167 : void setCurrentFromOverheadWire(double current);
168 :
169 : /// @brief Get actual voltage on the overhead wire segment
170 : double getVoltageOfOverheadWire() const;
171 :
172 : void setVoltageOfOverheadWire(double voltage);
173 :
174 : /// @brief Get consum
175 : double getConsum() const;
176 :
177 : double getDistance() const {
178 : return myDistance;
179 : }
180 :
181 : /// @brief Get consum
182 : bool isBatteryDischarged() const;
183 :
184 : /// @brief Set actual vehicle's Battery Capacity in kWh
185 : void setActualBatteryCapacity(const double actualBatteryCapacity);
186 :
187 : /// @brief Attempt to store energy into battery pack and return the energy that could not be accommodated due to SOC limits
188 : double storeEnergyToBattery(const double energy);
189 :
190 : /// @brief Add energyWasted to the total sum myTotalEnergyWasted
191 : void updateTotalEnergyWasted(const double energyWasted);
192 :
193 : void setConsum(const double consumption);
194 :
195 : double acceleration(SUMOVehicle& veh, double power, double oldSpeed);
196 :
197 : /// @brief return energy consumption in Wh (power multiplied by TS)
198 : double consumption(SUMOVehicle& veh, double a, double newSpeed);
199 :
200 : /// @brief compute charged energy properly considering recuperation and propulsion efficiency during charging battery from overhead wire or discharging battery to recuperate into overhead wire
201 : double computeChargedEnergy(double energyIn);
202 :
203 : MSOverheadWire* getActOverheadWireSegment() {
204 180 : return myActOverheadWireSegment;
205 : };
206 :
207 : Element* getVehElem() {
208 180 : return veh_elem;
209 : }
210 :
211 : private:
212 : /** @brief Constructor
213 : *
214 : * @param[in] holder The vehicle that holds this device
215 : * @param[in] id The ID of the device
216 : */
217 : MSDevice_ElecHybrid(SUMOVehicle& holder, const std::string& id,
218 : const double actualBatteryCapacity, const double maximumBatteryCapacity, const double overheadWireChargingPower);
219 :
220 : protected:
221 : /// @brief Parameter, The actual vehicles's Battery Capacity in Wh, [myActualBatteryCapacity <= myMaximumBatteryCapacity]
222 : double myActualBatteryCapacity;
223 :
224 : /// @brief Parameter, The total vehicles's Battery Capacity in Wh, [myMaximumBatteryCapacity >= 0]
225 : double myMaximumBatteryCapacity;
226 :
227 : /// @brief Parameter, overhead wire charging power to battery, if the battery SoC is not full (in Watt)
228 : double myOverheadWireChargingPower;
229 :
230 : /// @brief Parameter holding emission device
231 : MSDevice_Emissions* myEmissionDevice;
232 :
233 : /// @brief Parameter, Vehicle's last angle
234 : double myLastAngle;
235 :
236 : /// @brief Parameter, Vehicle consumption during a time step (by default is 0.)
237 : double myConsum;
238 :
239 : /// @brief Parameter, Flag: Battery of Vehicle is fully discharged (by default is false)
240 : bool myBatteryDischargedLogic;
241 :
242 : /// @brief Parameter, Flag: Vehicle is charging (by default is false)
243 : bool myCharging;
244 :
245 : /// @brief Energy flowing into (+) or from (-) the battery pack in the given timestep
246 : double myEnergyCharged;
247 :
248 : /// @brief Parameter, Current wanted at overhead wire in next timestep
249 : double myCircuitCurrent;
250 :
251 : double myCircuitVoltage;
252 :
253 : /// @name Tripinfo statistics
254 : /// @{
255 : double myMaxBatteryCharge;
256 : double myMinBatteryCharge;
257 : double myTotalEnergyConsumed;
258 : double myTotalEnergyRegenerated;
259 :
260 : /// @brief Energy that could not be stored back to the battery or traction station
261 : /// and was wasted on resistors. This is approximate, we ignore the use of classical
262 : /// brakes in lower speeds.
263 : double myTotalEnergyWasted;
264 : /// @}
265 :
266 : /// @name Power management parameters
267 : /// @{
268 : /// @brief Minimal SOC of the battery pack, below this value the battery is assumed discharged
269 : double mySOCMin;
270 : /// @brief Maximal SOC of the battery pack, battery will not be charged above this level.
271 : /// (But the buffer may still be used for regenerative braking).
272 : double mySOCMax;
273 : /// @}
274 :
275 : /// @brief Parameter, Pointer to the actual overhead wire segment in which vehicle is placed (by default is nullptr)
276 : MSOverheadWire* myActOverheadWireSegment;
277 :
278 : /// @brief Parameter, Pointer to the act overhead wire segment in previous step (by default is nullptr), i.e. auxiliar pointer for disabling charging vehicle from previous (not current) overherad wire segment
279 : MSOverheadWire* myPreviousOverheadWireSegment;
280 :
281 : double myDistance;
282 :
283 : //circuit element of elecHybrid device
284 : // ----|veh_pos_tail_elem|---------|pos_veh_node|--------
285 : // |
286 : // |
287 : // |veh_elem|
288 : // |
289 : // |
290 : // ----------------------------------|ground|------------
291 : Element* veh_elem;
292 : Element* veh_pos_tail_elem;
293 : Node* pos_veh_node;
294 :
295 : void deleteVehicleFromCircuit(SUMOVehicle& veh);
296 :
297 :
298 : private:
299 : /// @brief Invalidated copy constructor.
300 : MSDevice_ElecHybrid(const MSDevice_ElecHybrid&);
301 :
302 : /// @brief Invalidated assignment operator.
303 : MSDevice_ElecHybrid& operator=(const MSDevice_ElecHybrid&);
304 :
305 :
306 : };
|