/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file HelpersHBEFA.h14/// @author Daniel Krajzewicz15/// @author Michael Behrisch16/// @date Mon, 10.05.200417///18// Helper methods for HBEFA-based emission computation19/****************************************************************************/20#pragma once21#include <config.h>2223#include <vector>24#include <limits>25#include <cmath>26#include <utils/common/StdDefs.h>27#include <utils/geom/GeomHelper.h>28#include <utils/common/SUMOVehicleClass.h>29#include "EnergyParams.h"30#include "PollutantsInterface.h"313233// ===========================================================================34// class definitions35// ===========================================================================36/**37* @class HelpersHBEFA38* @brief Helper methods for HBEFA-based emission computation39*40* The parameter are stored per vehicle class; 6*6 parameter are used, sorted by41* the pollutant (CO2, CO, HC, fuel, NOx, PMx), and the function part42* (c0, cav1, cav2, c1, c2, c3).43*/44class HelpersHBEFA : public PollutantsInterface::Helper {45private:46static const int HBEFA_BASE = 1 << 16;4748public:49/** @brief Constructor (initializes myEmissionClassStrings)50*/51HelpersHBEFA();525354/** @brief Computes the emitted pollutant amount using the given speed and acceleration55*56* As the functions are defining emissions in g/hour, the function's result is normed57* by 3.6 (seconds in an hour/1000) yielding mg/s. For fuel ml/s is returned.58* Negative acceleration results directly in zero emission.59*60* @param[in] c emission class for the function parameters to use61* @param[in] e the type of emission (CO, CO2, ...)62* @param[in] v The vehicle's current velocity63* @param[in] a The vehicle's current acceleration64* @param[in] slope The road's slope at vehicle's position [deg]65* @return The amount emitted by the given emission class when moving with the given velocity and acceleration [mg/s or ml/s]66*/67inline double compute(const SUMOEmissionClass c, const PollutantsInterface::EmissionType e, const double v, const double a, const double slope, const EnergyParams* param) const {68if (e == PollutantsInterface::ELEC || (param != nullptr && param->isEngineOff())) {69return 0.;70}71if (v > ZERO_SPEED_ACCURACY && a < getCoastingDecel(c, v, a, slope, param)) {72return 0.;73}74const int index = (c & ~PollutantsInterface::HEAVY_BIT) - HBEFA_BASE;75const double kmh = v * 3.6;76const double scale = (e == PollutantsInterface::FUEL && myVolumetricFuel) ? 3.6 * 790. : 3.6;77if (index >= 42) {78const double* f = myFunctionParameter[index - 42] + 6 * e;79return MAX2((f[0] + f[3] * kmh + f[4] * kmh * kmh + f[5] * kmh * kmh * kmh) / scale, 0.);80}81const double* f = myFunctionParameter[index] + 6 * e;82const double alpha = RAD2DEG(asin(a / GRAVITY));83return 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.);84}858687private:88/// @brief The function parameter89static double myFunctionParameter[42][36];9091};929394