MEASUR-Tools-Suite v1.0.11
The MEASUR Tools Suite is a collection of industrial efficiency calculations written in C++ and with bindings for compilation to WebAssembly.
Loading...
Searching...
No Matches
gas_composition.h
Go to the documentation of this file.
1#pragma once
2#include <string>
3
4#include "physics/gas_constants.h"
5#include "physics/gas_properties.h"
6using namespace gas_properties;
7using namespace gas_constants;
8
23namespace gas_composition {
24
26 double mO2;
27 double mN2;
28 double mCO2;
29 double mH2O;
30 double mSO2;
31};
32
70 public:
71 std::string substance;
72 GasProperties ch4;
73 GasProperties c2h6;
76 GasProperties c3h8;
77 GasProperties c4h10_cnh2n;
78 GasProperties h2o;
80 GasProperties co2;
81 GasProperties so2;
83 double total_composition_weight;
84 double heating_value;
85 double heating_value_volume;
86 double specific_gravity;
87 double stoichometric_air;
88 GasComposition(const std::string substance, double ch4_percent, double c2h6_percent, double n2_percent,
89 double h2_percent, double c3h8_percent, double c4h10_cnh2n_percent, double h2o_percent,
90 double co_percent, double co2_percent, double so2_percent, double o2_percent)
91 : substance(substance), ch4(specificHeatCH4, 0, 0, 0, 0, 0, 0, 0, 0, 0),
92 c2h6(specificHeatC2H6, 0, 0, 0, 0, 0, 0, 0, 0, 0), n2(specificHeatN2, 0, 0, 0, 0, 0, 0, 0, 0, 0),
93 h2(specificHeatH2, 0, 0, 0, 0, 0, 0, 0, 0, 0), c3h8(specificHeatC3H8, 0, 0, 0, 0, 0, 0, 0, 0, 0),
94 c4h10_cnh2n(specificHeatC4H10CnH2n, 0, 0, 0, 0, 0, 0, 0, 0, 0),
95 h2o(specificHeatH2O, 0, 0, 0, 0, 0, 0, 0, 0, 0), co(specificHeatCO, 0, 0, 0, 0, 0, 0, 0, 0, 0),
96 co2(specificHeatCO2, 0, 0, 0, 0, 0, 0, 0, 0, 0), so2(specificHeatSO2, 0, 0, 0, 0, 0, 0, 0, 0, 0),
97 o2(specificHeatO2, 0, 0, 0, 0, 0, 0, 0, 0, 0) {
98 double total_percent = ch4_percent + c2h6_percent + n2_percent + h2_percent + c3h8_percent +
99 c4h10_cnh2n_percent + h2o_percent + co_percent + co2_percent + so2_percent + o2_percent;
100 setCH4(ch4_percent, ch4_percent / total_percent);
101 setC2H6(c2h6_percent, c2h6_percent / total_percent);
102 setN2(n2_percent, n2_percent / total_percent);
103 setH2(h2_percent, h2_percent / total_percent);
104 setC3H8(c3h8_percent, c3h8_percent / total_percent);
105 setC4H10CnH2n(c4h10_cnh2n_percent, c4h10_cnh2n_percent / total_percent);
106 setH2O(h2o_percent, h2o_percent / total_percent);
107 setCO(co_percent, co_percent / total_percent);
108 setCO2(co2_percent, co2_percent / total_percent);
109 setSO2(so2_percent, so2_percent / total_percent);
110 setO2(o2_percent, o2_percent / total_percent);
111 setTotalCompositionWeight();
112 setHeatingValue();
113 setHeatingValueVolume();
114 setSpecificGravity();
115 setStoichometricAir();
116 };
117
125 double excessAirFromO2(double flue_gas_o2_percentage);
126
134 double o2PercentageFromExcessAir(double excess_air);
135
143 double estimateExcessAirFromO2(double flue_gas_o2_percentage);
144
152 double calculateEnthalpyAtSaturation(double partial_pressure_water_vapor);
153
161 double calculateSaturationTemperature(double partial_pressure_water_vapor);
162
163 std::array<GasProperties*, 11> getConstituents() {
164 return {&ch4, &c2h6, &n2, &h2, &c3h8, &c4h10_cnh2n, &h2o, &co, &co2, &so2, &o2};
165 };
166
175 double adjustedFlueGasO2ForCalcError(double excess_air, double flue_gas_o2);
176
177 private:
178 void setCH4(double composition_percent, double composition_by_volume) {
179 ch4 = GasProperties(specificHeatCH4, kCh4MolecularWeight, kCh4SpecificWeight, composition_percent,
180 composition_by_volume, kCh4O2Generated, kCh4HeatingValue, kCh4HeatingValueVolume,
181 kCh4H2oGenerated, kCh4Co2Generated);
182 }
183
184 void setC2H6(double composition_percent, double composition_by_volume) {
185 c2h6 = GasProperties(specificHeatC2H6, kC2h6MolecularWeight, kC2h6SpecificWeight, composition_percent,
186 composition_by_volume, kC2h6O2Generated, kC2h6HeatingValue, kC2h6HeatingValueVolume,
187 kC2h6H2oGenerated, kC2h6Co2Generated);
188 }
189
190 void setN2(double composition_percent, double composition_by_volume) {
191 n2 = GasProperties(specificHeatN2, kN2MolecularWeight, kN2SpecificWeight, composition_percent,
192 composition_by_volume, 0, 0, 0, 0, 0);
193 }
194
195 void setH2(double composition_percent, double composition_by_volume) {
196 h2 = GasProperties(specificHeatH2, kH2MolecularWeight, kH2SpecificWeight, composition_percent,
197 composition_by_volume, kH2O2Generated, kH2HeatingValue, kH2HeatingValueVolume,
198 kH2H2oGenerated, 0);
199 }
200
201 void setC3H8(double composition_percent, double composition_by_volume) {
202 c3h8 = GasProperties(specificHeatC3H8, kC3h8MolecularWeight, kC3h8SpecificWeight, composition_percent,
203 composition_by_volume, kC3h8O2Generated, kC3h8HeatingValue, kC3h8HeatingValueVolume,
204 kC3h8H2oGenerated, kC3h8Co2Generated);
205 }
206
207 void setC4H10CnH2n(double composition_percent, double composition_by_volume) {
208 c4h10_cnh2n = GasProperties(specificHeatC4H10CnH2n, kC4h10Cnh2nMolecularWeight, kC4h10Cnh2nSpecificWeight,
209 composition_percent, composition_by_volume, kC4h10Cnh2nO2Generated,
210 kC4h10Cnh2nHeatingValue, kC4h10Cnh2nHeatingValueVolume,
211 kC4h10Cnh2nH2oGenerated, kC4h10Cnh2nCo2Generated);
212 }
213
214 void setH2O(double composition_percent, double composition_by_volume) {
215 h2o = GasProperties(specificHeatH2O, kH2oMolecularWeight, kH2oSpecificWeight, composition_percent,
216 composition_by_volume, 0, 0, 0, kH2oH2oGenerated, 0);
217 }
218
219 void setCO(double composition_percent, double composition_by_volume) {
220 co = GasProperties(specificHeatCO, kCoMolecularWeight, kCoSpecificWeight, composition_percent,
221 composition_by_volume, kCoO2Generated, kCoHeatingValue, kCoHeatingValueVolume, 0,
222 kCoCo2Generated);
223 }
224
225 void setCO2(double composition_percent, double composition_by_volume) {
226 co2 = GasProperties(specificHeatCO2, kCo2MolecularWeight, kCo2SpecificWeight, composition_percent,
227 composition_by_volume, 0, 0, 0, 0, kCo2Co2Generated);
228 }
229
230 void setSO2(double composition_percent, double composition_by_volume) {
231 so2 = GasProperties(specificHeatSO2, kSo2MolecularWeight, kSo2SpecificWeight, composition_percent,
232 composition_by_volume, 0, 0, 0, 0, 0);
233 }
234
235 void setO2(double composition_percent, double composition_by_volume) {
236 o2 = GasProperties(specificHeatO2, kO2MolecularWeight, kO2SpecificWeight, composition_percent,
237 composition_by_volume, kO2O2Generated, 0, 0, 0, 0);
238 }
239
240 void setTotalCompositionWeight();
241 void setHeatingValue();
242 void setHeatingValueVolume();
243 void setSpecificGravity();
244 void setStoichometricAir();
245 GasFlueGasComponents getMassFlueGasComponents(double excess_air);
246};
247}; // namespace gas_composition
Represents a fuel gas mixture and its properties for process heat calculations.
double adjustedFlueGasO2ForCalcError(double excess_air, double flue_gas_o2)
Iteratively adjusts calculated flue gas O2 to minimize error with target excess air.
double calculateEnthalpyAtSaturation(double partial_pressure_water_vapor)
Calculates enthalpy at saturation for a given partial pressure of water vapor.
double calculateSaturationTemperature(double partial_pressure_water_vapor)
Calculates saturation temperature for a given partial pressure of water vapor.
double excessAirFromO2(double flue_gas_o2_percentage)
Calculates excess air percentage from flue gas oxygen percentage.
double estimateExcessAirFromO2(double flue_gas_o2_percentage)
Estimates excess air percentage from flue gas oxygen percentage.
double o2PercentageFromExcessAir(double excess_air)
Calculates flue gas oxygen percentage from excess air percentage.
Contains functions for gas composition calculations.