Eclipse SUMO - Simulation of Urban MObility
V5/cpp/CEP.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2016-2024 German Aerospace Center (DLR) and others.
4 // PHEMlight module
5 // Copyright (C) 2016-2023 Technische Universitaet Graz, https://www.tugraz.at/
6 // This program and the accompanying materials are made available under the
7 // terms of the Eclipse Public License 2.0 which is available at
8 // https://www.eclipse.org/legal/epl-2.0/
9 // This Source Code may also be made available under the following Secondary
10 // Licenses when the conditions for such availability set forth in the Eclipse
11 // Public License 2.0 are satisfied: GNU General Public License, version 2
12 // or later which is available at
13 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
14 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
15 /****************************************************************************/
21 //
22 /****************************************************************************/
23 #pragma once
24 
25 #define _USE_MATH_DEFINES
26 #include <string>
27 #include <map>
28 #include <vector>
29 #include <cmath>
30 #include <utility>
31 #include "CEPHandler.h"
32 
33 //C# TO C++ CONVERTER NOTE: Forward class declarations:
34 namespace PHEMlightdllV5 { class VEHPHEMLightJSON; }
35 namespace PHEMlightdllV5 { class VEH; }
36 namespace PHEMlightdllV5 { class Helpers; }
37 
38 #define FLEET
39 
40 namespace PHEMlightdllV5 {
41  class CEP {
42  public:
46  };
47 
48  private:
50  std::string privateFuelType;
51  std::string privateCalcType;
53 
54  public:
55  CEP(VEHPHEMLightJSON::VEH* Vehicle, std::vector<std::string>& headerLineFCvalues, std::vector<std::vector<double> >& matrixFCvalues, std::vector<std::string>& headerLinePollutants, std::vector<std::vector<double> >& matrixPollutants, std::vector<double>& idlingFCvalues, std::vector<double>& idlingPollutants);
56 
57 
58  const bool& getHeavyVehicle() const;
59  const std::string& getFuelType() const;
60  void setFuelType(const std::string& value);
61  const std::string& getCalcType() const;
62  void setCalcType(const std::string& value);
63 
64  public:
65  const double& getRatedPower() const;
66  void setRatedPower(const double& value);
67  double getAuxPower() const {
68  return _auxPower * getRatedPower();
69  }
70  double getVehicleMass() const {
71  return _massVehicle;
72  }
73  double getVehicleLoading() const {
74  return _vehicleLoading;
75  }
76  double getVehicleMassRot() const {
77  return _vehicleMassRot;
78  }
79  double getCrossSectionalArea() const {
80  return _crossSectionalArea;
81  }
82  double getCWValue() const {
83  return _cWValue;
84  }
85  double getWheelRadius() const {
86  return _effectiveWheelDiameter / 2.;
87  }
88  double getResistanceF0() const {
89  return _resistanceF0;
90  }
91  double getResistance(const double speed, const double f0) const {
92  return f0 + _resistanceF1 * speed + _resistanceF2 * std::pow(speed, 2) + _resistanceF3 * std::pow(speed, 3) + _resistanceF4 * std::pow(speed, 4);
93  }
94  double getFMot(const double speed, const double ratedPower, const double wheelRadius);
95 
96  protected:
97  double _massVehicle;
101  double _cWValue;
107  double _axleRatio;
108  double _auxPower;
109  double _pNormV0;
110  double _pNormP0;
111  double _pNormV1;
112  double _pNormP1;
113 
117 
118  std::vector<double> _speedPatternRotational;
119  std::vector<double> _normalizedPowerPatternFCvalues;
121 
122  std::map<std::string, std::vector<double> > _normedCepCurveFCvalues;
123  std::vector<double> _gearTransmissionCurve;
124  std::vector<double> _speedCurveRotational;
125  std::map<std::string, std::vector<double> > _cepNormalizedCurvePollutants;
126  std::map<std::string, double> _FleetMix;
127  std::map<std::string, double> _idlingValueFCvalues;
128  std::map<std::string, double> _idlingValuesPollutants;
129 
130  std::vector<double> _nNormTable;
131  std::vector<double> _dragNormTable;
132 
133  public:
134  double CalcEngPower(double power, const double ratedPower);
135 
136  double GetEmission(const std::string& pollutant, double power, double speed, Helpers* VehicleClass, const double drivingPower, const double ratedPower);
137 
138  double GetCO2Emission(double _FC, double _CO, double _HC, Helpers* VehicleClass);
139 
140  //Calculate the weighted fuel factor values for Fleetmix
141  private:
142  bool CalcfCValMix(double& _fCBr, double& _fCHC, double& _fCCO, double& _fCCO2, Helpers* VehicleClass);
143 
144  // Get the fuel factor values
145  bool GetfcVals(const std::string& _fuelTypex, double& _fCBr, double& _fCHC, double& _fCCO, double& _fCCO2, Helpers* VehicleClass);
146 
147  public:
148  double GetRotationalCoeffecient(double speed);
149 
150 
151  private:
152  void FindLowerUpperInPattern(int& lowerIndex, int& upperIndex, const std::vector<double>& pattern, double value, double scale=1.);
153 
154  double Interpolate(double px, double p1, double p2, double e1, double e2);
155 
156  public:
157  double GetPMaxNorm(double speed);
158 
159  //--------------------------------------------------------------------------------------------------
160  // Operators for fleetmix
161  //--------------------------------------------------------------------------------------------------
162 
163 
164  private:
166  };
167 }
bool GetfcVals(const std::string &_fuelTypex, double &_fCBr, double &_fCHC, double &_fCCO, double &_fCCO2, Helpers *VehicleClass)
Definition: V5/cpp/CEP.cpp:338
double _vehicleMassRot
Definition: V5/cpp/CEP.h:99
void FindLowerUpperInPattern(int &lowerIndex, int &upperIndex, const std::vector< double > &pattern, double value, double scale=1.)
Definition: V5/cpp/CEP.cpp:399
double getWheelRadius() const
Definition: V5/cpp/CEP.h:85
double getVehicleMassRot() const
Definition: V5/cpp/CEP.h:76
std::map< std::string, std::vector< double > > _normedCepCurveFCvalues
Definition: V5/cpp/CEP.h:122
double GetRotationalCoeffecient(double speed)
Definition: V5/cpp/CEP.cpp:390
const double & getRatedPower() const
Definition: V5/cpp/CEP.cpp:188
double getCWValue() const
Definition: V5/cpp/CEP.h:82
std::vector< double > _normalizedPowerPatternFCvalues
Definition: V5/cpp/CEP.h:119
std::vector< double > _dragNormTable
Definition: V5/cpp/CEP.h:131
std::vector< double > _speedCurveRotational
Definition: V5/cpp/CEP.h:124
void setCalcType(const std::string &value)
Definition: V5/cpp/CEP.cpp:184
double getResistanceF0() const
Definition: V5/cpp/CEP.h:88
void InitializeInstanceFields()
Definition: V5/cpp/CEP.cpp:458
double getFMot(const double speed, const double ratedPower, const double wheelRadius)
Definition: V5/cpp/CEP.cpp:370
double getVehicleLoading() const
Definition: V5/cpp/CEP.h:73
double Interpolate(double px, double p1, double p2, double e1, double e2)
Definition: V5/cpp/CEP.cpp:437
double getResistance(const double speed, const double f0) const
Definition: V5/cpp/CEP.h:91
double getCrossSectionalArea() const
Definition: V5/cpp/CEP.h:79
const bool & getHeavyVehicle() const
Definition: V5/cpp/CEP.cpp:168
void setRatedPower(const double &value)
Definition: V5/cpp/CEP.cpp:192
const std::string & getCalcType() const
Definition: V5/cpp/CEP.cpp:180
std::map< std::string, double > _idlingValuesPollutants
Definition: V5/cpp/CEP.h:128
double GetPMaxNorm(double speed)
Definition: V5/cpp/CEP.cpp:445
double getVehicleMass() const
Definition: V5/cpp/CEP.h:70
std::vector< double > _speedPatternRotational
Definition: V5/cpp/CEP.h:118
std::vector< double > _gearTransmissionCurve
Definition: V5/cpp/CEP.h:123
const std::string & getFuelType() const
Definition: V5/cpp/CEP.cpp:172
double _engineRatedSpeed
Definition: V5/cpp/CEP.h:114
double getAuxPower() const
Definition: V5/cpp/CEP.h:67
double _vehicleLoading
Definition: V5/cpp/CEP.h:98
double GetEmission(const std::string &pollutant, double power, double speed, Helpers *VehicleClass, const double drivingPower, const double ratedPower)
Definition: V5/cpp/CEP.cpp:207
double _engineIdlingSpeed
Definition: V5/cpp/CEP.h:115
double GetCO2Emission(double _FC, double _CO, double _HC, Helpers *VehicleClass)
Definition: V5/cpp/CEP.cpp:273
std::vector< double > _nNormTable
Definition: V5/cpp/CEP.h:130
void setFuelType(const std::string &value)
Definition: V5/cpp/CEP.cpp:176
std::map< std::string, std::vector< double > > _cepNormalizedCurvePollutants
Definition: V5/cpp/CEP.h:125
double _crossSectionalArea
Definition: V5/cpp/CEP.h:100
double _effectiveWheelDiameter
Definition: V5/cpp/CEP.h:116
double CalcEngPower(double power, const double ratedPower)
Definition: V5/cpp/CEP.cpp:196
double privateRatedPower
Definition: V5/cpp/CEP.h:52
CEP(VEHPHEMLightJSON::VEH *Vehicle, std::vector< std::string > &headerLineFCvalues, std::vector< std::vector< double > > &matrixFCvalues, std::vector< std::string > &headerLinePollutants, std::vector< std::vector< double > > &matrixPollutants, std::vector< double > &idlingFCvalues, std::vector< double > &idlingPollutants)
Definition: V5/cpp/CEP.cpp:33
bool CalcfCValMix(double &_fCBr, double &_fCHC, double &_fCCO, double &_fCCO2, Helpers *VehicleClass)
Definition: V5/cpp/CEP.cpp:296
std::vector< double > _normalizedPowerPatternPollutants
Definition: V5/cpp/CEP.h:120
std::string privateCalcType
Definition: V5/cpp/CEP.h:51
std::map< std::string, double > _idlingValueFCvalues
Definition: V5/cpp/CEP.h:127
std::map< std::string, double > _FleetMix
Definition: V5/cpp/CEP.h:126
std::string privateFuelType
Definition: V5/cpp/CEP.h:50
C++ TraCI client API implementation.
Definition: Vehicle.h:34