/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2013-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 HelpersPHEMlight.h14/// @author Daniel Krajzewicz15/// @author Nikolaus Furian16/// @date Sat, 20.04.201317///18// Helper methods for PHEMlight-based emission computation19/****************************************************************************/20#pragma once21#include <config.h>2223#define INTERNAL_PHEM2425#include <vector>26#include <limits>27#include <cmath>28#ifdef INTERNAL_PHEM29#include "PHEMCEPHandler.h"30#endif31#include <foreign/PHEMlight/cpp/CEP.h>32#include <foreign/PHEMlight/cpp/CEPHandler.h>33#include <foreign/PHEMlight/cpp/Helpers.h>34#include <utils/common/StdDefs.h>35#include "PollutantsInterface.h"363738// ===========================================================================39// class definitions40// ===========================================================================41/**42* @class HelpersPHEMlight43* @brief Helper methods for PHEMlight-based emission computation44*/45class HelpersPHEMlight : public PollutantsInterface::Helper {46private:47static const int PHEMLIGHT_BASE = 3 << 16;4849public:50/** @brief Constructor51*/52HelpersPHEMlight();5354/** @brief Destructor55*/56virtual ~HelpersPHEMlight();5758protected:59/** @brief Constructor for subclasses60* @param[in] name the name of the model (string before the '/' in the emission class attribute)61*/62HelpersPHEMlight(std::string name, const int baseIndex, const int defaultClass)63: PollutantsInterface::Helper(name, baseIndex, defaultClass) {}6465public:66/** @brief Checks whether the string describes a known vehicle class67* @param[in] eClass The string describing the vehicle emission class68* @return whether it describes a valid emission class69*/70virtual SUMOEmissionClass getClassByName(const std::string& eClass, const SUMOVehicleClass vc);7172/** @brief Returns the emission class described by the given parameters.73* @param[in] base the base class giving the default74* @param[in] vClass the vehicle class as described in the Amitran interface (Passenger, ...)75* @param[in] fuel the fuel type as described in the Amitran interface (Gasoline, Diesel, ...)76* @param[in] eClass the emission class as described in the Amitran interface (Euro0, ...)77* @param[in] weight the vehicle weight in kg as described in the Amitran interface78* @return the class described by the parameters79*/80SUMOEmissionClass getClass(const SUMOEmissionClass base, const std::string& vClass, const std::string& fuel, const std::string& eClass, const double weight) const;8182/** @brief Returns the vehicle class described by this emission class as described in the Amitran interface (Passenger, ...)83* @param[in] c the emission class84* @return the name of the vehicle class85*/86std::string getAmitranVehicleClass(const SUMOEmissionClass c) const;8788/** @brief Returns the fuel type described by this emission class as described in the Amitran interface (Gasoline, Diesel, ...)89* @param[in] c the emission class90* @return the fuel type91*/92std::string getFuel(const SUMOEmissionClass c) const;9394/** @brief Returns the Euro emission class described by this emission class as described in the Amitran interface (0, ..., 6)95* @param[in] c the emission class96* @return the Euro class97*/98int getEuroClass(const SUMOEmissionClass c) const;99100/** @brief Returns a reference weight in kg described by this emission class as described in the Amitran interface101* This implementation returns only meaningful values for Solo_LKW (truck without trailer) and LNF (light duty vehicles).102* @param[in] c the emission class103* @return a reference weight104*/105double getWeight(const SUMOEmissionClass c) const;106107/** @brief Returns the amount of emitted pollutant given the vehicle type and state (in mg/s or in ml/s for fuel)108* @param[in] c The vehicle emission class109* @param[in] v The vehicle's current velocity110* @param[in] a The vehicle's current acceleration111* @param[in] slope The road's slope at vehicle's position [deg]112* @return The amount of the pollutant emitted by the given emission class when moving with the given velocity and acceleration [mg/s or ml/s]113*/114virtual double compute(const SUMOEmissionClass c, const PollutantsInterface::EmissionType e, const double v, const double a, const double slope, const EnergyParams* param) const;115116/** @brief Returns the adapted acceleration value, useful for comparing with external PHEMlight references.117* @param[in] c the emission class118* @param[in] v the speed value119* @param[in] a the acceleration value120* @param[in] slope The road's slope at vehicle's position [deg]121* @return the modified acceleration122*/123virtual double getModifiedAccel(const SUMOEmissionClass c, const double v, const double a, const double slope, const EnergyParams* param) const;124125/** @brief Returns the maximum deceleration value (as a negative number), which can still be considered as non-braking.126* @param[in] c the emission class127* @param[in] v the speed value128* @param[in] a the acceleration value129* @param[in] slope The road's slope at vehicle's position [deg]130* @param[in] param parameter of the emission model affecting the computation131* @return the coasting deceleration132*/133virtual double getCoastingDecel(const SUMOEmissionClass c, const double v, const double a, const double slope, const EnergyParams* param) const;134135private:136/** @brief Returns the amount of emitted pollutant given the vehicle type and state (in mg/s or in ml/s for fuel)137* @param[in] currCep The vehicle emission class138* @param[in] e The emission type139* @param[in] p The vehicle's current power140* @param[in] v The vehicle's current velocity141* @return The amount of the pollutant emitted by the given emission class when moving with the given velocity and acceleration [mg/s or ml/s]142*/143double getEmission(const PHEMCEP* oldCep, PHEMlightdll::CEP* currCep, const std::string& e, const double p, const double v) const;144145/// @brief the index of the next class146int myIndex;147PHEMlightdll::CEPHandler myCEPHandler;148mutable PHEMlightdll::Helpers myHelper;149std::map<SUMOEmissionClass, PHEMlightdll::CEP*> myCEPs;150};151152153