2024-02-02 22:03:47 +11:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "fluid_t.hpp"
|
2024-02-13 15:28:39 +11:00
|
|
|
#include "../conversions/temperature.hpp"
|
2024-02-02 22:03:47 +11:00
|
|
|
|
|
|
|
namespace sim::coolant
|
|
|
|
{
|
|
|
|
|
|
|
|
class fluid_holder
|
|
|
|
{
|
2024-02-09 21:31:36 +11:00
|
|
|
public://protected:
|
2024-02-02 22:03:47 +11:00
|
|
|
|
|
|
|
double level = 0; // litres
|
|
|
|
double steam = 0; // grams
|
2024-02-13 17:05:57 +11:00
|
|
|
double air = 0; // grams
|
2024-02-02 22:03:47 +11:00
|
|
|
double heat = 0; // celsius
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2024-02-05 18:33:31 +11:00
|
|
|
fluid_holder(fluid_t fluid, double volume, double extra_mass);
|
|
|
|
|
|
|
|
const fluid_t fluid;
|
|
|
|
const double volume; // litres
|
|
|
|
const double extra_mass; // grams
|
|
|
|
|
|
|
|
virtual double add_heat(double m, double t);
|
|
|
|
virtual double extract_fluid(double amount);
|
|
|
|
|
|
|
|
virtual double add_fluid(double amount, double heat);
|
2024-02-13 17:05:57 +11:00
|
|
|
virtual void add_gas(double steam, double air, double t);
|
2024-02-02 22:03:47 +11:00
|
|
|
|
2024-02-05 18:33:31 +11:00
|
|
|
virtual double get_volume() const { return volume; } // litres
|
|
|
|
virtual double get_level() const { return level; } // litres
|
|
|
|
virtual double get_heat() const { return heat; } // celsius
|
2024-02-13 15:28:39 +11:00
|
|
|
virtual double get_heat_k() const { return conversions::temperature::c_to_k(get_heat()); } // kelvin
|
2024-02-05 18:33:31 +11:00
|
|
|
virtual double get_steam() const { return steam; } // grams
|
2024-02-13 17:05:57 +11:00
|
|
|
virtual double get_gas() const { return steam + air; } // grams
|
|
|
|
virtual double get_air() const { return air; } // grams
|
|
|
|
virtual double get_gas_volume() const { return get_volume() - get_level(); } // litres
|
|
|
|
virtual double get_mass() const { return fluid.l_to_g(get_level()) + steam + air; } // grams
|
2024-02-05 18:33:31 +11:00
|
|
|
virtual double get_thermal_mass() const { return get_mass() + extra_mass; } // grams
|
|
|
|
virtual double get_pressure() const; // pascals
|
2024-02-13 17:05:57 +11:00
|
|
|
virtual double get_gas_density() const; // g/L
|
2024-02-07 16:04:22 +11:00
|
|
|
|
2024-02-13 15:28:39 +11:00
|
|
|
static double calc_pressure(double heat, double pressure, double mol);
|
|
|
|
static double calc_pressure_mol(double heat, double pressure, double volume);
|
|
|
|
|
|
|
|
void update_base(double dt);
|
2024-02-02 22:03:47 +11:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|