Update project structure and configurations
This commit is contained in:
@@ -85,7 +85,7 @@ impl BphxCondenser {
|
||||
///
|
||||
/// let geo = BphxGeometry::from_dh_area(0.003, 0.5, 20);
|
||||
/// let cond = BphxCondenser::new(geo);
|
||||
/// assert_eq!(cond.n_equations(), 3);
|
||||
/// assert_eq!(cond.n_equations(), 2);
|
||||
/// ```
|
||||
pub fn new(geometry: BphxGeometry) -> Self {
|
||||
let geometry = geometry.with_exchanger_type(BphxType::Condenser);
|
||||
@@ -409,6 +409,13 @@ impl Component for BphxCondenser {
|
||||
self.inner.energy_transfers(state)
|
||||
}
|
||||
|
||||
fn set_fluid_backend_from_builder(&mut self, backend: std::sync::Arc<dyn entropyk_fluids::FluidBackend>) {
|
||||
if self.fluid_backend.is_none() {
|
||||
self.fluid_backend = Some(backend.clone());
|
||||
self.inner.set_fluid_backend_from_builder(backend);
|
||||
}
|
||||
}
|
||||
|
||||
fn signature(&self) -> String {
|
||||
format!(
|
||||
"BphxCondenser({} plates, dh={:.2}mm, A={:.3}m², {}, SC={:.1}K, {})",
|
||||
@@ -420,6 +427,10 @@ impl Component for BphxCondenser {
|
||||
self.refrigerant_id
|
||||
)
|
||||
}
|
||||
|
||||
fn update_calib_factor(&mut self, factor: &str, value: f64) -> bool {
|
||||
self.inner.update_calib_factor(factor, value)
|
||||
}
|
||||
}
|
||||
|
||||
impl StateManageable for BphxCondenser {
|
||||
|
||||
@@ -130,7 +130,7 @@ impl BphxEvaporator {
|
||||
///
|
||||
/// let geo = BphxGeometry::from_dh_area(0.003, 0.5, 20);
|
||||
/// let evap = BphxEvaporator::new(geo);
|
||||
/// assert_eq!(evap.n_equations(), 3);
|
||||
/// assert_eq!(evap.n_equations(), 2);
|
||||
/// ```
|
||||
pub fn new(geometry: BphxGeometry) -> Self {
|
||||
let geometry = geometry.with_exchanger_type(BphxType::Evaporator);
|
||||
@@ -460,6 +460,13 @@ impl Component for BphxEvaporator {
|
||||
self.inner.energy_transfers(state)
|
||||
}
|
||||
|
||||
fn set_fluid_backend_from_builder(&mut self, backend: std::sync::Arc<dyn entropyk_fluids::FluidBackend>) {
|
||||
if self.fluid_backend.is_none() {
|
||||
self.fluid_backend = Some(backend.clone());
|
||||
self.inner.set_fluid_backend_from_builder(backend);
|
||||
}
|
||||
}
|
||||
|
||||
fn signature(&self) -> String {
|
||||
let mode_str = match self.mode {
|
||||
BphxEvaporatorMode::Dx { target_superheat } => {
|
||||
@@ -479,6 +486,10 @@ impl Component for BphxEvaporator {
|
||||
self.refrigerant_id
|
||||
)
|
||||
}
|
||||
|
||||
fn update_calib_factor(&mut self, factor: &str, value: f64) -> bool {
|
||||
self.inner.update_calib_factor(factor, value)
|
||||
}
|
||||
}
|
||||
|
||||
impl StateManageable for BphxEvaporator {
|
||||
|
||||
@@ -94,7 +94,7 @@ impl BphxExchanger {
|
||||
///
|
||||
/// let geo = BphxGeometry::from_dh_area(0.003, 0.5, 20);
|
||||
/// let hx = BphxExchanger::new(geo);
|
||||
/// assert_eq!(hx.n_equations(), 3);
|
||||
/// assert_eq!(hx.n_equations(), 2);
|
||||
/// ```
|
||||
pub fn new(geometry: BphxGeometry) -> Self {
|
||||
let ua_estimate = Self::estimate_ua(&geometry);
|
||||
@@ -363,6 +363,12 @@ impl Component for BphxExchanger {
|
||||
self.inner.energy_transfers(state)
|
||||
}
|
||||
|
||||
fn set_fluid_backend_from_builder(&mut self, backend: std::sync::Arc<dyn entropyk_fluids::FluidBackend>) {
|
||||
if self.fluid_backend.is_none() {
|
||||
self.fluid_backend = Some(backend);
|
||||
}
|
||||
}
|
||||
|
||||
fn signature(&self) -> String {
|
||||
format!(
|
||||
"BphxExchanger({} plates, dh={:.2}mm, A={:.3}m², {})",
|
||||
@@ -372,6 +378,10 @@ impl Component for BphxExchanger {
|
||||
self.correlation_selector.correlation.name()
|
||||
)
|
||||
}
|
||||
|
||||
fn update_calib_factor(&mut self, factor: &str, value: f64) -> bool {
|
||||
self.inner.update_calib_factor(factor, value)
|
||||
}
|
||||
}
|
||||
|
||||
impl StateManageable for BphxExchanger {
|
||||
|
||||
@@ -30,7 +30,7 @@ use entropyk_core::Calib;
|
||||
/// use entropyk_components::Component;
|
||||
///
|
||||
/// let condenser = Condenser::new(10_000.0); // UA = 10 kW/K
|
||||
/// assert_eq!(condenser.n_equations(), 3);
|
||||
/// assert_eq!(condenser.n_equations(), 2);
|
||||
/// ```
|
||||
#[derive(Debug)]
|
||||
pub struct Condenser {
|
||||
@@ -225,6 +225,18 @@ impl Component for Condenser {
|
||||
) -> Option<(entropyk_core::Power, entropyk_core::Power)> {
|
||||
self.inner.energy_transfers(state)
|
||||
}
|
||||
|
||||
fn signature(&self) -> String {
|
||||
self.inner.signature()
|
||||
}
|
||||
|
||||
fn to_params(&self) -> crate::ComponentParams {
|
||||
self.inner.to_params()
|
||||
}
|
||||
|
||||
fn update_calib_factor(&mut self, factor: &str, value: f64) -> bool {
|
||||
self.inner.update_calib_factor(factor, value)
|
||||
}
|
||||
}
|
||||
|
||||
impl StateManageable for Condenser {
|
||||
|
||||
@@ -33,7 +33,7 @@ use crate::{
|
||||
///
|
||||
/// let coil = CondenserCoil::new(10_000.0); // UA = 10 kW/K
|
||||
/// assert_eq!(coil.ua(), 10_000.0);
|
||||
/// assert_eq!(coil.n_equations(), 3);
|
||||
/// assert_eq!(coil.n_equations(), 2);
|
||||
/// ```
|
||||
#[derive(Debug)]
|
||||
pub struct CondenserCoil {
|
||||
@@ -147,6 +147,18 @@ impl Component for CondenserCoil {
|
||||
) -> Option<(entropyk_core::Power, entropyk_core::Power)> {
|
||||
self.inner.energy_transfers(state)
|
||||
}
|
||||
|
||||
fn signature(&self) -> String {
|
||||
self.inner.signature()
|
||||
}
|
||||
|
||||
fn to_params(&self) -> crate::ComponentParams {
|
||||
self.inner.to_params()
|
||||
}
|
||||
|
||||
fn update_calib_factor(&mut self, factor: &str, value: f64) -> bool {
|
||||
self.inner.update_calib_factor(factor, value)
|
||||
}
|
||||
}
|
||||
|
||||
impl StateManageable for CondenserCoil {
|
||||
|
||||
@@ -183,6 +183,14 @@ impl Component for Economizer {
|
||||
) -> Option<(entropyk_core::Power, entropyk_core::Power)> {
|
||||
self.inner.energy_transfers(state)
|
||||
}
|
||||
|
||||
fn signature(&self) -> String {
|
||||
self.inner.signature()
|
||||
}
|
||||
|
||||
fn to_params(&self) -> crate::ComponentParams {
|
||||
self.inner.to_params()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -29,7 +29,7 @@ use entropyk_core::Calib;
|
||||
/// use entropyk_components::Component;
|
||||
///
|
||||
/// let evaporator = Evaporator::new(8_000.0); // UA = 8 kW/K
|
||||
/// assert_eq!(evaporator.n_equations(), 3);
|
||||
/// assert_eq!(evaporator.n_equations(), 2);
|
||||
/// ```
|
||||
#[derive(Debug)]
|
||||
pub struct Evaporator {
|
||||
@@ -237,6 +237,18 @@ impl Component for Evaporator {
|
||||
) -> Option<(entropyk_core::Power, entropyk_core::Power)> {
|
||||
self.inner.energy_transfers(state)
|
||||
}
|
||||
|
||||
fn signature(&self) -> String {
|
||||
self.inner.signature()
|
||||
}
|
||||
|
||||
fn to_params(&self) -> crate::ComponentParams {
|
||||
self.inner.to_params()
|
||||
}
|
||||
|
||||
fn update_calib_factor(&mut self, factor: &str, value: f64) -> bool {
|
||||
self.inner.update_calib_factor(factor, value)
|
||||
}
|
||||
}
|
||||
|
||||
impl StateManageable for Evaporator {
|
||||
|
||||
@@ -33,7 +33,7 @@ use crate::{
|
||||
///
|
||||
/// let coil = EvaporatorCoil::new(8_000.0); // UA = 8 kW/K
|
||||
/// assert_eq!(coil.ua(), 8_000.0);
|
||||
/// assert_eq!(coil.n_equations(), 3);
|
||||
/// assert_eq!(coil.n_equations(), 2);
|
||||
/// ```
|
||||
#[derive(Debug)]
|
||||
pub struct EvaporatorCoil {
|
||||
@@ -157,6 +157,18 @@ impl Component for EvaporatorCoil {
|
||||
) -> Option<(entropyk_core::Power, entropyk_core::Power)> {
|
||||
self.inner.energy_transfers(state)
|
||||
}
|
||||
|
||||
fn signature(&self) -> String {
|
||||
self.inner.signature()
|
||||
}
|
||||
|
||||
fn to_params(&self) -> crate::ComponentParams {
|
||||
self.inner.to_params()
|
||||
}
|
||||
|
||||
fn update_calib_factor(&mut self, factor: &str, value: f64) -> bool {
|
||||
self.inner.update_calib_factor(factor, value)
|
||||
}
|
||||
}
|
||||
|
||||
impl StateManageable for EvaporatorCoil {
|
||||
|
||||
@@ -91,7 +91,7 @@ impl<Model: HeatTransferModel + 'static> HeatExchangerBuilder<Model> {
|
||||
///
|
||||
/// let model = LmtdModel::new(5000.0, FlowConfiguration::CounterFlow);
|
||||
/// let hx = HeatExchanger::new(model, "Condenser");
|
||||
/// assert_eq!(hx.n_equations(), 3);
|
||||
/// assert_eq!(hx.n_equations(), 2);
|
||||
/// ```
|
||||
/// Boundary conditions for one side of the heat exchanger.
|
||||
///
|
||||
@@ -448,8 +448,8 @@ impl<Model: HeatTransferModel + 'static> HeatExchanger<Model> {
|
||||
|
||||
/// Sets calibration factors.
|
||||
pub fn set_calib(&mut self, calib: Calib) {
|
||||
self.calib = calib;
|
||||
self.model.set_ua_scale(calib.f_ua);
|
||||
self.calib = calib;
|
||||
}
|
||||
|
||||
/// Creates a fluid state from temperature, pressure, enthalpy, mass flow, and Cp.
|
||||
@@ -741,6 +741,32 @@ impl<Model: HeatTransferModel + 'static> Component for HeatExchanger<Model> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn set_fluid_backend_from_builder(&mut self, backend: std::sync::Arc<dyn entropyk_fluids::FluidBackend>) {
|
||||
if self.fluid_backend.is_none() {
|
||||
self.fluid_backend = Some(backend);
|
||||
}
|
||||
}
|
||||
|
||||
fn signature(&self) -> String {
|
||||
format!("{}(circuit={})", self.name, self.circuit_id.0)
|
||||
}
|
||||
|
||||
fn to_params(&self) -> crate::ComponentParams {
|
||||
crate::ComponentParams::new(&self.name)
|
||||
.with_param("circuitId", self.circuit_id.0)
|
||||
.with_param("calib", serde_json::to_value(&self.calib).unwrap_or(serde_json::Value::Null))
|
||||
}
|
||||
|
||||
fn update_calib_factor(&mut self, factor: &str, value: f64) -> bool {
|
||||
let mut c = self.calib().clone();
|
||||
if c.set_factor(factor, value) {
|
||||
self.set_calib(c);
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<Model: HeatTransferModel + 'static> StateManageable for HeatExchanger<Model> {
|
||||
|
||||
@@ -314,6 +314,12 @@ impl Component for FloodedCondenser {
|
||||
self.inner.energy_transfers(state)
|
||||
}
|
||||
|
||||
fn set_fluid_backend_from_builder(&mut self, backend: std::sync::Arc<dyn entropyk_fluids::FluidBackend>) {
|
||||
if self.fluid_backend.is_none() {
|
||||
self.fluid_backend = Some(backend);
|
||||
}
|
||||
}
|
||||
|
||||
fn signature(&self) -> String {
|
||||
format!(
|
||||
"FloodedCondenser(UA={:.0},fluid={},target_sc={:.1}K)",
|
||||
@@ -322,6 +328,18 @@ impl Component for FloodedCondenser {
|
||||
self.target_subcooling_k
|
||||
)
|
||||
}
|
||||
|
||||
fn to_params(&self) -> crate::ComponentParams {
|
||||
crate::ComponentParams::new("FloodedCondenser")
|
||||
.with_param("fluid", self.refrigerant_id.as_str())
|
||||
.with_param("ua", self.ua())
|
||||
.with_param("targetSubcoolingK", self.target_subcooling_k)
|
||||
.with_param("calib", serde_json::to_value(&self.calib()).unwrap_or(serde_json::Value::Null))
|
||||
}
|
||||
|
||||
fn update_calib_factor(&mut self, factor: &str, value: f64) -> bool {
|
||||
self.inner.update_calib_factor(factor, value)
|
||||
}
|
||||
}
|
||||
|
||||
impl StateManageable for FloodedCondenser {
|
||||
|
||||
@@ -330,6 +330,12 @@ impl Component for FloodedEvaporator {
|
||||
self.inner.energy_transfers(state)
|
||||
}
|
||||
|
||||
fn set_fluid_backend_from_builder(&mut self, backend: std::sync::Arc<dyn entropyk_fluids::FluidBackend>) {
|
||||
if self.fluid_backend.is_none() {
|
||||
self.fluid_backend = Some(backend);
|
||||
}
|
||||
}
|
||||
|
||||
fn signature(&self) -> String {
|
||||
format!(
|
||||
"FloodedEvaporator(UA={:.0},fluid={},target_q={:.2})",
|
||||
@@ -338,6 +344,18 @@ impl Component for FloodedEvaporator {
|
||||
self.target_quality
|
||||
)
|
||||
}
|
||||
|
||||
fn to_params(&self) -> crate::ComponentParams {
|
||||
crate::ComponentParams::new("FloodedEvaporator")
|
||||
.with_param("fluid", self.refrigerant_id.as_str())
|
||||
.with_param("ua", self.ua())
|
||||
.with_param("targetQuality", self.target_quality)
|
||||
.with_param("calib", serde_json::to_value(&self.calib()).unwrap_or(serde_json::Value::Null))
|
||||
}
|
||||
|
||||
fn update_calib_factor(&mut self, factor: &str, value: f64) -> bool {
|
||||
self.inner.update_calib_factor(factor, value)
|
||||
}
|
||||
}
|
||||
|
||||
impl StateManageable for FloodedEvaporator {
|
||||
|
||||
@@ -345,6 +345,10 @@ impl Component for MchxCondenserCoil {
|
||||
self.t_air_k
|
||||
)
|
||||
}
|
||||
|
||||
fn update_calib_factor(&mut self, factor: &str, value: f64) -> bool {
|
||||
self.inner.update_calib_factor(factor, value)
|
||||
}
|
||||
}
|
||||
|
||||
impl StateManageable for MchxCondenserCoil {
|
||||
|
||||
@@ -257,6 +257,17 @@ impl Component for MovingBoundaryHX {
|
||||
fn energy_transfers(&self, state: &StateSlice) -> Option<(Power, Power)> {
|
||||
self.inner.energy_transfers(state)
|
||||
}
|
||||
|
||||
fn set_fluid_backend_from_builder(&mut self, backend: std::sync::Arc<dyn entropyk_fluids::FluidBackend>) {
|
||||
if self.fluid_backend.is_none() {
|
||||
self.fluid_backend = Some(backend.clone());
|
||||
self.inner.set_fluid_backend_from_builder(backend);
|
||||
}
|
||||
}
|
||||
|
||||
fn update_calib_factor(&mut self, factor: &str, value: f64) -> bool {
|
||||
self.inner.update_calib_factor(factor, value)
|
||||
}
|
||||
}
|
||||
|
||||
impl StateManageable for MovingBoundaryHX {
|
||||
|
||||
Reference in New Issue
Block a user