41 #ifdef CHECK_MEMORY_LEAKS
43 #endif // CHECK_MEMORY_LEAKS
50 double vehicleMass,
double vehicleLoading,
double vehicleMassRot,
51 double crossArea,
double cdValue,
52 double f0,
double f1,
double f2,
double f3,
double f4,
53 double ratedPower,
double pNormV0,
double pNormP0,
double pNormV1,
double pNormP1,
54 double axleRatio,
double engineIdlingSpeed,
double engineRatedSpeed,
double effectiveWheelDiameter,
56 const std::string& vehicleFuelType,
57 const std::vector< std::vector<double> >& matrixFC,
58 const std::vector<std::string>& headerLinePollutants,
59 const std::vector< std::vector<double> >& matrixPollutants,
60 const std::vector< std::vector<double> >& matrixSpeedRotational,
61 const std::vector< std::vector<double> >& normedDragTable,
62 const std::vector<double>& idlingValuesPollutants) {
90 std::vector<std::string> pollutantIdentifier;
91 std::vector< std::vector<double> > pollutantMeasures;
92 std::vector<std::vector<double> > normalizedPollutantMeasures;
95 for (
int i = 0; i < (int)headerLinePollutants.size(); i++) {
96 pollutantIdentifier.push_back(headerLinePollutants[i]);
104 for (
int i = 0; i < (int)headerLinePollutants.size(); i++) {
105 pollutantMeasures.push_back(std::vector<double>());
106 normalizedPollutantMeasures.push_back(std::vector<double>());
113 for (
int i = 0; i < (int)matrixSpeedRotational.size(); i++) {
114 if (matrixSpeedRotational[i].size() != 3) {
115 throw InvalidArgument(
"Error loading vehicle file for: " + emissionClassIdentifier);
126 for (
int i = 0; i < (int) normedDragTable.size(); i++) {
127 if (normedDragTable[i].size() != 2) {
141 for (
int i = 0; i < (int)matrixFC.size(); i++) {
142 if (matrixFC[i].size() != 2) {
143 throw InvalidArgument(
"Error loading vehicle file for: " + emissionClassIdentifier);
148 _cepCurveFC.push_back(matrixFC[i][1] * _ratedPower);
154 double pollutantMultiplyer = 1;
169 const int headerCount = (int)headerLinePollutants.size();
170 for (
int i = 0; i < (int)matrixPollutants.size(); i++) {
171 for (
int j = 0; j < (int)matrixPollutants[i].size(); j++) {
172 if ((
int)matrixPollutants[i].size() != headerCount + 1) {
180 pollutantMeasures[j - 1].push_back(matrixPollutants[i][j] * pollutantMultiplyer);
181 normalizedPollutantMeasures[j - 1].push_back(matrixPollutants[i][j]);
186 for (
int i = 0; i < (int) headerLinePollutants.size(); i++) {
209 std::vector<double> emissionCurve;
210 std::vector<double> powerPattern;
213 if (pollutant ==
"FC") {
220 if (pollutant ==
"FC") {
230 throw InvalidArgument(
"Emission pollutant " + pollutant +
" not found!");
245 if (emissionCurve.size() == 0) {
246 throw InvalidArgument(
"Empty emission curve for " + pollutant +
" found!");
249 if (emissionCurve.size() == 1) {
250 return emissionCurve[0];
254 if (power <= powerPattern.front()) {
255 double calcEmission =
PHEMCEP::Interpolate(power, powerPattern[0], powerPattern[1], emissionCurve[0], emissionCurve[1]);
257 if (calcEmission < 0) {
266 if (power >= powerPattern.back()) {
267 return PHEMCEP::Interpolate(power, powerPattern[powerPattern.size() - 2], powerPattern.back(), emissionCurve[emissionCurve.size() - 2], emissionCurve.back());
276 return PHEMCEP::Interpolate(power, powerPattern[lowerIndex], powerPattern[upperIndex], emissionCurve[lowerIndex], emissionCurve[upperIndex]);
286 return e1 + (px - p1) / (p2 - p1) * (e2 - e1);
311 if (speed >= 10e-2) {
370 if (value <= pattern.front()) {
377 if (value >= pattern.back()) {
378 lowerIndex = (int)pattern.size() - 1;
379 upperIndex = (int)pattern.size() - 1;
384 int middleIndex = ((int)pattern.size() - 1) / 2;
385 upperIndex = (int)pattern.size() - 1;
388 while (upperIndex - lowerIndex > 1) {
389 if (pattern[middleIndex] == value) {
390 lowerIndex = middleIndex;
391 upperIndex = middleIndex;
393 }
else if (pattern[middleIndex] < value) {
394 lowerIndex = middleIndex;
395 middleIndex = (upperIndex - lowerIndex) / 2 + lowerIndex;
397 upperIndex = middleIndex;
398 middleIndex = (upperIndex - lowerIndex) / 2 + lowerIndex;
402 if (pattern[lowerIndex] <= value && value < pattern[upperIndex]) {
405 throw ProcessError(
"Error during calculation of position in pattern!");
std::vector< double > _powerPatternFC
void FindLowerUpperInPattern(int &lowerIndex, int &upperIndex, const std::vector< double > &pattern, double value) const
Finds bounding upper and lower index in pattern for value.
std::vector< double > _normedCepCurveFC
bool hasString(const std::string &str) const
PHEMCEP(bool heavyVehicel, SUMOEmissionClass emissionClass, const std::string &emissionClassIdentifier, double vehicleMass, double vehicleLoading, double vehicleMassRot, double crossArea, double cdValue, double f0, double f1, double f2, double f3, double f4, double ratedPower, double pNormV0, double pNormP0, double pNormV1, double pNormP1, double axleRatio, double engineIdlingSpeed, double engineRatedSpeed, double effectiveWheelDiameter, double idlingFC, const std::string &vehicleFuelType, const std::vector< std::vector< double > > &matrixFC, const std::vector< std::string > &headerLinePollutants, const std::vector< std::vector< double > > &matrixPollutants, const std::vector< std::vector< double > > &matrixSpeedRotational, const std::vector< std::vector< double > > &normedDragTable, const std::vector< double > &idlingValuesPollutants)
std::vector< double > _speedCurveRotational
double _massVehicle
vehicle mass
double _resistanceF1
Rolling resistance f1.
double GetGearCoeffecient(double speed) const
std::string _vehicleFuelType
const double NORMALIZING_SPEED
double _pNormP0
Step functions parameter for maximum rated power.
double _pNormV1
Step functions parameter for maximum rated power.
double _resistanceF3
Rolling resistance f3.
double _massRot
rotational mass of vehicle
#define UNUSED_PARAMETER(x)
std::vector< double > _gearTransmissionCurve
double _pNormV0
Step functions parameter for maximum rated power.
const double ZERO_SPEED_ACCURACY
std::vector< double > _nNormTable
const double NORMALIZING_ACCELARATION
double _crossSectionalArea
crosssectional area of vehicle
double _vehicleLoading
vehicle loading
void insert(const std::string str, const T key, bool checkDuplicates=true)
double _pNormP1
Step functions parameter for maximum rated power.
std::vector< double > _speedPatternRotational
const double GRAVITY_CONST
double GetRotationalCoeffecient(double speed) const
Calculates rotational index for speed.
double _resistanceF4
Rolling resistance f4.
double _engineIdlingSpeed
double _resistanceF0
Rolling resistance f0.
std::vector< double > _normailzedPowerPatternPollutants
std::vector< double > _cepCurveFC
double GetPMaxNorm(double speed) const
Calculates maximum available rated power for speed.
StringBijection< std::vector< double > > _normalizedCepCurvePollutants
int _sizeOfPatternPollutants
double GetMaxAccel(double v, double a, double gradient, double vehicleLoading=0) const
Returns the maximum accelaration for a vehicle at state v,a, slope and loading.
std::vector< double > _powerPatternPollutants
const double AIR_DENSITY_CONST
double CalcPower(double v, double a, double slope, double vehicleLoading=0) const
Returns the power of used for a vehicle at state v,a, slope and loading.
std::vector< double > _normalizedPowerPatternFC
StringBijection< double > _idlingValuesPollutants
double Interpolate(double px, double p1, double p2, double e1, double e2) const
Interpolates emission linearly between two known power-emission pairs.
double _ratedPower
rated power of vehicle
StringBijection< std::vector< double > > _cepCurvePollutants
T get(const std::string &str) const
double _effictiveWheelDiameter
double GetDragCoeffecient(double nNorm) const
double GetDecelCoast(double speed, double acc, double gradient, double vehicleLoading) const
SUMOEmissionClass _emissionClass
PHEM emission class of vehicle.
double GetEmission(const std::string &pollutantIdentifier, double power, double speed, bool normalized=false) const
Returns a emission measure for power[kW] level.
double _resistanceF2
Rolling resistance f2.
NormalizingType _normalizingType
const double SPEED_DCEL_MIN
std::vector< double > _dragNormTable