41 #ifdef CHECK_MEMORY_LEAKS
43 #endif // CHECK_MEMORY_LEAKS
50 double vehicleMass,
double vehicleLoading,
double vehicleMassRot,
51 double crossArea,
double cWValue,
52 double f0,
double f1,
double f2,
double f3,
double f4,
53 double ratedPower,
double pNormV0,
double pNormP0,
double pNormV1,
54 double pNormP1, std::string vehicelFuelType,
55 const std::vector< std::vector<double> >& matrixFC,
56 const std::vector<std::string>& headerLinePollutants,
57 const std::vector< std::vector<double> >& matrixPollutants,
58 const std::vector< std::vector<double> > matrixSpeedRotational) {
78 std::vector<std::string> pollutantIdentifier;
79 std::vector< std::vector<double> > pollutantMeasures;
82 for (
int i = 0; i < (
int)headerLinePollutants.size(); i++) {
83 pollutantIdentifier.push_back(headerLinePollutants[i]);
91 for (
int i = 0; i < (
int)headerLinePollutants.size(); i++) {
92 pollutantMeasures.push_back(std::vector<double>());
98 for (
int i = 0; i < (
int)matrixSpeedRotational.size(); i++) {
99 if (matrixSpeedRotational[i].size() != 2) {
100 throw InvalidArgument(
"Error loading vehicle file for: " + emissionClassIdentifier);
110 for (
int i = 0; i < (
int)matrixFC.size(); i++) {
111 if (matrixFC[i].size() != 2) {
112 throw InvalidArgument(
"Error loading vehicle file for: " + emissionClassIdentifier);
122 double normalizingPower = 0;
130 const int headerCount = (
int)headerLinePollutants.size();
131 for (
int i = 0; i < (
int)matrixPollutants.size(); i++) {
132 for (
int j = 0; j < (
int)matrixPollutants[i].size(); j++) {
133 if ((
int)matrixPollutants[i].size() != headerCount + 1) {
140 pollutantMeasures[j - 1].push_back(matrixPollutants[i][j]);
145 for (
int i = 0; i < headerCount; i++) {
183 std::vector<double> emissionCurve;
184 std::vector<double> powerPattern;
186 if (pollutant ==
"FC") {
191 throw InvalidArgument(
"Emission pollutant " + pollutant +
" not found!");
200 if (emissionCurve.size() == 0) {
201 throw InvalidArgument(
"Empty emission curve for " + pollutant +
" found!");
204 if (emissionCurve.size() == 1) {
205 return emissionCurve[0];
209 if (power <= powerPattern.front()) {
210 double calcEmission =
PHEMCEP::Interpolate(power, powerPattern[0], powerPattern[1], emissionCurve[0], emissionCurve[1]);
212 if (calcEmission < 0) {
221 if (power >= powerPattern.back()) {
222 return PHEMCEP::Interpolate(power, powerPattern[powerPattern.size() - 2], powerPattern.back(), emissionCurve[emissionCurve.size() - 2], emissionCurve.back());
231 return PHEMCEP::Interpolate(power, powerPattern[lowerIndex], powerPattern[upperIndex], emissionCurve[lowerIndex], emissionCurve[upperIndex]);
241 return e1 + (px - p1) / (p2 - p1) * (e2 - e1);
261 if (value <= pattern.front()) {
268 if (value >= pattern.back()) {
269 lowerIndex = (
int)pattern.size() - 1;
270 upperIndex = (
int)pattern.size() - 1;
275 int middleIndex = ((
int)pattern.size() - 1) / 2;
276 upperIndex = (
int)pattern.size() - 1;
279 while (upperIndex - lowerIndex > 1) {
280 if (pattern[middleIndex] == value) {
281 lowerIndex = middleIndex;
282 upperIndex = middleIndex;
284 }
else if (pattern[middleIndex] < value) {
285 lowerIndex = middleIndex;
286 middleIndex = (upperIndex - lowerIndex) / 2 + lowerIndex;
288 upperIndex = middleIndex;
289 middleIndex = (upperIndex - lowerIndex) / 2 + lowerIndex;
293 if (pattern[lowerIndex] <= value && value < pattern[upperIndex]) {
296 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.
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
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.
PHEMCEP(bool heavyVehicel, SUMOEmissionClass emissionClass, const std::string &emissionClassIdentifier, 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 _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.