mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 14:10:19 +00:00
Round MOD to lower depths
When computing the suggested switch depth for a gas, we should take the next stop depth above the MOD, i.e. round down. Otherwise we can produce MOD violation warnings. We need, however, a bit of fudge as otherwise we do not suggest to switch to o2 at 6m. TestPlan uses the MOD to determine the depth to switch to Tx21/35. This happens to be 65.378m. Therefore, switching at 66m violates the MOD, the switch should be at 63m. This then affects the gas usage. Signed-off-by: Robert C. Helling <helling@atdotde.de>
This commit is contained in:
parent
a898173ce7
commit
7dc92e170f
2 changed files with 6 additions and 4 deletions
|
@ -2457,7 +2457,9 @@ int dive::mbar_to_depth(int mbar) const
|
|||
depth_t dive::gas_mod(struct gasmix mix, pressure_t po2_limit, int roundto) const
|
||||
{
|
||||
double depth = (double) mbar_to_depth(po2_limit.mbar * 1000 / get_o2(mix));
|
||||
return depth_t { .mm = int_cast<int>(depth / roundto) * roundto };
|
||||
// Rounding should be towards lower=safer depths but we give a bit
|
||||
// of fudge to all to switch to o2 at 6m. So from .9 we round up.
|
||||
return depth_t { .mm = (int)(depth / roundto + 0.1) * roundto };
|
||||
}
|
||||
|
||||
/* Maximum narcotic depth rounded to multiples of roundto mm */
|
||||
|
|
|
@ -865,17 +865,17 @@ void TestPlan::testVpmbMetricRepeat()
|
|||
|
||||
// check minimum gas result
|
||||
dp = std::find_if(testPlan.dp.begin(), testPlan.dp.end(), [](auto &dp) { return dp.minimum_gas.mbar != 0; });
|
||||
QCOMPARE(lrint(dp == testPlan.dp.end() ? 0.0 : dp->minimum_gas.mbar / 1000.0), 80l);
|
||||
QCOMPARE(lrint(dp == testPlan.dp.end() ? 0.0 : dp->minimum_gas.mbar / 1000.0), 85l);
|
||||
// print first ceiling
|
||||
printf("First ceiling %.1f m\n", dive.mbar_to_depth(test_deco_state.first_ceiling_pressure.mbar) * 0.001);
|
||||
QVERIFY(dive.dcs[0].events.size() >= 3);
|
||||
// check first gas change to 21/35 at 66m
|
||||
// check first gas change to 21/35 at 63m
|
||||
struct event *ev = &dive.dcs[0].events[0];
|
||||
QVERIFY(ev != NULL);
|
||||
QCOMPARE(ev->gas.index, 1);
|
||||
QCOMPARE(ev->gas.mix.o2.permille, 210);
|
||||
QCOMPARE(ev->gas.mix.he.permille, 350);
|
||||
QCOMPARE(get_depth_at_time(&dive.dcs[0], ev->time.seconds), 66000);
|
||||
QCOMPARE(get_depth_at_time(&dive.dcs[0], ev->time.seconds), 63000);
|
||||
// check second gas change to EAN50 at 21m
|
||||
ev = &dive.dcs[0].events[1];
|
||||
QCOMPARE(ev->gas.index, 2);
|
||||
|
|
Loading…
Reference in a new issue