chore: sync project state and current artifacts

This commit is contained in:
Sepehr
2026-02-22 23:27:31 +01:00
parent 1b6415776e
commit dd77089b22
232 changed files with 37056 additions and 4296 deletions

View File

@@ -44,7 +44,7 @@ use crate::port::{Connected, Disconnected, FluidId, Port};
use crate::state_machine::StateManageable;
use crate::{
CircuitId, Component, ComponentError, ConnectedPort, JacobianBuilder, OperationalState,
ResidualVector, SystemState,
ResidualVector, StateSlice,
};
use entropyk_core::{Calib, MassFlow};
use std::marker::PhantomData;
@@ -164,7 +164,7 @@ pub mod friction_factor {
if reynolds < 2300.0 {
return 64.0 / reynolds;
}
// Prevent division by zero or negative values in log
let re_clamped = reynolds.max(1.0);
@@ -505,7 +505,7 @@ impl Pipe<Connected> {
// Darcy-Weisbach nominal: ΔP_nominal = f × (L/D) × (ρ × v² / 2); ΔP_eff = f_dp × ΔP_nominal
let dp_nominal = f * ld * self.fluid_density_kg_per_m3 * velocity * velocity / 2.0;
let dp = dp_nominal * self.calib.f_dp;
if flow_m3_per_s < 0.0 {
-dp
} else {
@@ -557,7 +557,7 @@ impl Pipe<Connected> {
impl Component for Pipe<Connected> {
fn compute_residuals(
&self,
state: &SystemState,
state: &StateSlice,
residuals: &mut ResidualVector,
) -> Result<(), ComponentError> {
if residuals.len() != self.n_equations() {
@@ -571,7 +571,10 @@ impl Component for Pipe<Connected> {
OperationalState::Off => {
// Blocked pipe: no flow
if state.is_empty() {
return Err(ComponentError::InvalidStateDimensions { expected: 1, actual: 0 });
return Err(ComponentError::InvalidStateDimensions {
expected: 1,
actual: 0,
});
}
residuals[0] = state[0];
return Ok(());
@@ -612,7 +615,7 @@ impl Component for Pipe<Connected> {
fn jacobian_entries(
&self,
state: &SystemState,
state: &StateSlice,
jacobian: &mut JacobianBuilder,
) -> Result<(), ComponentError> {
match self.operational_state {
@@ -652,7 +655,10 @@ impl Component for Pipe<Connected> {
1
}
fn port_mass_flows(&self, state: &SystemState) -> Result<Vec<entropyk_core::MassFlow>, ComponentError> {
fn port_mass_flows(
&self,
state: &StateSlice,
) -> Result<Vec<entropyk_core::MassFlow>, ComponentError> {
if state.is_empty() {
return Err(ComponentError::InvalidStateDimensions {
expected: 1,
@@ -660,12 +666,40 @@ impl Component for Pipe<Connected> {
});
}
let m = entropyk_core::MassFlow::from_kg_per_s(state[0]);
Ok(vec![m, entropyk_core::MassFlow::from_kg_per_s(-m.to_kg_per_s())])
Ok(vec![
m,
entropyk_core::MassFlow::from_kg_per_s(-m.to_kg_per_s()),
])
}
fn get_ports(&self) -> &[ConnectedPort] {
&[]
}
fn port_enthalpies(
&self,
_state: &StateSlice,
) -> Result<Vec<entropyk_core::Enthalpy>, ComponentError> {
Ok(vec![
self.port_inlet.enthalpy(),
self.port_outlet.enthalpy(),
])
}
fn energy_transfers(
&self,
_state: &StateSlice,
) -> Option<(entropyk_core::Power, entropyk_core::Power)> {
match self.operational_state {
OperationalState::Off | OperationalState::Bypass | OperationalState::On => {
// Pipes are adiabatic
Some((
entropyk_core::Power::from_watts(0.0),
entropyk_core::Power::from_watts(0.0),
))
}
}
}
}
impl StateManageable for Pipe<Connected> {