3.0 KiB
3.0 KiB
Tutorial: Getting Started with Entropyk
This guide will walk you through setting up your environment, running your first simulation, using the visual UI, and building your own thermodynamic models.
1. Environment Setup
Prerequisites
Ensure you have the latest stable version of Rust installed:
rustup update stable
Clone and Build
Clone the repository and build the workspace:
git clone https://github.com/your-username/Entropyk.git
cd Entropyk
cargo build --workspace
2. Running Your First Simulation
The best way to understand Entropyk's capabilities is by running the Water Chiller Demo.
Run the Demo
cargo run --bin chiller
What's Happening?
The chiller.rs demo sets up a complete refrigeration cycle:
- Water Side (Circuit 1): Pump moves 12°C water at 0.5 kg/s through an evaporator.
- Refrigerant Side (Circuit 0): R410A flows through a compressor (2900 RPM), condenser (air-cooled at 35°C), expansion valve, and evaporator.
- Thermal Coupling: The evaporator exchanges heat between the water and refrigerant circuits.
The output displays the Point de Design (COP, power consumption, heat transfer).
3. Using the Visual UI
Entropyk includes a web-based interface to build systems without writing code.
Launch the UI Server
cargo run -p entropyk-demo --bin ui-server
Build a System Graphically
- Open http://localhost:3030.
- Palette: Drag and drop components (Pump, Compressor, Pipe, etc.) onto the canvas.
- Configure: Click a component to adjust its parameters (fluids, polynomials, geometry).
- Connect:
- Click "Relier" in the toolbar.
- Click a Source (orange port) and then a Target (green port).
- Simulate: The UI sends the configuration to the Rust backend, which performs calculations using real thermodynamic models.
4. Coding with the Library
Here's how to create a simple unit-safe model using the Entropyk crates.
Basic Physical Quantities
use entropyk_core::{Pressure, Temperature};
let p = Pressure::from_bar(3.5);
let t = Temperature::from_celsius(25.0);
println!("Pressure: {} Pa", p.to_pascals());
Creating and Connecting Ports
Entropyk uses the Type-State Pattern to prevent uninitialized connections.
use entropyk_components::port::{Port, FluidId};
// 1. Create disconnected ports
let p1 = Port::new(FluidId::new("Water"), p, h);
let p2 = Port::new(FluidId::new("Water"), p, h);
// 2. Connect (returns Result of connected ports)
let (mut c1, mut c2) = p1.connect(p2).expect("Incompatible ports!");
5. Next Steps
- EXAMPLES.md: Explore code snippets for every component (Heat Exchangers, Pumps, Fans, etc.).
- Crates Documentation: Deep dive into the library architecture.
- Story 1.3 README: Technical details on the port and connection system.
Happy simulating!