Eclipse SUMO - Simulation of Urban MObility
EnergyParams.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-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 /****************************************************************************/
18 // A class for parameters used by the emission models
19 /****************************************************************************/
20 #include <config.h>
22 #include <utils/common/ToString.h>
24 
25 #include "EnergyParams.h"
26 
27 
28 // ===========================================================================
29 // method definitions
30 // ===========================================================================
31 
33 
34  // default values from
35  // Kurczveil, T., López, P.Á., & Schnieder, E. (2014). Implementation of an Energy Model and a Charging Infrastructure in SUMO.
46  myMap[SUMO_ATTR_ANGLE] = 0.; // actually angleDiff in the last step
47  // @todo set myVecMap defaults as needed
48 
49  // Default values for the MMPEVEM
50  myMap[SUMO_ATTR_WHEELRADIUS] = 0.3588; // [m]
51  myMap[SUMO_ATTR_MAXIMUMTORQUE] = 310.0; // [Nm]
52  // @todo SUMO_ATTR_MAXIMUMPOWER predates the MMPEVEM emission model. Do you want to set this somewhere else or to another value?
53  myMap[SUMO_ATTR_MAXIMUMPOWER] = 107000.0; // [W]
54  myMap[SUMO_ATTR_GEAREFFICIENCY] = 0.96; // [1]
55  myMap[SUMO_ATTR_GEARRATIO] = 10.0; // [1]
57  myMap[SUMO_ATTR_MAXIMUMRECUPERATIONPOWER] = 42800.0; // [W]
58  myMap[SUMO_ATTR_INTERNALBATTERYRESISTANCE] = 0.1142; // [Ohm]
59  myMap[SUMO_ATTR_NOMINALBATTERYVOLTAGE] = 396.0; // [V]
60  myCharacteristicMapMap.insert(std::pair<SumoXMLAttr, CharacteristicMap>(SUMO_ATTR_POWERLOSSMAP, CharacteristicMap("2,1|-1e9,1e9;-1e9,1e9|0,0,0,0"))); // P_loss_EM = 0 W for all operating points in the default EV power loss map
61 
62  if (typeParams != nullptr) {
63  for (auto item : myMap) {
64  myMap[item.first] = typeParams->getDouble(toString(item.first), item.second);
65  }
66  for (auto item : myVecMap) {
67  myVecMap[item.first] = typeParams->getDoubles(toString(item.first), item.second);
68  }
69  for (auto item : myCharacteristicMapMap) {
70  std::string characteristicMapString = typeParams->getParameter(toString(item.first), "");
71  if (characteristicMapString != "") {
72  myCharacteristicMapMap.at(item.first) = CharacteristicMap(typeParams->getParameter(toString(item.first)));
73  }
74  }
75  }
76 }
77 
78 
79 
80 
82 
83 
84 void
85 EnergyParams::setDouble(SumoXMLAttr attr, double value) {
86  myMap[attr] = value;
87 }
88 
89 double
91  auto it = myMap.find(attr);
92  if (it != myMap.end()) {
93  return it->second;
94  } else {
95  throw UnknownElement("Unknown Energy Model parameter: " + toString(attr));
96  }
97 }
98 
99 const std::vector<double>&
101  auto it = myVecMap.find(attr);
102  if (it != myVecMap.end()) {
103  return it->second;
104  } else {
105  throw UnknownElement("Unknown Energy Model parameter: " + toString(attr));
106  }
107 }
108 
109 const CharacteristicMap&
111  auto it = myCharacteristicMapMap.find(attr);
112  if (it != myCharacteristicMapMap.end()) {
113  return it->second;
114  } else {
115  throw UnknownElement("Unknown Energy Model parameter: " + toString(attr));
116  }
117 }
118 
119 bool
121  return myMap.find(attr) != myMap.end()
122  || myVecMap.find(attr) != myVecMap.end()
123  || myCharacteristicMapMap.find(attr) != myCharacteristicMapMap.end();
124 }
125 
126 /****************************************************************************/
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_GEAREFFICIENCY
Gear efficiency.
@ SUMO_ATTR_MAXIMUMPOWER
Maximum Power.
@ SUMO_ATTR_INTERNALBATTERYRESISTANCE
Internal battery resistance.
@ SUMO_ATTR_MAXIMUMTORQUE
Maximum torque.
@ SUMO_ATTR_ROLLDRAGCOEFFICIENT
Roll Drag coefficient.
@ SUMO_ATTR_CONSTANTPOWERINTAKE
Constant Power Intake.
@ SUMO_ATTR_RECUPERATIONEFFICIENCY_BY_DECELERATION
Recuperation efficiency (by deceleration)
@ SUMO_ATTR_WHEELRADIUS
@ SUMO_ATTR_RECUPERATIONEFFICIENCY
Recuperation efficiency (constant)
@ SUMO_ATTR_AIRDRAGCOEFFICIENT
Air drag coefficient.
@ SUMO_ATTR_POWERLOSSMAP
A string encoding the power loss map.
@ SUMO_ATTR_ANGLE
@ SUMO_ATTR_MAXIMUMRECUPERATIONPOWER
Maximum recuperation power.
@ SUMO_ATTR_MAXIMUMRECUPERATIONTORQUE
Maximum recuperation torque.
@ SUMO_ATTR_VEHICLEMASS
Vehicle mass.
@ SUMO_ATTR_RADIALDRAGCOEFFICIENT
Radial drag coefficient.
@ SUMO_ATTR_GEARRATIO
Gear ratio.
@ SUMO_ATTR_PROPULSIONEFFICIENCY
Propulsion efficiency.
@ SUMO_ATTR_INTERNALMOMENTOFINERTIA
Internal moment of inertia.
@ SUMO_ATTR_NOMINALBATTERYVOLTAGE
Nominal battery voltage.
@ SUMO_ATTR_FRONTSURFACEAREA
Front surface area.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
The purpose of this class is to store a characteristic map (German: Kennfeld) of arbitrary dimensions...
double getDouble(SumoXMLAttr attr) const
bool knowsParameter(SumoXMLAttr attr) const
void setDouble(SumoXMLAttr attr, double value)
Sets a parameter.
std::map< SumoXMLAttr, double > myMap
The key->value maps.
Definition: EnergyParams.h:77
EnergyParams(const SUMOVTypeParameter *typeParams=nullptr)
Default constructor.
std::map< SumoXMLAttr, std::vector< double > > myVecMap
Definition: EnergyParams.h:78
std::map< SumoXMLAttr, CharacteristicMap > myCharacteristicMapMap
Definition: EnergyParams.h:79
const CharacteristicMap & getCharacteristicMap(SumoXMLAttr attr) const
Return the CharacteristicMap that belongs to a given attribute.
~EnergyParams()
Destructor.
const std::vector< double > & getDoubles(SumoXMLAttr attr) const
Returns the value for a given key.
std::vector< double > getDoubles(const std::string &key, std::vector< double > defaultValue=std::vector< double >()) const
Returns the value for a given key converted to a list of doubles.
double getDouble(const std::string &key, const double defaultValue) const
Returns the value for a given key converted to a double.
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
Structure representing possible vehicle parameter.