SUMO - Simulation of Urban MObility
PollutantsInterface.h
Go to the documentation of this file.
1 /****************************************************************************/
8 // Interface to capsulate different emission models
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
11 // Copyright (C) 2013-2015 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 #ifndef PollutantsInterface_h
22 #define PollutantsInterface_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <vector>
35 #include <limits>
36 #include <cmath>
37 #include <algorithm>
38 #include <utils/common/StdDefs.h>
40 #include "PHEMCEP.h"
41 
42 
43 // ===========================================================================
44 // class declarations
45 // ===========================================================================
46 class HelpersHBEFA;
47 class HelpersHBEFA3;
48 class HelpersPHEMlight;
49 
50 
51 // ===========================================================================
52 // class definitions
53 // ===========================================================================
59 public:
60 
62  enum EmissionType { CO2, CO, HC, FUEL, NO_X, PM_X };
63 
64 
69  struct Emissions {
76 
85  Emissions(SUMOReal co2 = 0, SUMOReal co = 0, SUMOReal hc = 0, SUMOReal f = 0, SUMOReal nox = 0, SUMOReal pmx = 0)
86  : CO2(co2), CO(co), HC(hc), fuel(f), NOx(nox), PMx(pmx) {
87  }
88 
93  void addScaled(const Emissions& a, const SUMOReal scale = 1.) {
94  CO2 += scale * a.CO2;
95  CO += scale * a.CO;
96  HC += scale * a.HC;
97  fuel += scale * a.fuel;
98  NOx += scale * a.NOx;
99  PMx += scale * a.PMx;
100  }
101  };
102 
103 
108  class Helper {
109  public:
113  Helper(std::string name) : myName(name) {}
114 
118  const std::string& getName() const {
119  return myName;
120  }
121 
131  virtual SUMOEmissionClass getClassByName(const std::string& eClass, const SUMOVehicleClass vc) {
132  UNUSED_PARAMETER(vc);
133  if (myEmissionClassStrings.hasString(eClass)) {
134  return myEmissionClassStrings.get(eClass);
135  }
136  std::string eclower = eClass;
137  std::transform(eclower.begin(), eclower.end(), eclower.begin(), tolower);
138  return myEmissionClassStrings.get(eclower);
139  }
140 
145  const std::string getClassName(const SUMOEmissionClass c) const {
146  return myName + "/" + myEmissionClassStrings.getString(c);
147  }
148 
154  virtual bool isSilent(const SUMOEmissionClass c) {
155  return (c & 0xffffffff & ~HEAVY_BIT) == 0;
156  }
157 
160 
171  virtual SUMOEmissionClass getClass(const SUMOEmissionClass base, const std::string& vClass,
172  const std::string& fuel, const std::string& eClass, const double weight) const {
173  UNUSED_PARAMETER(vClass);
174  UNUSED_PARAMETER(fuel);
175  UNUSED_PARAMETER(eClass);
176  UNUSED_PARAMETER(weight);
177  return base;
178  }
179 
185  virtual std::string getAmitranVehicleClass(const SUMOEmissionClass c) const {
186  UNUSED_PARAMETER(c);
187  return "Passenger";
188  }
189 
195  virtual std::string getFuel(const SUMOEmissionClass c) const {
196  UNUSED_PARAMETER(c);
197  return "Gasoline";
198  }
199 
205  virtual int getEuroClass(const SUMOEmissionClass c) const {
206  UNUSED_PARAMETER(c);
207  return 0;
208  }
209 
216  virtual SUMOReal getWeight(const SUMOEmissionClass c) const {
217  UNUSED_PARAMETER(c);
218  return -1.;
219  }
221 
230  virtual SUMOReal compute(const SUMOEmissionClass c, const EmissionType e, const double v, const double a, const double slope) const = 0;
231 
240  virtual SUMOReal getMaxAccel(SUMOEmissionClass c, double v, double a, double slope) const {
241  UNUSED_PARAMETER(c);
242  UNUSED_PARAMETER(v);
243  UNUSED_PARAMETER(a);
244  UNUSED_PARAMETER(slope);
245  return -1.;
246  }
247 
251  void addAllClassesInto(std::vector<SUMOEmissionClass>& list) const {
252  myEmissionClassStrings.addKeysInto(list);
253  }
254 
255 
256  protected:
258  const std::string myName;
259 
262 
263  private:
264  Helper& operator=(const Helper&); // just to avoid a compiler warning
265 
266 
267  };
268 
269 
271  static Helper* myHelpers[];
272 
274  static const int ZERO_EMISSIONS = 0;
275 
277  static const int HEAVY_BIT = 1 << 15;
278 
283  static SUMOEmissionClass getClassByName(const std::string& eClass, const SUMOVehicleClass vc = SVC_IGNORING);
284 
285 
290  static const std::vector<SUMOEmissionClass> getAllClasses();
291 
292 
297  static std::string getName(const SUMOEmissionClass c);
298 
299 
304  static bool isHeavy(const SUMOEmissionClass c);
305 
306 
311  static bool isSilent(const SUMOEmissionClass c);
312 
313 
321  static SUMOReal getMaxAccel(SUMOEmissionClass c, double v, double a, double slope);
322 
323 
332  static SUMOEmissionClass getClass(const SUMOEmissionClass base, const std::string& vClass, const std::string& fuel, const std::string& eClass, const double weight);
333 
334 
339  static std::string getAmitranVehicleClass(const SUMOEmissionClass c);
340 
341 
346  static std::string getFuel(const SUMOEmissionClass c);
347 
348 
353  static int getEuroClass(const SUMOEmissionClass c);
354 
355 
361  static SUMOReal getWeight(const SUMOEmissionClass c);
362 
363 
372  static SUMOReal compute(const SUMOEmissionClass c, const EmissionType e, const double v, const double a, const double slope);
373 
374 
382  static Emissions computeAll(const SUMOEmissionClass c, const double v, const double a, const double slope);
383 
384 
394  static SUMOReal computeDefault(const SUMOEmissionClass c, const EmissionType e, const double v, const double a, const double slope, const SUMOReal tt);
395 
396 private:
403 
404 };
405 
406 
407 #endif
408 
409 /****************************************************************************/
410 
virtual int getEuroClass(const SUMOEmissionClass c) const
Returns the Euro emission class described by this emission class as described in the Amitran interfac...
static SUMOReal getWeight(const SUMOEmissionClass c)
Returns a representative weight for the given emission class see http://colombo-fp7.eu/deliverables/COLOMBO_D4.2_ExtendedPHEMSUMO_v1.7.pdf.
void addScaled(const Emissions &a, const SUMOReal scale=1.)
Add the values of the other struct to this one, scaling the values if needed.
Emissions(SUMOReal co2=0, SUMOReal co=0, SUMOReal hc=0, SUMOReal f=0, SUMOReal nox=0, SUMOReal pmx=0)
Constructor, intializes all members.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
void addAllClassesInto(std::vector< SUMOEmissionClass > &list) const
Add all known emission classes of this model to the given container.
static Emissions computeAll(const SUMOEmissionClass c, const double v, const double a, const double slope)
Returns the amount of all emitted pollutants given the vehicle type and state (in mg/s or ml/s for fu...
virtual SUMOReal getMaxAccel(SUMOEmissionClass c, double v, double a, double slope) const
Returns the maximum possible acceleration or -1. if the model cannot determine the maximum accelerati...
virtual bool isSilent(const SUMOEmissionClass c)
Returns whether the class denotes a silent vehicle for interfacing with the noise model...
EmissionType
Enumerating all emission types, including fuel.
virtual SUMOReal getWeight(const SUMOEmissionClass c) const
Returns a reference weight in kg described by this emission class as described in the Amitran interfa...
Storage for collected values of all emission types.
const std::string myName
the name of the model
const std::string getClassName(const SUMOEmissionClass c) const
Returns the complete name of the emission class including the model.
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:39
static const int HEAVY_BIT
the bit to set for denoting heavy vehicles
Helper methods for PHEMlight-based emission computation.
static const int ZERO_EMISSIONS
the first class in each model representing a zero emission vehicle
const std::string & getName() const
Returns the name of the model.
static Helper * myHelpers[]
the known model helpers
static std::string getAmitranVehicleClass(const SUMOEmissionClass c)
Returns the vehicle class described by the given emission class.
virtual std::string getAmitranVehicleClass(const SUMOEmissionClass c) const
Returns the vehicle class described by this emission class as described in the Amitran interface (Pas...
static HelpersPHEMlight myPHEMlightHelper
Instance of PHEMlightHelper which gets cleaned up automatically.
abstract superclass for the model helpers
int SUMOEmissionClass
static SUMOReal computeDefault(const SUMOEmissionClass c, const EmissionType e, const double v, const double a, const double slope, const SUMOReal tt)
Returns the amount of emitted pollutant given the vehicle type and default values for the state (in m...
Helper methods for HBEFA3-based emission computation.
Definition: HelpersHBEFA3.h:54
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 HelpersHBEFA3 myHBEFA3Helper
Instance of HBEFA3Helper which gets cleaned up automatically.
static const std::vector< SUMOEmissionClass > getAllClasses()
Checks whether the string describes a known vehicle class.
static bool isSilent(const SUMOEmissionClass c)
Checks whether the emission class describes an electric or similar silent vehicle.
static std::string getName(const SUMOEmissionClass c)
Checks whether the string describes a known vehicle class.
static bool isHeavy(const SUMOEmissionClass c)
Checks whether the emission class describes a bus, truck or similar vehicle.
static int getEuroClass(const SUMOEmissionClass c)
Returns the Euro norm described by the given emission class.
Helper(std::string name)
Constructor, intializes the name.
Helper methods for HBEFA-based emission computation.
Definition: HelpersHBEFA.h:54
static SUMOReal compute(const SUMOEmissionClass c, const EmissionType e, const double v, const double a, const double slope)
Returns the amount of the emitted pollutant given the vehicle type and state (in mg/s or ml/s for fue...
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...
static SUMOEmissionClass getClassByName(const std::string &eClass, const SUMOVehicleClass vc=SVC_IGNORING)
Checks whether the string describes a known vehicle class.
StringBijection< SUMOEmissionClass > myEmissionClassStrings
Mapping between emission class names and integer representations.
static HelpersHBEFA myHBEFA2Helper
Instance of HBEFA2Helper which gets cleaned up automatically.
static SUMOReal getMaxAccel(SUMOEmissionClass c, double v, double a, double slope)
Returns the maximum possible acceleration.
#define SUMOReal
Definition: config.h:214
vehicles ignoring classes
static std::string getFuel(const SUMOEmissionClass c)
Returns the fuel type of the given emission class.
Helper methods for PHEMlight-based emission computation.
virtual std::string getFuel(const SUMOEmissionClass c) const
Returns the fuel type described by this emission class as described in the Amitran interface (Gasolin...
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...