1 /****************************************************************************/ 2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo 3 // Copyright (C) 2016-2019 German Aerospace Center (DLR) and others. 4 // PHEMlight module 5 // Copyright (C) 2016-2017 Technische Universitaet Graz, https://www.tugraz.at/ 6 // This program and the accompanying materials 7 // are made available under the terms of the Eclipse Public License v2.0 8 // which accompanies this distribution, and is available at 9 // http://www.eclipse.org/legal/epl-v20.html 10 // SPDX-License-Identifier: EPL-2.0 11 /****************************************************************************/ 12 /// @file CEP.h 13 /// @author Martin Dippold 14 /// @author Michael Behrisch 15 /// @date July 2016 16 /// @version $Id$ 17 /// 18 // 19 /****************************************************************************/ 20 21 22 #ifndef PHEMlightCEP 23 #define PHEMlightCEP 24 25 #define _USE_MATH_DEFINES 26 #include <string> 27 #include <map> 28 #include <vector> 29 #include <cmath> 30 #include <utility> 31 32 //C# TO C++ CONVERTER NOTE: Forward class declarations: 33 namespace PHEMlightdll { class Helpers; } 34 35 36 namespace PHEMlightdll { 37 class CEP { 38 //-------------------------------------------------------------------------------------------------- 39 // Constructors 40 //-------------------------------------------------------------------------------------------------- 41 42 public: 43 CEP(bool heavyVehicle, double vehicleMass, double vehicleLoading, double vehicleMassRot, double crossArea, double cWValue, double f0, double f1, double f2, double f3, double f4, double axleRatio, std::vector<double>& transmissionGearRatios, double auxPower, double ratedPower, double engineIdlingSpeed, double engineRatedSpeed, double effictiveWheelDiameter, double pNormV0, double pNormP0, double pNormV1, double pNormP1, const std::string& vehicelFuelType, std::vector<std::vector<double> >& matrixFC, std::vector<std::string>& headerLinePollutants, std::vector<std::vector<double> >& matrixPollutants, std::vector<std::vector<double> >& matrixSpeedRotational, std::vector<std::vector<double> >& normedDragTable, double idlingFC, std::vector<double>& idlingPollutants); 44 45 46 //-------------------------------------------------------------------------------------------------- 47 // Members 48 //-------------------------------------------------------------------------------------------------- 49 50 private: 51 bool _heavyVehicle; 52 public: 53 const bool& getHeavyVehicle() const; 54 55 private: 56 std::string _fuelType; 57 public: 58 const std::string& getFuelType() const; 59 60 public: 61 enum NormalizingType { 62 NormalizingType_RatedPower, 63 NormalizingType_DrivingPower 64 }; 65 private: 66 NormalizingType _normalizingType; 67 public: 68 const NormalizingType& getNormalizingTypeX() const; 69 70 private: 71 double _ratedPower; 72 public: 73 const double& getRatedPower() const; 74 void setRatedPower(const double& value); 75 76 private: 77 double _normalizingPower; 78 public: 79 const double& getNormalizingPower() const; 80 81 private: 82 double _drivingPower; 83 public: 84 const double& getDrivingPower() const; 85 void setDrivingPower(const double& value); 86 87 88 89 protected: 90 double _massVehicle; 91 double _vehicleLoading; 92 double _vehicleMassRot; 93 double _crossSectionalArea; 94 double _cWValue; 95 double _resistanceF0; 96 double _resistanceF1; 97 double _resistanceF2; 98 double _resistanceF3; 99 double _resistanceF4; 100 double _axleRatio; 101 double _auxPower; 102 double _pNormV0; 103 double _pNormP0; 104 double _pNormV1; 105 double _pNormP1; 106 107 double _engineRatedSpeed; 108 double _engineIdlingSpeed; 109 double _effectiveWheelDiameter; 110 111 std::vector<double> _speedPatternRotational; 112 std::vector<double> _powerPatternFC; 113 std::vector<double> _normalizedPowerPatternFC; 114 std::vector<double> _normailzedPowerPatternPollutants; 115 std::vector<double> _powerPatternPollutants; 116 117 std::vector<double> _cepCurveFC; 118 std::vector<double> _normedCepCurveFC; 119 std::vector<double> _gearTransmissionCurve; 120 std::vector<double> _speedCurveRotational; 121 std::map<std::string, std::vector<double> > _cepCurvePollutants; 122 std::map<std::string, std::vector<double> > _cepNormalizedCurvePollutants; 123 double _idlingValueFC; 124 std::map<std::string, double> _idlingValuesPollutants; 125 126 std::vector<double> _nNormTable; 127 std::vector<double> _dragNormTable; 128 129 130 //-------------------------------------------------------------------------------------------------- 131 // Methods 132 //-------------------------------------------------------------------------------------------------- 133 134 public: 135 double CalcPower(double speed, double acc, double gradient); 136 137 double CalcEngPower(double power); 138 139 double GetEmission(const std::string& pollutant, double power, double speed, Helpers* VehicleClass); 140 141 142 double GetCO2Emission(double _FC, double _CO, double _HC, Helpers* VehicleClass); 143 144 double GetDecelCoast(double speed, double acc, double gradient); 145 146 double GetRotationalCoeffecient(double speed); 147 148 149 private: 150 void FindLowerUpperInPattern(int& lowerIndex, int& upperIndex, std::vector<double>& pattern, double value); 151 152 double Interpolate(double px, double p1, double p2, double e1, double e2); 153 154 public: 155 double GetMaxAccel(double speed, double gradient); 156 157 private: 158 double GetPMaxNorm(double speed); 159 160 //-------------------------------------------------------------------------------------------------- 161 // Operators for fleetmix 162 //-------------------------------------------------------------------------------------------------- 163 164 165 private: 166 void InitializeInstanceFields(); 167 }; 168 } 169 170 171 #endif //#ifndef PHEMlightCEP 172