From 37d90f62b3f7815ae79675ed9450d3b886ba5abc Mon Sep 17 00:00:00 2001 From: Kuba Groblewski Date: Mon, 18 Nov 2024 00:47:06 +0100 Subject: [PATCH] fix: ndl always 0 in deco --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/buehlmann/buehlmann_model.rs | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1cb03d3..4042395 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -168,7 +168,7 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "dive-deco" -version = "4.3.4" +version = "4.3.5" dependencies = [ "criterion", ] diff --git a/Cargo.toml b/Cargo.toml index 62e288d..6697f0e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dive-deco" -version = "4.3.4" +version = "4.3.5" edition = "2021" license = "MIT" description = "A dive decompression models library (Buehlmann ZH-L 16C)" diff --git a/src/buehlmann/buehlmann_model.rs b/src/buehlmann/buehlmann_model.rs index 81fb709..2fab66f 100644 --- a/src/buehlmann/buehlmann_model.rs +++ b/src/buehlmann/buehlmann_model.rs @@ -117,6 +117,10 @@ impl DecoModel for BuehlmannModel { fn ndl(&self) -> Minutes { let mut ndl: Minutes = NDL_CUT_OFF_MINS; + if self.in_deco() { + return 0; + } + // create a simulation model based on current model's state let mut sim_model = self.fork(); @@ -538,4 +542,18 @@ mod tests { "invalid config update results in Err" ); } + + #[test] + fn test_ndl_0_if_in_deco() { + let mut model = BuehlmannModel::new( + BuehlmannConfig::default() + .with_gradient_factors(30, 70) + .with_ceiling_type(CeilingType::Actual), + ); + let air = Gas::air(); + model.record(40., 6 * 60, &air); + model.record(9., 0, &air); + let ndl = model.ndl(); + assert_eq!(ndl, 0); + } }