44 std::map<SUMOEmissionClass, PHEMCEP*>::iterator iter =
_ceps.begin();
45 while (iter !=
_ceps.end()) {
46 delete (iter->second);
63 std::vector< std::vector<double> > matrixSpeedInertiaTable;
64 std::vector< std::vector<double> > normedDragTable;
65 std::vector< std::vector<double> > matrixFC;
66 std::vector< std::vector<double> > matrixPollutants;
67 std::vector<std::string> headerFC;
68 std::vector<std::string> headerPollutants;
69 std::vector<double> idlingValues;
70 std::vector<double> idlingValuesFC;
73 double vehicleLoading;
74 double vehicleMassRot;
75 double crosssectionalArea;
84 double engineIdlingSpeed;
85 double engineRatedSpeed;
86 double effectiveWheelDiameter;
87 std::string vehicleMassType;
88 std::string vehicleFuelType;
96 std::vector<std::string> phemPath;
97 phemPath.push_back(oc.
getString(
"phemlight-path") +
"/");
98 if (getenv(
"PHEMLIGHT_PATH") !=
nullptr) {
99 phemPath.push_back(std::string(getenv(
"PHEMLIGHT_PATH")) +
"/");
101 if (getenv(
"SUMO_HOME") !=
nullptr) {
102 phemPath.push_back(std::string(getenv(
"SUMO_HOME")) +
"/data/emissions/PHEMlight/");
119 effectiveWheelDiameter,
126 matrixSpeedInertiaTable,
131 if (!
ReadEmissionData(
true, phemPath, emissionClassIdentifier, headerFC, matrixFC, idlingValuesFC)) {
135 if (!
ReadEmissionData(
false, phemPath, emissionClassIdentifier, headerPollutants, matrixPollutants, idlingValues)) {
139 _ceps[emissionClass] =
new PHEMCEP(vehicleMassType ==
"HV",
140 emissionClass, emissionClassIdentifier,
159 effectiveWheelDiameter,
160 idlingValuesFC.front(),
165 matrixSpeedInertiaTable,
176 if (
_ceps.find(emissionClass) ==
_ceps.end()) {
180 return _ceps[emissionClass];
187 double& vehicleLoading,
188 double& vehicleMassRot,
198 double& engineIdlingSpeed,
199 double& engineRatedSpeed,
200 double& effectiveWheelDiameter,
201 std::string& vehicleMassType,
202 std::string& vehicleFuelType,
207 std::vector< std::vector<double> >& matrixSpeedInertiaTable,
208 std::vector< std::vector<double> >& normedDragTable)
211 std::ifstream fileVehicle;
212 for (std::vector<std::string>::const_iterator i = path.begin(); i != path.end(); i++) {
213 fileVehicle.open(((*i) + emissionClass +
".PHEMLight.veh").c_str());
214 if (fileVehicle.good()) {
218 if (!fileVehicle.good()) {
224 std::string commentPrefix =
"c";
228 std::getline(fileVehicle, line);
230 while (std::getline(fileVehicle, line) && dataCount <= 49) {
232 if (line.size() > 0 && line.substr(line.size() - 1) ==
"\r") {
233 line = line.substr(0, line.size() - 1);
236 std::stringstream lineStream(line);
238 if (line.substr(0, 1) == commentPrefix) {
244 std::getline(lineStream, cell,
',');
247 if (dataCount == 1) {
248 std::istringstream(cell) >> vehicleMass;
252 if (dataCount == 2) {
253 std::istringstream(cell) >> vehicleLoading;
257 if (dataCount == 3) {
258 std::istringstream(cell) >> cWValue;
262 if (dataCount == 4) {
263 std::istringstream(cell) >> crossArea;
267 if (dataCount == 7) {
268 std::istringstream(cell) >> vehicleMassRot;
272 if (dataCount == 10) {
273 std::istringstream(cell) >> ratedPower;
277 if (dataCount == 11) {
278 std::istringstream(cell) >> engineRatedSpeed;
282 if (dataCount == 12) {
283 std::istringstream(cell) >> engineIdlingSpeed;
287 if (dataCount == 14) {
288 std::istringstream(cell) >> f0;
292 if (dataCount == 15) {
293 std::istringstream(cell) >> f1;
297 if (dataCount == 16) {
298 std::istringstream(cell) >> f2;
302 if (dataCount == 17) {
303 std::istringstream(cell) >> f3;
307 if (dataCount == 18) {
308 std::istringstream(cell) >> f4;
311 if (dataCount == 21) {
312 std::istringstream(cell) >> axleRatio;
316 if (dataCount == 22) {
317 std::istringstream(cell) >> effectiveWheelDiameter;
321 if (dataCount == 45) {
322 vehicleMassType = cell;
326 if (dataCount == 46) {
327 vehicleFuelType = cell;
331 if (dataCount == 47) {
332 std::istringstream(cell) >> pNormV0;
336 if (dataCount == 48) {
337 std::istringstream(cell) >> pNormP0;
341 if (dataCount == 49) {
342 std::istringstream(cell) >> pNormV1;
346 if (dataCount == 50) {
347 std::istringstream(cell) >> pNormP1;
351 while (std::getline(fileVehicle, line) && line.substr(0, 1) != commentPrefix) {
352 std::stringstream lineStream(line);
354 std::vector <double> vi;
355 while (std::getline(lineStream, cell,
',')) {
357 std::istringstream(cell) >> entry;
361 matrixSpeedInertiaTable.push_back(vi);
364 while (std::getline(fileVehicle, line)) {
365 if (line.substr(0, 1) == commentPrefix) {
369 std::stringstream lineStream(line);
371 std::vector <double> vi;
372 while (std::getline(lineStream, cell,
',')) {
374 std::istringstream(cell) >> entry;
378 normedDragTable.push_back(vi);
388 std::vector<std::string>& header, std::vector<std::vector<double> >& matrix, std::vector<double>& idlingValues) {
390 std::string pollutantExtension =
"";
392 pollutantExtension +=
"_FC";
395 std::ifstream fileEmission;
396 for (std::vector<std::string>::const_iterator i = path.begin(); i != path.end(); i++) {
397 fileEmission.open(((*i) + emissionClass + pollutantExtension +
".csv").c_str());
398 if (fileEmission.good()) {
403 if (!fileEmission.good()) {
410 if (std::getline(fileEmission, line)) {
411 std::stringstream lineStream(line);
414 std::getline(lineStream, cell,
',');
416 while (std::getline(lineStream, cell,
',')) {
417 header.push_back(cell);
423 std::getline(fileEmission, line);
426 std::getline(fileEmission, line);
429 std::getline(fileEmission, line);
431 std::stringstream idlingStream(line);
432 std::string idlingCell;
435 std::getline(idlingStream, idlingCell,
',');
437 while (std::getline(idlingStream, idlingCell,
',')) {
439 std::istringstream(idlingCell) >> entry;
440 idlingValues.push_back(entry);
443 while (std::getline(fileEmission, line)) {
444 std::stringstream lineStream(line);
446 std::vector <double> vi;
447 while (std::getline(lineStream, cell,
',')) {
449 std::istringstream(cell) >> entry;
453 matrix.push_back(vi);
456 fileEmission.close();