1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
use crateState;
use ThermoModel;
/// Capability for constructing a [`State`] from a typed input.
///
/// A thermodynamic [`State`] includes a `Fluid` value. In Twine, `Fluid` is
/// allowed to carry *state-defining* information such as mixture composition,
/// salinity, or any other configuration needed to make the state well-defined.
///
/// `StateFrom<Input>` expresses, at compile time, which combinations of
/// inputs a model can use to construct a state.
/// If a model does not implement `StateFrom<Input>`, then that input is simply
/// not supported (no runtime "not implemented" errors).
///
/// ## Common input patterns
///
/// Inputs are intentionally represented as normal Rust types (often tuples).
/// Common patterns include:
/// - `(Fluid, ThermodynamicTemperature, Pressure)` (temperature + pressure)
/// - `(Fluid, Pressure, MassDensity)` (pressure + density)
/// - `(Fluid, Pressure, SpecificEnthalpy)` (pressure + enthalpy)
/// - `(Fluid, Pressure, SpecificEntropy)` (pressure + entropy)
/// - `(Fluid, ThermodynamicTemperature)` (e.g. for an incompressible liquid)
///
/// ## Default fluid convenience
///
/// Many call sites don't want to spell the fluid value when the `Fluid` is a
/// simple marker type (or otherwise has no state-defining data).
/// To support that ergonomically while keeping the core API explicit,
/// we provide blanket implementations that create the fluid using `Fluid::default()`.
///
/// For example, if a model implements `StateFrom<(Fluid, A, B)>` and `Fluid:
/// Default`, then it also implements `StateFrom<(A, B)>`.
/// This enables calls like `thermo.state_from((t, p))` without losing the
/// ability to pass an explicit `Fluid` when the fluid carries state-defining
/// data (composition, salinity, etc.).
/// Default-fluid convenience impl.
///
/// If a model can construct a state from an explicit `(Fluid, A, B)` input and
/// `Fluid: Default`, then it can also construct a state from just `(A, B)` by
/// using `Fluid::default()`.
///
/// This is intended for cases where `Fluid` is a marker type (or otherwise does
/// not carry state-defining data). If the `Fluid` carries state-defining data,
/// prefer inputs that include the explicit fluid value.