39 double vehicleMass,
double vehicleLoading,
double vehicleMassRot,
40 double crossArea,
double cdValue,
41 double f0,
double f1,
double f2,
double f3,
double f4,
42 double ratedPower,
double pNormV0,
double pNormP0,
double pNormV1,
double pNormP1,
43 double axleRatio,
double engineIdlingSpeed,
double engineRatedSpeed,
double effectiveWheelDiameter,
45 const std::string& vehicleFuelType,
46 const std::vector< std::vector<double> >& matrixFC,
47 const std::vector<std::string>& headerLinePollutants,
48 const std::vector< std::vector<double> >& matrixPollutants,
49 const std::vector< std::vector<double> >& matrixSpeedRotational,
50 const std::vector< std::vector<double> >& normedDragTable,
51 const std::vector<double>& idlingValuesPollutants) {
79 std::vector<std::string> pollutantIdentifier;
80 std::vector< std::vector<double> > pollutantMeasures;
81 std::vector<std::vector<double> > normalizedPollutantMeasures;
84 for (
int i = 0; i < (int)headerLinePollutants.size(); i++) {
85 pollutantIdentifier.push_back(headerLinePollutants[i]);
93 for (
int i = 0; i < (int)headerLinePollutants.size(); i++) {
94 pollutantMeasures.push_back(std::vector<double>());
95 normalizedPollutantMeasures.push_back(std::vector<double>());
102 for (
int i = 0; i < (int)matrixSpeedRotational.size(); i++) {
103 if (matrixSpeedRotational[i].size() != 3) {
104 throw InvalidArgument(
"Error loading vehicle file for: " + emissionClassIdentifier);
115 for (
int i = 0; i < (int) normedDragTable.size(); i++) {
116 if (normedDragTable[i].size() != 2) {
130 for (
int i = 0; i < (int)matrixFC.size(); i++) {
131 if (matrixFC[i].size() != 2) {
132 throw InvalidArgument(
"Error loading vehicle file for: " + emissionClassIdentifier);
137 _cepCurveFC.push_back(matrixFC[i][1] * _ratedPower);
143 double pollutantMultiplyer = 1;
158 const int headerCount = (int)headerLinePollutants.size();
159 for (
int i = 0; i < (int)matrixPollutants.size(); i++) {
160 for (
int j = 0; j < (int)matrixPollutants[i].size(); j++) {
161 if ((
int)matrixPollutants[i].size() != headerCount + 1) {
169 pollutantMeasures[j - 1].push_back(matrixPollutants[i][j] * pollutantMultiplyer);
170 normalizedPollutantMeasures[j - 1].push_back(matrixPollutants[i][j]);
175 for (
int i = 0; i < (int) headerLinePollutants.size(); i++) {
198 std::vector<double> emissionCurve;
199 std::vector<double> powerPattern;
202 if (pollutant ==
"FC") {
209 if (pollutant ==
"FC") {
219 throw InvalidArgument(
"Emission pollutant " + pollutant +
" not found!");
234 if (emissionCurve.size() == 0) {
235 throw InvalidArgument(
"Empty emission curve for " + pollutant +
" found!");
238 if (emissionCurve.size() == 1) {
239 return emissionCurve[0];
243 if (power <= powerPattern.front()) {
244 double calcEmission =
PHEMCEP::Interpolate(power, powerPattern[0], powerPattern[1], emissionCurve[0], emissionCurve[1]);
246 if (calcEmission < 0) {
255 if (power >= powerPattern.back()) {
256 return PHEMCEP::Interpolate(power, powerPattern[powerPattern.size() - 2], powerPattern.back(), emissionCurve[emissionCurve.size() - 2], emissionCurve.back());
265 return PHEMCEP::Interpolate(power, powerPattern[lowerIndex], powerPattern[upperIndex], emissionCurve[lowerIndex], emissionCurve[upperIndex]);
275 return e1 + (px - p1) / (p2 - p1) * (e2 - e1);
300 if (speed >= 10e-2) {
359 if (value <= pattern.front()) {
366 if (value >= pattern.back()) {
367 lowerIndex = (int)pattern.size() - 1;
368 upperIndex = (int)pattern.size() - 1;
373 int middleIndex = ((int)pattern.size() - 1) / 2;
374 upperIndex = (int)pattern.size() - 1;
377 while (upperIndex - lowerIndex > 1) {
378 if (pattern[middleIndex] == value) {
379 lowerIndex = middleIndex;
380 upperIndex = middleIndex;
382 }
else if (pattern[middleIndex] < value) {
383 lowerIndex = middleIndex;
384 middleIndex = (upperIndex - lowerIndex) / 2 + lowerIndex;
386 upperIndex = middleIndex;
387 middleIndex = (upperIndex - lowerIndex) / 2 + lowerIndex;
391 if (pattern[lowerIndex] <= value && value < pattern[upperIndex]) {
394 throw ProcessError(
"Error during calculation of position in pattern!");
std::vector< double > _powerPatternFC
std::vector< double > _normedCepCurveFC
double GetPMaxNorm(double speed) const
Calculates maximum available rated power for speed.
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.
std::string _vehicleFuelType
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.
void FindLowerUpperInPattern(int &lowerIndex, int &upperIndex, const std::vector< double > &pattern, double value) const
Finds bounding upper and lower index in pattern for value.
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
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.
double GetEmission(const std::string &pollutantIdentifier, double power, double speed, bool normalized=false) const
Returns a emission measure for power[kW] level.
const double GRAVITY_CONST
double GetDecelCoast(double speed, double acc, double gradient, double vehicleLoading) const
double _resistanceF4
Rolling resistance f4.
T get(const std::string &str) const
double _engineIdlingSpeed
double _resistanceF0
Rolling resistance f0.
std::vector< double > _normailzedPowerPatternPollutants
std::vector< double > _cepCurveFC
StringBijection< std::vector< double > > _normalizedCepCurvePollutants
int _sizeOfPatternPollutants
std::vector< double > _powerPatternPollutants
const double AIR_DENSITY_CONST
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
double GetGearCoeffecient(double speed) const
double _effictiveWheelDiameter
bool hasString(const std::string &str) const
SUMOEmissionClass _emissionClass
PHEM emission class of vehicle.
double GetDragCoeffecient(double nNorm) const
double GetRotationalCoeffecient(double speed) const
Calculates rotational index for speed.
double _resistanceF2
Rolling resistance f2.
NormalizingType _normalizingType
const double SPEED_DCEL_MIN
std::vector< double > _dragNormTable