37 #ifdef CHECK_MEMORY_LEAKS
39 #endif // CHECK_MEMORY_LEAKS
46 double vehicleMass,
double vehicleLoading,
double vehicleMassRot,
47 double crossArea,
double cWValue,
48 double f0,
double f1,
double f2,
double f3,
double f4,
49 double ratedPower,
double pNormV0,
double pNormP0,
double pNormV1,
50 double pNormP1, std::string vehicelFuelType,
51 const std::vector< std::vector<double> >& matrixFC,
52 const std::vector<std::string>& headerLinePollutants,
53 const std::vector< std::vector<double> >& matrixPollutants,
54 const std::vector< std::vector<double> > matrixSpeedRotational) {
74 std::vector<std::string> pollutantIdentifier;
75 std::vector< std::vector<double> > pollutantMeasures;
78 for (
int i = 0; i < (
int)headerLinePollutants.size(); i++) {
79 pollutantIdentifier.push_back(headerLinePollutants[i]);
87 for (
int i = 0; i < (
int)headerLinePollutants.size(); i++) {
88 pollutantMeasures.push_back(std::vector<double>());
94 for (
int i = 0; i < (
int)matrixSpeedRotational.size(); i++) {
95 if (matrixSpeedRotational[i].size() != 2) {
106 for (
int i = 0; i < (
int)matrixFC.size(); i++) {
107 if (matrixFC[i].size() != 2) {
118 double normalizingPower = 0;
126 const int headerCount = (
int)headerLinePollutants.size();
127 for (
int i = 0; i < (
int)matrixPollutants.size(); i++) {
128 for (
int j = 0; j < (
int)matrixPollutants[i].size(); j++) {
129 if ((
int)matrixPollutants[i].size() != headerCount + 1) {
136 pollutantMeasures[j - 1].push_back(matrixPollutants[i][j]);
141 for (
int i = 0; i < headerCount; i++) {
179 std::vector<double> emissionCurve;
180 std::vector<double> powerPattern;
182 if (pollutant ==
"FC") {
187 throw InvalidArgument(
"Emission pollutant " + pollutant +
" not found!");
196 if (emissionCurve.size() == 0) {
197 throw InvalidArgument(
"Empty emission curve for " + pollutant +
" found!");
200 if (emissionCurve.size() == 1) {
201 return emissionCurve[0];
205 if (power <= powerPattern.front()) {
206 double calcEmission =
PHEMCEP::Interpolate(power, powerPattern[0], powerPattern[1], emissionCurve[0], emissionCurve[1]);
208 if (calcEmission < 0) {
217 if (power >= powerPattern.back()) {
218 return PHEMCEP::Interpolate(power, powerPattern[powerPattern.size() - 2], powerPattern.back(), emissionCurve[emissionCurve.size() - 2], emissionCurve.back());
227 return PHEMCEP::Interpolate(power, powerPattern[lowerIndex], powerPattern[upperIndex], emissionCurve[lowerIndex], emissionCurve[upperIndex]);
237 return e1 + (px - p1) / (p2 - p1) * (e2 - e1);
257 if (value <= pattern.front()) {
264 if (value >= pattern.back()) {
265 lowerIndex = (
int)pattern.size() - 1;
266 upperIndex = (
int)pattern.size() - 1;
271 int middleIndex = ((
int)pattern.size() - 1) / 2;
272 upperIndex = (
int)pattern.size() - 1;
275 while (upperIndex - lowerIndex > 1) {
276 if (pattern[middleIndex] == value) {
277 lowerIndex = middleIndex;
278 upperIndex = middleIndex;
280 }
else if (pattern[middleIndex] < value) {
281 lowerIndex = middleIndex;
282 middleIndex = (upperIndex - lowerIndex) / 2 + lowerIndex;
284 upperIndex = middleIndex;
285 middleIndex = (upperIndex - lowerIndex) / 2 + lowerIndex;
289 if (pattern[lowerIndex] <= value && value < pattern[upperIndex]) {
292 throw ProcessError(
"Error during calculation of position in pattern!");
std::vector< double > _powerPatternFC
bool hasString(const std::string &str) const
double GetEmission(const std::string &pollutantIdentifier, double power) const
Returns a emission measure for power[kW] level.
StringBijection< SUMOEmissionClass > SumoEmissionClassStrings(SumoEmissionClassStringInitializer, SVE_Solo_LKW_D_EU6_II)
std::vector< double > _speedCurveRotational
double _massVehicle
vehicle mass
double _resistanceF1
Rolling resistance f1.
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)
double GetMaxAccel(double v, double a, double gradient) const
Returns the maximum accelaration for a vehicle at state v,a, slope and loading.
double _pNormV0
Step functions parameter for maximum rated power.
const double NORMALIZING_ACCELARATION
SUMOEmissionClass
Definition of vehicle emission classes.
double _crossSectionalArea
crosssectional area of vehicle
double _vehicleLoading
vehicle loading
double _pNormP1
Step functions parameter for maximum rated power.
std::vector< double > _speedPatternRotational
const double GRAVITY_CONST
PHEMCEP(bool heavyVehicel, SUMOEmissionClass emissionClass, double vehicleMass, double vehicleLoading, double vehicleMassRot, double crossArea, double cWValue, double f0, double f1, double f2, double f3, double f4, double ratedPower, double pNormV0, double pNormP0, double pNormV1, double pNormP1, std::string vehicelFuelType, 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)
double GetRotationalCoeffecient(double speed) const
Calculates rotational index for speed.
double _resistanceF4
Rolling resistance f4.
void insert(const std::string str, const T key)
double _resistanceF0
Rolling resistance f0.
std::vector< double > _cepCurveFC
double GetPMaxNorm(double speed) const
Calculates maximum available rated power for speed.
int _sizeOfPatternPollutants
std::vector< double > _powerPatternPollutants
const double AIR_DENSITY_CONST
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
double CalcPower(double v, double a, double slope) const
Returns the power of used for a vehicle at state v,a, slope and loading.
StringBijection< std::vector< double > > _cepCurvePollutants
T get(const std::string &str) const
void FindLowerUpperInPattern(int &lowerIndex, int &upperIndex, std::vector< double > pattern, double value) const
Finds bounding upper and lower index in pattern for value.
SUMOEmissionClass _emissionClass
PHEM emission class of vehicle.
double _resistanceF2
Rolling resistance f2.