Skip to content

Commit

Permalink
Support fuel NOx or not
Browse files Browse the repository at this point in the history
  • Loading branch information
wallytutor committed Oct 22, 2024
1 parent 6a68bdf commit 01888a6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
22 changes: 15 additions & 7 deletions src/wallymodules/PyCanteraTools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,22 @@ function chons_fuel_formula(x, y, z, n, s)
return L"%$(formula)"
end

function chons_fuel_equation(x, y, z, n, s)
a = (1/2)*(2x + 2s + n + y/2 - z)
function chons_fuel_equation(x, y, z, n, s; burn_nitrogen = false)
a = 2x + 2s + y/2 - z
a = (burn_nitrogen ? a + n : a) / 2

o2 = "$(@sprintf("%.6f", a)) \\:\\mathrm{O}_{2}"
co2 = "$(@sprintf("%.6f", x)) \\:\\mathrm{CO}_2"
h2o = "$(@sprintf("%.6f", y/2)) \\:\\mathrm{H}_2\\mathrm{O}"
so2 = "$(@sprintf("%.6f", s)) \\:\\mathrm{SO}_2"
no1 = "$(@sprintf("%.6f", n)) \\:\\mathrm{NO}"
return L"\mathrm{HFO} + %$(o2) → %$(co2) + %$(h2o) + %$(so2) + %$(no1)"
co2 = "$(@sprintf("%.6f", x)) \\:\\mathrm{CO}_2"
h2o = "$(@sprintf("%.6f", y/2)) \\:\\mathrm{H}_2\\mathrm{O}"
so2 = "$(@sprintf("%.6f", s)) \\:\\mathrm{SO}_2"

nit = if burn_nitrogen
"$(@sprintf("%.6f", n)) \\:\\mathrm{NO}"
else
"$(@sprintf("%.6f", n/2)) \\:\\mathrm{N}_2"
end

return L"\mathrm{HFO} + %$(o2) → %$(co2) + %$(h2o) + %$(so2) + %$(nit)"
end

##############################################################################
Expand Down
19 changes: 15 additions & 4 deletions src/wallytoolbox/thermochemistry/combustion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ function Base.String(f::EmpiricalFuel)
end

"""
oxidizer_mass_flow_rate(f::EmpiricalFuel; y_o2 = 0.23)
oxidizer_mass_flow_rate(
f::EmpiricalFuel;
y_o2 = 0.23,
burn_nitrogen = false
)
Computes the required amount of oxidizer to perform complete combustion
of 1 kg provided empirical fuel. The value of `y_o2` represents the mass
Expand All @@ -90,11 +94,15 @@ fraction of oxygen in oxidizer; default value is typical for air.
```jldoctest
julia> fuel = EmpiricalFuel([0.937, 0.063, 0.0]; scaler=:C=>10);
julia> oxidizer_mass_flow_rate(fuel)
julia> oxidizer_mass_flow_rate(fuel; burn_nitrogen = true)
13.02691759229764
```
"""
function oxidizer_mass_flow_rate(f::EmpiricalFuel; y_o2 = 0.23)
function oxidizer_mass_flow_rate(
f::EmpiricalFuel;
y_o2 = 0.23,
burn_nitrogen = false
)
m_o2 = molecularmass(Stoichiometry(; O = 2))

fn = EmpiricalFuel(f.Y; f.elements, scaler=nothing)
Expand All @@ -106,9 +114,12 @@ function oxidizer_mass_flow_rate(f::EmpiricalFuel; y_o2 = 0.23)

get_element(e) = fn.X[findall(==(e), fn.elements) |> first]
rhs += -1*((:O in fn.elements) ? get_element(:O) : 0.0)
rhs += 1*((:N in fn.elements) ? get_element(:N) : 0.0)
rhs += 2*((:S in fn.elements) ? get_element(:S) : 0.0)

if burn_nitrogen
rhs += 1*((:N in fn.elements) ? get_element(:N) : 0.0)
end

return (1//2) * rhs * m_o2 / y_o2
end

Expand Down
1 change: 1 addition & 0 deletions tools/vscode/user-data/User/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,6 @@
},
"redhat.telemetry.enabled": false,
"git.confirmSync": false,
"git.autofetch": true,

}

0 comments on commit 01888a6

Please sign in to comment.