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.org/sumo
3 // Copyright (C) 2016-2022 German Aerospace Center (DLR) and others.
4 // PHEMlight module
5 // Copyright (C) 2016-2022 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;
56 
57  public:
58  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);
59 
60 
61  const bool& getHeavyVehicle() const;
62  const std::string& getFuelType() const;
63  void setFuelType(const std::string& value);
64  const std::string& getCalcType() const;
65  void setCalcType(const std::string& value);
66 
67  public:
68  const eNormalizingType& getNormalizingType() const;
69  void setNormalizingType(const eNormalizingType& value);
70 
71  const double& getRatedPower() const;
72  void setRatedPower(const double& value);
73  const double& getNormalizingPower() const;
74  void setNormalizingPower(const double& value);
75  const double& getDrivingPower() const;
76  void setDrivingPower(const double& value);
77  double getAuxPower() const {
78  return _auxPower * getRatedPower();
79  }
80 
81  protected:
82  double _massVehicle;
86  double _cWValue;
87  double _resistanceF0;
88  double _resistanceF1;
89  double _resistanceF2;
90  double _resistanceF3;
91  double _resistanceF4;
92  double _axleRatio;
93  double _auxPower;
94  double _pNormV0;
95  double _pNormP0;
96  double _pNormV1;
97  double _pNormP1;
98 
102 
103  std::vector<double> _speedPatternRotational;
104  std::vector<double> _powerPatternFCvalues;
105  std::vector<double> _normalizedPowerPatternFCvalues;
107  std::vector<double> _powerPatternPollutants;
108 
109  std::map<std::string, std::vector<double> > _cepCurveFCvalues;
110  std::map<std::string, std::vector<double> > _normedCepCurveFCvalues;
111  std::vector<double> _gearTransmissionCurve;
112  std::vector<double> _speedCurveRotational;
113  std::map<std::string, std::vector<double> > _cepCurvePollutants;
114  std::map<std::string, std::vector<double> > _cepNormalizedCurvePollutants;
115  std::map<std::string, double> _FleetMix;
116  std::map<std::string, double> _idlingValueFCvalues;
117  std::map<std::string, double> _idlingValuesPollutants;
118 
119  std::vector<double> _nNormTable;
120  std::vector<double> _dragNormTable;
121 
122  public:
123  double CalcPower(double speed, double acc, double gradient, bool HBEV);
124 
125  double CalcWheelPower(double speed, double acc, double gradient);
126 
127  double CalcEngPower(double power);
128 
129  double GetEmission(const std::string& pollutant, double power, double speed, Helpers* VehicleClass);
130 
131  double GetCO2Emission(double _FC, double _CO, double _HC, Helpers* VehicleClass);
132 
133  //Calculate the weighted fuel factor values for Fleetmix
134  private:
135  bool CalcfCValMix(double& _fCBr, double& _fCHC, double& _fCCO, double& _fCCO2, Helpers* VehicleClass);
136 
137  // Get the fuel factor values
138  bool GetfcVals(const std::string& _fuelTypex, double& _fCBr, double& _fCHC, double& _fCCO, double& _fCCO2, Helpers* VehicleClass);
139 
140  public:
141  double GetDecelCoast(double speed, double acc, double gradient);
142 
143  double GetRotationalCoeffecient(double speed);
144 
145 
146  private:
147  void FindLowerUpperInPattern(int& lowerIndex, int& upperIndex, std::vector<double>& pattern, double value);
148 
149  double Interpolate(double px, double p1, double p2, double e1, double e2);
150 
151  public:
152  double GetMaxAccel(double speed, double gradient, bool HBEV);
153 
154  private:
155  double GetPMaxNorm(double speed);
156 
157  //--------------------------------------------------------------------------------------------------
158  // Operators for fleetmix
159  //--------------------------------------------------------------------------------------------------
160 
161 
162  private:
164  };
165 }
166 
bool GetfcVals(const std::string &_fuelTypex, double &_fCBr, double &_fCHC, double &_fCCO, double &_fCCO2, Helpers *VehicleClass)
Definition: V5/cpp/CEP.cpp:420
double _vehicleMassRot
Definition: V5/cpp/CEP.h:84
std::map< std::string, std::vector< double > > _normedCepCurveFCvalues
Definition: V5/cpp/CEP.h:110
double GetRotationalCoeffecient(double speed)
Definition: V5/cpp/CEP.cpp:487
const double & getRatedPower() const
Definition: V5/cpp/CEP.cpp:224
void setNormalizingPower(const double &value)
Definition: V5/cpp/CEP.cpp:236
eNormalizingType privateNormalizingType
Definition: V5/cpp/CEP.h:52
double CalcPower(double speed, double acc, double gradient, bool HBEV)
Definition: V5/cpp/CEP.cpp:248
double GetDecelCoast(double speed, double acc, double gradient)
Definition: V5/cpp/CEP.cpp:452
std::vector< double > _normalizedPowerPatternFCvalues
Definition: V5/cpp/CEP.h:105
const eNormalizingType & getNormalizingType() const
Definition: V5/cpp/CEP.cpp:216
std::vector< double > _dragNormTable
Definition: V5/cpp/CEP.h:120
std::vector< double > _speedCurveRotational
Definition: V5/cpp/CEP.h:112
void setCalcType(const std::string &value)
Definition: V5/cpp/CEP.cpp:212
std::vector< double > _normailzedPowerPatternPollutants
Definition: V5/cpp/CEP.h:106
void InitializeInstanceFields()
Definition: V5/cpp/CEP.cpp:566
double Interpolate(double px, double p1, double p2, double e1, double e2)
Definition: V5/cpp/CEP.cpp:538
std::vector< double > _powerPatternPollutants
Definition: V5/cpp/CEP.h:107
double CalcWheelPower(double speed, double acc, double gradient)
Definition: V5/cpp/CEP.cpp:269
const bool & getHeavyVehicle() const
Definition: V5/cpp/CEP.cpp:196
std::vector< double > _powerPatternFCvalues
Definition: V5/cpp/CEP.h:104
void setRatedPower(const double &value)
Definition: V5/cpp/CEP.cpp:228
const std::string & getCalcType() const
Definition: V5/cpp/CEP.cpp:208
std::map< std::string, double > _idlingValuesPollutants
Definition: V5/cpp/CEP.h:117
double GetPMaxNorm(double speed)
Definition: V5/cpp/CEP.cpp:553
std::vector< double > _speedPatternRotational
Definition: V5/cpp/CEP.h:103
double GetMaxAccel(double speed, double gradient, bool HBEV)
Definition: V5/cpp/CEP.cpp:546
std::vector< double > _gearTransmissionCurve
Definition: V5/cpp/CEP.h:111
const std::string & getFuelType() const
Definition: V5/cpp/CEP.cpp:200
double _engineRatedSpeed
Definition: V5/cpp/CEP.h:99
double getAuxPower() const
Definition: V5/cpp/CEP.h:77
double _vehicleLoading
Definition: V5/cpp/CEP.h:83
void FindLowerUpperInPattern(int &lowerIndex, int &upperIndex, std::vector< double > &pattern, double value)
Definition: V5/cpp/CEP.cpp:496
double privateDrivingPower
Definition: V5/cpp/CEP.h:55
void setNormalizingType(const eNormalizingType &value)
Definition: V5/cpp/CEP.cpp:220
double CalcEngPower(double power)
Definition: V5/cpp/CEP.cpp:285
double privateNormalizingPower
Definition: V5/cpp/CEP.h:54
double _engineIdlingSpeed
Definition: V5/cpp/CEP.h:100
double GetCO2Emission(double _FC, double _CO, double _HC, Helpers *VehicleClass)
Definition: V5/cpp/CEP.cpp:355
std::vector< double > _nNormTable
Definition: V5/cpp/CEP.h:119
void setFuelType(const std::string &value)
Definition: V5/cpp/CEP.cpp:204
std::map< std::string, std::vector< double > > _cepNormalizedCurvePollutants
Definition: V5/cpp/CEP.h:114
double GetEmission(const std::string &pollutant, double power, double speed, Helpers *VehicleClass)
Definition: V5/cpp/CEP.cpp:296
std::map< std::string, std::vector< double > > _cepCurveFCvalues
Definition: V5/cpp/CEP.h:109
const double & getDrivingPower() const
Definition: V5/cpp/CEP.cpp:240
double _crossSectionalArea
Definition: V5/cpp/CEP.h:85
double _effectiveWheelDiameter
Definition: V5/cpp/CEP.h:101
double privateRatedPower
Definition: V5/cpp/CEP.h:53
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
void setDrivingPower(const double &value)
Definition: V5/cpp/CEP.cpp:244
std::map< std::string, std::vector< double > > _cepCurvePollutants
Definition: V5/cpp/CEP.h:113
bool CalcfCValMix(double &_fCBr, double &_fCHC, double &_fCCO, double &_fCCO2, Helpers *VehicleClass)
Definition: V5/cpp/CEP.cpp:378
std::string privateCalcType
Definition: V5/cpp/CEP.h:51
std::map< std::string, double > _idlingValueFCvalues
Definition: V5/cpp/CEP.h:116
const double & getNormalizingPower() const
Definition: V5/cpp/CEP.cpp:232
std::map< std::string, double > _FleetMix
Definition: V5/cpp/CEP.h:115
std::string privateFuelType
Definition: V5/cpp/CEP.h:50
C++ TraCI client API implementation.
Definition: Vehicle.h:34