mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-04 16:11:28 +00:00
core: convert gas-model.c to C++
A nice one - nothing to do. Introduce an std::clamp(), just because we can... Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
17b23ddb69
commit
14d60a7245
3 changed files with 10 additions and 12 deletions
|
@ -57,7 +57,7 @@ SOURCES += subsurface-mobile-main.cpp \
|
|||
core/filterpreset.cpp \
|
||||
core/divelist.cpp \
|
||||
core/divelog.cpp \
|
||||
core/gas-model.c \
|
||||
core/gas-model.cpp \
|
||||
core/gaspressures.c \
|
||||
core/git-access.cpp \
|
||||
core/globals.cpp \
|
||||
|
|
|
@ -101,7 +101,7 @@ set(SUBSURFACE_CORE_LIB_SRCS
|
|||
fulltext.h
|
||||
gas.c
|
||||
gas.h
|
||||
gas-model.c
|
||||
gas-model.cpp
|
||||
gaspressures.c
|
||||
gaspressures.h
|
||||
gettext.h
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
/* gas-model.c */
|
||||
/* gas-model.cpp */
|
||||
/* gas compressibility model */
|
||||
#include <algorithm> // std::clamp
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "dive.h"
|
||||
|
@ -46,23 +47,20 @@ double gas_compressibility_factor(struct gasmix gas, double bar)
|
|||
-8.83632921053e-08,
|
||||
+5.33304543646e-11
|
||||
};
|
||||
int o2, he;
|
||||
double Z;
|
||||
|
||||
/*
|
||||
* The curve fitting range is only [0,500] bar.
|
||||
* Anything else is way out of range for cylinder
|
||||
* pressures.
|
||||
*/
|
||||
if (bar < 0) bar = 0;
|
||||
if (bar > 500) bar = 500;
|
||||
bar = std::clamp(bar, 0.0, 500.0);
|
||||
|
||||
o2 = get_o2(gas);
|
||||
he = get_he(gas);
|
||||
int o2 = get_o2(gas);
|
||||
int he = get_he(gas);
|
||||
|
||||
Z = virial_m1(o2_coefficients, bar) * o2 +
|
||||
virial_m1(he_coefficients, bar) * he +
|
||||
virial_m1(n2_coefficients, bar) * (1000 - o2 - he);
|
||||
double Z = virial_m1(o2_coefficients, bar) * o2 +
|
||||
virial_m1(he_coefficients, bar) * he +
|
||||
virial_m1(n2_coefficients, bar) * (1000 - o2 - he);
|
||||
|
||||
/*
|
||||
* We add the 1.0 at the very end - the linear mixing of the
|
Loading…
Reference in a new issue