Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/emissions/PHEMCEPHandler.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 PHEMCEPHandler.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 singleton class for PHEM Light, holds CEP data for emission computation
22
/****************************************************************************/
23
#pragma once
24
#include <config.h>
25
26
#include <vector>
27
#include <utils/common/StringBijection.h>
28
#include "PHEMCEP.h"
29
30
31
// ===========================================================================
32
// class definitions
33
// ===========================================================================
34
/**
35
* @class PHEMCEPHandler
36
* @brief Data Handler for all CEP emission and vehicle Data
37
*/
38
class PHEMCEPHandler {
39
public:
40
/// @brief Destructor
41
~PHEMCEPHandler();
42
43
44
/** @brief Implementatio of Singelton pattern
45
* @return reference on the actual instance
46
*/
47
static PHEMCEPHandler& getHandlerInstance();
48
49
50
/** @brief Returns the CEP data for a PHEM emission class
51
* @param[in] emissionClass desired PHEM emission class
52
* @return CEP Data
53
*/
54
PHEMCEP* GetCep(SUMOEmissionClass emissionClass);
55
56
57
/** @brief Helper method to load CEP and vehicle files from file system
58
* @param[in] emissionClass desired PHEM emission class
59
* @return Indicator if loading was successul
60
*/
61
bool Load(SUMOEmissionClass emissionClass, const std::string& emissionClassIdentifier);
62
63
64
private:
65
/** @brief Helper method to read a vehicle file from file system
66
* @param[in] path The possible paths to PHEMlight data files
67
* @param[in] emissionClass desired PHEM emission class
68
* @param[in] vehicleMass out variable for vehicle mass
69
* @param[in] vehivleLoading out variable for vehicle loading
70
* @param[in] crossArea out variable for crosssectional area of vehicle
71
* @param[in] cwValue dout variable for cd value of vehivle
72
* @param[in] f0 out variable for rolling resistance coefficient f0
73
* @param[in] f1 out variable for rolling resistance coefficient f1
74
* @param[in] f2 out variable for rolling resistance coefficient f2
75
* @param[in] f3 out variable for rolling resistance coefficient f3
76
* @param[in] f4 out variable for rolling resistance coefficient f4
77
* @param[in] ratedPower out variable for rated power of vehicle
78
* @param[in] vehicleMassType out variable for mass tyepe of vehicle, light (LV) or heavy (HV)
79
* @param[in] vehicleFuelType out variable for fuel type (D, G) of vehicle, needed for density of fuel
80
* @param[in] pNormV0 out variable for step function to get maximum normalized rated power over speed
81
* @param[in] pNormP0 out variable for step function to get maximum normalized rated power over speed
82
* @param[in] pNormV1 out variable for step function to get maximum normalized rated power over speed
83
* @param[in] pNormP1 out variable for step function to get maximum normalized rated power over speed
84
* @param[in] matrixRotFactor out variable for rotational factors over speed for more accurate power calculation
85
* @return Indicator if reading was successul
86
*/
87
bool ReadVehicleFile(const std::vector<std::string>& path, const std::string& emissionClass,
88
double& vehicleMass,
89
double& vehicleLoading,
90
double& vehicleMassRot,
91
double& crossArea,
92
double& cWValue,
93
double& f0,
94
double& f1,
95
double& f2,
96
double& f3,
97
double& f4,
98
double& axleRatio,
99
double& ratedPower,
100
double& engineIdlingSpeed,
101
double& engineRatedSpeed,
102
double& effectiveWheelDiameter,
103
std::string& vehicleMassType,
104
std::string& vehicleFuelType,
105
double& pNormV0,
106
double& pNormP0,
107
double& pNormV1,
108
double& pNormP1,
109
std::vector< std::vector<double> >& matrixSpeedInertiaTable,
110
std::vector< std::vector<double> >& normedDragTable);
111
112
113
114
/** @brief Helper method to read a CEP file from file system
115
* @param[in] path The possible paths to PHEMlight data files
116
* @param[in] emissionClass desired PHEM emission class
117
* @param[in] header vector of pollutant identifiers
118
* @param[in] matrix matrix holding power pattern and CEP curves
119
* @return Indicator if reading was successul
120
*/
121
bool ReadEmissionData(bool readFC, const std::vector<std::string>& path, const std::string& emissionClass,
122
std::vector<std::string>& header, std::vector<std::vector<double> >& matrix, std::vector<double>& idlingValues);
123
124
125
private:
126
/// @brief bijection between PHEMEmissionClass and CEPs
127
std::map<SUMOEmissionClass, PHEMCEP*> _ceps;
128
// StringBijection<PHEMEmissionClass> _stringRepsPhemEmissionClass;
129
130
131
private:
132
/** @brief Implementation of Singelton pattern
133
* private (copy) constructor and =operator to avoid more than one instances
134
*/
135
PHEMCEPHandler();
136
PHEMCEPHandler(PHEMCEPHandler const&);
137
void operator=(PHEMCEPHandler const&);
138
139
};
140
141