38 double vehicleMass,
double vehicleLoading,
double vehicleMassRot,
39 double crossArea,
double cdValue,
40 double f0,
double f1,
double f2,
double f3,
double f4,
41 double ratedPower,
double pNormV0,
double pNormP0,
double pNormV1,
double pNormP1,
42 double axleRatio,
double engineIdlingSpeed,
double engineRatedSpeed,
double effectiveWheelDiameter,
44 const std::string& vehicleFuelType,
45 const std::vector< std::vector<double> >& matrixFC,
46 const std::vector<std::string>& headerLinePollutants,
47 const std::vector< std::vector<double> >& matrixPollutants,
48 const std::vector< std::vector<double> >& matrixSpeedRotational,
49 const std::vector< std::vector<double> >& normedDragTable,
50 const std::vector<double>& idlingValuesPollutants) {
78 std::vector<std::string> pollutantIdentifier;
79 std::vector< std::vector<double> > pollutantMeasures;
80 std::vector<std::vector<double> > normalizedPollutantMeasures;
83 for (
int i = 0; i < (int)headerLinePollutants.size(); i++) {
84 pollutantIdentifier.push_back(headerLinePollutants[i]);
92 for (
int i = 0; i < (int)headerLinePollutants.size(); i++) {
93 pollutantMeasures.push_back(std::vector<double>());
94 normalizedPollutantMeasures.push_back(std::vector<double>());
101 for (
int i = 0; i < (int)matrixSpeedRotational.size(); i++) {
102 if (matrixSpeedRotational[i].size() != 3) {
103 throw InvalidArgument(
"Error loading vehicle file for: " + emissionClassIdentifier);
114 for (
int i = 0; i < (int) normedDragTable.size(); i++) {
115 if (normedDragTable[i].size() != 2) {
129 for (
int i = 0; i < (int)matrixFC.size(); i++) {
130 if (matrixFC[i].size() != 2) {
131 throw InvalidArgument(
"Error loading vehicle file for: " + emissionClassIdentifier);
142 double pollutantMultiplyer = 1;
157 const int headerCount = (int)headerLinePollutants.size();
158 for (
int i = 0; i < (int)matrixPollutants.size(); i++) {
159 for (
int j = 0; j < (int)matrixPollutants[i].size(); j++) {
160 if ((
int)matrixPollutants[i].size() != headerCount + 1) {
168 pollutantMeasures[j - 1].push_back(matrixPollutants[i][j] * pollutantMultiplyer);
169 normalizedPollutantMeasures[j - 1].push_back(matrixPollutants[i][j]);
174 for (
int i = 0; i < (int) headerLinePollutants.size(); i++) {
197 std::vector<double> emissionCurve;
198 std::vector<double> powerPattern;
201 if (pollutant ==
"FC") {
208 if (pollutant ==
"FC") {
218 throw InvalidArgument(
"Emission pollutant " + pollutant +
" not found!");
233 if (emissionCurve.size() == 0) {
234 throw InvalidArgument(
"Empty emission curve for " + pollutant +
" found!");
237 if (emissionCurve.size() == 1) {
238 return emissionCurve[0];
242 if (power <= powerPattern.front()) {
243 double calcEmission =
PHEMCEP::Interpolate(power, powerPattern[0], powerPattern[1], emissionCurve[0], emissionCurve[1]);
245 if (calcEmission < 0) {
254 if (power >= powerPattern.back()) {
255 return PHEMCEP::Interpolate(power, powerPattern[powerPattern.size() - 2], powerPattern.back(), emissionCurve[emissionCurve.size() - 2], emissionCurve.back());
264 return PHEMCEP::Interpolate(power, powerPattern[lowerIndex], powerPattern[upperIndex], emissionCurve[lowerIndex], emissionCurve[upperIndex]);
274 return e1 + (px - p1) / (p2 - p1) * (e2 - e1);
299 if (speed >= 10e-2) {
358 if (value <= pattern.front()) {
365 if (value >= pattern.back()) {
366 lowerIndex = (int)pattern.size() - 1;
367 upperIndex = (int)pattern.size() - 1;
372 int middleIndex = ((int)pattern.size() - 1) / 2;
373 upperIndex = (int)pattern.size() - 1;
376 while (upperIndex - lowerIndex > 1) {
377 if (pattern[middleIndex] == value) {
378 lowerIndex = middleIndex;
379 upperIndex = middleIndex;
381 }
else if (pattern[middleIndex] < value) {
382 lowerIndex = middleIndex;
383 middleIndex = (upperIndex - lowerIndex) / 2 + lowerIndex;
385 upperIndex = middleIndex;
386 middleIndex = (upperIndex - lowerIndex) / 2 + lowerIndex;
390 if (pattern[lowerIndex] <= value && value < pattern[upperIndex]) {
393 throw ProcessError(
"Error during calculation of position in pattern!");