Eclipse SUMO - Simulation of Urban MObility
HelpersHBEFA3.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2020 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 // Helper methods for HBEFA3-based emission computation
20 /****************************************************************************/
21 #pragma once
22 #include <config.h>
23 
24 #include <vector>
25 #include <limits>
26 #include <cmath>
27 #include <utils/common/StdDefs.h>
28 #include <utils/geom/GeomHelper.h>
30 #include "PollutantsInterface.h"
31 
32 
33 // ===========================================================================
34 // class definitions
35 // ===========================================================================
45 private:
46  static const int HBEFA3_BASE = 2 << 16;
47 
48 public:
51  HelpersHBEFA3();
52 
61  SUMOEmissionClass getClass(const SUMOEmissionClass base, const std::string& vClass, const std::string& fuel, const std::string& eClass, const double weight) const;
62 
67  std::string getAmitranVehicleClass(const SUMOEmissionClass c) const;
68 
73  std::string getFuel(const SUMOEmissionClass c) const;
74 
79  int getEuroClass(const SUMOEmissionClass c) const;
80 
81 
95  inline double compute(const SUMOEmissionClass c, const PollutantsInterface::EmissionType e, const double v, const double a, const double slope, const std::map<int, double>* param) const {
96  UNUSED_PARAMETER(slope);
97  UNUSED_PARAMETER(param);
98  if (a < 0. || e == PollutantsInterface::ELEC) {
99  return 0.;
100  }
101  const int index = (c & ~PollutantsInterface::HEAVY_BIT) - HBEFA3_BASE;
102  double scale = 3.6;
103  if (e == PollutantsInterface::FUEL) {
104  if (getFuel(c) == "Diesel") {
105  scale *= 836.;
106  } else {
107  scale *= 742.;
108  }
109  }
110  const double* f = myFunctionParameter[index][e];
111  return (double) MAX2((f[0] + f[1] * a * v + f[2] * a * a * v + f[3] * v + f[4] * v * v + f[5] * v * v * v) / scale, 0.);
112  }
113 
114 
115 private:
117  static double myFunctionParameter[45][6][6];
118 
119 };
int SUMOEmissionClass
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:29
T MAX2(T a, T b)
Definition: StdDefs.h:79
Helper methods for HBEFA3-based emission computation.
Definition: HelpersHBEFA3.h:44
static double myFunctionParameter[45][6][6]
The function parameter.
std::string getFuel(const SUMOEmissionClass c) const
Returns the fuel type described by this emission class as described in the Amitran interface (Gasolin...
int getEuroClass(const SUMOEmissionClass c) const
Returns the Euro emission class described by this emission class as described in the Amitran interfac...
double compute(const SUMOEmissionClass c, const PollutantsInterface::EmissionType e, const double v, const double a, const double slope, const std::map< int, double > *param) const
Computes the emitted pollutant amount using the given speed and acceleration.
Definition: HelpersHBEFA3.h:95
std::string getAmitranVehicleClass(const SUMOEmissionClass c) const
Returns the vehicle class described by this emission class as described in the Amitran interface (Pas...
HelpersHBEFA3()
Constructor (initializes myEmissionClassStrings)
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.
static const int HBEFA3_BASE
Definition: HelpersHBEFA3.h:46
zero emission model, used as superclass for the other model helpers
Helper methods for PHEMlight-based emission computation.
EmissionType
Enumerating all emission types, including fuel.