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);
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!");