//! Exemple: Détendeur (expansion valve)
//!
//! Modélisation d'une détente isenthalpique.
//!
//! Exécuter: cargo run -p entropyk-demo --bin expansion_valve

use entropyk_components::expansion_valve::ExpansionValve;
use entropyk_components::port::{FluidId, Port};
use entropyk_core::{Enthalpy, Pressure};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    println!("=== Exemple: Détendeur (Expansion Valve) ===\n");

    let inlet = Port::new(
        FluidId::new("R134a"),
        Pressure::from_bar(10.0),
        Enthalpy::from_joules_per_kg(250_000.0),
    );
    let outlet = Port::new(
        FluidId::new("R134a"),
        Pressure::from_bar(10.0),
        Enthalpy::from_joules_per_kg(250_000.0),
    );

    let valve = ExpansionValve::new(inlet, outlet, Some(1.0))?;

    println!("Détendeur créé:");
    println!("  - Fluide: {}", valve.fluid_id());
    println!("  - Ouverture: {:?}", valve.opening());

    Ok(())
}
