core: move gas_volume() to cylinder_t

Feels natural in a C++ code base.

The commit is somewhat complex, because it also changes the
return type to volume_t. The units system really needs some
work. :(

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-07-02 11:12:27 +02:00 committed by bstoeger
parent 4cb3db2548
commit 9c726d8d6f
7 changed files with 27 additions and 21 deletions

View file

@ -198,11 +198,11 @@ const char *gasname(struct gasmix gasmix)
return gas;
}
int gas_volume(const cylinder_t *cyl, pressure_t p)
volume_t cylinder_t::gas_volume(pressure_t p) const
{
double bar = p.mbar / 1000.0;
double z_factor = gas_compressibility_factor(cyl->gasmix, bar);
return lrint(cyl->type.size.mliter * bar_to_atm(bar) / z_factor);
double z_factor = gas_compressibility_factor(gasmix, bar);
return volume_t { static_cast<int>(lrint(type.size.mliter * bar_to_atm(bar) / z_factor)) };
}
int find_best_gasmix_match(struct gasmix mix, const struct cylinder_table &cylinders)