ReactionBuilder¶
ReactionBuilder
¶
Bases: Builder[Reaction]
Builder for creating REAC namelists.
Provides convenient methods for defining combustion reactions using either predefined fuels from the database or custom fuel compositions.
Examples:
>>> # Use predefined fuel
>>> reac = ReactionBuilder() \
... .fuel('PROPANE') \
... .soot_yield(0.015) \
... .build()
>>> # Custom fuel with heat of combustion
>>> reac = ReactionBuilder() \
... .fuel('CUSTOM_FUEL') \
... .heat_of_combustion(44600) \
... .soot_yield(0.01) \
... .co_yield(0.02) \
... .radiative_fraction(0.33) \
... .build()
>>> # Complex fuel with all parameters
>>> reac = ReactionBuilder() \
... .fuel('POLYURETHANE') \
... .yields(soot=0.10, co=0.02) \
... .radiative_fraction(0.30) \
... .auto_ignition_temperature(350) \
... .build()
Initialize the ReactionBuilder.
Source code in src/pyfds/builders/reaction.py
Functions¶
fuel
¶
Use a predefined fuel from the database.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Name of the fuel (case-insensitive)
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReactionBuilder
|
Self for method chaining |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If fuel name is not in the database |
Examples:
Notes
Available fuels: METHANE, ETHANE, PROPANE, BUTANE, HYDROGEN, N-HEPTANE, N-HEXANE, GASOLINE, ACETONE, METHANOL, ETHANOL, POLYURETHANE, WOOD, PMMA, POLYSTYRENE, POLYETHYLENE, POLYPROPYLENE
Source code in src/pyfds/builders/reaction.py
predefined_fuel
¶
Use a predefined fuel from the database.
This is an alias for fuel() method.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Name of the fuel (case-insensitive)
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReactionBuilder
|
Self for method chaining |
Source code in src/pyfds/builders/reaction.py
custom_fuel
¶
Define a custom fuel composition.
For simple chemistry, you can specify the fuel composition using the atom counts C, H, O, N. If using a predefined fuel, you can just specify heat_of_combustion to override the default.
| PARAMETER | DESCRIPTION |
|---|---|
c
|
Number of carbon atoms in fuel molecule
TYPE:
|
h
|
Number of hydrogen atoms in fuel molecule
TYPE:
|
o
|
Number of oxygen atoms in fuel molecule
TYPE:
|
n
|
Number of nitrogen atoms in fuel molecule
TYPE:
|
heat_of_combustion
|
Heat of combustion in kJ/kg
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReactionBuilder
|
Self for method chaining |
Examples:
>>> # Define heptane-like fuel
>>> reac = ReactionBuilder() \
... .custom_fuel(c=7, h=16, heat_of_combustion=44600) \
... .build()
>>> # Override heat of combustion for predefined fuel
>>> reac = ReactionBuilder() \
... .predefined_fuel('HEPTANE') \
... .custom_fuel(heat_of_combustion=44000) \
... .build()
Source code in src/pyfds/builders/reaction.py
heat_of_combustion
¶
Set heat of combustion.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
Heat of combustion in kJ/kg
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReactionBuilder
|
Self for method chaining |
Source code in src/pyfds/builders/reaction.py
soot_yield
¶
Set soot yield.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
Soot yield in kg soot per kg fuel, range [0, 1]
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReactionBuilder
|
Self for method chaining |
Source code in src/pyfds/builders/reaction.py
co_yield
¶
Set CO yield.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
CO yield in kg CO per kg fuel, range [0, 1]
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReactionBuilder
|
Self for method chaining |
Source code in src/pyfds/builders/reaction.py
yields
¶
Set both soot and CO yields.
| PARAMETER | DESCRIPTION |
|---|---|
soot
|
Soot yield, default: 0.0
TYPE:
|
co
|
CO yield, default: 0.0
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReactionBuilder
|
Self for method chaining |
Examples:
>>> reac = ReactionBuilder() \
... .fuel('PROPANE') \
... .yields(soot=0.015, co=0.02) \
... .build()
Source code in src/pyfds/builders/reaction.py
radiative_fraction
¶
Set radiative fraction.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
Fraction of energy radiated, range [0, 1] Typical values: 0.3-0.4 for most fuels
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReactionBuilder
|
Self for method chaining |
Source code in src/pyfds/builders/reaction.py
ramp_chi_r
¶
Set ramp for time-varying radiative fraction.
| PARAMETER | DESCRIPTION |
|---|---|
ramp_id
|
Ramp ID for radiative fraction
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReactionBuilder
|
Self for method chaining |
Source code in src/pyfds/builders/reaction.py
auto_ignition_temperature
¶
Set auto-ignition temperature.
| PARAMETER | DESCRIPTION |
|---|---|
temp
|
Auto-ignition temperature in °C
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReactionBuilder
|
Self for method chaining |
Source code in src/pyfds/builders/reaction.py
with_extinction
¶
Configure extinction parameters.
Note: The extinction MODEL (EXTINCTION ½) is set on MISC namelist, not REAC. This method sets the CRITICAL_FLAME_TEMPERATURE on REAC.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
Extinction model: 'EXTINCTION 1' or 'EXTINCTION 2'. Note: This is informational only - set on MISC.
TYPE:
|
critical_temp
|
Critical flame temperature for extinction (°C)
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReactionBuilder
|
Self for method chaining |
Examples:
>>> reac = ReactionBuilder() \
... .fuel('PROPANE') \
... .with_extinction(critical_temp=1200.0) \
... .build()
Source code in src/pyfds/builders/reaction.py
with_species_stoichiometry
¶
Set species stoichiometry.
| PARAMETER | DESCRIPTION |
|---|---|
species
|
List of species IDs
TYPE:
|
coefficients
|
List of stoichiometric coefficients
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReactionBuilder
|
Self for method chaining |
Examples:
>>> reac = ReactionBuilder() \
... .fuel('METHANE') \
... .with_species_stoichiometry(['CO2', 'H2O'], [1.0, 2.0]) \
... .build()
Source code in src/pyfds/builders/reaction.py
use_non_ideal_hoc
¶
Use non-ideal heat of combustion.
| RETURNS | DESCRIPTION |
|---|---|
ReactionBuilder
|
Self for method chaining |
Examples:
Source code in src/pyfds/builders/reaction.py
reaction_id
¶
Set reaction identifier.
| PARAMETER | DESCRIPTION |
|---|---|
id
|
Reaction identifier
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReactionBuilder
|
Self for method chaining |
Source code in src/pyfds/builders/reaction.py
hcn_yield
¶
Set HCN yield.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
HCN yield in kg HCN per kg fuel, range [0, 1]
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReactionBuilder
|
Self for method chaining |
Source code in src/pyfds/builders/reaction.py
energy_per_o2
¶
Set energy per unit mass of O2 consumed.
| PARAMETER | DESCRIPTION |
|---|---|
epumo2
|
Energy per unit mass of O2 [kJ/kg]
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReactionBuilder
|
Self for method chaining |
Source code in src/pyfds/builders/reaction.py
complete_heat_of_combustion
¶
Set complete heat of combustion.
| PARAMETER | DESCRIPTION |
|---|---|
hoc_complete
|
Complete heat of combustion [kJ/kg]
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReactionBuilder
|
Self for method chaining |
Source code in src/pyfds/builders/reaction.py
with_two_step_chemistry
¶
Enable two-step chemistry model.
| PARAMETER | DESCRIPTION |
|---|---|
co_fraction
|
Fraction of fuel carbon converted to CO, default: 0.1
TYPE:
|
hcn_fraction
|
Fraction of fuel nitrogen converted to HCN, default: 0.0
TYPE:
|
h2_fraction
|
Fraction of fuel hydrogen converted to H2, default: 0.0
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReactionBuilder
|
Self for method chaining |
Examples:
>>> reac = ReactionBuilder() \
... .fuel('WOOD') \
... .with_two_step_chemistry(co_fraction=0.15, hcn_fraction=0.001) \
... .build()
Source code in src/pyfds/builders/reaction.py
yields_all
¶
Set all product yields.
| PARAMETER | DESCRIPTION |
|---|---|
soot
|
Soot yield, default: 0.0
TYPE:
|
co
|
CO yield, default: 0.0
TYPE:
|
hcn
|
HCN yield, default: 0.0
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReactionBuilder
|
Self for method chaining |
Examples:
>>> reac = ReactionBuilder() \
... .fuel('POLYURETHANE') \
... .yields_all(soot=0.10, co=0.02, hcn=0.001) \
... .build()
Source code in src/pyfds/builders/reaction.py
with_extinction_limit
¶
Set lower oxygen limit for extinction.
| PARAMETER | DESCRIPTION |
|---|---|
lower_o2
|
Lower oxygen index for extinction, range [0, 1]
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReactionBuilder
|
Self for method chaining |
Source code in src/pyfds/builders/reaction.py
with_auto_ignition_exclusion
¶
Add an auto-ignition exclusion zone.
| PARAMETER | DESCRIPTION |
|---|---|
zone_bounds
|
XB bounds for exclusion zone (6 values)
TYPE:
|
temperature
|
Temperature above which ignition is allowed [°C]
TYPE:
|
device_id
|
Device to control exclusion zone
TYPE:
|
control_id
|
Control logic for exclusion zone
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReactionBuilder
|
Self for method chaining |
Examples:
>>> reac = ReactionBuilder() \
... .fuel('PROPANE') \
... .with_auto_ignition_exclusion(
... zone_bounds=(0, 1, 0, 1, 0, 1),
... temperature=300.0
... ) \
... .build()
Source code in src/pyfds/builders/reaction.py
disable_atom_balance_check
¶
Disable atom balance checking.
| RETURNS | DESCRIPTION |
|---|---|
ReactionBuilder
|
Self for method chaining |
with_finite_rate_kinetics
¶
Configure finite-rate Arrhenius kinetics.
| PARAMETER | DESCRIPTION |
|---|---|
a
|
Pre-exponential factor
TYPE:
|
e
|
Activation energy [J/mol]
TYPE:
|
n_t
|
Temperature exponent, default: 0.0
TYPE:
|
species
|
Species IDs for concentration exponents
TYPE:
|
exponents
|
Concentration exponents for each species
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReactionBuilder
|
Self for method chaining |
Source code in src/pyfds/builders/reaction.py
with_third_body
¶
Enable third body reaction.
| PARAMETER | DESCRIPTION |
|---|---|
efficiencies
|
Third body efficiencies
TYPE:
|
species
|
Species IDs for third body efficiencies
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReactionBuilder
|
Self for method chaining |
Source code in src/pyfds/builders/reaction.py
list_fuels
classmethod
¶
List all available predefined fuels.
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
Sorted list of fuel names |
Examples:
Source code in src/pyfds/builders/reaction.py
get_fuel_info
classmethod
¶
Get information about a predefined fuel.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Name of the fuel (case-insensitive)
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
FuelData
|
Dictionary with fuel composition and properties |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If fuel name is not in the database |
Examples:
>>> info = ReactionBuilder.get_fuel_info('PROPANE')
>>> print(info)
{'c': 3, 'h': 8, 'o': 0, 'n': 0, 'hoc': 46000, 'soot_yield': 0.010, ...}
Source code in src/pyfds/builders/reaction.py
Overview¶
ReactionBuilder creates combustion reaction definitions (&REAC namelists) using predefined fuels or custom compositions.
Key Features¶
- Fuel Database: 17 predefined fuels (gases, liquids, solids)
- Custom Fuels: Define C/H/O/N composition
- Product Yields: Soot, CO, radiative fraction
- Auto-Ignition: Temperature specification
Quick Examples¶
Predefined Fuel¶
from pyfds.builders import ReactionBuilder
# Use predefined fuel from database
reac = (
ReactionBuilder()
.fuel('PROPANE')
.yields(soot=0.015, co=0.02)
.radiative_fraction(0.33)
.build()
)
Custom Fuel Composition¶
# Define custom fuel
reac = (
ReactionBuilder()
.custom_fuel(
c=7, # Carbon atoms
h=16, # Hydrogen atoms
heat_of_combustion=44600 # kJ/kg
)
.yields(soot=0.01, co=0.02)
.build()
)
# With oxygen and nitrogen
reac = (
ReactionBuilder()
.custom_fuel(
c=3.52,
h=5.48,
o=0.88,
n=0.32,
heat_of_combustion=23200
)
.build()
)
Complete Configuration¶
reac = (
ReactionBuilder()
.fuel('POLYURETHANE')
.soot_yield(0.10)
.co_yield(0.03)
.radiative_fraction(0.30)
.auto_ignition_temperature(350)
.build()
)
Fuel Database¶
PyFDS includes 17 predefined fuels:
Gases¶
| Fuel | Formula | HOC (kJ/kg) | Soot Yield | CO Yield |
|---|---|---|---|---|
| METHANE | CH₄ | 50000 | 0.001 | 0.001 |
| ETHANE | C₂H₆ | 47500 | 0.005 | 0.003 |
| PROPANE | C₃H₈ | 46000 | 0.010 | 0.004 |
| BUTANE | C₄H₁₀ | 45700 | 0.015 | 0.005 |
| HYDROGEN | H₂ | 120000 | 0.000 | 0.000 |
Liquids¶
| Fuel | Formula | HOC (kJ/kg) | Soot Yield | CO Yield |
|---|---|---|---|---|
| N-HEPTANE | C₇H₁₆ | 44600 | 0.037 | 0.010 |
| N-HEXANE | C₆H₁₄ | 44750 | 0.033 | 0.009 |
| GASOLINE | ~C₇H₁₄ | 43700 | 0.059 | 0.014 |
| ACETONE | C₃H₆O | 25800 | 0.014 | 0.004 |
| METHANOL | CH₃OH | 19900 | 0.001 | 0.003 |
| ETHANOL | C₂H₅OH | 26800 | 0.005 | 0.003 |
Solids¶
| Fuel | Approx. Formula | HOC (kJ/kg) | Soot Yield | CO Yield |
|---|---|---|---|---|
| POLYURETHANE | C₃.₅₂H₅.₄₈O₀.₈₈N₀.₃₂ | 23200 | 0.131 | 0.042 |
| WOOD | C₃.₄H₆.₂O₂.₅ | 12400 | 0.015 | 0.004 |
| PMMA | C₅H₈O₂ | 24900 | 0.022 | 0.004 |
| POLYSTYRENE | C₈H₈ | 39200 | 0.060 | 0.010 |
| POLYETHYLENE | C₂H₄ | 43600 | 0.060 | 0.024 |
| POLYPROPYLENE | C₃H₆ | 43300 | 0.059 | 0.024 |
Querying the Database¶
# List all available fuels
fuels = ReactionBuilder.list_fuels()
print(fuels)
# ['ACETONE', 'BUTANE', 'ETHANE', 'ETHANOL', 'GASOLINE', ...]
# Get detailed info about a fuel
info = ReactionBuilder.get_fuel_info('PROPANE')
print(info)
# {
# 'c': 3,
# 'h': 8,
# 'o': 0,
# 'n': 0,
# 'hoc': 46000,
# 'soot_yield': 0.010,
# 'co_yield': 0.004,
# 'description': 'Propane gas'
# }
# Case-insensitive lookup
info = ReactionBuilder.get_fuel_info('propane') # Works
Usage in Simulations¶
Simple Fire¶
from pyfds import Simulation
from pyfds.builders import ReactionBuilder
sim = Simulation('propane_fire')
# Add reaction
reac = ReactionBuilder().fuel('PROPANE').build()
sim.add_reaction(reac)
# Create fire surface
sim.add(Surface(id='FIRE', hrrpua=1000.0, color='RED'))
sim.add(Obstruction(xb=Bounds3D.of(4.5, 5.5, 4.5, 5.5, 0, 0.1), surf_id='FIRE'))
With Pyrolysis¶
# Pyrolyzing material
polymer = (
MaterialBuilder('POLYMER')
.density(40)
.add_pyrolysis_reaction(
a=1e10,
e=80000,
product_species='FUEL_VAPOR'
)
.build()
)
sim.add_material(polymer)
# Reaction for fuel vapor
reac = ReactionBuilder().fuel('POLYURETHANE').build()
sim.add_reaction(reac)
# Surface with pyrolysis
sim.add(Surface(id='FOAM', matl_id='POLYMER', thickness=0.05))
Custom Fuel with Species¶
# Define custom fuel species
sim.spec(id='MY_FUEL', mw=114) # C₇H₁₆ molecular weight
# Custom fuel for that species
reac = (
ReactionBuilder()
.custom_fuel(c=7, h=16, heat_of_combustion=44600)
.fuel_id('MY_FUEL')
.yields(soot=0.037, co=0.010)
.build()
)
sim.add_reaction(reac)
Product Yields¶
Soot Yield¶
Fraction of fuel mass converted to soot:
Typical values: - Clean burning gases (methane, hydrogen): 0.000-0.005 - Gasoline/alkanes: 0.010-0.040 - Aromatics/plastics: 0.040-0.130
CO Yield¶
Fraction of fuel mass converted to CO:
Typical values: - Complete combustion: 0.001-0.005 - Well-ventilated: 0.004-0.010 - Under-ventilated: 0.010-0.050
Setting Both¶
Radiative Fraction¶
Fraction of heat release radiated:
Typical values: - Small/clean fires: 0.30-0.35 - Sooty fires: 0.25-0.30 - Large pool fires: 0.20-0.30
Auto-Ignition¶
Set auto-ignition temperature:
Common auto-ignition temperatures: - Propane: 450-500°C - Methane: 540°C - Gasoline: 280-450°C - Wood: 300-400°C
Overriding Database Values¶
Database values are defaults that can be overridden:
# Database default: soot_yield=0.010
reac = ReactionBuilder().fuel('PROPANE').build()
assert reac.soot_yield == 0.010
# Override with custom value
reac = ReactionBuilder().fuel('PROPANE').soot_yield(0.020).build()
assert reac.soot_yield == 0.020
Validation¶
The builder validates:
- Fuel specified: Either
.fuel()or.custom_fuel()required - Valid fuel name: Fuel must exist in database
- Positive values: HOC, yields must be non-negative
Chemical Background¶
Combustion Equation¶
General hydrocarbon combustion:
With nitrogen and oxygen in fuel:
where:
Heat of Combustion¶
Lower heating value (LHV) ranges:
- Gases: 45,000-50,000 kJ/kg
- Liquids: 40,000-45,000 kJ/kg
- Solid fuels: 15,000-45,000 kJ/kg
Best Practices¶
Use Database Fuels¶
# Good: Use predefined fuel
reac = ReactionBuilder().fuel('PROPANE').build()
# Avoid: Manually entering known fuel
reac = ReactionBuilder().custom_fuel(c=3, h=8, heat_of_combustion=46000).build()
Realistic Yields¶
# Good: Reasonable yields based on literature
reac = ReactionBuilder().fuel('GASOLINE').yields(soot=0.059, co=0.014).build()
# Avoid: Unrealistic yields
reac = ReactionBuilder().fuel('METHANE').yields(soot=0.5, co=0.9).build()
Override When Needed¶
# Good: Override for specific scenario
reac = (
ReactionBuilder()
.fuel('PROPANE')
.soot_yield(0.030) # Higher soot for under-ventilated
.build()
)
See Also¶
- User Guide - Combustion
- User Guide - Builders
- MaterialBuilder - For pyrolysis materials