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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//! Canonical phase-qualified identity for equilibrium solver components.
//!
//! A component is not merely a substance name: `gas::H2O` and `liquid::H2O`
//! are distinct unknowns with potentially different standard-state records.
//! This module is deliberately independent from bridge construction and from
//! nonlinear solvers so both layers share one identity contract.
use crate::Thermodynamics::ChemEquilibrium::equilibrium_activity::PhaseActivityModel;
use crate::Thermodynamics::User_PhaseOrSolution::PhaseModel;
use crate::Thermodynamics::phase_layout::{PhaseComponentId, PhaseId};
use crate::Thermodynamics::physical_state::PhysicalState;
/// Solver-facing identity and thermodynamic interpretation of one component.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct EquilibriumComponentDescriptor {
id: PhaseComponentId,
physical_state: PhysicalState,
phase_model: PhaseModel,
activity_model: PhaseActivityModel,
}
impl EquilibriumComponentDescriptor {
/// Creates one fully qualified equilibrium component.
pub fn new(
id: PhaseComponentId,
physical_state: PhysicalState,
phase_model: PhaseModel,
activity_model: PhaseActivityModel,
) -> Self {
Self {
id,
physical_state,
phase_model,
activity_model,
}
}
/// Phase-qualified component identity in canonical solver order.
pub fn id(&self) -> &PhaseComponentId {
&self.id
}
/// Bare substance name used for thermochemical record lookup.
pub fn substance(&self) -> &str {
&self.id.substance
}
/// Stable user-facing label that remains unique across phases.
pub fn label(&self) -> String {
self.id.label()
}
/// Physical state selected during thermochemical lookup.
pub fn physical_state(&self) -> PhysicalState {
self.physical_state
}
/// Domain-level phase model declared by the data subsystem.
pub fn phase_model(&self) -> PhaseModel {
self.phase_model
}
/// Canonical activity law consumed by equilibrium residuals.
pub fn activity_model(&self) -> PhaseActivityModel {
self.activity_model
}
}
/// Compatibility conversion for existing one-phase gas callers.
///
/// New multiphase code must construct [`EquilibriumComponentDescriptor`]
/// explicitly. A bare string is projected into the anonymous single gas phase
/// only so old one-phase tests and examples keep a well-defined identity while
/// they migrate.
impl From<String> for EquilibriumComponentDescriptor {
fn from(substance: String) -> Self {
Self::new(
PhaseComponentId::new(PhaseId::new(None), substance),
PhysicalState::Gas,
PhaseModel::IdealGas,
PhaseActivityModel::IdealGas,
)
}
}