3 using System.Collections.Generic;
6 using System.Threading.Tasks;
17 public CEP(
bool heavyVehicle,
19 double vehicleLoading,
20 double vehicleMassRot,
29 List<double> transmissionGearRatios,
32 double engineIdlingSpeed,
33 double engineRatedSpeed,
34 double effictiveWheelDiameter,
39 string vehicelFuelType,
40 List<List<double>> matrixFC,
41 List<string> headerLinePollutants,
42 List<List<double>> matrixPollutants,
43 List<List<double>> matrixSpeedRotational,
44 List<List<double>> normedDragTable,
46 List<double> idlingPollutants)
72 List<string> pollutantIdentifier =
new List<string>();
73 List<List<double>> pollutantMeasures =
new List<List<double>>();
74 List<List<double>> normalizedPollutantMeasures =
new List<List<double>>();
77 for (
int i = 0; i < headerLinePollutants.Count; i++)
79 pollutantIdentifier.Add(headerLinePollutants[i]);
83 for (
int i = 0; i < headerLinePollutants.Count; i++)
85 pollutantMeasures.Add(
new List<double>());
86 normalizedPollutantMeasures.Add(
new List<double>());
93 for (
int i = 0; i < matrixSpeedRotational.Count; i++)
95 if (matrixSpeedRotational[i].Count != 3)
98 _speedPatternRotational.Add(matrixSpeedRotational[i][0] / 3.6);
99 _gearTransmissionCurve.Add(matrixSpeedRotational[i][1]);
106 for (
int i = 0; i < normedDragTable.Count; i++)
108 if (normedDragTable[i].Count != 2)
112 _dragNormTable.Add(normedDragTable[i][1]);
120 for (
int i = 0; i < matrixFC.Count; i++)
122 if (matrixFC[i].Count != 2)
126 _normalizedPowerPatternFC.Add(matrixFC[i][0]);
128 _normedCepCurveFC.Add(matrixFC[i][1]);
134 double pollutantMultiplyer = 1;
155 int headerCount = headerLinePollutants.Count;
156 for (
int i = 0; i < matrixPollutants.Count; i++)
158 for (
int j = 0; j < matrixPollutants[i].Count; j++)
160 if (matrixPollutants[i].Count != headerCount + 1)
170 pollutantMeasures[j - 1].Add(matrixPollutants[i][j] * pollutantMultiplyer);
171 normalizedPollutantMeasures[j - 1].Add(matrixPollutants[i][j]);
179 for (
int i = 0; i < headerLinePollutants.Count; i++)
182 _cepNormalizedCurvePollutants.Add(pollutantIdentifier[i], normalizedPollutantMeasures[i]);
183 _idlingValuesPollutants.Add(pollutantIdentifier[i], idlingPollutants[i] * pollutantMultiplyer);
191 #region ConstrutorForFleetmix 192 private CEP(
bool heavyVehicle,
194 double vehicleLoading,
195 double vehicleMassRot,
206 double engineIdlingSpeed,
207 double engineRatedSpeed,
208 double effictiveWheelDiameter,
269 #region NormalizingType 300 #region NormalizingPower 321 _drivingPower = value;
327 #region Private Members 375 public double CalcPower(
double speed,
double acc,
double gradient)
385 power += (_massVehicle * rotFactor + _vehicleMassRot +
_vehicleLoading) * acc * speed;
399 if (power < _powerPatternFC.First())
return _powerPatternFC.First();
400 if (power > _powerPatternFC.Last())
return _powerPatternFC.Last();
410 List<double> emissionCurve;
411 List<double> powerPattern;
421 if (pollutant ==
"FC")
427 if (!_cepCurvePollutants.ContainsKey(pollutant))
429 VehicleClass.
ErrMsg =
"Emission pollutant " + pollutant +
" not found!";
433 return _idlingValuesPollutants[pollutant];
438 if (pollutant ==
"FC")
445 if (!_cepCurvePollutants.ContainsKey(pollutant))
447 VehicleClass.
ErrMsg =
"Emission pollutant " + pollutant +
" not found!";
451 emissionCurve = _cepCurvePollutants[pollutant];
455 if (emissionCurve.Count == 0)
457 VehicleClass.
ErrMsg =
"Empty emission curve for " + pollutant +
" found!";
460 if (emissionCurve.Count == 1)
462 return emissionCurve[0];
466 if (power <= powerPattern.First())
468 return emissionCurve[0];
472 if (power >= powerPattern.Last())
474 return emissionCurve.Last();
478 return Interpolate(power, powerPattern[lowerIndex], powerPattern[upperIndex], emissionCurve[lowerIndex], emissionCurve[upperIndex]);
483 #region GetNormedEmission 487 List<double> emissionCurve;
488 List<double> powerPattern;
494 if (pollutant ==
"FC")
501 if (!_cepCurvePollutants.ContainsKey(pollutant))
503 VehicleClass.
ErrMsg =
"Emission pollutant " + pollutant +
" not found!";
506 emissionCurve = _cepNormalizedCurvePollutants[pollutant];
510 if (emissionCurve.Count == 0)
512 VehicleClass.
ErrMsg =
"Empty emission curve for " + pollutant +
" found!";
515 if (emissionCurve.Count == 1)
517 return emissionCurve[0];
520 if (power <= powerPattern.First())
522 return emissionCurve[0];
526 if (power >= powerPattern.Last())
528 return emissionCurve.Last();
532 return Interpolate(power, powerPattern[lowerIndex], powerPattern[upperIndex], emissionCurve[lowerIndex], emissionCurve[upperIndex]);
537 #region GetCO2Emission 544 double fCCO2 = 0.273;
563 VehicleClass.
ErrMsg =
"The propolsion type is not known! (" + _fuelType +
")";
567 return (_FC * fCBr - _CO * fCCO - _HC * fCHC) / fCCO2;
571 #region GetDecelCoast 586 _speedPatternRotational[lowerIndex],
587 _speedPatternRotational[upperIndex],
588 _gearTransmissionCurve[lowerIndex],
589 _gearTransmissionCurve[upperIndex]);
593 double n = (30 * speed * iTot) / ((_effectiveWheelDiameter / 2) * Math.PI);
603 _nNormTable[lowerIndex],
604 _nNormTable[upperIndex],
605 _dragNormTable[lowerIndex],
606 _dragNormTable[upperIndex]) * _ratedPower * 1000 / speed) / 0.9;
609 double fRoll = (_resistanceF0
610 + _resistanceF1 * speed
611 + Math.Pow(_resistanceF2 * speed, 2)
612 + Math.Pow(_resistanceF3 * speed, 3)
615 double fAir = _cWValue * _crossSectionalArea * 1.2 * 0.5 * Math.Pow(speed, 2);
619 return -(fMot + fRoll + fAir + fGrad) / ((_massVehicle +
_vehicleLoading) * rotCoeff);
623 #region GetRotationalCoeffecient 632 _speedPatternRotational[lowerIndex],
633 _speedPatternRotational[upperIndex],
634 _speedCurveRotational[lowerIndex],
635 _speedCurveRotational[upperIndex]);
640 #region GetGearCoeffecient 649 _speedPatternRotational[lowerIndex],
650 _speedPatternRotational[upperIndex],
651 _gearTransmissionCurve[lowerIndex],
652 _gearTransmissionCurve[upperIndex]);
656 #region GetDragCoeffecient 665 _nNormTable[lowerIndex],
666 _nNormTable[upperIndex],
667 _dragNormTable[lowerIndex],
668 _dragNormTable[upperIndex]);
673 #region FindLowerUpperInPattern 679 if (value <= pattern.First())
686 if (value >= pattern.Last())
688 lowerIndex = pattern.Count - 1;
689 upperIndex = pattern.Count - 1;
694 int middleIndex = (pattern.Count - 1) / 2;
695 upperIndex = pattern.Count - 1;
698 while (upperIndex - lowerIndex > 1)
700 if (pattern[middleIndex] == value)
702 lowerIndex = middleIndex;
703 upperIndex = middleIndex;
706 else if (pattern[middleIndex] < value)
708 lowerIndex = middleIndex;
709 middleIndex = (upperIndex - lowerIndex) / 2 + lowerIndex;
713 upperIndex = middleIndex;
714 middleIndex = (upperIndex - lowerIndex) / 2 + lowerIndex;
718 if (pattern[lowerIndex] <= value && value < pattern[upperIndex])
726 private double Interpolate(
double px,
double p1,
double p2,
double e1,
double e2)
731 return e1 + (px - p1) / (p2 - p1) * (e2 - e1);
741 return (pMaxForAcc * 1000) / ((_massVehicle * rotFactor + _vehicleMassRot +
_vehicleLoading) * speed);
749 if (speed <= _pNormV0)
751 else if (speed >= _pNormV1)
755 return Interpolate(speed, _pNormV0, _pNormV1, _pNormP0, _pNormP1);
769 CEP newCEP =
new CEP(cps.Select(p => p.HeavyVehicle ? 1 : 0).Sum() > 0,
770 cps.Select(p => p._massVehicle).Sum(),
771 cps.Select(p => p._vehicleLoading).Sum(),
772 cps.Select(p => p._vehicleMassRot).Sum(),
773 cps.Select(p => p._crossSectionalArea).Sum(),
774 cps.Select(p => p._cWValue).Sum(),
775 cps.Select(p => p._resistanceF0).Sum(),
776 cps.Select(p => p._resistanceF1).Sum(),
777 cps.Select(p => p._resistanceF2).Sum(),
778 cps.Select(p => p._resistanceF3).Sum(),
779 cps.Select(p => p._resistanceF4).Sum(),
780 cps.Select(p => p._axleRatio).Sum(),
781 cps.Select(p => p._auxPower).Sum(),
782 cps.Select(p => p._ratedPower).Sum(),
783 cps.Select(p => p._engineIdlingSpeed).Sum(),
784 cps.Select(p => p._engineRatedSpeed).Sum(),
785 cps.Select(p => p._effectiveWheelDiameter).Sum(),
786 cps.Select(p => p._pNormV0).Sum(),
787 cps.Select(p => p._pNormP0).Sum(),
788 cps.Select(p => p._pNormV1).Sum(),
789 cps.Select(p => p._pNormP1).Sum());
791 newCEP._fuelType = cps.First().FuelType;
794 #region SpeedRotationalTable 795 double minSpeedRotational = cps.Select(p => p._speedPatternRotational.First()).
Min();
796 double maxSpeedRotational = cps.Select(p => p._speedPatternRotational.Last()).
Max();
798 newCEP._speedPatternRotational
803 newCEP._speedCurveRotational =
new List<double>();
804 newCEP._gearTransmissionCurve =
new List<double>();
806 for (
int i = 0; i < newCEP._speedPatternRotational.Count; i++)
808 newCEP._speedCurveRotational.Add(cps.Select(p => p.GetRotationalCoeffecient(newCEP._speedPatternRotational[i])).Sum());
810 newCEP._gearTransmissionCurve.Add(cps.Select(p => p.GetGearCoeffecient(newCEP._speedPatternRotational[i])).Sum());
814 #region NormalizingPower 817 if (newCEP._heavyVehicle)
819 newCEP._normalizingPower = newCEP._ratedPower;
824 newCEP._normalizingPower = newCEP._drivingPower;
830 double minNormPowerPatternFC = cps.Select(p => p._normalizedPowerPatternFC.First()).
Min();
831 double maxNormPowerPatternFC = cps.Select(p => p._normalizedPowerPatternFC.Last()).
Max();
833 newCEP._normalizedPowerPatternFC
835 maxNormPowerPatternFC,
838 newCEP._cepCurveFC =
new List<double>();
839 newCEP._normedCepCurveFC =
new List<double>();
840 newCEP._powerPatternFC =
new List<double>();
842 for (
int i = 0; i < newCEP._normalizedPowerPatternFC.Count; i++)
844 double newCepVal = cps.Select(p => p.GetNormedEmission(
"FC", newCEP._normalizedPowerPatternFC[i],
double.MaxValue, Helper)).Sum();
845 newCEP._cepCurveFC.Add(newCepVal * newCEP._ratedPower);
846 newCEP._normedCepCurveFC.Add(newCepVal);
847 newCEP._powerPatternFC.Add(newCEP._normalizedPowerPatternFC[i] * newCEP._ratedPower);
852 double minNormPowerPattern = cps.Select(p => p._normailzedPowerPatternPollutants.First()).
Min();
853 double maxNormPowerPattern = cps.Select(p => p._normailzedPowerPatternPollutants.Last()).
Max();
855 newCEP._normailzedPowerPatternPollutants
860 newCEP._cepCurvePollutants =
new Dictionary<string, List<double>>();
861 newCEP._powerPatternPollutants =
new List<double>();
862 newCEP._cepNormalizedCurvePollutants =
new Dictionary<string, List<double>>();
864 foreach (
string id in cps.First()._cepCurvePollutants.Keys)
866 newCEP._cepCurvePollutants.Add(
id,
new List<double>());
867 newCEP._cepNormalizedCurvePollutants.Add(
id,
new List<double>());
870 for (
int i = 0; i < newCEP._normailzedPowerPatternPollutants.Count; i++)
872 foreach (
string id in newCEP._cepCurvePollutants.Keys)
876 double newCepVal = cps.Select(p => p.GetNormedEmission(
id, newCEP._normailzedPowerPatternPollutants[i],
double.MaxValue, Helper)).Sum();
877 newCEP._cepCurvePollutants[id].Add(newCepVal * newCEP._ratedPower);
878 newCEP._cepNormalizedCurvePollutants[id].Add(newCepVal);
882 newCEP._cepCurvePollutants[id].Add(cps.Select(p => p.GetEmission(
id, newCEP._normailzedPowerPatternPollutants[i] * p._normalizingPower,
double.MaxValue, Helper)).Sum());
883 newCEP._cepNormalizedCurvePollutants[id].Add(cps.Select(p => p.GetNormedEmission(
id, newCEP._normailzedPowerPatternPollutants[i],
double.MaxValue, Helper)).Sum());
886 newCEP._powerPatternPollutants.Add(newCEP._normailzedPowerPatternPollutants[i] * newCEP.NormalizingPower);
891 newCEP._idlingValueFC = cps.Select(p => p._idlingValueFC).Sum();
892 newCEP._idlingValuesPollutants =
new Dictionary<string, double>();
894 foreach (
string id in cps.First()._idlingValuesPollutants.Keys)
896 newCEP._idlingValuesPollutants.Add(
id, cps.Select(p => p._idlingValuesPollutants[
id]).Sum());
901 double minTragTable = cps.Select(p => p._nNormTable.First()).
Min();
902 double maxTragTable = cps.Select(p => p._nNormTable.Last()).
Max();
909 newCEP._dragNormTable =
new List<double>();
911 for (
int i = 0; i < newCEP._nNormTable.Count; i++)
913 newCEP._dragNormTable.Add(cps.Select(p => p.GetDragCoeffecient(newCEP._nNormTable[i])).Sum());
924 CEP newCEP =
new CEP(cp1.HeavyVehicle,
925 d * cp1._massVehicle,
926 d * cp1._vehicleLoading,
927 d * cp1._vehicleMassRot,
928 d * cp1._crossSectionalArea,
930 d * cp1._resistanceF0,
931 d * cp1._resistanceF1,
932 d * cp1._resistanceF2,
933 d * cp1._resistanceF3,
934 d * cp1._resistanceF4,
938 d * cp1._engineIdlingSpeed,
939 d * cp1._engineRatedSpeed,
940 d * cp1._effectiveWheelDiameter,
946 newCEP._fuelType = cp1.FuelType;
949 #region SpeedRotationalTable 950 newCEP._speedPatternRotational =
new List<double>(cp1._speedPatternRotational);
951 newCEP._speedCurveRotational =
new List<double>(cp1._speedCurveRotational.Select(p => p * d));
952 newCEP._gearTransmissionCurve =
new List<double>(cp1._gearTransmissionCurve.Select(p => p * d));
955 #region NormalizingPower 958 if (newCEP._heavyVehicle)
960 newCEP._normalizingPower = newCEP._ratedPower;
965 newCEP._normalizingPower = newCEP._drivingPower;
971 newCEP._powerPatternFC =
new List<double>(cp1._powerPatternFC.Select(p => p * d));
972 newCEP._normalizedPowerPatternFC =
new List<double>(cp1._normalizedPowerPatternFC);
973 newCEP._cepCurveFC =
new List<double>(cp1._cepCurveFC.Select(p => p * d));
974 newCEP._normedCepCurveFC =
new List<double>(cp1._normedCepCurveFC.Select(p => p * d));
978 newCEP._powerPatternPollutants =
new List<double>(cp1._normailzedPowerPatternPollutants.Select(p => p * newCEP._normalizingPower));
979 newCEP._normailzedPowerPatternPollutants =
new List<double>(cp1._normailzedPowerPatternPollutants);
980 newCEP._cepCurvePollutants =
new Dictionary<string, List<double>>();
981 newCEP._cepNormalizedCurvePollutants =
new Dictionary<string, List<double>>();
983 foreach (
string id in cp1._cepCurvePollutants.Keys)
985 newCEP._cepCurvePollutants.Add(
id,
new List<double>(cp1._cepCurvePollutants[
id].Select(p => p * d)));
986 newCEP._cepNormalizedCurvePollutants.Add(
id,
new List<double>(cp1._cepNormalizedCurvePollutants[
id].Select(p => p * d)));
991 newCEP._idlingValueFC = cp1._idlingValueFC * d;
992 newCEP._idlingValuesPollutants =
new Dictionary<string, double>();
994 foreach (
string id in cp1._idlingValuesPollutants.Keys)
996 newCEP._idlingValuesPollutants.Add(
id,
997 cp1._idlingValuesPollutants[
id] * d);
1002 newCEP._nNormTable =
new List<double>(cp1._nNormTable);
1003 newCEP._dragNormTable =
new List<double>(cp1._dragNormTable.Select(p => p * d));
1009 #region CreatePattern 1010 static public List<double>
CreatePattern(
double min,
double max,
double increment)
1013 List<double> pattern =
new List<double>();
1014 double actualMin = min;
1015 double actualMax = max;
1018 actualMin = Math.Ceiling(min / increment) * increment;
1020 actualMin = Math.Floor(min / increment) * increment;
1023 actualMax = Math.Floor(max / increment) * increment;
1025 actualMax = Math.Ceiling(max / increment) * increment;
1027 double curVal = actualMin;
1029 while (curVal <= actualMax)
1031 pattern.Add(curVal);
1032 curVal += increment;
List< double > _normalizedPowerPatternFC
List< double > _cepCurveFC
std::vector< double > _speedPatternRotational
List< double > _normedCepCurveFC
static const double SPEED_DCEL_MIN
static const std::string strCNG
List< double > _speedPatternRotational
const double SPEED_ROTATIONAL_INCREMENT
const double POWER_FC_INCREMENT
Dictionary< string, List< double > > _cepNormalizedCurvePollutants
double GetEmission(string pollutant, double power, double speed, Helpers VehicleClass)
List< double > _powerPatternPollutants
std::vector< double > _normailzedPowerPatternPollutants
std::vector< double > _dragNormTable
std::map< std::string, std::vector< double > > _cepCurvePollutants
double _effectiveWheelDiameter
std::vector< double > _nNormTable
List< double > _nNormTable
double GetDragCoeffecient(double nNorm)
static const std::string strLPG
static CEP AddRangeCeps(CEP[] cps, Helpers Helper)
List< double > _gearTransmissionCurve
const double NNORM_INCREMENT
double GetGearCoeffecient(double speed)
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, List< double > transmissionGearRatios, double auxPower, double ratedPower, double engineIdlingSpeed, double engineRatedSpeed, double effictiveWheelDiameter, double pNormV0, double pNormP0, double pNormV1, double pNormP1, string vehicelFuelType, List< List< double >> matrixFC, List< string > headerLinePollutants, List< List< double >> matrixPollutants, List< List< double >> matrixSpeedRotational, List< List< double >> normedDragTable, double idlingFC, List< double > idlingPollutants)
Dictionary< string, double > _idlingValuesPollutants
static CEP operator*(CEP cp1, double d)
List< double > _powerPatternFC
double GetRotationalCoeffecient(double speed)
double _engineIdlingSpeed
std::map< std::string, double > _idlingValuesPollutants
std::vector< double > _normedCepCurveFC
static const double NORMALIZING_SPEED
Dictionary< string, List< double > > _cepCurvePollutants
NormalizingType _normalizingType
std::map< std::string, std::vector< double > > _cepNormalizedCurvePollutants
List< double > _normailzedPowerPatternPollutants
std::vector< double > _normalizedPowerPatternFC
static const double NORMALIZING_ACCELARATION
static const std::string strDiesel
double GetDecelCoast(double speed, double acc, double gradient)
NormalizingType NormalizingTypeX
double CalcEngPower(double power)
List< double > _dragNormTable
double GetNormedEmission(string pollutant, double power, double speed, Helpers VehicleClass)
const double POWER_POLLUTANT_INCREMENT
std::vector< double > _speedCurveRotational
std::vector< double > _gearTransmissionCurve
static const std::string strGasoline
void FindLowerUpperInPattern(out int lowerIndex, out int upperIndex, List< double > pattern, double value)
double GetMaxAccel(double speed, double gradient)
static List< double > CreatePattern(double min, double max, double increment)
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)
std::vector< double > _powerPatternFC
List< double > _speedCurveRotational
std::vector< double > _cepCurveFC
double GetPMaxNorm(double speed)
static const std::string strBEV
double Interpolate(double px, double p1, double p2, double e1, double e2)
static const double GRAVITY_CONST
double GetCO2Emission(double _FC, double _CO, double _HC, Helpers VehicleClass)
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, double auxPower, double ratedPower, double engineIdlingSpeed, double engineRatedSpeed, double effictiveWheelDiameter, double pNormV0, double pNormP0, double pNormV1, double pNormP1)
double _crossSectionalArea
std::vector< double > _powerPatternPollutants
static double _DRIVE_TRAIN_EFFICIENCY
static const double ZERO_SPEED_ACCURACY
double CalcPower(double speed, double acc, double gradient)
static const double AIR_DENSITY_CONST
void FindLowerUpperInPattern(int &lowerIndex, int &upperIndex, std::vector< double > &pattern, double value)