# Entropyk

A thermodynamic cycle simulation library with type-safe APIs and idiomatic Rust design.

## Features

- **Type-safe physical quantities**: Never mix up units with NewType wrappers for Pressure, Temperature, Enthalpy, and MassFlow
- **Component-based modeling**: Build complex systems from reusable blocks (Compressor, Condenser, Evaporator, etc.)
- **Multiple solver strategies**: Newton-Raphson with automatic fallback to Sequential Substitution
- **Multi-fluid support**: CoolProp integration, tabular interpolation, incompressible fluids
- **Zero-panic policy**: All errors return `Result<T, ThermoError>`

## Quick Start

Add to your `Cargo.toml`:

```toml
[dependencies]
entropyk = "0.1"
```

## Example

```rust,ignore
use entropyk::{
    System, Solver, NewtonConfig,
    Compressor, Condenser, Evaporator, ExpansionValve,
    Ahri540Coefficients, ThermalConductance,
};

// Build a simple refrigeration cycle
let mut system = System::new();

// Define component parameters (see API docs for details)
let coeffs = Ahri540Coefficients { /* ... */ };
let ua = ThermalConductance::new(5000.0);

// Add components
let comp = system.add_component(Box::new(Compressor::new(coeffs)));
let cond = system.add_component(Box::new(Condenser::new(ua)));
let evap = system.add_component(Box::new(Evaporator::new(ua)));
let valve = system.add_component(Box::new(ExpansionValve::new()));

// Connect components
system.add_edge(comp, cond)?;
system.add_edge(cond, valve)?;
system.add_edge(valve, evap)?;
system.add_edge(evap, comp)?;

// Finalize and solve
system.finalize()?;

let solver = NewtonConfig::default();
let result = solver.solve(&system)?;
```

## Documentation

See the [API documentation](https://docs.rs/entropyk) for full details.

## License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
