Eclipse SUMO - Simulation of Urban MObility
HelpersHBEFA.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 HBEFA-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 HBEFA_BASE = 1 << 16;
47 
48 public:
51  HelpersHBEFA();
52 
53 
67  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 {
68  UNUSED_PARAMETER(slope);
69  UNUSED_PARAMETER(param);
70  if (e == PollutantsInterface::ELEC) {
71  return 0.;
72  }
73  const int index = (c & ~PollutantsInterface::HEAVY_BIT) - HBEFA_BASE;
74  const double kmh = v * 3.6;
75  const double scale = (e == PollutantsInterface::FUEL) ? 3.6 * 790. : 3.6;
76  if (index >= 42) {
77  const double* f = myFunctionParameter[index - 42] + 6 * e;
78  return (double) MAX2((f[0] + f[3] * kmh + f[4] * kmh * kmh + f[5] * kmh * kmh * kmh) / scale, 0.);
79  }
80  if (a < 0.) {
81  return 0.;
82  }
83  const double* f = myFunctionParameter[index] + 6 * e;
84  const double alpha = RAD2DEG(asin(a / GRAVITY));
85  return (double) MAX2((f[0] + f[1] * alpha * kmh + f[2] * alpha * alpha * kmh + f[3] * kmh + f[4] * kmh * kmh + f[5] * kmh * kmh * kmh) / scale, 0.);
86  }
87 
88 
89 private:
91  static double myFunctionParameter[42][36];
92 
93 };
#define GRAVITY
Definition: GeomHelper.h:37
#define RAD2DEG(x)
Definition: GeomHelper.h:36
int SUMOEmissionClass
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:29
T MAX2(T a, T b)
Definition: StdDefs.h:79
Helper methods for HBEFA-based emission computation.
Definition: HelpersHBEFA.h:44
static const int HBEFA_BASE
Definition: HelpersHBEFA.h:46
static double myFunctionParameter[42][36]
The function parameter.
Definition: HelpersHBEFA.h:91
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: HelpersHBEFA.h:67
HelpersHBEFA()
Constructor (initializes myEmissionClassStrings)
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.