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