salt_water/
property_tables.rs1use strum::IntoEnumIterator;
2use strum_macros::{EnumCount,EnumIter};
3use std::sync::LazyLock;
4use cobia::{CapeOpenMap,CapeStringConstProvider};
5
6pub(crate) struct PropertyTables {
8 single_phase_property_map : CapeOpenMap<SinglePhaseProperty>,
10}
11
12#[derive(EnumIter,EnumCount)]
14pub(crate) enum SinglePhaseProperty {
15 Viscosity,
17 ViscositydTemperature,
19 ViscositydPressure,
21 ViscositydMoles,
23 ViscositydMolFraction,
25 ThermalConductivity,
27 ThermalConductivitydTemperature,
29 ThermalConductivitydPressure,
31 ThermalConductivitydMoles,
33 ThermalConductivitydMolFraction,
35 Enthalpy,
37 EnthalpydTemperature,
39 EnthalpydPressure,
41 EnthalpydMoles,
43 EnthalpydMolFraction,
45 Entropy,
47 EntropydTemperature,
49 EntropydPressure,
51 EntropydMoles,
53 EntropydMolFraction,
55 Density,
57 DensitydTemperature,
59 DensitydPressure,
61 DensitydMoles,
63 DensitydMolFraction,
65 Volume,
67 VolumedTemperature,
69 VolumedPressure,
71 VolumedMoles,
73 VolumedMolFraction,
75}
76
77impl SinglePhaseProperty {
78
79 pub(crate) fn name(&self) -> &str {
84 match self {
85 SinglePhaseProperty::Viscosity => "viscosity",
86 SinglePhaseProperty::ViscositydTemperature => "viscosity.Dtemperature",
87 SinglePhaseProperty::ViscositydPressure => "viscosity.Dpressure",
88 SinglePhaseProperty::ViscositydMoles => "viscosity.Dmoles",
89 SinglePhaseProperty::ViscositydMolFraction => "viscosity.Dmolfraction",
90 SinglePhaseProperty::ThermalConductivity => "thermalConductivity",
91 SinglePhaseProperty::ThermalConductivitydTemperature => "thermalConductivity.Dtemperature",
92 SinglePhaseProperty::ThermalConductivitydPressure => "thermalConductivity.Dpressure",
93 SinglePhaseProperty::ThermalConductivitydMoles => "thermalConductivity.Dmoles",
94 SinglePhaseProperty::ThermalConductivitydMolFraction => "thermalConductivity.Dmolfraction",
95 SinglePhaseProperty::Enthalpy => "enthalpy",
96 SinglePhaseProperty::EnthalpydTemperature => "enthalpy.Dtemperature",
97 SinglePhaseProperty::EnthalpydPressure => "enthalpy.Dpressure",
98 SinglePhaseProperty::EnthalpydMoles => "enthalpy.Dmoles",
99 SinglePhaseProperty::EnthalpydMolFraction => "enthalpy.Dmolfraction",
100 SinglePhaseProperty::Entropy=> "entropy",
101 SinglePhaseProperty::EntropydTemperature => "entropy.Dtemperature",
102 SinglePhaseProperty::EntropydPressure => "entropy.Dpressure",
103 SinglePhaseProperty::EntropydMoles => "entropy.Dmoles",
104 SinglePhaseProperty::EntropydMolFraction => "entropy.Dmolfraction",
105 SinglePhaseProperty::Density=> "density",
106 SinglePhaseProperty::DensitydTemperature => "density.Dtemperature",
107 SinglePhaseProperty::DensitydPressure => "density.Dpressure",
108 SinglePhaseProperty::DensitydMoles => "density.Dmoles",
109 SinglePhaseProperty::DensitydMolFraction => "density.Dmolfraction",
110 SinglePhaseProperty::Volume=> "volume",
111 SinglePhaseProperty::VolumedTemperature => "volume.Dtemperature",
112 SinglePhaseProperty::VolumedPressure => "volume.Dpressure",
113 SinglePhaseProperty::VolumedMoles => "volume.Dmoles",
114 SinglePhaseProperty::VolumedMolFraction => "volume.Dmolfraction",
115 }
116 }
117}
118
119impl PropertyTables {
120
121 fn new() -> PropertyTables {
128
129 let mut single_phase_property_map = CapeOpenMap::new();
130 for prop in SinglePhaseProperty::iter() {
131 single_phase_property_map.insert(prop.name().into(),prop);
132 }
133 PropertyTables {
134 single_phase_property_map,
135 }
136 }
137
138 pub fn get_single_phase_property<'a,'b,S:CapeStringConstProvider>(&'a self,prop_name:&'b S) -> Option<&'a SinglePhaseProperty> where 'b:'a {
146 self.single_phase_property_map.get(prop_name)
147 }
148
149}
150
151pub(crate) static PROPERTYTABLES: LazyLock<PropertyTables> = LazyLock::new(|
153|{PropertyTables::new()});