Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/emissions/HelpersPHEMlight5.h
169678 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2013-2025 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
/****************************************************************************/
14
/// @file HelpersPHEMlight5.h
15
/// @author Daniel Krajzewicz
16
/// @author Nikolaus Furian
17
/// @date Sat, 20.04.2013
18
///
19
// Helper methods for PHEMlight-based emission computation
20
/****************************************************************************/
21
#pragma once
22
#include <config.h>
23
24
#define INTERNAL_PHEM
25
26
#include <vector>
27
#include <limits>
28
#include <cmath>
29
#include <foreign/PHEMlight/V5/cpp/CEP.h>
30
#include <foreign/PHEMlight/V5/cpp/CEPHandler.h>
31
#include <foreign/PHEMlight/V5/cpp/Helpers.h>
32
#include <utils/common/StdDefs.h>
33
#include "HelpersPHEMlight.h"
34
35
36
// ===========================================================================
37
// class definitions
38
// ===========================================================================
39
/**
40
* @class HelpersPHEMlight5
41
* @brief Helper methods for PHEMlight-based emission computation
42
*/
43
class HelpersPHEMlight5 : public HelpersPHEMlight {
44
private:
45
static const int PHEMLIGHT5_BASE = 6 << 16;
46
47
public:
48
/** @brief Constructor
49
*/
50
HelpersPHEMlight5();
51
52
/** @brief Destructor
53
*/
54
virtual ~HelpersPHEMlight5();
55
56
/** @brief Checks whether the string describes a known vehicle class
57
* @param[in] eClass The string describing the vehicle emission class
58
* @return whether it describes a valid emission class
59
*/
60
SUMOEmissionClass getClassByName(const std::string& eClass, const SUMOVehicleClass vc);
61
62
/** @brief Returns the fuel type described by this emission class as described in the Amitran interface (Gasoline, Diesel, ...)
63
* @param[in] c the emission class
64
* @return the fuel type
65
*/
66
std::string getFuel(const SUMOEmissionClass c) const;
67
68
/** @brief Returns a reference weight in kg described by this emission class
69
* This implementation returns the value from the corresponding veh description file.
70
* @param[in] c the emission class
71
* @return a reference weight
72
*/
73
double getWeight(const SUMOEmissionClass c) const;
74
75
/** @brief Returns the amount of emitted pollutant given the vehicle type and state (in mg/s or in ml/s for fuel)
76
* @param[in] c The vehicle emission class
77
* @param[in] v The vehicle's current velocity
78
* @param[in] a The vehicle's current acceleration
79
* @param[in] slope The road's slope at vehicle's position [deg]
80
* @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]
81
*/
82
double compute(const SUMOEmissionClass c, const PollutantsInterface::EmissionType e, const double v, const double a, const double slope, const EnergyParams* param) const;
83
84
/** @brief Returns the adapted acceleration value, useful for comparing with external PHEMlight references.
85
* @param[in] c the emission class
86
* @param[in] v the speed value
87
* @param[in] a the acceleration value
88
* @param[in] slope The road's slope at vehicle's position [deg]
89
* @return the modified acceleration
90
*/
91
double getModifiedAccel(const SUMOEmissionClass c, const double v, const double a, const double slope, const EnergyParams* param) const;
92
93
/** @brief Returns the maximum deceleration value (as a negative number), which can still be considered as non-braking.
94
* @param[in] c the emission class
95
* @param[in] v the speed value
96
* @param[in] a the acceleration value
97
* @param[in] slope The road's slope at vehicle's position [deg]
98
* @param[in] param parameter of the emission model affecting the computation
99
* @return the coasting deceleration
100
*/
101
virtual double getCoastingDecel(const SUMOEmissionClass c, const double v, const double a, const double slope, const EnergyParams* param) const;
102
103
private:
104
/** @brief Returns the amount of emitted pollutant given the vehicle type and state (in mg/s or in ml/s for fuel)
105
* @param[in] currCep The vehicle emission class
106
* @param[in] e The emission type
107
* @param[in] p The vehicle's current power
108
* @param[in] v The vehicle's current velocity
109
* @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]
110
*/
111
double getEmission(PHEMlightdllV5::CEP* currCep, const std::string& e, const double p, const double v, const double drivingPower, const double ratedPower) const;
112
113
/** @brief Returns the total power needed.
114
* @param[in] currCep the emission class
115
* @param[in] v the speed value
116
* @param[in] a the acceleration value
117
* @param[in] slope The road's slope at vehicle's position [deg]
118
* @return the total power needed
119
*/
120
double calcPower(PHEMlightdllV5::CEP* currCep, const double v, const double a, const double slope, const EnergyParams* param) const;
121
122
/** @brief Returns the power without auxiliaries.
123
* @param[in] currCep the emission class
124
* @param[in] v the speed value
125
* @param[in] a the acceleration value
126
* @param[in] slope The road's slope at vehicle's position [deg]
127
* @return the power without auxiliaries
128
*/
129
double calcWheelPower(PHEMlightdllV5::CEP* currCep, const double v, const double a, const double slope, const EnergyParams* param) const;
130
131
/// @brief the index of the next class
132
int myIndex;
133
PHEMlightdllV5::CEPHandler myCEPHandler;
134
PHEMlightdllV5::Correction* myCorrection = nullptr;
135
mutable PHEMlightdllV5::Helpers myHelper;
136
std::map<SUMOEmissionClass, PHEMlightdllV5::CEP*> myCEPs;
137
};
138
139