Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion data/example_data
2 changes: 1 addition & 1 deletion doc/sphinx/reference/releasenotes/v3.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The Cantera development team is pleased to announce the availability of Cantera
- Introduce factory for creating functor objects (`newFunc1` in C++; `func_new_basic`, `func_new_advanced`, `func_new_compound`, and `func_new_modified` in `clib`; and `Func1.cxx_functor` in Python) (<a href="../../cxx/dc/d4c/group__func1.html">documentation</a>, [#1513](https://github.com/Cantera/cantera/pull/1513), [#1521](https://github.com/Cantera/cantera/pull/1521))
- Provide a more complete interface to the C++ `Units` class in Python ([#1285](https://github.com/Cantera/cantera/pull/1285))
- Add a sample program demonstrating the use of the Cantera C interface, `clib` ([#1454](https://github.com/Cantera/cantera/pull/1454))
- Add an example of modelling a porous media burner using the `ExtensibleReactor` class ([`PorousMediaBurner.py`](/examples/python/reactors/PorousMediaBurner), [#1443](https://github.com/Cantera/cantera/pull/1443))
- Add an example of modelling a porous media burner using the `ExtensibleReactor` class ([`PorousMediaBurner.py`](/examples/python/reactors/porous_media_burner), [#1443](https://github.com/Cantera/cantera/pull/1443))
- Add an example demonstrating saving and loading of 1D flame simulations and restarting with different initial guesses ([`flame_initial_guess.py`](/examples/python/onedim/flame_initial_guess), [#1293](https://github.com/Cantera/cantera/pull/1293))
- The test suite now includes a comprehensive set of thermodynamic consistency tests for all phase models ([E#114](https://github.com/Cantera/enhancements/issues/114), [#1299](https://github.com/Cantera/cantera/pull/1299), [#1501](https://github.com/Cantera/cantera/pull/1501))
- Consolidate literature references in the C++ documentation into a <a href="../../cxx/d0/de3/citelist.html">bibliography</a> ([#1550](https://github.com/Cantera/cantera/pull/1550), [#1575](https://github.com/Cantera/cantera/pull/1575))
Expand Down
2 changes: 1 addition & 1 deletion doc/sphinx/userguide/extensible-reactor.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ methods listed in the documentation for the {py:class}`ExtensibleReactor` class.
methods. The result is a reactor network with a wall between two reactors that has
inertia and takes time to respond to changes in the reactor's pressure.

[Reactor cascade model for reactive flows in inert porous media](/examples/python/reactors/PorousMediaBurner)
[Reactor cascade model for reactive flows in inert porous media](/examples/python/reactors/porous_media_burner)
: This example showcases the use of {py:class}`ExtensibleReactor` to add a temperature
equation for a solid phase and custom heat transfer/radiation models. Each reactor in
the network represents a different spatial locations along the length of a porous
Expand Down
2 changes: 1 addition & 1 deletion doc/sphinx/userguide/python-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,6 @@ interest:
* [](/examples/python/thermo/equations_of_state)
* [](/examples/python/kinetics/lithium_ion_battery)
* [](/examples/python/reactors/continuous_reactor)
* [](/examples/python/reactors/NonIdealShockTube)
* [](/examples/python/reactors/non_ideal_shock_tube)
* [](/examples/python/onedim/flamespeed_sensitivity)
* [](/examples/python/onedim/premixed_counterflow_twin_flame)
20 changes: 9 additions & 11 deletions samples/python/reactors/fuel_injection.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
a `MassFlowController`, and the use of the `SolutionArray` class to store results
during reactor network integration and use these results to generate plots.

Requires: cantera >= 2.5.0, matplotlib >= 2.0
Requires: cantera >= 3.1, matplotlib >= 2.0

.. tags:: Python, combustion, reactor network, kinetics, pollutant formation, plotting
"""
Expand All @@ -33,17 +33,15 @@
r = ct.IdealGasReactor(gas)
r.volume = 0.001 # 1 liter

def fuel_mdot(total_mass=3.0e-3, std_dev=0.5, center_time=2.0):
"""Create a Gaussian pulse function."""
# units are kg for mass and seconds for times
amplitude = total_mass / (std_dev * np.sqrt(2 * np.pi))
fwhm = std_dev * 2 * np.sqrt(2 * np.log(2))
return ct.Func1("Gaussian", [amplitude, center_time, fwhm])

def fuel_mdot(t):
"""Create an inlet for the fuel, supplied as a Gaussian pulse"""
total = 3.0e-3 # mass of fuel [kg]
width = 0.5 # width of the pulse [s]
t0 = 2.0 # time of fuel pulse peak [s]
amplitude = total / (width * np.sqrt(2*np.pi))
return amplitude * np.exp(-(t-t0)**2 / (2*width**2))


mfc = ct.MassFlowController(inlet, r, mdot=fuel_mdot)
# Create an inlet for the fuel, supplied as a Gaussian pulse
mfc = ct.MassFlowController(inlet, r, mdot=fuel_mdot())

# Create the reactor network
sim = ct.ReactorNet([r])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@
EN_peak = 190 * 1e-21 # 190 Td
pulse_center = 24e-9 # 24 ns
pulse_width = 3e-9 # standard deviation (3 ns)

def gaussian_EN(t):
return EN_peak * np.exp(-((t - pulse_center)**2) / (2 * pulse_width**2))
pulse_fwhm = pulse_width * 2 * (2 * np.log(2))**.5
gaussian_EN = ct.Func1("Gaussian", [EN_peak, pulse_center, pulse_fwhm])

# setup
gas = ct.Solution('example_data/methane-plasma-pavan-2023.yaml')
Expand All @@ -55,7 +54,7 @@ def gaussian_EN(t):
dt_chunk = 1e-9 # 1 ns chunk
states = ct.SolutionArray(gas, extra=['t'])

print('{:>10} {:>10} {:>10} {:>14}'.format('t [s]', 'T [K]', 'P [Pa]', 'h [J/kg]'))
print(f"{'t [s]':>10} {'T [K]':>10} {'P [Pa]':>10} {'h [J/kg]':>14}")

# simulate in 1 ns chunks
t = 0.0
Expand All @@ -66,8 +65,7 @@ def gaussian_EN(t):
while sim.time < t_end:
sim.advance(sim.time + dt_max) #use sim.step
states.append(r.thermo.state, t=sim.time)
print('{:10.3e} {:10.3f} {:10.3f} {:14.6f}'.format(
sim.time, r.T, r.thermo.P, r.thermo.h))
print(f"{sim.time:10.3e} {r.T:10.3f} {r.thermo.P:10.3f} {r.thermo.h:14.6f}")

EN_t = gaussian_EN(t)
gas.reduced_electric_field = EN_t
Expand Down
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For these two existing examples, it would be helpful to add redirects for these names to the .htaccess files in the cantera-website repository.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,14 @@ def effectiveConductivityYZA(Ts): # for yittria-stabilized zirconia alumina
pore_diameter=0.0085,
heat_conductivity=effectiveConductivitySiC,
specific_area=246.075,
solid_phase=ct.Solution("example_data/silicon_carbide.yaml"),
solid_phase=ct.Solution("example_data/silicon-carbide.yaml"),
emissivity=0.85)

SiC10PPI = SolidProperties(porosity=0.84,
pore_diameter=0.00134,
heat_conductivity=effectiveConductivitySiC,
specific_area=978.,
solid_phase=ct.Solution("example_data/silicon_carbide.yaml"),
solid_phase=ct.Solution("example_data/silicon-carbide.yaml"),
emissivity=0.85)


Expand Down
10 changes: 5 additions & 5 deletions test/python/test_reactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2474,15 +2474,15 @@ def setup_combustor_tests(self):
fuel_mdot = factor * fuel_mw

# The igniter will use a time-dependent igniter mass flow rate.
def igniter_mdot(t, t0=0.1, fwhm=0.05, amplitude=0.1):
return amplitude * math.exp(-(t - t0) ** 2 * 4 * math.log(2) / fwhm ** 2)
def igniter_mdot(amplitude=0.1, t0=0.1, fwhm=0.05):
return ct.Func1("Gaussian", [amplitude, t0, fwhm])

# create and install the mass flow controllers. Controllers m1 and m2 provide
# constant mass flow rates, and m3 provides a short Gaussian pulse only to ignite
# the mixture
# constant mass flow rates, and m3 provides a short Gaussian pulse only to
# ignite the mixture
m1 = ct.MassFlowController(fuel_in, combustor, mdot=fuel_mdot)
m2 = ct.MassFlowController(oxidizer_in, combustor, mdot=oxidizer_mdot)
m3 = ct.MassFlowController(igniter, combustor, mdot=igniter_mdot)
m3 = ct.MassFlowController(igniter, combustor, mdot=igniter_mdot())

# put a valve on the exhaust line to regulate the pressure
valve = ct.Valve(combustor, exhaust, K=1.0)
Expand Down
Loading