//! Exemple: Conduite (pipe)
//!
//! Perte de charge avec Darcy-Weisbach.
//!
//! Exécuter: cargo run -p entropyk-demo --bin pipe

use entropyk_components::pipe::{roughness, Pipe, PipeGeometry};
use entropyk_components::port::{FluidId, Port};
use entropyk_core::{Enthalpy, Pressure};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    println!("=== Exemple: Conduite (Pipe) ===\n");

    let geometry = PipeGeometry::new(10.0, 0.022, roughness::SMOOTH)?;

    let inlet = Port::new(
        FluidId::new("Water"),
        Pressure::from_bar(2.0),
        Enthalpy::from_joules_per_kg(84_000.0),
    );
    let outlet = Port::new(
        FluidId::new("Water"),
        Pressure::from_bar(2.0),
        Enthalpy::from_joules_per_kg(84_000.0),
    );

    let pipe = Pipe::new(geometry, inlet, outlet, 998.0, 0.001)?;

    println!("Conduite créée:");
    println!("  - Longueur: {} m", pipe.geometry().length_m);
    println!("  - Diamètre: {} m", pipe.geometry().diameter_m);
    println!("  - Rugosité: {} m", pipe.geometry().roughness_m);
    println!("  - Fluide: {}", pipe.fluid_id());

    Ok(())
}
