SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PollutantsInterface.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // Interface to capsulate different emission models
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
10 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
31 #include "PollutantsInterface.h"
32 #include "HelpersHBEFA.h"
33 #include "HelpersPHEMlight.h"
34 #include <limits>
35 #include <cmath>
36 
37 #ifdef CHECK_MEMORY_LEAKS
38 #include <foreign/nvwa/debug_new.h>
39 #endif // CHECK_MEMORY_LEAKS
40 
41 
42 // ===========================================================================
43 // method definitions
44 // ===========================================================================
46 PollutantsInterface::getMaxAccel(SUMOEmissionClass c, double v, double a, double slope) {
47  if (c < SVE_META_HBEFA21_END) {
48  return -1;
49  } else if (c > SVE_META_HBEFA21_END && c < SVE_META_PHEMLIGHT_END) {
50  return HelpersPHEMlight::getMaxAccel(c, v, a, slope);
51  } else {
52  return 0;
53  }
54 }
55 
56 
58 PollutantsInterface::computeCO(SUMOEmissionClass c, double v, double a, double slope) {
59  if (c < SVE_META_HBEFA21_END) {
60  return HelpersHBEFA::computeCO(c, v, a);
61  } else if (c > SVE_META_HBEFA21_END && c < SVE_META_PHEMLIGHT_END) {
62  return HelpersPHEMlight::computeCO(c, v, a, slope);
63  } else {
64  return 0;
65  }
66 }
67 
68 
70 PollutantsInterface::computeCO2(SUMOEmissionClass c, double v, double a, double slope) {
71  if (c < SVE_META_HBEFA21_END) {
72  return HelpersHBEFA::computeCO2(c, v, a);
73  } else if (c > SVE_META_HBEFA21_END && c < SVE_META_PHEMLIGHT_END) {
74  return HelpersPHEMlight::computeCO2(c, v, a, slope);
75  } else {
76  return 0;
77  }
78 }
79 
80 
82 PollutantsInterface::computeHC(SUMOEmissionClass c, double v, double a, double slope) {
83  if (c < SVE_META_HBEFA21_END) {
84  return HelpersHBEFA::computeHC(c, v, a);
85  } else if (c > SVE_META_HBEFA21_END && c < SVE_META_PHEMLIGHT_END) {
86  return HelpersPHEMlight::computeHC(c, v, a, slope);
87  } else {
88  return 0;
89  }
90 }
91 
92 
94 PollutantsInterface::computeNOx(SUMOEmissionClass c, double v, double a, double slope) {
95  if (c < SVE_META_HBEFA21_END) {
96  return HelpersHBEFA::computeNOx(c, v, a);
97  } else if (c > SVE_META_HBEFA21_END && c < SVE_META_PHEMLIGHT_END) {
98  return HelpersPHEMlight::computeNOx(c, v, a, slope);
99  } else {
100  return 0;
101  }
102 }
103 
104 
105 SUMOReal
106 PollutantsInterface::computePMx(SUMOEmissionClass c, double v, double a, double slope) {
107  if (c < SVE_META_HBEFA21_END) {
108  return HelpersHBEFA::computePMx(c, v, a);
109  } else if (c > SVE_META_HBEFA21_END && c < SVE_META_PHEMLIGHT_END) {
110  return HelpersPHEMlight::computePMx(c, v, a, slope);
111  } else {
112  return 0;
113  }
114 }
115 
116 
117 SUMOReal
118 PollutantsInterface::computeFuel(SUMOEmissionClass c, double v, double a, double slope) {
119  if (c < SVE_META_HBEFA21_END) {
120  return HelpersHBEFA::computeFuel(c, v, a);
121  } else if (c > SVE_META_HBEFA21_END && c < SVE_META_PHEMLIGHT_END) {
122  return HelpersPHEMlight::computeFuel(c, v, a, slope);
123  } else {
124  return 0;
125  }
126 }
127 
128 
129 
130 
131 SUMOReal
132 PollutantsInterface::computeDefaultCO(SUMOEmissionClass c, double v, double a, double slope, SUMOReal tt) {
133  if (c < SVE_META_HBEFA21_END) {
134  return (HelpersHBEFA::computeCO(c, v, 0) + HelpersHBEFA::computeCO(c, v - a, a)) * tt / 2.;
135  } else if (c > SVE_META_HBEFA21_END && c < SVE_META_PHEMLIGHT_END) {
136  return (HelpersPHEMlight::computeCO(c, v, 0, slope) + HelpersPHEMlight::computeCO(c, v - a, a, slope)) * tt / 2.;
137  } else {
138  return 0;
139  }
140 }
141 
142 
143 SUMOReal
144 PollutantsInterface::computeDefaultCO2(SUMOEmissionClass c, double v, double a, double slope, SUMOReal tt) {
145  if (c < SVE_META_HBEFA21_END) {
146  return (HelpersHBEFA::computeCO2(c, v, 0) + HelpersHBEFA::computeCO2(c, v - a, a)) * tt / 2.;
147  } else if (c > SVE_META_HBEFA21_END && c < SVE_META_PHEMLIGHT_END) {
148  return (HelpersPHEMlight::computeCO2(c, v, 0, slope) + HelpersPHEMlight::computeCO2(c, v - a, a, slope)) * tt / 2.;
149  } else {
150  return 0;
151  }
152 }
153 
154 
155 SUMOReal
156 PollutantsInterface::computeDefaultHC(SUMOEmissionClass c, double v, double a, double slope, SUMOReal tt) {
157  if (c < SVE_META_HBEFA21_END) {
158  return (HelpersHBEFA::computeHC(c, v, 0) + HelpersHBEFA::computeHC(c, v - a, a)) * tt / 2.;
159  } else if (c > SVE_META_HBEFA21_END && c < SVE_META_PHEMLIGHT_END) {
160  return (HelpersPHEMlight::computeHC(c, v, 0, slope) + HelpersPHEMlight::computeHC(c, v - a, a, slope)) * tt / 2.;
161  } else {
162  return 0;
163  }
164 }
165 
166 
167 SUMOReal
168 PollutantsInterface::computeDefaultNOx(SUMOEmissionClass c, double v, double a, double slope, SUMOReal tt) {
169  if (c < SVE_META_HBEFA21_END) {
170  return (HelpersHBEFA::computeNOx(c, v, 0) + HelpersHBEFA::computeNOx(c, v - a, a)) * tt / 2.;
171  } else if (c > SVE_META_HBEFA21_END && c < SVE_META_PHEMLIGHT_END) {
172  return (HelpersPHEMlight::computeNOx(c, v, 0, slope) + HelpersPHEMlight::computeNOx(c, v - a, a, slope)) * tt / 2.;
173  } else {
174  return 0;
175  }
176 }
177 
178 
179 SUMOReal
180 PollutantsInterface::computeDefaultPMx(SUMOEmissionClass c, double v, double a, double slope, SUMOReal tt) {
181  if (c < SVE_META_HBEFA21_END) {
182  return (HelpersHBEFA::computePMx(c, v, 0) + HelpersHBEFA::computePMx(c, v - a, a)) * tt / 2.;
183  } else if (c > SVE_META_HBEFA21_END && c < SVE_META_PHEMLIGHT_END) {
184  return (HelpersPHEMlight::computePMx(c, v, 0, slope) + HelpersPHEMlight::computePMx(c, v - a, a, slope)) * tt / 2.;
185  } else {
186  return 0;
187  }
188 }
189 
190 
191 SUMOReal
192 PollutantsInterface::computeDefaultFuel(SUMOEmissionClass c, double v, double a, double slope, SUMOReal tt) {
193  if (c < SVE_META_HBEFA21_END) {
194  return (HelpersHBEFA::computeFuel(c, v, 0) + HelpersHBEFA::computeFuel(c, v - a, a)) * tt / 2.;
195  } else if (c > SVE_META_HBEFA21_END && c < SVE_META_PHEMLIGHT_END) {
196  return (HelpersPHEMlight::computeFuel(c, v, 0, slope) + HelpersPHEMlight::computeFuel(c, v - a, a, slope)) * tt / 2.;
197  } else {
198  return 0;
199  }
200 }
201 
202 
203 /****************************************************************************/
204 
static SUMOReal computeDefaultCO2(SUMOEmissionClass c, double v, double a, double slope, SUMOReal tt)
Returns the amount of emitted CO2 given the vehicle type and default values for the state (in mg) ...
static SUMOReal computeCO(SUMOEmissionClass c, double v, double a, double slope)
Returns the amount of emitted CO given the vehicle type and state (in mg/s)
static SUMOReal computeCO(SUMOEmissionClass c, double v, double a)
Returns the amount of emitted CO given the vehicle type and state (in mg/s)
static SUMOReal computeHC(SUMOEmissionClass c, double v, double a)
Returns the amount of emitted HC given the vehicle type and state (in mg/s)
static SUMOReal computePMx(SUMOEmissionClass c, double v, double a, double slope)
Returns the amount of emitted PMx given the vehicle type and state (in mg/s)
static SUMOReal computeHC(SUMOEmissionClass c, double v, double a, double slope)
Returns the amount of emitted HC given the vehicle type and state (in mg/s)
static SUMOReal computeDefaultHC(SUMOEmissionClass c, double v, double a, double slope, SUMOReal tt)
Returns the amount of emitted HC given the vehicle type and default values for the state (in mg) ...
static SUMOReal computeNOx(SUMOEmissionClass c, double v, double a, double slope)
Returns the amount of emitted NOx given the vehicle type and state (in mg/s)
static SUMOReal computeDefaultNOx(SUMOEmissionClass c, double v, double a, double slope, SUMOReal tt)
Returns the amount of emitted NOx given the vehicle type and default values for the state (in mg) ...
static SUMOReal computeFuel(SUMOEmissionClass c, double v, double a, double slope)
Returns the amount of consumed fuel given the vehicle type and state (in ml/s)
SUMOEmissionClass
Definition of vehicle emission classes.
static SUMOReal computeCO2(SUMOEmissionClass c, double v, double a, double slope)
Returns the amount of emitted CO2 given the vehicle type and state (in mg/s)
static SUMOReal computeDefaultPMx(SUMOEmissionClass c, double v, double a, double slope, SUMOReal tt)
Returns the amount of emitted PMx given the vehicle type and default values for the state (in mg) ...
static SUMOReal computeNOx(SUMOEmissionClass c, double v, double a, double slope)
Returns the amount of emitted NOx given the vehicle type and state (in mg/s)
static SUMOReal getMaxAccel(SUMOEmissionClass c, double v, double a, double slope)
Returns the maximum possible acceleration.
static SUMOReal computeCO2(SUMOEmissionClass c, double v, double a)
Returns the amount of emitted CO2 given the vehicle type and state (in mg/s)
static SUMOReal computeHC(SUMOEmissionClass c, double v, double a, double slope)
Returns the amount of emitted HC given the vehicle type and state (in mg/s)
static SUMOReal computeDefaultFuel(SUMOEmissionClass c, double v, double a, double slope, SUMOReal tt)
Returns the amount of fuel given the vehicle type and default values for the state (in ml) ...
static SUMOReal computeDefaultCO(SUMOEmissionClass c, double v, double a, double slope, SUMOReal tt)
Returns the amount of emitted CO given the vehicle type and default values for the state (in mg) ...
static SUMOReal computeCO2(SUMOEmissionClass c, double v, double a, double slope)
Returns the amount of emitted CO2 given the vehicle type and state (in mg/s)
static SUMOReal computeCO(SUMOEmissionClass c, double v, double a, double slope)
Returns the amount of emitted CO given the vehicle type and state (in mg/s)
static SUMOReal computeNOx(SUMOEmissionClass c, double v, double a)
Returns the amount of emitted NOx given the vehicle type and state (in mg/s)
static SUMOReal computeFuel(SUMOEmissionClass c, double v, double a, double slope)
Returns the amount of consumed fuel given the vehicle type and state (in ml/s)
static SUMOReal getMaxAccel(SUMOEmissionClass c, double v, double a, double slope)
Returns the maximum possible acceleration.
static SUMOReal computeFuel(SUMOEmissionClass c, double v, double a)
Returns the amount of consumed fuel given the vehicle type and state (in ml/s)
static SUMOReal computePMx(SUMOEmissionClass c, double v, double a)
Returns the amount of emitted PMx given the vehicle type and state (in mg/s)
#define SUMOReal
Definition: config.h:215
static SUMOReal computePMx(SUMOEmissionClass c, double v, double a, double slope)
Returns the amount of emitted PMx given the vehicle type and state (in mg/s)