Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
HelpersHBEFA4.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 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 HBEFA4-based emission computation
20/****************************************************************************/
21#pragma once
22#include <config.h>
23
24#include <vector>
25#include <limits>
26#include <cmath>
30#include "EnergyParams.h"
31#include "PollutantsInterface.h"
32
33
34// ===========================================================================
35// class definitions
36// ===========================================================================
46private:
47 static const int HBEFA4_BASE = 7 << 16;
48
49public:
53
62 SUMOEmissionClass getClass(const SUMOEmissionClass base, const std::string& vClass, const std::string& fuel, const std::string& eClass, const double weight) const;
63
68 std::string getAmitranVehicleClass(const SUMOEmissionClass c) const;
69
74 std::string getFuel(const SUMOEmissionClass c) const;
75
80 int getEuroClass(const SUMOEmissionClass c) const;
81
82
96 inline double compute(const SUMOEmissionClass c, const PollutantsInterface::EmissionType e, const double v, const double a, const double slope, const EnergyParams* param) const {
97 if (param != nullptr && param->isEngineOff()) {
98 return 0.;
99 }
100 const std::string& fuel = getFuel(c);
101 if (fuel != "Electricity" && v > ZERO_SPEED_ACCURACY && a < getCoastingDecel(c, v, a, slope, param)) {
102 return 0.;
103 }
104 const int index = (c & ~PollutantsInterface::HEAVY_BIT) - HBEFA4_BASE;
105 double scale = 1.;
107 if (fuel == "Diesel") {
108 scale *= 836.;
109 } else if (fuel == "Gasoline") {
110 scale *= 742.;
111 }
112 }
113 const double* f = myFunctionParameter[index][e];
114 double result = (f[0] + f[1] * v + f[2] * a + f[3] * v * v + f[4] * v * v * v + f[5] * a * v + f[6] * a * v * v) / scale;
115 if (e != PollutantsInterface::ELEC) {
116 // no negative emissions
117 result = MAX2(0.0, result);
118 }
119 return result;
120 }
121
122
123private:
125 static double myFunctionParameter[833][7][7];
126
127};
int SUMOEmissionClass
T MAX2(T a, T b)
Definition StdDefs.h:82
An upper class for objects with additional parameters.
bool isEngineOff() const
Returns the state of the engine when the vehicle is not moving.
Helper methods for HBEFA4-based emission computation.
double compute(const SUMOEmissionClass c, const PollutantsInterface::EmissionType e, const double v, const double a, const double slope, const EnergyParams *param) const
Computes the emitted pollutant amount using the given speed and acceleration.
static const int HBEFA4_BASE
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.
std::string getAmitranVehicleClass(const SUMOEmissionClass c) const
Returns the vehicle class described by this emission class as described in the Amitran interface (Pas...
std::string getFuel(const SUMOEmissionClass c) const
Returns the fuel type described by this emission class as described in the Amitran interface (Gasolin...
HelpersHBEFA4()
Constructor (initializes myEmissionClassStrings)
int getEuroClass(const SUMOEmissionClass c) const
Returns the Euro emission class described by this emission class as described in the Amitran interfac...
static double myFunctionParameter[833][7][7]
The function parameter.
zero emission model, used as superclass for the other model helpers
virtual double getCoastingDecel(const SUMOEmissionClass c, const double v, const double a, const double slope, const EnergyParams *param) const
Returns the maximum deceleration value (as a negative number), which can still be considered as non-b...
static const double ZERO_SPEED_ACCURACY
the lowest speed which allows reliable coasting calculations
bool myVolumetricFuel
return fuel consumption in l instead of mg
Helper methods for PHEMlight-based emission computation.
EmissionType
Enumerating all emission types, including fuel.