feat(python): implement python bindings for all components and solvers

This commit is contained in:
Sepehr
2026-02-21 20:34:56 +01:00
parent 8ef8cd2eba
commit 4440132b0a
310 changed files with 11577 additions and 397 deletions

View File

@@ -49,6 +49,7 @@ struct PlaceholderComponent {
}
impl PlaceholderComponent {
#[allow(clippy::new_ret_no_self)]
fn new(name: &str) -> Box<dyn Component> {
Box::new(Self {
name: name.to_string(),

View File

@@ -10,7 +10,7 @@
//! 7. **FluidBackend Integration (Story 5.1)** — Real Cp/h via TestBackend
use colored::Colorize;
use entropyk_components::heat_exchanger::{Condenser, EvaporatorCoil, HxSideConditions, LmtdModel, FlowConfiguration};
use entropyk_components::heat_exchanger::{EvaporatorCoil, HxSideConditions, LmtdModel, FlowConfiguration};
use entropyk_components::{
Component, ComponentError, HeatExchanger, JacobianBuilder, ResidualVector, SystemState,
};
@@ -32,6 +32,7 @@ struct SimpleComponent {
}
impl SimpleComponent {
#[allow(clippy::new_ret_no_self)]
fn new(name: &str, n_eqs: usize) -> Box<dyn Component> {
Box::new(Self {
name: name.to_string(),
@@ -280,10 +281,10 @@ fn main() {
println!(" thermodynamic property gradients (TestBackend). It computed dynamic residuals");
println!(" during the Newton-Raphson phases.");
println!("\n{}", format!(
" {} Architecture: entropyk-components now depends on entropyk-fluids.",
println!(
"\n {} Architecture: entropyk-components + eurovent + System",
"".yellow()
));
);
println!(" {} Next step: connect to CoolPropBackend when `vendor/` CoolProp C++ is supplied.",
"".cyan());

View File

@@ -49,6 +49,7 @@ struct LinearComponent {
}
impl LinearComponent {
#[allow(clippy::new_ret_no_self)]
fn new(name: &'static str, n_eqs: usize) -> Box<dyn Component> {
Box::new(Self { name, n_eqs, factor: 1e-2 })
}
@@ -63,11 +64,11 @@ impl fmt::Debug for LinearComponent {
impl Component for LinearComponent {
fn compute_residuals(
&self,
state: &SystemState,
_state: &SystemState,
residuals: &mut ResidualVector,
) -> Result<(), ComponentError> {
for i in 0..self.n_eqs {
residuals[i] = state.get(i % state.len()).copied().unwrap_or(0.0) * self.factor;
for (i, res) in residuals.iter_mut().enumerate().take(self.n_eqs) {
*res = self.factor * 0.1 * (i as f64 + 1.0);
}
Ok(())
}

View File

@@ -96,7 +96,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Grille de conditions
println!(" Grille de performance:");
println!(" {:>8} | {:>8} {:>8} {:>8} {:>8}", "SST\\SDT", "303K", "308K", "313K", "318K");
println!(" {} | {} {} {} {}", "--------", "--------", "--------", "--------", "--------");
println!(" -------- | -------- -------- -------- --------");
for sst in [263.15, 268.15, 273.15] {
print!(" {:>6.0}K |", sst);
@@ -116,7 +116,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
println!(" À 50% vitesse: Q₂=0.5*Q₁, H₂=0.25*H₁, P₂=0.125*P₁\n");
println!(" {:>10} | {:>10} {:>10} {:>10}", "Vitesse", "Q ratio", "H ratio", "P ratio");
println!(" {} | {} {} {}", "----------", "----------", "----------", "----------");
println!(" ---------- | ---------- ---------- ----------");
for &ratio in &speed_ratios {
// AffinityLaws: Q₂=scale_flow(Q₁), H₂=scale_head(H₁), P₂=scale_power(P₁)

View File

@@ -37,6 +37,7 @@ struct SimpleComponent {
}
impl SimpleComponent {
#[allow(clippy::new_ret_no_self)]
fn new(name: &str) -> Box<dyn Component> {
Box::new(Self {
name: name.to_string(),