Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e374c44
Initial implemetnatino of rust for all equations by CoPilot
simonsantama Jan 8, 2026
f9b8622
Adds equation to list of similar equations, including equation in cib…
simonsantama Jan 11, 2026
4dfe750
Adds equation to list of similar equations, including equation in cib…
simonsantama Jan 11, 2026
7bfe119
Finishes 50-18 for rust
simonsantama Jan 11, 2026
6af661c
Finishes 50-19
simonsantama Jan 11, 2026
a088e07
Finishes 50-18
simonsantama Jan 11, 2026
4e648df
Update crates/fire_dynamics_tools/Cargo.toml
simonsantama Jan 13, 2026
d7e2113
Implements 50-19
simonsantama Jan 15, 2026
aabe100
Start of 50-20
simonsantama Jan 15, 2026
f5d17cd
Implements rust aspect of 50-20
simonsantama Jan 15, 2026
8b3f07d
Finishes first implementation of 50-20
simonsantama Jan 15, 2026
61e27a9
Minor changes to fix issues with docs
simonsantama Jan 15, 2026
d2d6e92
Update crates/python_api/docs/api/sfpe-handbook.rst
simonsantama Jan 15, 2026
3d9423b
Update crates/python_api/src/sfpe_handbook/chapter_50/equation_50_19.rs
simonsantama Jan 15, 2026
6820501
Update crates/sfpe_handbook/src/chapter_50/equation_50_20.rs
simonsantama Jan 15, 2026
cf1b2ed
fixes error in example
simonsantama Jan 15, 2026
58192ee
Fixes error in units
simonsantama Jan 15, 2026
c73134b
Update crates/python_api/src/sfpe_handbook/chapter_50/equation_50_18.rs
simonsantama Jan 15, 2026
eebb7eb
Update crates/python_api/src/sfpe_handbook/chapter_50/equation_50_19.rs
simonsantama Jan 15, 2026
53dcb05
Update crates/python_api/src/sfpe_handbook/chapter_50/equation_50_19.rs
simonsantama Jan 15, 2026
3d9535f
Update crates/python_api/src/sfpe_handbook/chapter_50/equation_50_20.rs
simonsantama Jan 15, 2026
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
23 changes: 23 additions & 0 deletions crates/python_api/docs/api/sfpe-handbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,29 @@ Equation 50.16 - Flow Area Factor for Pressurization Systems
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. automodule:: ofire.sfpe_handbook.chapter_50.equation_50_16
:members:
:undoc-members:
:show-inheritance:

Equation 50.18 - Fractional Effective Dose
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. automodule:: ofire.sfpe_handbook.chapter_50.equation_50_18
:members:
:undoc-members:
:show-inheritance:

Equation 50.19 - Visibility Through Uniform Smoke
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. automodule:: ofire.sfpe_handbook.chapter_50.equation_50_19
:members:
:undoc-members:
:show-inheritance:
Equation 50.20 - Visibility Through Smoke (Percent Obscuration)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. automodule:: ofire.sfpe_handbook.chapter_50.equation_50_20
:members:
:undoc-members:
:show-inheritance:
14 changes: 12 additions & 2 deletions crates/python_api/docs/guide/equation-relationships.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,18 @@ Visibility

These equations calculate visibility distance through smoke but use different formulations:

- :func:`ofire.cibse_guide_e.chapter_10.equation_10_7.visibility` - CIBSE Guide E, Chapter 10, Equation 10.7 (uses extinction coefficient and optical density: k/(2.303×d))
- :func:`ofire.fire_dynamics_tools.chapter_18.equation_18_1.visibility` - Fire Dynamics Tools, Chapter 18, Equation 18.1 (uses extinction coefficient, mass extinction coefficient, and particulate concentration: k/(αₘ×mₚ))
- :func:`ofire.cibse_guide_e.chapter_10.equation_10_7.visibility` - CIBSE Guide E, Chapter 10, Equation 10.7
- :func:`ofire.fire_dynamics_tools.chapter_18.equation_18_1.visibility` - Fire Dynamics Tools, Chapter 18, Equation 18.1

Fractional Effective Dose
~~~~~~~~~~~~~~~~~~~~~~~~~

*Group 3: Fractional Effective Dose Calculations*

These equations calculate the fractional effective dose (FED), representing accumulated toxic exposure over time as a fraction of the lethal dose, but use different formulations:

- :func:`ofire.sfpe_handbook.chapter_50.equation_50_18.fed` - SFPE Handbook, Chapter 50, Equation 50-18
- :func:`ofire.cibse_guide_e.chapter_10.equation_10_8.fractional_effective_dose` - CIBSE Guide E, Chapter 10, Equation 10-8

Contributing to Equation Relationships
---------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions crates/python_api/src/sfpe_handbook/chapter_50.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ pub mod equation_50_1;
pub mod equation_50_14;
pub mod equation_50_15;
pub mod equation_50_16;
pub mod equation_50_18;
pub mod equation_50_19;
pub mod equation_50_2;
pub mod equation_50_20;
pub mod equation_50_4;
pub mod equation_50_6;
pub mod equation_50_7;
Expand All @@ -21,5 +24,8 @@ pub fn chapter_50(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_wrapped(wrap_pymodule!(equation_50_14::equation_50_14))?;
m.add_wrapped(wrap_pymodule!(equation_50_15::equation_50_15))?;
m.add_wrapped(wrap_pymodule!(equation_50_16::equation_50_16))?;
m.add_wrapped(wrap_pymodule!(equation_50_18::equation_50_18))?;
m.add_wrapped(wrap_pymodule!(equation_50_19::equation_50_19))?;
m.add_wrapped(wrap_pymodule!(equation_50_20::equation_50_20))?;
Ok(())
}
49 changes: 49 additions & 0 deletions crates/python_api/src/sfpe_handbook/chapter_50/equation_50_18.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
use pyo3::prelude::*;
use pyo3::wrap_pyfunction;

use openfire::sfpe_handbook::chapter_50::equation_50_18 as rust_equation_50_18;

#[pyfunction]
/// Fractional Effective Dose (FED) calculation for evaluation of exposure to smoke.
///
/// .. math::
///
/// FED = \frac{\sum (C_i \Delta t_i)}{LCt_{50}}
///
/// where:
///
/// - :math:`FED` is the fractional effective dose (dimensionless)
/// - :math:`C_i` is the mass concentration of material burned at the end of time interval i (g/m³)
/// - :math:`\Delta t_i` is the time interval i (s)
/// - :math:`LC_{t50}` is the lethal exposure dose from test data (g/m³)
///
/// Args:
/// c_i (list[float]): Concentration values at each time interval (g/m³)
/// delta_t_i (float): Time intervals (s)
/// lc_t50 (float): Lethal exposure dose from test data (g/m³)
///
/// Returns:
/// float: Fractional effective dose (dimensionless)
///
/// Assumptions:
/// Uniform time intervals.
///
/// Limitations:
/// Simplest model for evaluating exposure to smoke.
///
/// Example:
/// >>> import ofire
/// >>> c_i = [0.001, 0.002, 0.003]
/// >>> delta_t_i = 1.0
/// >>> lc_t50 = 10.0
/// >>> result = ofire.sfpe_handbook.chapter_50.equation_50_18.fed(c_i, delta_t_i, lc_t50)
/// >>> print(f"{result:.2f}")
fn fed(c_i: Vec<f64>, delta_t_i: f64, lc_t50: f64) -> PyResult<f64> {
Ok(rust_equation_50_18::fed(c_i, delta_t_i, lc_t50))
}

#[pymodule]
pub fn equation_50_18(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_function(wrap_pyfunction!(fed, m)?)?;
Ok(())
}
46 changes: 46 additions & 0 deletions crates/python_api/src/sfpe_handbook/chapter_50/equation_50_19.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
use pyo3::prelude::*;
use pyo3::wrap_pyfunction;

use openfire::sfpe_handbook::chapter_50::equation_50_19 as rust_equation_50_19;

#[pyfunction]
/// Visibility in smoke at a point where mass concentration of fuel burned is known.
///
/// .. math::
///
/// S_i = \frac{K}{2.303 {\delta}_m C_i}
///
/// where:
///
/// - :math:`S_i` is the visibility through smoke (m)
/// - :math:`K` is the proportionality constant (dimensionless)
/// - :math:`{\delta}_m` is the mass optical density (m²/g)
/// - :math:`C_i` is the mass concentration of fuel burned (g/m³)
///
/// Args:
/// k (float): Proportionality constant (dimensionless)
/// delta_m (float): Mass optical density (m²/g)
/// c_i (float): Mass concentration of fuel burned (g/m³)
///
/// Returns:
/// float: Visibility through smoke (m)
///
/// Assumptions:
/// The calculated visibility can be thought of as visibility if smoke is uniform.
///
/// Limitations:
/// See assumptions above. Assumes uniform smoke and, utilises the proportionality constant K, commonly taken as 8 for illuminated signs and 3 for non-illuminated.
///
/// Example:
/// >>> import ofire
/// >>> result = ofire.sfpe_handbook.chapter_50.equation_50_19.visibility(8.0, 0.22, 1.0)
/// >>> print(f"{result:.2f}")
fn visibility(k: f64, delta_m: f64, c_i: f64) -> PyResult<f64> {
Ok(rust_equation_50_19::visibility(k, delta_m, c_i))
}

#[pymodule]
pub fn equation_50_19(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_function(wrap_pyfunction!(visibility, m)?)?;
Ok(())
}
46 changes: 46 additions & 0 deletions crates/python_api/src/sfpe_handbook/chapter_50/equation_50_20.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
use pyo3::prelude::*;
use pyo3::wrap_pyfunction;

use openfire::sfpe_handbook::chapter_50::equation_50_20 as rust_equation_50_20;

#[pyfunction]
/// Visibility calculation through smoke from percent obscuration.
///
/// .. math::
///
/// S_i = -\frac{K L}{\ln(1 - \frac{\lambda}{100})}
///
/// where:
///
/// - :math:`S_i` is the visibility through smoke (m)
/// - :math:`K` is proportionality constant (dimensionless)
/// - :math:`L` is the path length (m)
/// - :math:`\lambda` is the percent obscuration (dimensionless)
///
/// Args:
/// k (float): Proportionality constant (dimensionless)
/// l (float): Path length (m)
/// lambda (float): Percent obscuration (dimensionless)
///
/// Returns:
/// float: Visibility through smoke (m)
///
/// Assumptions:
/// An object can be seen for S > L.
///
/// Limitations:
/// None stated.
///
/// Example:
/// >>> import ofire
/// >>> result = ofire.sfpe_handbook.chapter_50.equation_50_20.visibility(8.0, 10.0, 95.0)
/// >>> print(f"{result:.2f}")
fn visibility(k: f64, l: f64, lambda: f64) -> PyResult<f64> {
Ok(rust_equation_50_20::visibility(k, l, lambda))
}

#[pymodule]
pub fn equation_50_20(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_function(wrap_pyfunction!(visibility, m)?)?;
Ok(())
}
3 changes: 3 additions & 0 deletions crates/sfpe_handbook/src/chapter_50.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ pub mod equation_50_1;
pub mod equation_50_14;
pub mod equation_50_15;
pub mod equation_50_16;
pub mod equation_50_18;
pub mod equation_50_19;
pub mod equation_50_2;
pub mod equation_50_20;
pub mod equation_50_4;
pub mod equation_50_6;
pub mod equation_50_7;
27 changes: 27 additions & 0 deletions crates/sfpe_handbook/src/chapter_50/equation_50_18.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
pub fn fed(c_i: Vec<f64>, delta_t: f64, lc_t50: f64) -> f64 {
let numerator: f64 = c_i.iter().map(|c| c * delta_t).sum();
numerator / lc_t50
}

#[cfg(not(coverage))]
pub fn fed_equation(fed: String, c_i: String, delta_t: String, lc_t50: String) -> String {
format!(
"{} = \\frac{{ \\sum {} \\times {} }}{{ {} }}",
fed, c_i, delta_t, lc_t50
)
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_fed() {
let c_i = vec![0.001, 0.003];
let delta_t = 1.0;
let lc_t50 = 0.015;
let result = fed(c_i, delta_t, lc_t50);
let expected = 0.266666667;
assert!((result - expected).abs() < 1e-6);
}
}
23 changes: 23 additions & 0 deletions crates/sfpe_handbook/src/chapter_50/equation_50_19.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
pub fn visibility(k: f64, delta_m: f64, c_i: f64) -> f64 {
k / (2.303 * delta_m * c_i)
}

#[cfg(not(coverage))]
pub fn visibility_equation(s_i: String, k: String, delta_m: String, c_i: String) -> String {
format!(
"{} = \\frac{{{}}}{{2.303 \\times {} \\times {}}}",
s_i, k, delta_m, c_i,
)
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_visibility() {
let result = visibility(8.0, 0.22, 1.0);
let expected = 15.78968144;
assert!((result - expected).abs() < 1e-6);
}
}
23 changes: 23 additions & 0 deletions crates/sfpe_handbook/src/chapter_50/equation_50_20.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
pub fn visibility(k: f64, l: f64, lambda: f64) -> f64 {
-k * l / ((1.0 - lambda / 100.0).ln())
}

#[cfg(not(coverage))]
pub fn visibility_equation(s_i: String, k: String, l: String, lambda: String) -> String {
format!(
"{} = \\frac{{{} \\times {}}}{{\\ln(1 - \\frac{{{}}}{{100}})}}",
s_i, k, l, lambda,
)
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_visibility() {
let result = visibility(8.0, 10.0, 95.0);
let expected = 26.70465606;
assert!((result - expected).abs() < 1e-6);
}
}