Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2013-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 : /****************************************************************************/
14 : /// @file PHEMCEP.h
15 : /// @author Nikolaus Furian
16 : /// @author Daniel Krajzewicz
17 : /// @author Michael Behrisch
18 : /// @author Marek Heinrich
19 : /// @date Thu, 13.06.2013
20 : ///
21 : // Helper class for PHEM Light, holds a specific CEP for a PHEM emission class
22 : /****************************************************************************/
23 : #pragma once
24 : #include <config.h>
25 :
26 : #include <vector>
27 : #include <utils/common/SUMOVehicleClass.h>
28 : #include <utils/common/StringBijection.h>
29 : #include "PHEMConstants.h"
30 :
31 :
32 :
33 : // ===========================================================================
34 : // enumerations
35 : // ===========================================================================
36 : enum NormalizingType {
37 : RatedPower,
38 : DrivingPower
39 : };
40 :
41 :
42 : // ===========================================================================
43 : // class definitions
44 : // ===========================================================================
45 : /**
46 : * @class PHEMCEP
47 : * @brief Data Handler for a single CEP emission data set
48 : */
49 : class PHEMCEP {
50 : public:
51 : /*** @brief Constructor
52 : * @param[in] emissionClass PHEM emission class of vehicle
53 : * @param[in] vehicleMass vehicle mass
54 : * @param[in] vehicleLoading vehicle loading
55 : * @param[in] vehicleMassRot rotational mass of vehicle
56 : * @param[in] crossArea crosssectional area of vehicle
57 : * @param[in] cWValue cw-value
58 : * @param[in] f0 Rolling resistance f0
59 : * @param[in] f1 Rolling resistance f1
60 : * @param[in] f2 Rolling resistance f2
61 : * @param[in] f3 Rolling resistance f3
62 : * @param[in] f4 Rolling resistance f4
63 : * @param[in] ratedPower rated power of vehicle
64 : * @param[in] pNormV0 out variable for step function to get maximum normalized rated power over speed
65 : * @param[in] pNormP0 out variable for step function to get maximum normalized rated power over speed
66 : * @param[in] pNormV1 out variable for step function to get maximum normalized rated power over speed
67 : * @param[in] pNormP1 out variable for step function to get maximum normalized rated power over speed
68 : * @param[in] vehicleFuelType out variable for fuel type (D, G) of vehicle, needed for density of fuel
69 : * @param[in] matrixFC Coefficients of the fuel consumption
70 : * @param[in] headerLine Definition of covered pollutants
71 : * @param[in] headerLinePollutants Coefficients of the pollutants
72 : * @param[in] matrixPollutants Coefficients of the pollutants
73 : * @param[in] matrixSpeedRotational Table for rotational coefficients over speed
74 : */
75 : PHEMCEP(bool heavyVehicel, SUMOEmissionClass emissionClass, const std::string& emissionClassIdentifier,
76 : double vehicleMass, double vehicleLoading, double vehicleMassRot,
77 : double crossArea, double cdValue,
78 : double f0, double f1, double f2, double f3, double f4,
79 : double ratedPower, double pNormV0, double pNormP0, double pNormV1, double pNormP1,
80 : double axleRatio, double engineIdlingSpeed, double engineRatedSpeed, double effectiveWheelDiameter,
81 : double idlingFC,
82 : const std::string& vehicleFuelType,
83 : const std::vector< std::vector<double> >& matrixFC,
84 : const std::vector<std::string>& headerLinePollutants,
85 : const std::vector< std::vector<double> >& matrixPollutants,
86 : const std::vector< std::vector<double> >& matrixSpeedRotational,
87 : const std::vector< std::vector<double> >& normedDragTable,
88 : const std::vector<double>& idlingValuesPollutants);
89 :
90 : /// @brief Destructor
91 : ~PHEMCEP();
92 :
93 : /** @brief Returns the power of used for a vehicle at state v,a, slope and loading
94 : * @param[in] v The vehicle's average velocity
95 : * @param[in] a The vehicle's average acceleration
96 : * @param[in] slope The road's slope at vehicle's position [deg]
97 : * @param{in] vehicleCep vehicles CEP data
98 : * @param{in] loading vehicle loading [kg]
99 : * @return The power demand for desired state [kW]
100 : */
101 : double CalcPower(double v, double a, double slope, double vehicleLoading = 0) const;
102 :
103 :
104 : /** @brief Returns the maximum accelaration for a vehicle at state v,a, slope and loading
105 : * @param[in] v The vehicle's average velocity
106 : * @param[in] a The vehicle's average acceleration
107 : * @param[in] slope The road's slope at vehicle's position [deg]
108 : * @param{in] vehicleCep vehicles CEP data
109 : * @param{in] loading vehicle loading [kg]
110 : * @return The maximum accelaration for desired state [kW]
111 : */
112 : double GetMaxAccel(double v, double a, double gradient, double vehicleLoading = 0) const;
113 :
114 : /** @brief Returns a emission measure for power[kW] level
115 : * @param[in] pollutantIdentifier Desired pollutant, e.g. NOx
116 : * @param[in] power in [kW]
117 : * @return emission in [g/h]
118 : */
119 : double GetEmission(const std::string& pollutantIdentifier, double power, double speed, bool normalized = false) const;
120 : double GetDecelCoast(double speed, double acc, double gradient, double vehicleLoading) const;
121 :
122 :
123 : /** @brief Getter function to recieve vehicle data from CEP
124 : * @return PHEM emission class of vehicle
125 : */
126 : SUMOEmissionClass GetEmissionClass() const {
127 : return _emissionClass;
128 : }
129 :
130 :
131 : /** @brief Getter function to recieve vehicle data from CEP
132 : * @return Rolling resistance f0
133 : */
134 : double GetResistanceF0() const {
135 : return _resistanceF0;
136 : }
137 :
138 :
139 : /** @brief Getter function to recieve vehicle data from CEP
140 : * @return Rolling resistance f1
141 : */
142 : double GetResistanceF1() const {
143 : return _resistanceF1;
144 : }
145 :
146 :
147 : /** @brief Getter function to recieve vehicle data from CEP
148 : * @return Rolling resistance f2
149 : */
150 : double GetResistanceF2() const {
151 : return _resistanceF2;
152 : }
153 :
154 :
155 : /** @brief Getter function to recieve vehicle data from CEP
156 : * @return Rolling resistance f3
157 : */
158 : double GetResistanceF3() const {
159 : return _resistanceF3;
160 : }
161 :
162 :
163 : /** @brief Getter function to recieve vehicle data from CEP
164 : * @return Rolling resistance f4
165 : */
166 : double GetResistanceF4() const {
167 : return _resistanceF4;
168 : }
169 :
170 :
171 : /** @brief Getter function to recieve vehicle data from CEP
172 : * @return Cw value
173 : * @todo: Why is it named "cdValue", here?
174 : */
175 : double GetCdValue() const {
176 : return _cdValue;
177 : }
178 :
179 : /** @brief Getter function to recieve vehicle data from CEP
180 : * @return crosssectional area of vehicle
181 : */
182 : double GetCrossSectionalArea() const {
183 : return _crossSectionalArea;
184 : }
185 :
186 :
187 : /** @brief Getter function to recieve vehicle data from CEP
188 : * @return vehicle mass
189 : */
190 : double GetMassVehicle() const {
191 : return _massVehicle;
192 : }
193 :
194 : /** @brief Getter function to recieve vehicle data from CEP
195 : * @return vehicle loading
196 : */
197 : double GetVehicleLoading() const {
198 : return _vehicleLoading;
199 : }
200 :
201 :
202 : /** @brief Getter function to recieve vehicle data from CEP
203 : * @return rotational mass of vehicle
204 : */
205 : double GetMassRot() const {
206 : return _massRot;
207 : }
208 :
209 :
210 : /** @brief Getter function to recieve vehicle data from CEP
211 : * @return rated power of vehicle
212 : */
213 : double GetRatedPower() const {
214 : return _ratedPower;
215 : }
216 :
217 : /** @brief Getter function to recieve vehicle data from CEP
218 : * @return fuel type of vehicle
219 : */
220 : const std::string& GetVehicleFuelType() const {
221 0 : return _vehicleFuelType;
222 : }
223 :
224 : private:
225 : /** @brief Interpolates emission linearly between two known power-emission pairs
226 : * @param[in] px power-value to interpolate
227 : * @param[in] p1 first known power value
228 : * @param[in] p2 second known power value
229 : * @param[in] e1 emission value for p1
230 : * @param[in] e2 emission value for p2
231 : * @return emission value for px
232 : */
233 : double Interpolate(double px, double p1, double p2, double e1, double e2) const;
234 :
235 : /** @brief Finds bounding upper and lower index in pattern for value
236 : * @param[out] lowerIndex out variable for lower index
237 : * @param[out] upperIndex out variable for lower index
238 : * @param[in] pattern to search
239 : * @param[in] value to search
240 : */
241 : void FindLowerUpperInPattern(int& lowerIndex, int& upperIndex, const std::vector<double>& pattern, double value) const;
242 :
243 : /** @brief Calculates rotational index for speed
244 : * @param[in] speed desired speed
245 : */
246 : double GetRotationalCoeffecient(double speed) const;
247 : double GetGearCoeffecient(double speed) const;
248 : double GetDragCoeffecient(double nNorm) const;
249 :
250 : /** @brief Calculates maximum available rated power for speed
251 : * @param[in] speed desired speed
252 : */
253 : double GetPMaxNorm(double speed) const;
254 :
255 : private:
256 : /// @brief PHEM emission class of vehicle
257 : SUMOEmissionClass _emissionClass;
258 : NormalizingType _normalizingType;
259 : /// @brief Rolling resistance f0
260 : double _resistanceF0;
261 : /// @brief Rolling resistance f1
262 : double _resistanceF1;
263 : /// @brief Rolling resistance f2
264 : double _resistanceF2;
265 : /// @brief Rolling resistance f3
266 : double _resistanceF3;
267 : /// @brief Rolling resistance f4
268 : double _resistanceF4;
269 : /// @brief Cw value
270 : double _cdValue;
271 : /// @brief crosssectional area of vehicle
272 : double _crossSectionalArea;
273 : /// @brief vehicle mass
274 : double _massVehicle;
275 : /// @brief vehicle loading
276 : double _vehicleLoading;
277 : /// @brief rotational mass of vehicle
278 : double _massRot;
279 : /// @brief rated power of vehicle
280 : double _ratedPower;
281 : /// @brief Step functions parameter for maximum rated power
282 : double _pNormV0;
283 : /// @brief Step functions parameter for maximum rated power
284 : double _pNormP0;
285 : /// @brief Step functions parameter for maximum rated power
286 : double _pNormV1;
287 : /// @brief Step functions parameter for maximum rated power
288 : double _pNormP1;
289 : double _axleRatio;
290 : double _engineIdlingSpeed;
291 : double _engineRatedSpeed;
292 : double _effictiveWheelDiameter;
293 : double _idlingFC;
294 : std::string _vehicleFuelType;
295 : int _sizeOfPatternFC;
296 : /// @todo describe
297 : int _sizeOfPatternPollutants;
298 : double _normalizingPower;
299 : double _drivingPower;
300 : bool _heavyVehicle;
301 : std::vector<double> _speedPatternRotational;
302 : /// @todo describe
303 : std::vector<double> _powerPatternFC;
304 : /// @todo describe
305 : std::vector<double> _powerPatternPollutants;
306 : std::vector<double> _normalizedPowerPatternFC;
307 : std::vector<double> _normailzedPowerPatternPollutants;
308 : /// @todo describe
309 : std::vector<double> _cepCurveFC;
310 : /// @todo describe
311 : std::vector<double> _normedCepCurveFC;
312 : std::vector<double> _speedCurveRotational;
313 : std::vector<double> _gearTransmissionCurve;
314 : std::vector<double> _nNormTable;
315 : std::vector<double> _dragNormTable;
316 : StringBijection< std::vector<double> > _cepCurvePollutants;
317 : StringBijection<std::vector<double> > _normalizedCepCurvePollutants;
318 : StringBijection<double> _idlingValuesPollutants;
319 :
320 : };
|