33 CEP::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) {
80 std::vector<std::string> FCvaluesIdentifier;
81 std::vector<std::vector<double> > FCvaluesMeasures;
82 std::vector<std::vector<double> > normalizedFCvaluesMeasures;
83 for (
int i = 0; i < (int)headerLineFCvalues.size(); i++) {
84 FCvaluesIdentifier.push_back(headerLineFCvalues[i]);
85 FCvaluesMeasures.push_back(std::vector<double>());
86 normalizedFCvaluesMeasures.push_back(std::vector<double>());
90 std::vector<std::string> pollutantIdentifier;
91 std::vector<std::vector<double> > pollutantMeasures;
92 std::vector<std::vector<double> > normalizedPollutantMeasures;
93 for (
int i = 0; i < (int)headerLinePollutants.size(); i++) {
94 pollutantIdentifier.push_back(headerLinePollutants[i]);
95 pollutantMeasures.push_back(std::vector<double>());
96 normalizedPollutantMeasures.push_back(std::vector<double>());
101 for (
int i = 0; i < (int)
Vehicle->getTransmissionData()->getTransm()[
"Speed"].size(); i++) {
116 int headerFCCount = (int)headerLineFCvalues.size();
117 for (
int i = 0; i < (int)matrixFCvalues.size(); i++) {
118 for (
int j = 0; j < (int)matrixFCvalues[i].size(); j++) {
119 if ((
int)matrixFCvalues[i].size() != headerFCCount + 1) {
128 FCvaluesMeasures[j - 1].push_back(matrixFCvalues[i][j] *
getRatedPower());
129 normalizedFCvaluesMeasures[j - 1].push_back(matrixFCvalues[i][j]);
138 for (
int i = 0; i < (int)headerLineFCvalues.size(); i++) {
139 _cepCurveFCvalues.insert(std::make_pair(FCvaluesIdentifier[i], FCvaluesMeasures[i]));
145 double pollutantMultiplyer = 1;
162 int headerCount = (int)headerLinePollutants.size();
163 for (
int i = 0; i < (int)matrixPollutants.size(); i++) {
164 for (
int j = 0; j < (int)matrixPollutants[i].size(); j++) {
165 if ((
int)matrixPollutants[i].size() != headerCount + 1) {
174 pollutantMeasures[j - 1].push_back(matrixPollutants[i][j] * pollutantMultiplyer);
175 normalizedPollutantMeasures[j - 1].push_back(matrixPollutants[i][j]);
183 for (
int i = 0; i < (int)headerLinePollutants.size(); i++) {
186 _idlingValuesPollutants.insert(std::make_pair(pollutantIdentifier[i], idlingPollutants[i] * pollutantMultiplyer));
189 _FleetMix = std::map<std::string, double>();
298 std::vector<double> emissionCurve;
299 std::vector<double> powerPattern;
307 VehicleClass->
setErrMsg(std::string(
"Emission pollutant or fuel value ") + pollutant + std::string(
" not found!"));
320 VehicleClass->
setErrMsg(std::string(
"Emission pollutant or fuel value ") + pollutant + std::string(
" not found!"));
333 if (emissionCurve.empty()) {
334 VehicleClass->
setErrMsg(std::string(
"Empty emission curve for ") + pollutant + std::string(
" found!"));
337 if (emissionCurve.size() == 1) {
338 return emissionCurve[0];
342 if (power <= powerPattern.front()) {
343 return emissionCurve[0];
347 if (power >= powerPattern.back()) {
348 return emissionCurve.back();
352 return Interpolate(power, powerPattern[lowerIndex], powerPattern[upperIndex], emissionCurve[lowerIndex], emissionCurve[upperIndex]);
357 double fCBr, fCHC, fCCO, fCCO2;
370 if (!
CalcfCValMix(fCBr, fCHC, fCCO, fCCO2, VehicleClass)) {
375 return (_FC * fCBr - _CO * fCCO - _HC * fCHC) / fCCO2;
381 double sumfCBr, sumfCHC, sumfCCO, sumfCCO2;
390 for (std::map<std::string, double>::const_iterator
id =
_FleetMix.begin();
id !=
_FleetMix.end(); ++
id) {
396 VehicleClass->
setErrMsg(
"All propolsion types in the fleetshares file are not known!");
400 for (std::map<std::string, double>::const_iterator
id =
_FleetMix.begin();
id !=
_FleetMix.end(); ++
id) {
401 if (!
GetfcVals(id->first, _fCBr, _fCHC, _fCCO, _fCCO2, VehicleClass)) {
405 sumfCBr += _fCBr *
_FleetMix[
id->first] / Sum;
406 sumfCHC += _fCHC *
_FleetMix[
id->first] / Sum;
407 sumfCCO += _fCCO *
_FleetMix[
id->first] / Sum;
408 sumfCCO2 += _fCCO2 *
_FleetMix[
id->first] / Sum;
420 bool CEP::GetfcVals(
const std::string& _fuelTypex,
double& _fCBr,
double& _fCHC,
double& _fCCO,
double& _fCCO2,
Helpers* VehicleClass) {
446 VehicleClass->
setErrMsg(std::string(
"The propolsion type is not known! (") +
getFuelType() + std::string(
")"));
474 if (speed >= 10e-2) {
500 if (value <= pattern.front()) {
506 if (value >= pattern.back()) {
507 lowerIndex = (int)pattern.size() - 1;
508 upperIndex = (int)pattern.size() - 1;
513 int middleIndex = ((int)pattern.size() - 1) / 2;
514 upperIndex = (int)pattern.size() - 1;
517 while (upperIndex - lowerIndex > 1) {
518 if (pattern[middleIndex] == value) {
519 lowerIndex = middleIndex;
520 upperIndex = middleIndex;
523 else if (pattern[middleIndex] < value) {
524 lowerIndex = middleIndex;
525 middleIndex = (upperIndex - lowerIndex) / 2 + lowerIndex;
528 upperIndex = middleIndex;
529 middleIndex = (upperIndex - lowerIndex) / 2 + lowerIndex;
533 if (pattern[lowerIndex] <= value && value < pattern[upperIndex]) {
543 return e1 + (px - p1) / (p2 - p1) * (e2 - e1);
bool GetfcVals(const std::string &_fuelTypex, double &_fCBr, double &_fCHC, double &_fCCO, double &_fCCO2, Helpers *VehicleClass)
std::map< std::string, std::vector< double > > _normedCepCurveFCvalues
double GetRotationalCoeffecient(double speed)
const double & getRatedPower() const
void setNormalizingPower(const double &value)
eNormalizingType privateNormalizingType
double CalcPower(double speed, double acc, double gradient, bool HBEV)
double GetDecelCoast(double speed, double acc, double gradient)
std::vector< double > _normalizedPowerPatternFCvalues
const eNormalizingType & getNormalizingType() const
std::vector< double > _dragNormTable
std::vector< double > _speedCurveRotational
void setCalcType(const std::string &value)
std::vector< double > _normailzedPowerPatternPollutants
void InitializeInstanceFields()
double Interpolate(double px, double p1, double p2, double e1, double e2)
std::vector< double > _powerPatternPollutants
double CalcWheelPower(double speed, double acc, double gradient)
const bool & getHeavyVehicle() const
std::vector< double > _powerPatternFCvalues
void setRatedPower(const double &value)
@ eNormalizingType_RatedPower
@ eNormalizingType_DrivingPower
const std::string & getCalcType() const
std::map< std::string, double > _idlingValuesPollutants
double GetPMaxNorm(double speed)
std::vector< double > _speedPatternRotational
double GetMaxAccel(double speed, double gradient, bool HBEV)
std::vector< double > _gearTransmissionCurve
const std::string & getFuelType() const
void FindLowerUpperInPattern(int &lowerIndex, int &upperIndex, std::vector< double > &pattern, double value)
double privateDrivingPower
void setNormalizingType(const eNormalizingType &value)
double CalcEngPower(double power)
double privateNormalizingPower
double _engineIdlingSpeed
double GetCO2Emission(double _FC, double _CO, double _HC, Helpers *VehicleClass)
std::vector< double > _nNormTable
void setFuelType(const std::string &value)
std::map< std::string, std::vector< double > > _cepNormalizedCurvePollutants
double GetEmission(const std::string &pollutant, double power, double speed, Helpers *VehicleClass)
std::map< std::string, std::vector< double > > _cepCurveFCvalues
const double & getDrivingPower() const
double _crossSectionalArea
double _effectiveWheelDiameter
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)
void setDrivingPower(const double &value)
std::map< std::string, std::vector< double > > _cepCurvePollutants
bool CalcfCValMix(double &_fCBr, double &_fCHC, double &_fCCO, double &_fCCO2, Helpers *VehicleClass)
std::string privateCalcType
std::map< std::string, double > _idlingValueFCvalues
const double & getNormalizingPower() const
std::map< std::string, double > _FleetMix
std::string privateFuelType
static const std::string HeavyVehicle
static const double NORMALIZING_ACCELARATION
static const double NORMALIZING_SPEED
static const double & getDRIVE_TRAIN_EFFICIENCY()
static const std::string strLPG
static const std::string strCNG
static const double SPEED_DCEL_MIN
static const double ZERO_SPEED_ACCURACY
static const double AIR_DENSITY_CONST
static const std::string strGasoline
static const std::string strDiesel
static const double GRAVITY_CONST
static double _DRIVE_TRAIN_EFFICIENCY
void setErrMsg(const std::string &value)
C++ TraCI client API implementation.