SUMO - Simulation of Urban MObility
MSDevice_Battery.cpp
Go to the documentation of this file.
1 /****************************************************************************/
8 // The Battery parameters for the vehicle
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
11 // Copyright (C) 2013-2016 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
34 #include <utils/common/SUMOTime.h>
35 #include <utils/geom/GeomHelper.h>
36 #include <microsim/MSNet.h>
37 #include <microsim/MSLane.h>
38 #include <microsim/MSEdge.h>
39 #include <microsim/MSVehicle.h>
40 #include "MSDevice_Tripinfo.h"
41 #include "MSDevice_Battery.h"
42 
43 #ifdef CHECK_MEMORY_LEAKS
44 #include <foreign/nvwa/debug_new.h>
45 #endif // CHECK_MEMORY_LEAKS
46 
47 
48 // ===========================================================================
49 // method definitions
50 // ===========================================================================
51 // ---------------------------------------------------------------------------
52 // static initialisation methods
53 // ---------------------------------------------------------------------------
54 void
56  insertDefaultAssignmentOptions("battery", "Battery", oc);
57 }
58 
59 
60 void
61 MSDevice_Battery::buildVehicleDevices(SUMOVehicle& v, std::vector<MSDevice*>& into) {
63  return;
64  }
65 
66  // myMaximumBatteryCapacity
67  SUMOReal maximumBatteryCapacity = TplConvert::_2SUMOReal(v.getVehicleType().getParameter().getParameter("maximumBatteryCapacity", "0").c_str());
68 
69  // myActualBatteryCapacity
70  SUMOReal actualBatteryCapacity = 0;
71  if (v.getParameter().getParameter("actualBatteryCapacity", "-") == "-") {
72  actualBatteryCapacity = maximumBatteryCapacity / 2.0;
73  } else {
74  actualBatteryCapacity = TplConvert::_2SUMOReal(v.getParameter().getParameter("actualBatteryCapacity", "0").c_str());
75  }
76 
77  // powerMax
78  SUMOReal powerMax = TplConvert::_2SUMOReal(v.getVehicleType().getParameter().getParameter("maximumPower", "100").c_str());
79 
80  // mass
81  SUMOReal mass = TplConvert::_2SUMOReal(v.getVehicleType().getParameter().getParameter("vehicleMass", "1000").c_str());
82 
83  // frontSurfaceArea
84  SUMOReal frontSurfaceArea = TplConvert::_2SUMOReal(v.getVehicleType().getParameter().getParameter("frontSurfaceArea", "2").c_str());
85 
86  // airDragCoefficient
87  SUMOReal airDragCoefficient = TplConvert::_2SUMOReal(v.getVehicleType().getParameter().getParameter("airDragCoefficient", "0.4").c_str());
88 
89  // internalMomentOfInertia
90  SUMOReal internalMomentOfInertia = TplConvert::_2SUMOReal(v.getVehicleType().getParameter().getParameter("internalMomentOfInertia", "10").c_str());
91 
92  // radialDragCoefficient
93  SUMOReal radialDragCoefficient = TplConvert::_2SUMOReal(v.getVehicleType().getParameter().getParameter("radialDragCoefficient", "1").c_str());
94 
95  // rollDragCoefficient
96  SUMOReal rollDragCoefficient = TplConvert::_2SUMOReal(v.getVehicleType().getParameter().getParameter("rollDragCoefficient", "0.5").c_str());
97 
98  // constantPowerIntake
99  SUMOReal constantPowerIntake = TplConvert::_2SUMOReal(v.getVehicleType().getParameter().getParameter("constantPowerIntake", "10").c_str());
100 
101  // propulsionEfficiency
102  SUMOReal propulsionEfficiency = TplConvert::_2SUMOReal(v.getVehicleType().getParameter().getParameter("propulsionEfficiency", "0.5").c_str());
103 
104  // recuperationEfficiency
105  SUMOReal recuperationEfficiency = TplConvert::_2SUMOReal(v.getVehicleType().getParameter().getParameter("recuperationEfficiency", "0").c_str());
106 
107  // constructor
108  MSDevice_Battery* device = new MSDevice_Battery(v, "battery_" + v.getID(),
109  actualBatteryCapacity, maximumBatteryCapacity, powerMax, mass, frontSurfaceArea, airDragCoefficient,
110  internalMomentOfInertia, radialDragCoefficient, rollDragCoefficient,
111  constantPowerIntake, propulsionEfficiency, recuperationEfficiency, 0, 0);
112 
113  // Add device to vehicle
114  into.push_back(device);
115 }
116 
117 
118 bool MSDevice_Battery::notifyMove(SUMOVehicle& veh, SUMOReal /* oldPos */, SUMOReal /* newPos */, SUMOReal /* newSpeed */) {
119  // Start vehicleStoppedTimer if the vehicle is stopped. In other case reset timer
120  if (veh.getSpeed() < SUMO_const_haltingSpeed)
121  // Increase vehicle stopped timer
122  {
124  } else
125  // Reset vehicle Stopped
126  {
128  }
129 
130  // Update Energy from the battery
131  if (getMaximumBatteryCapacity() != 0) {
132  myConsum = getPropEnergy(veh);
133 
134  // Energy lost/gained from vehicle movement (via vehicle energy model) [kWh]
136 
137  // saturate between 0 and myMaximumBatteryCapacity [kWh]
138  if (getActualBatteryCapacity() < 0) {
140 
141  // Show warning if battery is depleted
142  if (getMaximumBatteryCapacity() > 0)
143  WRITE_WARNING("Battery of vehicle '" + veh.getID() + "' is depleted.")
144 
147  }
148 
149  setLastAngle(veh.getAngle());
150  }
151 
152  // Check if vehicle has under their position one charge Station
153  std::string ChargingStationID = MSNet::getInstance()->getChargingStationID(veh.getLane(), veh.getPositionOnLane());
154 
155  // If vehicle is over a charging station
156  if (ChargingStationID != "") {
157  // if the vehicle is almost stopped, or charge in transit is enabled, then charge vehicle
158  if ((veh.getSpeed() < SUMO_const_haltingSpeed) || (MSNet::getInstance()->getChargingStation(ChargingStationID)->getChargeInTransit() == 1)) {
159  // Set Flags Stopped/intransit to
160  if (veh.getSpeed() < SUMO_const_haltingSpeed) {
161  // vehicle ist almost stopped, then is charging stopped
162  myChargingStopped = true;
163 
164  // therefore isn't charging in transit
165  myChargingInTransit = false;
166  } else {
167  // vehicle is moving, and the Charging station allow charge in transit
168  myChargingStopped = false;
169 
170  // Therefore charge in transit
171  myChargingInTransit = true;
172  }
173 
174  // get pointer to charging station
176 
177  // Only update charging start time if vehicle allow charge in transit, or in other case
178  // if the vehicle not allow charge in transit but it's stopped.
180  // Update Charging start time
181  {
183  }
184 
185  // time it takes the vehicle at the station < charging station time delay?
187  // Enable charging vehicle
189 
190  // Calulate energy charged
192 
193  // Convert from [kWs] to [kWh] (3600s / 1h):
194  myEnergyCharged /= 3600;
195 
196  // Update Battery charge
199  } else {
201  }
202  }
203  }
204  }
205  // In other case, vehicle will be not charged
206  else {
207  // Disable flags
208  myChargingInTransit = false;
209  myChargingStopped = false;
210 
211  // Disable charging vehicle
212  if (myActChargingStation != NULL) {
214  }
215 
216  // Set charging station pointer to NULL
217  myActChargingStation = NULL;
218 
219  // Set energy charged to 0
220  myEnergyCharged = 0.00;
221 
222  // Reset timer
224  }
225 
226  // Always return true.
227  return true;
228 }
229 
230 
232  // Set last Energy ONLY when the vehicle is introduced in the simulation
234  setLastEnergy(getMass() * veh.getSpeed() * veh.getSpeed() / 2 + getMass() * 9.81 * veh.getLane()->getShape().front().z() + getInternalMomentOfInertia() * 0.5 * veh.getSpeed() * veh.getSpeed());
236  }
237 
238  // This function return always true
239  return true;
240 }
241 
242 
244  //Function implemented in MSBatteryExport
245 }
246 
247 
248 // ---------------------------------------------------------------------------
249 // MSDevice_Battery-methods
250 // ---------------------------------------------------------------------------
251 MSDevice_Battery::MSDevice_Battery(SUMOVehicle& holder, const std::string& id, const SUMOReal actualBatteryCapacity, const SUMOReal maximumBatteryCapacity, const SUMOReal powerMax, const SUMOReal mass, const SUMOReal frontSurfaceArea, const SUMOReal airDragCoefficient, const SUMOReal internalMomentOfInertia, const SUMOReal radialDragCoefficient, const SUMOReal rollDragCoefficient, const SUMOReal constantPowerIntake, const SUMOReal propulsionEfficiency, const SUMOReal recuperationEfficiency, const SUMOReal lastAngle, const SUMOReal lastEnergy) :
252  MSDevice(holder, id),
253  myActualBatteryCapacity(0), // [actualBatteryCapacity <= maximumBatteryCapacity]
254  myMaximumBatteryCapacity(0), // [maximumBatteryCapacity >= 0]
255  myPowerMax(0), // [maximumPower >= 0]
256  myMass(0), // [vehicleMass >= 0]
257  myFrontSurfaceArea(0), // [frontSurfaceArea >= 0]
258  myAirDragCoefficient(0), // [airDragCoefficient >=0]
259  myInternalMomentOfInertia(0), // [internalMomentOfInertia >= 0]
260  myRadialDragCoefficient(0), // [radialDragCoefficient >=0]
261  myRollDragCoefficient(0), // [rollDragCoefficient >= 0]
262  myConstantPowerIntake(0), // [constantPowerIntake >= 0]
263  myPropulsionEfficiency(0), // [1 >= propulsionEfficiency >= 0]
264  myRecuperationEfficiency(0), // [1 >= recuperationEfficiency >= 0]
265  myLastAngle(lastAngle), // Limit not needed
266  myLastEnergy(lastEnergy), // Limit not needed
267  myChargingStopped(false), // Initially vehicle don't charge stopped
268  myChargingInTransit(false), // Initially vehicle don't charge in transit
269  myConsum(0), // Initially the vehicle is stopped and therefore the consum is zero.
270  myActChargingStation(NULL), // Initially the vehicle isn't over a Charging Station
271  myEnergyCharged(0), // Initially the energy charged is zero
272  myVehicleStopped(0) { // Initially the vehicle is stopped and the corresponding variable is 0
273 
274  if (maximumBatteryCapacity < 0)
275  WRITE_WARNING("Battery builder: Vehicle '" + getID() + "' doesn't have a valid value for parameter maximum battery capacity (" + TplConvert::_2str(maximumBatteryCapacity) + ").")
276  else {
277  myMaximumBatteryCapacity = maximumBatteryCapacity;
278  }
279 
280  if (actualBatteryCapacity > maximumBatteryCapacity) {
281  WRITE_WARNING("Battery builder: Vehicle '" + getID() + "' has a actual battery capacity (" + TplConvert::_2str(actualBatteryCapacity) + ") greater than it's max battery capacity(" + TplConvert::_2str(maximumBatteryCapacity) + "). A max battery capacity value will be asigned");
283  } else {
284  myActualBatteryCapacity = actualBatteryCapacity;
285  }
286 
287  if (powerMax < 0)
288  WRITE_WARNING("Battery builder: Vehicle '" + getID() + "' doesn't have a valid value for parameter maximum power (" + TplConvert::_2str(powerMax) + ").")
289  else {
290  myPowerMax = powerMax;
291  }
292 
293  if (mass < 0)
294  WRITE_WARNING("Battery builder: Vehicle '" + getID() + "' doesn't have a valid value for parameter mass (" + TplConvert::_2str(mass) + ").")
295  else {
296  myMass = mass;
297  }
298 
299  if (frontSurfaceArea < 0)
300  WRITE_WARNING("Battery builder: Vehicle '" + getID() + "' doesn't have a valid value for parameter front surface Area (" + TplConvert::_2str(frontSurfaceArea) + ").")
301  else {
302  myFrontSurfaceArea = frontSurfaceArea;
303  }
304 
305  if (airDragCoefficient < 0)
306  WRITE_WARNING("Battery builder: Vehicle '" + getID() + "' doesn't have a valid value for parameter drag coefficient (" + TplConvert::_2str(airDragCoefficient) + ").")
307  else {
308  myAirDragCoefficient = airDragCoefficient;
309  }
310 
311  if (internalMomentOfInertia < 0)
312  WRITE_WARNING("Battery builder: Vehicle '" + getID() + "' doesn't have a valid value for parameter internal moment of insertia (" + TplConvert::_2str(internalMomentOfInertia) + ").")
313  else {
314  myInternalMomentOfInertia = internalMomentOfInertia;
315  }
316 
317  if (radialDragCoefficient < 0)
318  WRITE_WARNING("Battery builder: Vehicle '" + getID() + "' doesn't have a valid value for parameter radial friction coefficient (" + TplConvert::_2str(radialDragCoefficient) + ").")
319  else {
320  myRadialDragCoefficient = radialDragCoefficient;
321  }
322 
323  if (rollDragCoefficient < 0)
324  WRITE_WARNING("Battery builder: Vehicle '" + getID() + "' doesn't have a valid value for parameter roll friction coefficient (" + TplConvert::_2str(rollDragCoefficient) + ").")
325  else {
326  myRollDragCoefficient = rollDragCoefficient;
327  }
328 
329  if (constantPowerIntake < 0)
330  WRITE_WARNING("Battery builder: Vehicle '" + getID() + "' doesn't have a valid value for parameter constant power intake (" + TplConvert::_2str(constantPowerIntake) + ").")
331  else {
332  myConstantPowerIntake = constantPowerIntake;
333  }
334 
335  if (propulsionEfficiency < 0 || propulsionEfficiency > 1)
336  WRITE_WARNING("Battery builder: Vehicle '" + getID() + "' doesn't have a valid value for parameter propulsion efficiency (" + TplConvert::_2str(propulsionEfficiency) + ").")
337  else {
338  myPropulsionEfficiency = propulsionEfficiency;
339  }
340 
341  if (recuperationEfficiency < 0 || recuperationEfficiency > 1)
342  WRITE_WARNING("Battery builder: Vehicle '" + getID() + "' doesn't have a valid value for parameter Recuparation efficiency (" + TplConvert::_2str(recuperationEfficiency) + ").")
343  else {
344  myRecuperationEfficiency = recuperationEfficiency;
345  }
346 }
347 
348 
350 }
351 
352 
353 void
355  if (actualBatteryCapacity < 0) {
357  } else if (actualBatteryCapacity > myMaximumBatteryCapacity) {
359  } else {
360  myActualBatteryCapacity = actualBatteryCapacity;
361  }
362 }
363 
364 
365 void
367  if (myMaximumBatteryCapacity < 0)
368  WRITE_WARNING("Function setMaximumBatteryCapacity: Trying to insert into a battery device of vehicle '" + getID() + "' a invalid maximum battery capacity (" + TplConvert::_2str(maximumBatteryCapacity) + ").")
369  else {
370  myMaximumBatteryCapacity = maximumBatteryCapacity;
371  }
372 }
373 
374 
375 void
377  if (myMass < 0)
378  WRITE_WARNING("Function setMass: Trying to insert into a battery device of vehicle '" + getID() + "' a invalid mass value (" + TplConvert::_2str(mass) + ").")
379  else {
380  myMass = mass;
381  }
382 }
383 
384 
385 void
387  if (myPowerMax < 0)
388  WRITE_WARNING("Function setPowerMax: Trying to insert into a battery device of vehicle '" + getID() + "' a invalid power max value (" + TplConvert::_2str(powerMax) + ").")
389  else {
390  myPowerMax = powerMax;
391  }
392 }
393 
394 
395 void
397  if (myFrontSurfaceArea < 0)
398  WRITE_WARNING("Function setFrontSurfaceArea: Trying to insert into a battery device of vehicle '" + getID() + "' a invalid front surface Area value (" + TplConvert::_2str(frontSurfaceArea) + ").")
399  else {
400  myFrontSurfaceArea = frontSurfaceArea;
401  }
402 }
403 
404 
405 void
407  if (myAirDragCoefficient < 0)
408  WRITE_WARNING("Function setAirDragCoefficient: Trying to insert into a battery device of vehicle '" + getID() + "' a invalid drag coefficient value (" + TplConvert::_2str(airDragCoefficient) + ").")
409  else {
410  myAirDragCoefficient = airDragCoefficient;
411  }
412 }
413 
414 
415 void
418  WRITE_WARNING("Function setInternalMomentOfInertia: Trying to insert into a battery device of vehicle '" + getID() + "' a invalid internal moment of insertia value (" + TplConvert::_2str(internalMomentOfInertia) + ").")
419  else {
420  myInternalMomentOfInertia = internalMomentOfInertia;
421  }
422 }
423 
424 
425 void
427  if (myRadialDragCoefficient < 0)
428  WRITE_WARNING("Function setRadialDragCoefficient: Trying to insert into a battery device of vehicle '" + getID() + "' a invalid radial friction coefficient value (" + TplConvert::_2str(radialDragCoefficient) + ").")
429  else {
430  myRadialDragCoefficient = radialDragCoefficient;
431  }
432 }
433 
434 
435 void
437  if (myRollDragCoefficient < 0)
438  WRITE_WARNING("Function setRollDragCoefficient: Trying to insert into a battery device of vehicle '" + getID() + "' a invalid roll friction coefficient value (" + TplConvert::_2str(rollDragCoefficient) + ").")
439  else {
440  myRollDragCoefficient = rollDragCoefficient;
441  }
442 }
443 
444 
445 void
447  if (myConstantPowerIntake < 0)
448  WRITE_WARNING("Function setConstantPowerIntake: Trying to insert into a battery device of vehicle '" + getID() + "' a invalid constant power intake value (" + TplConvert::_2str(constantPowerIntake) + ").")
449  else {
450  myConstantPowerIntake = constantPowerIntake;
451  }
452 }
453 
454 
455 void
457  if (myPropulsionEfficiency < 0 || myPropulsionEfficiency > 1)
458  WRITE_WARNING("Function setPropulsionEfficiency: Trying to insert into a battery device of vehicle '" + getID() + "' a invalid propulsion efficiency value (" + TplConvert::_2str(propulsionEfficiency) + ").")
459  else {
460  myPropulsionEfficiency = propulsionEfficiency;
461  }
462 }
463 
464 
465 void
467  if (myRecuperationEfficiency < 0 || myRecuperationEfficiency > 1)
468  WRITE_WARNING("Function setRecuperationEfficiency: Trying to insert into a battery device of vehicle '" + getID() + "' a invalid recuparation efficiency value (" + TplConvert::_2str(recuperationEfficiency) + ").")
469  else {
470  myRecuperationEfficiency = recuperationEfficiency;
471  }
472 }
473 
474 
475 void
477  myLastAngle = lastAngle;
478 }
479 
480 
481 void
483  myLastEnergy = lastEnergy ;
484 }
485 
486 
487 void
490 }
491 
492 
493 void
496 }
497 
498 
499 void
501  myVehicleStopped = 0;
502 }
503 
504 
505 void
508 }
509 
510 
511 SUMOReal
514 }
515 
516 
517 SUMOReal
520 }
521 
522 
523 SUMOReal
525  return myPowerMax;
526 }
527 
528 
529 SUMOReal
531  return myMass;
532 }
533 
534 
535 SUMOReal
537  return myFrontSurfaceArea;
538 }
539 
540 
541 SUMOReal
543  return myAirDragCoefficient;
544 }
545 
546 
547 SUMOReal
550 }
551 
552 
553 SUMOReal
556 }
557 
558 
559 SUMOReal
561  return myRollDragCoefficient;
562 }
563 
564 
565 SUMOReal
567  return myConstantPowerIntake;
568 }
569 
570 
571 SUMOReal
573  return myPropulsionEfficiency;
574 }
575 
576 
577 SUMOReal
580 }
581 
582 
583 SUMOReal
585  return myLastAngle;
586 }
587 
588 
589 SUMOReal
591  return myLastEnergy;
592 }
593 
594 
595 SUMOReal
597  return myConsum;
598 }
599 
600 
601 bool
603  return myChargingStopped;
604 }
605 
606 
607 bool
609  return myChargingInTransit;
610 }
611 
612 
613 SUMOReal
615  return myChargingStartTime;
616 }
617 
618 
619 std::string
621  if (myActChargingStation != NULL) {
622  return myActChargingStation->getID();
623  } else {
624  return "NULL";
625  }
626 }
627 
628 
629 SUMOReal
631  return myEnergyCharged;
632 }
633 
634 
636  return myVehicleStopped;
637 }
638 
639 
641  assert(veh.getSpeed() >= 0.);
642 
643  //XXX: All formulas below work with the logic of the euler update (refs #860).
644  // Approximation order could be improved. Refs. #2592.
645 
646  // calculate current height
647  SUMOReal height_cur = veh.getPositionOnLane() / veh.getLane()->getLength() * (veh.getLane()->getShape().back().z() - veh.getLane()->getShape().front().z());
648 
649  // kinetic energy of vehicle with current velocity
650  SUMOReal currentEnergy = 0.5 * getMass() * veh.getSpeed() * veh.getSpeed();
651 
652  // add current potential energy of vehicle at current position
653  currentEnergy += getMass() * 9.81 * height_cur;
654 
655  // Calculate the radius of the vehicle's current path if is distinct (r = ds / dphi)
656  SUMOReal radius = 0;
657 
658  // add current rotational energy of internal rotating elements
659  currentEnergy += getInternalMomentOfInertia() * veh.getSpeed() * veh.getSpeed();
660 
661  // kinetic + potential + rotational energy gain [Ws] (MODIFICATED LAST ANGLE)
662  SUMOReal EnergyLoss = (currentEnergy - getLastEnergy());
663 
664  // save current total energy for next time step
665  setLastEnergy(currentEnergy);
666 
667 
668  // Energy loss through Air resistance [Ws]
669  // Calculate energy losses:
670  // EnergyLoss,Air = 1/2 * rho_air [kg/m^3] * myFrontSurfaceArea [m^2] * myAirDragCoefficient [-] * v_Veh^2 [m/s] * s [m]
671  // ... with rho_air [kg/m^3] = 1,2041 kg/m^3 (at T = 20C)
672  // ... with s [m] = v_Veh [m/s] * TS [s]
673  EnergyLoss += 0.5 * 1.2041 * getFrontSurfaceArea() * getAirDragCoefficient() * veh.getSpeed() * veh.getSpeed() * SPEED2DIST(veh.getSpeed());
674 
675 
676  // Energy loss through Roll resistance [Ws]
677  // ... (fabs(veh.getSpeed())>=0.01) = 0, if vehicle isn't moving
678  // EnergyLoss,Tire = c_R [-] * F_N [N] * s [m]
679  // ... with c_R = ~0.012 (car tire on asphalt)
680  // ... with F_N [N] = myMass [kg] * g [m/s^2]
681  EnergyLoss += getRollDragCoefficient() * 9.81 * getMass() * SPEED2DIST(veh.getSpeed());
682 
683 
684  // Energy loss through friction by radial force [Ws]
685  // If angle of vehicle was changed
686  if (getLastAngle() != veh.getAngle()) {
687  // Compute new radio
688  radius = SPEED2DIST(veh.getSpeed()) / fabs(GeomHelper::angleDiff(getLastAngle(), veh.getAngle()));
689 
690  // Check if radius is in the interval [0.0001 - 10000] (To avoid overflow and division by zero)
691  if (radius < 0.0001) {
692  radius = 0.0001;
693  } else if (radius > 10000) {
694  radius = 10000;
695  }
696  }
697  // EnergyLoss,internalFrictionRadialForce = c [m] * F_rad [N];
698  if (getLastAngle() != veh.getAngle()) {
699  // Energy loss through friction by radial force [Ws]
700  EnergyLoss += getRadialDragCoefficient() * getMass() * veh.getSpeed() * veh.getSpeed() / radius;
701  }
702 
703  // EnergyLoss,constantConsumers
704  // Energy loss through constant loads (e.g. A/C) [Ws]
705  EnergyLoss += getConstantPowerIntake();
706 
707  //E_Bat = E_kin_pot + EnergyLoss;
708  if (EnergyLoss > 0) {
709  // Assumption: Efficiency of myPropulsionEfficiency when accelerating
710  EnergyLoss = EnergyLoss / getPropulsionEfficiency();
711  } else {
712  // Assumption: Efficiency of myRecuperationEfficiency when recuperating
713  EnergyLoss = EnergyLoss * getRecuperationEfficiency();
714  }
715 
716  // convert from [Ws] to [kWh] (3600s / 1h):
717  EnergyLoss = EnergyLoss / 3600 ; // EnergyLoss[Ws] * 1[h]/3600[s] * 1[k]/1000
718 
719  // Return calculated energy
720  return EnergyLoss;
721 }
722 
SUMOReal getPropEnergy(SUMOVehicle &veh)
get propulsion energy
void setFrontSurfaceArea(const SUMOReal frontSurfaceArea)
Set vehicle&#39;s front surface Area.
SUMOReal myActualBatteryCapacity
Parameter, The actual vehicles&#39;s Battery Capacity in kWh [myActualBatteryCapacity <= myMaximumBatter...
SUMOReal getLastEnergy() const
Get vehicles&#39;s last Energy.
SUMOReal getLength() const
Returns the lane&#39;s length.
Definition: MSLane.h:480
MSChargingStation * myActChargingStation
Parameter, Pointer to current charging station in which vehicle is placed by default is NULL...
void setLastEnergy(const SUMOReal lastEnergy)
Set vehicle&#39;s last Energy.
#define SPEED2DIST(x)
Definition: SUMOTime.h:55
void setPowerMax(const SUMOReal new_Pmax)
Set maximum power when accelerating.
SUMOReal myFrontSurfaceArea
Parameter, Vehicle&#39;s front surface Area [myFrontSurfaceArea >= 0].
void setRollDragCoefficient(const SUMOReal rollDragCoefficient)
Set vehicle&#39;s roll friction coefficient.
SUMOReal getMaximumBatteryCapacity() const
Get the total vehicle&#39;s Battery Capacity in kWh.
SUMOReal getEfficency() const
Get efficiency of the charging station.
void increaseVehicleStoppedTimer()
Increase myVehicleStopped.
static SUMOReal _2SUMOReal(const E *const data)
converts a char-type array into the SUMOReal value described by it
Definition: TplConvert.h:290
SUMOReal getEnergyCharged() const
Get charged energy.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice *> &into)
Build devices for the given vehicle, if needed.
SUMOReal myChargingStartTime
Parameter, Moment, wich the vehicle has beging to charging none.
virtual SUMOReal getPositionOnLane() const =0
Get the vehicle&#39;s position along the lane.
void setActualBatteryCapacity(const SUMOReal actualBatteryCapacity)
Set actual vehicle&#39;s Battery Capacity in kWh.
int myVehicleStopped
Parameter, How many timestep the vehicle is stopped.
SUMOReal myLastAngle
Parameter, Vehicle&#39;s last angle none.
virtual SUMOReal getAngle() const =0
Get the vehicle&#39;s angle.
SUMOReal getFrontSurfaceArea() const
Get vehicle&#39;s front surface Area.
Notification
Definition of a vehicle state.
virtual MSLane * getLane() const =0
Returns the lane the vehicle is on.
SUMOReal getLastAngle() const
Get vehicles&#39;s last angle.
SUMOReal getActualBatteryCapacity() const
Get the actual vehicle&#39;s Battery Capacity in kWh.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:159
std::string getChargingStationID() const
Get current Charging Station ID.
SUMOReal getRecuperationEfficiency() const
Get vehicles&#39;s Recuparation efficiency.
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:427
SUMOReal getPropulsionEfficiency() const
Get vehicles&#39;s Propulsion efficiency.
const std::string & getID() const
Returns the id.
Definition: Named.h:66
bool notifyMove(SUMOVehicle &veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed)
Checks for waiting steps when the vehicle moves.
int getVehicleStopped() const
Get number of timestep that vehicle is stopped.
static SUMOReal angleDiff(const SUMOReal angle1, const SUMOReal angle2)
Returns the difference of the second angle to the first angle in radiants.
Definition: GeomHelper.cpp:178
MSChargingStation * getChargingStation(const std::string &id) const
Returns the named charging station.
Definition: MSNet.cpp:837
SUMOReal myAirDragCoefficient
Parameter, Vehicle&#39;s drag coefficient [myAirDragCoefficient >=0].
bool myChargingStopped
Parameter, Flag: Vehicles it&#39;s charging stopped by default is false.
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
SUMOReal getAirDragCoefficient() const
Get vehicle&#39;s drag coefficient.
SUMOReal myPropulsionEfficiency
Parameter, Vehicle&#39;s propulsion efficiency [1 >= myPropulsionEfficiency >= 0].
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:69
bool isChargingStopped() const
Get true if Vehicle is charging, false if not.
SUMOReal myPowerMax
Parameter, The Maximum Power when accelerating [myPowerMax >= 0].
SUMOReal getRollDragCoefficient() const
Get vehicles&#39;s roll friction coefficient.
SUMOReal getChargeDelay() const
Get Charge Delay.
SUMOReal beginEndAngle() const
returns the angle in radians of the line connecting the first and the last position ...
SUMOReal myConsum
Parameter, Vehicle consum during a time step by default is 0.
bool getChargeInTransit() const
Get chargeInTransit.
void setRadialDragCoefficient(const SUMOReal radialDragCoefficient)
Set vehicle&#39;s radial friction coefficient.
void resetVehicleStoppedTimer()
Reset myVehicleStopped.
SUMOReal myLastEnergy
Parameter, Vehicle&#39;s last energy none.
void setPropulsionEfficiency(const SUMOReal propulsionEfficiency)
Set vehicle&#39;s Propulsion efficiency.
Representation of a vehicle.
Definition: SUMOVehicle.h:66
void setMass(const SUMOReal mass)
Set vehicle&#39;s myMass.
SUMOReal getConstantPowerIntake() const
Get vehicles&#39;s constant power intake.
SUMOReal myMaximumBatteryCapacity
Parameter, The total vehicles&#39;s Battery Capacity in kWh [myMaximumBatteryCapacity >= 0]...
void setLastAngle(const SUMOReal lastAngle)
Set vehicle&#39;s last Angle.
void resetChargingStartTime()
Reset charging start time.
SUMOReal getInternalMomentOfInertia() const
Get vehicles&#39;s internal moment of inertia.
void setChargingVehicle(bool value)
enable or disable charging vehicle
static void insertDefaultAssignmentOptions(const std::string &deviceName, const std::string &optionsTopic, OptionsCont &oc)
Adds common command options that allow to assign devices to vehicles.
Definition: MSDevice.cpp:94
void setRecuperationEfficiency(const SUMOReal recuperationEfficiency)
Set vehicle&#39;s Recuparation efficiency.
bool myChargingInTransit
Parameter, Flag: Vehicles it&#39;s charging in transit by default is false.
const SUMOVTypeParameter & getParameter() const
SUMOReal myRecuperationEfficiency
Parameter, Vehicle&#39;s recuparation efficiency [1 >= myRecuperationEfficiency >= 0].
SUMOReal getChargingPower() const
Get charging station&#39;s charging power.
void setInternalMomentOfInertia(const SUMOReal internalMomentOfInertia)
Set vehicle&#39;s internal moment of inertia.
SUMOReal myInternalMomentOfInertia
Parameter, Vehicle&#39;s internal moment of inertia [myInternalMomentOfInertia >= 0].
Abstract in-vehicle device.
Definition: MSDevice.h:69
const std::string & getParameter(const std::string &key, const std::string &defaultValue) const
Returns the value for a given key.
static bool equippedByDefaultAssignmentOptions(const OptionsCont &oc, const std::string &deviceName, SUMOVehicle &v)
Determines whether a vehicle should get a certain device.
Definition: MSDevice.cpp:108
The vehicle has departed (was inserted into the network)
virtual SUMOReal getSpeed() const =0
Returns the vehicle&#39;s current speed.
Battery device for electric vehicles.
void increaseChargingStartTime()
Increase Charging Start time.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle&#39;s parameter (including departure definition)
SUMOReal myConstantPowerIntake
Parameter, Vehicle&#39;s constant power intake [myConstantPowerIntake >= 0].
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Example-options.
A storage for options typed value containers)
Definition: OptionsCont.h:99
SUMOReal getConsum() const
Get consum.
void setMaximumBatteryCapacity(const SUMOReal maximumBatteryCapacity)
Set total vehicle&#39;s Battery Capacity in kWh.
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason)
Saves departure info on insertion.
SUMOReal myRollDragCoefficient
Parameter, Vehicle&#39;s roll friction coefficient [myRollDragCoefficient >= 0].
const SUMOReal SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
Definition: StdDefs.h:57
SUMOReal myRadialDragCoefficient
Parameter, Vehicle&#39;s radial friction coefficient [myRadialDragCoefficient >=0].
SUMOReal getChargingStartTime() const
Get charging start time.
void generateOutput() const
Called on writing tripinfo output.
bool isChargingInTransit() const
Get true if Vehicle it&#39;s charging, false if not.
#define SUMOReal
Definition: config.h:213
SUMOReal myMass
Parameter, Vehicle&#39;s myMass [myMass >= 0].
MSDevice_Battery(SUMOVehicle &holder, const std::string &id, const SUMOReal actualBatteryCapacity, const SUMOReal maximumBatteryCapacity, const SUMOReal powerMax, const SUMOReal mass, const SUMOReal frontSurfaceArea, const SUMOReal airDragCoefficient, const SUMOReal internalMomentOfInertia, const SUMOReal radialDragCoefficient, const SUMOReal rollDragCoefficient, const SUMOReal constantPowerIntake, const SUMOReal propulsionEfficiency, const SUMOReal recuperationEfficiency, const SUMOReal lastAngle, const SUMOReal lastEnergy)
Constructor.
SUMOReal getMaximumPower() const
Get the maximum power when accelerating.
void setConstantPowerIntake(const SUMOReal constantPowerIntake)
Set vehicle&#39;s constant power intake.
void setAirDragCoefficient(const SUMOReal new_C_Veh)
Set vehicle&#39;s drag coefficient.
static std::string _2str(const int var)
convert int to string
Definition: TplConvert.h:57
SUMOReal getRadialDragCoefficient() const
Get vehicles&#39;s radial friction coefficient.
SUMOReal getMass() const
Get vehicle&#39;s mass.
virtual const std::string & getID() const =0
Get the vehicle&#39;s ID.
std::string getChargingStationID(const MSLane *lane, const SUMOReal pos) const
Returns the charging station close to the given position.
Definition: MSNet.cpp:843
SUMOReal myEnergyCharged
Parameter, Energy charged in each timestep.
~MSDevice_Battery()
Destructor.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle&#39;s type.