Eclipse SUMO - Simulation of Urban MObility
PollutantsInterface.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2013-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 // Interface to capsulate different emission models
20 /****************************************************************************/
21 #pragma once
22 #include <config.h>
23 
24 #include <vector>
25 #include <limits>
26 #include <cmath>
27 #include <algorithm>
28 #include <utils/common/StdDefs.h>
30 #include "PHEMCEP.h"
31 
32 
33 // ===========================================================================
34 // class declarations
35 // ===========================================================================
36 class EnergyParams;
37 class HelpersHBEFA;
38 class HelpersHBEFA3;
39 class HelpersPHEMlight;
40 class HelpersEnergy;
41 class HelpersMMPEVEM;
42 
43 
44 // ===========================================================================
45 // class definitions
46 // ===========================================================================
52 
53 public:
55  enum EmissionType { CO2, CO, HC, FUEL, NO_X, PM_X, ELEC };
56 
61  struct Emissions {
71  Emissions(double co2 = 0, double co = 0, double hc = 0, double f = 0, double nox = 0, double pmx = 0, double elec = 0);
72 
77  void addScaled(const Emissions& a, const double scale = 1.);
78 
81  double CO2;
82  double CO;
83  double HC;
84  double fuel;
85  double NOx;
86  double PMx;
87  double electricity;
89  };
90 
95  class Helper {
96  public:
100  Helper(std::string name, const int baseIndex, const int defaultClass);
101 
105  const std::string& getName() const;
106 
116  virtual SUMOEmissionClass getClassByName(const std::string& eClass, const SUMOVehicleClass vc);
117 
122  const std::string getClassName(const SUMOEmissionClass c) const;
123 
129  virtual bool isSilent(const SUMOEmissionClass c);
130 
133 
144  virtual SUMOEmissionClass getClass(const SUMOEmissionClass base, const std::string& vClass, const std::string& fuel,
145  const std::string& eClass, const double weight) const;
146 
152  virtual std::string getAmitranVehicleClass(const SUMOEmissionClass c) const;
153 
159  virtual std::string getFuel(const SUMOEmissionClass c) const;
160 
166  virtual int getEuroClass(const SUMOEmissionClass c) const;
167 
174  virtual double getWeight(const SUMOEmissionClass c) const;
176 
185  virtual double compute(const SUMOEmissionClass c, const EmissionType e, const double v, const double a, const double slope, const EnergyParams* param) const;
186 
195  virtual double getModifiedAccel(const SUMOEmissionClass c, const double v, const double a, const double slope) const;
196 
200  void addAllClassesInto(std::vector<SUMOEmissionClass>& list) const;
201 
202  bool includesClass(const SUMOEmissionClass c) const;
203 
204  protected:
206  const std::string myName;
207 
209  const int myBaseIndex;
210 
213 
214  private:
216  Helper& operator=(const Helper&) = delete;
217  };
218 
220  static const int ZERO_EMISSIONS = 0;
221 
223  static const int HEAVY_BIT = 1 << 15;
224 
229  static SUMOEmissionClass getClassByName(const std::string& eClass, const SUMOVehicleClass vc = SVC_IGNORING);
230 
235  static const std::vector<SUMOEmissionClass> getAllClasses();
236 
238  static const std::vector<std::string>& getAllClassesStr();
239 
244  static std::string getName(const SUMOEmissionClass c);
245 
247  static std::string getPollutantName(const EmissionType e);
248 
253  static bool isHeavy(const SUMOEmissionClass c);
254 
259  static bool isSilent(const SUMOEmissionClass c);
260 
269  static SUMOEmissionClass getClass(const SUMOEmissionClass base, const std::string& vClass, const std::string& fuel, const std::string& eClass, const double weight);
270 
275  static std::string getAmitranVehicleClass(const SUMOEmissionClass c);
276 
281  static std::string getFuel(const SUMOEmissionClass c);
282 
287  static int getEuroClass(const SUMOEmissionClass c);
288 
294  static double getWeight(const SUMOEmissionClass c);
295 
304  static double compute(const SUMOEmissionClass c, const EmissionType e, const double v, const double a, const double slope, const EnergyParams* param = 0);
305 
313  static Emissions computeAll(const SUMOEmissionClass c, const double v, const double a, const double slope, const EnergyParams* param = 0);
314 
324  static double computeDefault(const SUMOEmissionClass c, const EmissionType e, const double v, const double a, const double slope, const double tt, const EnergyParams* param = 0);
325 
333  static double getModifiedAccel(const SUMOEmissionClass c, const double v, const double a, const double slope);
334 
336  static const HelpersEnergy& getEnergyHelper();
337 
338 private:
341 
344 
347 
350 
353 
356 
358  static Helper* myHelpers[];
359 
361  static std::vector<std::string> myAllClassesStr;
362 };
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_IGNORING
vehicles ignoring classes
int SUMOEmissionClass
An upper class for objects with additional parameters.
Definition: EnergyParams.h:41
Helper methods for energy-based electricity consumption computation based on the battery device.
Definition: HelpersEnergy.h:41
Helper methods for HBEFA3-based emission computation.
Definition: HelpersHBEFA3.h:44
Helper methods for HBEFA-based emission computation.
Definition: HelpersHBEFA.h:44
This helper class allows the PollutantsInterface to load and use different MMPEVEMs.
Helper methods for PHEMlight-based emission computation.
zero emission model, used as superclass for the other model helpers
virtual bool isSilent(const SUMOEmissionClass c)
Returns whether the class denotes a silent vehicle for interfacing with the noise model....
const std::string getClassName(const SUMOEmissionClass c) const
Returns the complete name of the emission class including the model.
virtual SUMOEmissionClass getClassByName(const std::string &eClass, const SUMOVehicleClass vc)
Returns the emission class associated with the given name, aliases are possible If this method is ask...
const std::string & getName() const
Returns the name of the model.
bool includesClass(const SUMOEmissionClass c) const
virtual SUMOEmissionClass getClass(const SUMOEmissionClass base, const std::string &vClass, const std::string &fuel, const std::string &eClass, const double weight) const
Returns the emission class described by the given parameters. The base is used to determine the model...
void addAllClassesInto(std::vector< SUMOEmissionClass > &list) const
Add all known emission classes of this model to the given container.
const std::string myName
the name of the model
virtual std::string getAmitranVehicleClass(const SUMOEmissionClass c) const
Returns the vehicle class described by this emission class as described in the Amitran interface (Pas...
const int myBaseIndex
the starting index for classes of this model
Helper & operator=(const Helper &)=delete
invalidate copy constructor
virtual double getModifiedAccel(const SUMOEmissionClass c, const double v, const double a, const double slope) const
Returns the adapted acceleration value, useful for comparing with external PHEMlight references....
virtual double getWeight(const SUMOEmissionClass c) const
Returns a reference weight in kg described by this emission class as described in the Amitran interfa...
Helper(std::string name, const int baseIndex, const int defaultClass)
Constructor, intializes the name.
virtual double compute(const SUMOEmissionClass c, const EmissionType e, const double v, const double a, const double slope, const EnergyParams *param) const
Returns the amount of the emitted pollutant given the vehicle type and state (in mg/s or ml/s for fue...
virtual int getEuroClass(const SUMOEmissionClass c) const
Returns the Euro emission class described by this emission class as described in the Amitran interfac...
StringBijection< SUMOEmissionClass > myEmissionClassStrings
Mapping between emission class names and integer representations.
virtual std::string getFuel(const SUMOEmissionClass c) const
Returns the fuel type described by this emission class as described in the Amitran interface (Gasolin...
Helper methods for PHEMlight-based emission computation.
static bool isSilent(const SUMOEmissionClass c)
Checks whether the emission class describes an electric or similar silent vehicle.
static HelpersHBEFA3 myHBEFA3Helper
Instance of HBEFA3Helper which gets cleaned up automatically.
static HelpersPHEMlight myPHEMlightHelper
Instance of PHEMlightHelper which gets cleaned up automatically.
static double getModifiedAccel(const SUMOEmissionClass c, const double v, const double a, const double slope)
Returns the adapted acceleration value, useful for comparing with external PHEMlight references.
static std::string getAmitranVehicleClass(const SUMOEmissionClass c)
Returns the vehicle class described by the given emission class.
static const HelpersEnergy & getEnergyHelper()
get energy helper
static double compute(const SUMOEmissionClass c, const EmissionType e, const double v, const double a, const double slope, const EnergyParams *param=0)
Returns the amount of the emitted pollutant given the vehicle type and state (in mg/s or ml/s for fue...
static std::string getPollutantName(const EmissionType e)
return the name for the given emission type
static double computeDefault(const SUMOEmissionClass c, const EmissionType e, const double v, const double a, const double slope, const double tt, const EnergyParams *param=0)
Returns the amount of emitted pollutant given the vehicle type and default values for the state (in m...
EmissionType
Enumerating all emission types, including fuel.
static std::string getFuel(const SUMOEmissionClass c)
Returns the fuel type of the given emission class.
static bool isHeavy(const SUMOEmissionClass c)
Checks whether the emission class describes a bus, truck or similar vehicle.
static double getWeight(const SUMOEmissionClass c)
Returns a representative weight for the given emission class see http://colombo-fp7....
static std::vector< std::string > myAllClassesStr
get all emission classes in string format
static HelpersHBEFA myHBEFA2Helper
Instance of HBEFA2Helper which gets cleaned up automatically.
static std::string getName(const SUMOEmissionClass c)
Checks whether the string describes a known vehicle class.
static const std::vector< SUMOEmissionClass > getAllClasses()
Checks whether the string describes a known vehicle class.
static const int ZERO_EMISSIONS
the first class in each model representing a zero emission vehicle
static Emissions computeAll(const SUMOEmissionClass c, const double v, const double a, const double slope, const EnergyParams *param=0)
Returns the amount of all emitted pollutants given the vehicle type and state (in mg/s or ml/s for fu...
static SUMOEmissionClass getClass(const SUMOEmissionClass base, const std::string &vClass, const std::string &fuel, const std::string &eClass, const double weight)
Returns the emission class fittig the given parameters.
static const int HEAVY_BIT
the bit to set for denoting heavy vehicles
static int getEuroClass(const SUMOEmissionClass c)
Returns the Euro norm described by the given emission class.
static HelpersEnergy myEnergyHelper
Instance of EnergyHelper which gets cleaned up automatically.
static const std::vector< std::string > & getAllClassesStr()
Get all SUMOEmissionClass in string format.
static Helper * myHelpers[]
the known model helpers
static SUMOEmissionClass getClassByName(const std::string &eClass, const SUMOVehicleClass vc=SVC_IGNORING)
Checks whether the string describes a known vehicle class.
static HelpersMMPEVEM myMMPEVEMHelper
Instance of HelpersMMPEVEM which gets cleaned up automatically.
static Helper myZeroHelper
Instance of Helper which gets cleaned up automatically.
Storage for collected values of all emission types.
void addScaled(const Emissions &a, const double scale=1.)
Add the values of the other struct to this one, scaling the values if needed.
Emissions(double co2=0, double co=0, double hc=0, double f=0, double nox=0, double pmx=0, double elec=0)
Constructor, intializes all members.