/****************************************************************************/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 HelpersPHEMlight5.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#include <foreign/PHEMlight/V5/cpp/CEP.h>29#include <foreign/PHEMlight/V5/cpp/CEPHandler.h>30#include <foreign/PHEMlight/V5/cpp/Helpers.h>31#include <utils/common/StdDefs.h>32#include "HelpersPHEMlight.h"333435// ===========================================================================36// class definitions37// ===========================================================================38/**39* @class HelpersPHEMlight540* @brief Helper methods for PHEMlight-based emission computation41*/42class HelpersPHEMlight5 : public HelpersPHEMlight {43private:44static const int PHEMLIGHT5_BASE = 6 << 16;4546public:47/** @brief Constructor48*/49HelpersPHEMlight5();5051/** @brief Destructor52*/53virtual ~HelpersPHEMlight5();5455/** @brief Checks whether the string describes a known vehicle class56* @param[in] eClass The string describing the vehicle emission class57* @return whether it describes a valid emission class58*/59SUMOEmissionClass getClassByName(const std::string& eClass, const SUMOVehicleClass vc);6061/** @brief Returns the fuel type described by this emission class as described in the Amitran interface (Gasoline, Diesel, ...)62* @param[in] c the emission class63* @return the fuel type64*/65std::string getFuel(const SUMOEmissionClass c) const;6667/** @brief Returns a reference weight in kg described by this emission class68* This implementation returns the value from the corresponding veh description file.69* @param[in] c the emission class70* @return a reference weight71*/72double getWeight(const SUMOEmissionClass c) const;7374/** @brief Returns the amount of emitted pollutant given the vehicle type and state (in mg/s or in ml/s for fuel)75* @param[in] c The vehicle emission class76* @param[in] v The vehicle's current velocity77* @param[in] a The vehicle's current acceleration78* @param[in] slope The road's slope at vehicle's position [deg]79* @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]80*/81double compute(const SUMOEmissionClass c, const PollutantsInterface::EmissionType e, const double v, const double a, const double slope, const EnergyParams* param) const;8283/** @brief Returns the adapted acceleration value, useful for comparing with external PHEMlight references.84* @param[in] c the emission class85* @param[in] v the speed value86* @param[in] a the acceleration value87* @param[in] slope The road's slope at vehicle's position [deg]88* @return the modified acceleration89*/90double getModifiedAccel(const SUMOEmissionClass c, const double v, const double a, const double slope, const EnergyParams* param) const;9192/** @brief Returns the maximum deceleration value (as a negative number), which can still be considered as non-braking.93* @param[in] c the emission class94* @param[in] v the speed value95* @param[in] a the acceleration value96* @param[in] slope The road's slope at vehicle's position [deg]97* @param[in] param parameter of the emission model affecting the computation98* @return the coasting deceleration99*/100virtual double getCoastingDecel(const SUMOEmissionClass c, const double v, const double a, const double slope, const EnergyParams* param) const;101102private:103/** @brief Returns the amount of emitted pollutant given the vehicle type and state (in mg/s or in ml/s for fuel)104* @param[in] currCep The vehicle emission class105* @param[in] e The emission type106* @param[in] p The vehicle's current power107* @param[in] v The vehicle's current velocity108* @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]109*/110double getEmission(PHEMlightdllV5::CEP* currCep, const std::string& e, const double p, const double v, const double drivingPower, const double ratedPower) const;111112/** @brief Returns the total power needed.113* @param[in] currCep the emission class114* @param[in] v the speed value115* @param[in] a the acceleration value116* @param[in] slope The road's slope at vehicle's position [deg]117* @return the total power needed118*/119double calcPower(PHEMlightdllV5::CEP* currCep, const double v, const double a, const double slope, const EnergyParams* param) const;120121/** @brief Returns the power without auxiliaries.122* @param[in] currCep the emission class123* @param[in] v the speed value124* @param[in] a the acceleration value125* @param[in] slope The road's slope at vehicle's position [deg]126* @return the power without auxiliaries127*/128double calcWheelPower(PHEMlightdllV5::CEP* currCep, const double v, const double a, const double slope, const EnergyParams* param) const;129130/// @brief the index of the next class131int myIndex;132PHEMlightdllV5::CEPHandler myCEPHandler;133PHEMlightdllV5::Correction* myCorrection = nullptr;134mutable PHEMlightdllV5::Helpers myHelper;135std::map<SUMOEmissionClass, PHEMlightdllV5::CEP*> myCEPs;136};137138139