-
Notifications
You must be signed in to change notification settings - Fork 1
Adds equations 50-18, 50-19 and 50-20 of the SFPE handbook. #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
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 f9b8622
Adds equation to list of similar equations, including equation in cib…
simonsantama 4dfe750
Adds equation to list of similar equations, including equation in cib…
simonsantama 7bfe119
Finishes 50-18 for rust
simonsantama 6af661c
Finishes 50-19
simonsantama a088e07
Finishes 50-18
simonsantama 4e648df
Update crates/fire_dynamics_tools/Cargo.toml
simonsantama d7e2113
Implements 50-19
simonsantama aabe100
Start of 50-20
simonsantama f5d17cd
Implements rust aspect of 50-20
simonsantama 8b3f07d
Finishes first implementation of 50-20
simonsantama 61e27a9
Minor changes to fix issues with docs
simonsantama d2d6e92
Update crates/python_api/docs/api/sfpe-handbook.rst
simonsantama 3d9423b
Update crates/python_api/src/sfpe_handbook/chapter_50/equation_50_19.rs
simonsantama 6820501
Update crates/sfpe_handbook/src/chapter_50/equation_50_20.rs
simonsantama cf1b2ed
fixes error in example
simonsantama 58192ee
Fixes error in units
simonsantama c73134b
Update crates/python_api/src/sfpe_handbook/chapter_50/equation_50_18.rs
simonsantama eebb7eb
Update crates/python_api/src/sfpe_handbook/chapter_50/equation_50_19.rs
simonsantama 53dcb05
Update crates/python_api/src/sfpe_handbook/chapter_50/equation_50_19.rs
simonsantama 3d9535f
Update crates/python_api/src/sfpe_handbook/chapter_50/equation_50_20.rs
simonsantama File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
crates/python_api/src/sfpe_handbook/chapter_50/equation_50_18.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
46
crates/python_api/src/sfpe_handbook/chapter_50/equation_50_19.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
46
crates/python_api/src/sfpe_handbook/chapter_50/equation_50_20.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(()) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.