Examples¶
Learn PyFDS through practical, real-world examples.
Overview¶
This section contains complete, working examples demonstrating PyFDS features and capabilities. Each example includes full source code with explanations.
Example Categories¶
-
:material-home-fire: Basic Examples
Simple simulations to get started
-
Advanced Examples
Complex scenarios with multiple features
-
Special Applications
Specialized simulation types
-
Parametric Studies
Automating multiple simulations
-
:material-workflow: Complete Workflows
End-to-end simulation workflows
Featured Examples¶
Basic Room Fire¶
A simple 5m × 5m room with a 1m² fire source.
from pyfds import Simulation
sim = Simulation(chid='room_fire', title='Basic Room Fire')
sim.add(Time(t_end=600.0))
sim.add(Mesh(ijk=Grid3D.of(50, 50, 25), xb=Bounds3D.of(0, 5, 0, 5, 0, 2.5)))
sim.add(Surface(id='FIRE', hrrpua=1000.0, color='RED'))
sim.add(Obstruction(xb=Bounds3D.of(2, 3, 2, 3, 0, 0.1), surf_id='FIRE'))
sim.add(Device(id='TEMP_CEILING', quantity='TEMPERATURE', xyz=Point3D.of(2.5, 2.5, 2.4)))
sim.write('room_fire.fds')
HVAC System¶
Room with supply and exhaust ventilation.
from pyfds import Simulation
sim = Simulation(chid='hvac_room', title='HVAC Room Simulation')
sim.add(Time(t_end=600.0))
sim.add(Mesh(ijk=Grid3D.of(60, 60, 30), xb=Bounds3D.of(0, 6, 0, 6, 0, 3)))
# Set ambient conditions
sim.set_misc(tmpa=22.0, humidity=50.0)
# Supply vent (0.5 m³/s)
sim.add(Vent(xb=Bounds3D.of(2, 2.5, 2, 2.5, 3, 3), surf_id='HVAC', volume_flow=0.5))
# Exhaust vent (-0.4 m³/s)
sim.add(Vent(xb=Bounds3D.of(4, 4.5, 4, 4.5, 3, 3), surf_id='HVAC', volume_flow=-0.4))
sim.write('hvac_room.fds')
Wildfire Simulation¶
Large-scale outdoor fire spread.
from pyfds import Simulation
from pyfds.core.enums import TurbulenceModel
sim = Simulation(chid='wildfire', title='Wildfire Spread')
sim.add(Time(t_end=1800.0))
sim.add(Mesh(ijk=Grid3D.of(100, 100, 30), xb=Bounds3D.of(0, 100, 0, 100, 0, 30)))
# Configure for wildfire
sim.set_misc(
level_set_mode=1, # Fire spread mode
tmpa=35.0, # Hot ambient
humidity=15.0, # Low humidity
turbulence_model=TurbulenceModel.VREMAN
)
# Open boundaries
sim.add(Vent(mb='XMIN', surf_id='OPEN'))
sim.add(Vent(mb='XMAX', surf_id='OPEN'))
sim.add(Vent(mb='YMIN', surf_id='OPEN'))
sim.add(Vent(mb='YMAX', surf_id='OPEN'))
sim.write('wildfire.fds')
Example Index¶
By Difficulty¶
| Level | Examples |
|---|---|
| Beginner | Basic room fire, Simple corridor |
| Intermediate | HVAC system, Circular burner, Multiple rooms |
| Advanced | Wildfire, Heat transfer only, Sprinkler system |
By Feature¶
| Feature | Examples |
|---|---|
| VENT | HVAC system, Circular burner, Wildfire |
| MISC | Wildfire, Heat transfer, HVAC system |
| RAMP | Time-varying HRR, Temperature-dependent properties |
| MATL | Multi-layer wall, Heat transfer |
| CTRL | Sprinkler activation, HVAC control |
| Execution | Background jobs, Progress monitoring |
By Application¶
| Application | Examples |
|---|---|
| Building Fire | Room fire, Corridor, Multi-room |
| HVAC | Supply/exhaust, Pressurization |
| Wildfire | Vegetation fire, Wind-driven spread |
| Research | Grid convergence, Parametric study |
Running Examples¶
All examples are available in the project repository:
# Clone repository
git clone https://github.com/GraysonBellamy/pyfds.git
cd pyfds/examples
# Run an example
python basic_room_fire.py
# Or with uv
uv run python basic_room_fire.py
Example Structure¶
Each example follows this structure:
- Description - What the example demonstrates
- Key Features - Main PyFDS features used
- Complete Code - Full working Python script
- Explanation - Line-by-line breakdown
- Expected Output - What the FDS file looks like
- Variations - How to modify the example
Contributing Examples¶
Have a useful example? We'd love to include it!
- Follow the Contributing Guide
- Add your example to
examples/ - Document it following the structure above
- Open a pull request