chore: remove deprecated flow_boundary and update docs to match new architecture
This commit is contained in:
@@ -85,6 +85,7 @@ fn test_simulation_result_statuses() {
|
||||
convergence: None,
|
||||
iterations: Some(10),
|
||||
state: None,
|
||||
performance: None,
|
||||
error: None,
|
||||
elapsed_ms: 50,
|
||||
},
|
||||
@@ -94,6 +95,7 @@ fn test_simulation_result_statuses() {
|
||||
convergence: None,
|
||||
iterations: None,
|
||||
state: None,
|
||||
performance: None,
|
||||
error: Some("Error".to_string()),
|
||||
elapsed_ms: 0,
|
||||
},
|
||||
@@ -103,6 +105,7 @@ fn test_simulation_result_statuses() {
|
||||
convergence: None,
|
||||
iterations: Some(100),
|
||||
state: None,
|
||||
performance: None,
|
||||
error: None,
|
||||
elapsed_ms: 1000,
|
||||
},
|
||||
|
||||
@@ -19,6 +19,7 @@ fn test_simulation_result_serialization() {
|
||||
pressure_bar: 10.0,
|
||||
enthalpy_kj_kg: 400.0,
|
||||
}]),
|
||||
performance: None,
|
||||
error: None,
|
||||
elapsed_ms: 50,
|
||||
};
|
||||
@@ -55,6 +56,7 @@ fn test_error_result_serialization() {
|
||||
convergence: None,
|
||||
iterations: None,
|
||||
state: None,
|
||||
performance: None,
|
||||
error: Some("Configuration error".to_string()),
|
||||
elapsed_ms: 0,
|
||||
};
|
||||
@@ -75,3 +77,125 @@ fn test_create_minimal_config_file() {
|
||||
let content = std::fs::read_to_string(&config_path).unwrap();
|
||||
assert!(content.contains("R134a"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_screw_compressor_frequency_hz_config() {
|
||||
use entropyk_cli::config::ScenarioConfig;
|
||||
use tempfile::tempdir;
|
||||
|
||||
let dir = tempdir().unwrap();
|
||||
let config_path = dir.path().join("screw_vfd.json");
|
||||
|
||||
let json = r#"
|
||||
{
|
||||
"name": "Screw VFD Test",
|
||||
"fluid": "R134a",
|
||||
"circuits": [
|
||||
{
|
||||
"id": 0,
|
||||
"components": [
|
||||
{
|
||||
"type": "ScrewEconomizerCompressor",
|
||||
"name": "screw_test",
|
||||
"fluid": "R134a",
|
||||
"nominal_frequency_hz": 50.0,
|
||||
"frequency_hz": 40.0,
|
||||
"mechanical_efficiency": 0.92,
|
||||
"economizer_fraction": 0.12,
|
||||
"mf_a00": 1.2,
|
||||
"mf_a10": 0.003,
|
||||
"mf_a01": -0.002,
|
||||
"mf_a11": 0.00001,
|
||||
"pw_b00": 55000.0,
|
||||
"pw_b10": 200.0,
|
||||
"pw_b01": -300.0,
|
||||
"pw_b11": 0.5,
|
||||
"p_suction_bar": 3.2,
|
||||
"h_suction_kj_kg": 400.0,
|
||||
"p_discharge_bar": 12.8,
|
||||
"h_discharge_kj_kg": 440.0,
|
||||
"p_eco_bar": 6.4,
|
||||
"h_eco_kj_kg": 260.0
|
||||
}
|
||||
],
|
||||
"edges": []
|
||||
}
|
||||
],
|
||||
"solver": {
|
||||
"strategy": "fallback",
|
||||
"max_iterations": 10
|
||||
}
|
||||
}
|
||||
"#;
|
||||
|
||||
std::fs::write(&config_path, json).unwrap();
|
||||
|
||||
let config = ScenarioConfig::from_file(&config_path);
|
||||
assert!(config.is_ok(), "Config should parse successfully");
|
||||
|
||||
let config = config.unwrap();
|
||||
assert_eq!(config.circuits.len(), 1);
|
||||
|
||||
let screw_params = &config.circuits[0].components[0].params;
|
||||
assert_eq!(
|
||||
screw_params.get("frequency_hz").and_then(|v| v.as_f64()),
|
||||
Some(40.0)
|
||||
);
|
||||
assert_eq!(
|
||||
screw_params
|
||||
.get("nominal_frequency_hz")
|
||||
.and_then(|v| v.as_f64()),
|
||||
Some(50.0)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_run_simulation_with_coolprop() {
|
||||
use entropyk_cli::run::run_simulation;
|
||||
|
||||
let dir = tempdir().unwrap();
|
||||
let config_path = dir.path().join("coolprop.json");
|
||||
|
||||
let json = r#"
|
||||
{
|
||||
"fluid": "R134a",
|
||||
"fluid_backend": "CoolProp",
|
||||
"circuits": [
|
||||
{
|
||||
"id": 0,
|
||||
"components": [
|
||||
{
|
||||
"type": "HeatExchanger",
|
||||
"name": "hx1",
|
||||
"ua": 1000.0,
|
||||
"hot_fluid": "Water",
|
||||
"hot_t_inlet_c": 25.0,
|
||||
"cold_fluid": "R134a",
|
||||
"cold_t_inlet_c": 15.0
|
||||
}
|
||||
],
|
||||
"edges": []
|
||||
}
|
||||
],
|
||||
"solver": { "max_iterations": 1 }
|
||||
}
|
||||
"#;
|
||||
std::fs::write(&config_path, json).unwrap();
|
||||
|
||||
let result = run_simulation(&config_path, None, false).unwrap();
|
||||
|
||||
match result.status {
|
||||
SimulationStatus::Converged | SimulationStatus::NonConverged => {}
|
||||
SimulationStatus::Error => {
|
||||
let err_msg = result.error.unwrap();
|
||||
assert!(
|
||||
err_msg.contains("CoolProp")
|
||||
|| err_msg.contains("Fluid")
|
||||
|| err_msg.contains("Component"),
|
||||
"Unexpected error: {}",
|
||||
err_msg
|
||||
);
|
||||
}
|
||||
_ => panic!("Unexpected status: {:?}", result.status),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user