mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Fix pO2 for CCR at shallow depths
Even when diving a CCR, the pO2 cannot exceed ambient pressure. This only makes a difference at shallow depths. Fix this in the calculation of OTUs and CNS. This affects some tests that now have slightly different CNS and OTU values. Suggested-by: Justin Ashworth Signed-off-by: Robert C. Helling <helling@atdotde.de>
This commit is contained in:
parent
6b8a07f0d9
commit
2064ce06cc
11 changed files with 35 additions and 31 deletions
|
@ -109,12 +109,14 @@ static int calculate_otu(const struct dive *dive)
|
|||
po2f = sample->o2sensor[0].mbar; // ... use data from the first o2 sensor
|
||||
} else {
|
||||
if (dc->divemode == CCR) {
|
||||
po2i = psample->setpoint.mbar; // if CCR has no o2 sensors then use setpoint
|
||||
po2f = sample->setpoint.mbar;
|
||||
po2i = MIN((int) psample->setpoint.mbar,
|
||||
depth_to_mbar(psample->depth.mm, dive)); // if CCR has no o2 sensors then use setpoint
|
||||
po2f = MIN((int) sample->setpoint.mbar,
|
||||
depth_to_mbar(sample->depth.mm, dive));
|
||||
} else { // For OC and rebreather without o2 sensor/setpoint
|
||||
int o2 = active_o2(dive, dc, psample->time); // ... calculate po2 from depth and FiO2.
|
||||
po2i = lrint(o2 * depth_to_atm(psample->depth.mm, dive)); // (initial) po2 at start of segment
|
||||
po2f = lrint(o2 * depth_to_atm(sample->depth.mm, dive)); // (final) po2 at end of segment
|
||||
po2i = lrint(o2 * depth_to_bar(psample->depth.mm, dive)); // (initial) po2 at start of segment
|
||||
po2f = lrint(o2 * depth_to_bar(sample->depth.mm, dive)); // (final) po2 at end of segment
|
||||
}
|
||||
}
|
||||
if ((po2i > 500) || (po2f > 500)) { // If PO2 in segment is above 500 mbar then calculate otu
|
||||
|
@ -164,14 +166,16 @@ static double calculate_cns_dive(const struct dive *dive)
|
|||
trueo2 = true;
|
||||
}
|
||||
if ((dc->divemode == CCR) && (!trueo2)) {
|
||||
po2i = psample->setpoint.mbar; // if CCR has no o2 sensors then use setpoint
|
||||
po2f = sample->setpoint.mbar;
|
||||
po2i = MIN((int) psample->setpoint.mbar,
|
||||
depth_to_mbar(psample->depth.mm, dive)); // if CCR has no o2 sensors then use setpoint
|
||||
po2f = MIN((int) sample->setpoint.mbar,
|
||||
depth_to_mbar(sample->depth.mm, dive));
|
||||
trueo2 = true;
|
||||
}
|
||||
if (!trueo2) {
|
||||
int o2 = active_o2(dive, dc, psample->time); // For OC and rebreather without o2 sensor:
|
||||
po2i = lrint(o2 * depth_to_atm(psample->depth.mm, dive)); // (initial) po2 at start of segment
|
||||
po2f = lrint(o2 * depth_to_atm(sample->depth.mm, dive)); // (final) po2 at end of segment
|
||||
po2i = lrint(o2 * depth_to_bar(psample->depth.mm, dive)); // (initial) po2 at start of segment
|
||||
po2f = lrint(o2 * depth_to_bar(sample->depth.mm, dive)); // (final) po2 at end of segment
|
||||
}
|
||||
po2i = (po2i + po2f) / 2; // po2i now holds the mean po2 of initial and final po2 values of segment.
|
||||
/* Don't increase CNS when po2 below 500 matm */
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<divesites>
|
||||
</divesites>
|
||||
<dives>
|
||||
<dive number='1' otu='45' cns='15%' date='2013-02-02' time='16:14:08' duration='59:20 min'>
|
||||
<dive number='1' otu='46' cns='15%' date='2013-02-02' time='16:14:08' duration='59:20 min'>
|
||||
<notes>Notes are here</notes>
|
||||
<cylinder workpressure='200.0 bar' o2='33.0%' start='205.11 bar' />
|
||||
<divecomputer>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<divesites>
|
||||
</divesites>
|
||||
<dives>
|
||||
<dive number='1' sac='11.046 l/min' otu='45' cns='15%' date='2013-02-02' time='16:14:08' duration='59:20 min'>
|
||||
<dive number='1' sac='11.046 l/min' otu='46' cns='15%' date='2013-02-02' time='16:14:08' duration='59:20 min'>
|
||||
<notes>Notes are here</notes>
|
||||
<cylinder size='12.0 l' o2='33.0%' start='205.11 bar' />
|
||||
<divecomputer model='Vyper Air' deviceid='013749e4'>
|
||||
|
@ -194,7 +194,7 @@
|
|||
<sample time='59:20 min' depth='1.88 m' pressure='53.87 bar' />
|
||||
</divecomputer>
|
||||
</dive>
|
||||
<dive number='2' sac='11.298 l/min' otu='32' cns='11%' tags='boat, photography, tag' date='2013-02-02' time='13:44:21' duration='61:00 min'>
|
||||
<dive number='2' sac='11.298 l/min' otu='33' cns='12%' tags='boat, photography, tag' date='2013-02-02' time='13:44:21' duration='61:00 min'>
|
||||
<notes>Testing notes</notes>
|
||||
<cylinder size='12.0 l' o2='33.0%' start='209.04 bar' />
|
||||
<divecomputer model='Vyper Air' deviceid='013749e4'>
|
||||
|
@ -388,7 +388,7 @@
|
|||
<sample time='61:00 min' depth='1.67 m' pressure='72.34 bar' />
|
||||
</divecomputer>
|
||||
</dive>
|
||||
<dive number='3' sac='10.109 l/min' otu='41' cns='15%' date='2013-02-02' time='10:53:54' duration='66:00 min'>
|
||||
<dive number='3' sac='10.109 l/min' otu='42' cns='15%' date='2013-02-02' time='10:53:54' duration='66:00 min'>
|
||||
<notes>Dive notes</notes>
|
||||
<cylinder size='12.0 l' o2='33.0%' start='212.74 bar' />
|
||||
<divecomputer model='Vyper Air' deviceid='013749e4'>
|
||||
|
@ -597,7 +597,7 @@
|
|||
<sample time='66:00 min' depth='2.43 m' />
|
||||
</divecomputer>
|
||||
</dive>
|
||||
<dive number='4' sac='10.260 l/min' otu='48' cns='17%' date='2013-02-02' time='08:21:50' duration='60:40 min'>
|
||||
<dive number='4' sac='10.260 l/min' otu='49' cns='18%' date='2013-02-02' time='08:21:50' duration='60:40 min'>
|
||||
<notes>Notes test</notes>
|
||||
<cylinder size='12.0 l' o2='33.0%' start='194.74 bar' />
|
||||
<divecomputer model='Vyper Air' deviceid='013749e4'>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
</site>
|
||||
</divesites>
|
||||
<dives>
|
||||
<dive number='1' sac='15.471 l/min' otu='14' cns='5%' divesiteid='64785a00' date='2011-05-17' time='11:01:00' duration='32:00 min'>
|
||||
<dive number='1' sac='15.471 l/min' otu='15' cns='6%' divesiteid='64785a00' date='2011-05-17' time='11:01:00' duration='32:00 min'>
|
||||
<buddy>Linus</buddy>
|
||||
<notes>Second deep dive
|
||||
Linus and I planned and executed - Alex just watching
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<divesites>
|
||||
</divesites>
|
||||
<dives>
|
||||
<dive otu='3' cns='1%' date='2009-10-10' time='05:32:41' duration='7:32 min'>
|
||||
<dive otu='4' cns='1%' date='2009-10-10' time='05:32:41' duration='7:32 min'>
|
||||
<divecomputer model='DC text' deviceid='ffffffff'>
|
||||
<depth max='40.0 m' mean='22.32 m' />
|
||||
<temperature water='1.0 C' />
|
||||
|
|
|
@ -211,7 +211,7 @@
|
|||
<sample time='17:15 min' depth='0.0 m' />
|
||||
</divecomputer>
|
||||
</dive>
|
||||
<dive number='3' otu='13' cns='7%' date='2012-10-01' time='06:49:00' duration='16:25 min'>
|
||||
<dive number='3' otu='14' cns='8%' date='2012-10-01' time='06:49:00' duration='16:25 min'>
|
||||
<divecomputer model='Seabear H3' deviceid='ffffffff'>
|
||||
<depth max='69.9 m' mean='32.928 m' />
|
||||
<temperature water='25.0 C' />
|
||||
|
@ -418,7 +418,7 @@
|
|||
<sample time='17:15 min' depth='0.0 m' />
|
||||
</divecomputer>
|
||||
</dive>
|
||||
<dive number='4' otu='13' cns='14%' date='2012-10-01' time='07:07:00' duration='16:17 min'>
|
||||
<dive number='4' otu='14' cns='16%' date='2012-10-01' time='07:07:00' duration='16:17 min'>
|
||||
<divecomputer model='Seabear H3' deviceid='ffffffff' dctype='Freedive'>
|
||||
<depth max='70.1 m' mean='33.197 m' />
|
||||
<temperature water='25.0 C' />
|
||||
|
@ -1351,7 +1351,7 @@
|
|||
<sample time='16:24 min' depth='0.1 m' />
|
||||
</divecomputer>
|
||||
</dive>
|
||||
<dive number='5' otu='13' cns='21%' date='2012-10-01' time='07:24:00' duration='16:25 min'>
|
||||
<dive number='5' otu='14' cns='24%' date='2012-10-01' time='07:24:00' duration='16:25 min'>
|
||||
<divecomputer model='Seabear H3' deviceid='ffffffff'>
|
||||
<depth max='69.9 m' mean='32.928 m' />
|
||||
<temperature water='25.0 C' />
|
||||
|
@ -1973,7 +1973,7 @@
|
|||
<sample time='17:15 min' depth='0.0 m' />
|
||||
</divecomputer>
|
||||
</dive>
|
||||
<dive number='3' otu='13' cns='12%' date='2012-10-01' time='06:49:00' duration='16:25 min'>
|
||||
<dive number='3' otu='14' cns='12%' date='2012-10-01' time='06:49:00' duration='16:25 min'>
|
||||
<divecomputer model='Seabear T1' deviceid='ffffffff'>
|
||||
<depth max='69.9 m' mean='32.928 m' />
|
||||
<temperature water='25.0 C' />
|
||||
|
@ -2180,7 +2180,7 @@
|
|||
<sample time='17:15 min' depth='0.0 m' />
|
||||
</divecomputer>
|
||||
</dive>
|
||||
<dive number='4' otu='13' cns='19%' date='2012-10-01' time='07:07:00' duration='16:17 min'>
|
||||
<dive number='4' otu='14' cns='20%' date='2012-10-01' time='07:07:00' duration='16:17 min'>
|
||||
<divecomputer model='Seabear T1' deviceid='ffffffff' dctype='Freedive'>
|
||||
<depth max='70.1 m' mean='33.197 m' />
|
||||
<temperature water='24.0 C' />
|
||||
|
@ -3113,7 +3113,7 @@
|
|||
<sample time='16:24 min' depth='0.1 m' />
|
||||
</divecomputer>
|
||||
</dive>
|
||||
<dive number='5' otu='13' cns='26%' date='2012-10-01' time='07:24:00' duration='16:25 min'>
|
||||
<dive number='5' otu='14' cns='28%' date='2012-10-01' time='07:24:00' duration='16:25 min'>
|
||||
<divecomputer model='Seabear T1' deviceid='ffffffff'>
|
||||
<depth max='69.9 m' mean='32.928 m' />
|
||||
<temperature water='25.0 C' />
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<divesites>
|
||||
</divesites>
|
||||
<dives>
|
||||
<dive number='1' otu='52' cns='22%' date='2017-02-03' time='06:58:00' duration='72:00 min'>
|
||||
<dive number='1' otu='53' cns='22%' date='2017-02-03' time='06:58:00' duration='72:00 min'>
|
||||
<cylinder size='11.094 l' workpressure='206.843 bar' description='AL80' />
|
||||
<cylinder size='11.094 l' workpressure='206.843 bar' description='AL80' o2='32.0%' />
|
||||
<cylinder size='11.094 l' workpressure='206.843 bar' description='AL80' o2='31.0%' />
|
||||
|
@ -103,7 +103,7 @@
|
|||
<sample time='76:56 min' depth='0.01 m' ndl='0:00 min' cns='0%' />
|
||||
</divecomputer>
|
||||
</dive>
|
||||
<dive number='2' otu='39' cns='22%' date='2017-02-03' time='10:24:00' duration='66:00 min'>
|
||||
<dive number='2' otu='40' cns='22%' date='2017-02-03' time='10:24:00' duration='66:00 min'>
|
||||
<cylinder size='11.094 l' workpressure='206.843 bar' description='AL80' />
|
||||
<cylinder size='11.094 l' workpressure='206.843 bar' description='AL80' o2='32.0%' />
|
||||
<cylinder size='11.094 l' workpressure='206.843 bar' description='AL80' o2='31.0%' />
|
||||
|
@ -194,7 +194,7 @@
|
|||
<sample time='70:46 min' depth='0.0 m' ndl='0:00 min' cns='0%' />
|
||||
</divecomputer>
|
||||
</dive>
|
||||
<dive number='1' sac='9.026 l/min' otu='53' cns='17%' date='2017-02-03' time='06:59:41' duration='71:40 min'>
|
||||
<dive number='1' sac='9.026 l/min' otu='54' cns='17%' date='2017-02-03' time='06:59:41' duration='71:40 min'>
|
||||
<cylinder size='11.094 l' workpressure='206.843 bar' description='AL80' o2='32.0%' />
|
||||
<divecomputer model='Suunto Vyper Air' deviceid='11223344' diveid='c51cb31b'>
|
||||
<depth max='26.72 m' mean='16.837 m' />
|
||||
|
@ -420,7 +420,7 @@
|
|||
<sample time='71:40 min' depth='1.5 m' pressure='53.05 bar' cns='0%' />
|
||||
</divecomputer>
|
||||
</dive>
|
||||
<dive number='2' sac='9.173 l/min' otu='40' cns='17%' date='2017-02-03' time='10:25:16' duration='65:40 min'>
|
||||
<dive number='2' sac='9.173 l/min' otu='41' cns='17%' date='2017-02-03' time='10:25:16' duration='65:40 min'>
|
||||
<cylinder size='11.094 l' workpressure='206.843 bar' description='AL80' o2='32.0%' />
|
||||
<divecomputer model='Suunto Vyper Air' deviceid='20993833' diveid='5372ae57'>
|
||||
<depth max='27.8 m' mean='14.594 m' />
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
<depth max='24.9 m' mean='20.1 m' />
|
||||
</divecomputer>
|
||||
</dive>
|
||||
<dive number='417' otu='135' cns='54%' divesiteid='deadbeef' date='2015-05-23' time='13:23:00' duration='100:00 min'>
|
||||
<dive number='417' otu='138' cns='54%' divesiteid='deadbeef' date='2015-05-23' time='13:23:00' duration='100:00 min'>
|
||||
<notes>{\rtf1\ansi\ansicpg1252\deff0\deflang1035{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}
|
||||
\viewkind4\uc1\pard\f0\fs17\par
|
||||
}</notes>
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
<settings>
|
||||
</settings>
|
||||
<divesites>
|
||||
<site uuid='15ae02d0' name='Test dive'>
|
||||
<site uuid='15ae02d1' name='Test dive'>
|
||||
</site>
|
||||
</divesites>
|
||||
<dives>
|
||||
<dive number='1' tags='test' divesiteid='15ae02d0' date='2015-10-01' time='08:00:25' duration='46:00 min'>
|
||||
<dive number='1' cns='2%' tags='test' divesiteid='15ae02d1' date='2015-10-01' time='08:00:25' duration='46:00 min'>
|
||||
<cylinder size='11.1 l' workpressure='207.0 bar' description='unknown' />
|
||||
<divecomputer model='do not care' date='2015-10-05' time='08:45:25'>
|
||||
<depth max='13.716 m' mean='10.595 m' />
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
<settings>
|
||||
</settings>
|
||||
<divesites>
|
||||
<site uuid='15ae02d0' name='Test dive'>
|
||||
<site uuid='15ae02d1' name='Test dive'>
|
||||
</site>
|
||||
</divesites>
|
||||
<dives>
|
||||
<dive number='1' divesiteid='15ae02d0' date='2015-10-01' time='08:00:25' duration='46:00 min'>
|
||||
<dive number='1' cns='2%' divesiteid='15ae02d1' date='2015-10-01' time='08:00:25' duration='46:00 min'>
|
||||
<cylinder size='11.1 l' workpressure='207.0 bar' description='unknown' />
|
||||
<divecomputer model='do not care' date='2015-10-05' time='08:45:25'>
|
||||
<depth max='13.716 m' mean='10.595 m' />
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
</site>
|
||||
</divesites>
|
||||
<dives>
|
||||
<dive number='1' tags='test' divesiteid='15ae02d1' date='2015-10-01' time='08:00:25' duration='46:00 min'>
|
||||
<dive number='1' cns='2%' tags='test' divesiteid='15ae02d1' date='2015-10-01' time='08:00:25' duration='46:00 min'>
|
||||
<cylinder size='11.1 l' workpressure='207.0 bar' description='unknown' />
|
||||
<divecomputer model='do not care' date='2015-10-05' time='08:45:25'>
|
||||
<depth max='13.716 m' mean='10.595 m' />
|
||||
|
|
Loading…
Reference in a new issue