90 lines
3.0 KiB
Markdown
90 lines
3.0 KiB
Markdown
# 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](https://www.rust-lang.org/) installed:
|
|
```bash
|
|
rustup update stable
|
|
```
|
|
|
|
### Clone and Build
|
|
Clone the repository and build the workspace:
|
|
```bash
|
|
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
|
|
```bash
|
|
cargo run --bin chiller
|
|
```
|
|
|
|
### What's Happening?
|
|
The `chiller.rs` demo sets up a complete refrigeration cycle:
|
|
1. **Water Side (Circuit 1)**: Pump moves 12°C water at 0.5 kg/s through an evaporator.
|
|
2. **Refrigerant Side (Circuit 0)**: R410A flows through a compressor (2900 RPM), condenser (air-cooled at 35°C), expansion valve, and evaporator.
|
|
3. **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
|
|
```bash
|
|
cargo run -p entropyk-demo --bin ui-server
|
|
```
|
|
|
|
### Build a System Graphically
|
|
1. Open [http://localhost:3030](http://localhost:3030).
|
|
2. **Palette**: Drag and drop components (Pump, Compressor, Pipe, etc.) onto the canvas.
|
|
3. **Configure**: Click a component to adjust its parameters (fluids, polynomials, geometry).
|
|
4. **Connect**:
|
|
- Click "Relier" in the toolbar.
|
|
- Click a **Source** (orange port) and then a **Target** (green port).
|
|
5. **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
|
|
```rust
|
|
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.
|
|
```rust
|
|
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](../EXAMPLES.md)**: Explore code snippets for every component (Heat Exchangers, Pumps, Fans, etc.).
|
|
- **[Crates Documentation](../crates/entropyk/README.md)**: Deep dive into the library architecture.
|
|
- **[Story 1.3 README](../README_STORY_1_3.md)**: Technical details on the port and connection system.
|
|
|
|
Happy simulating!
|