Update project structure and configurations
This commit is contained in:
@@ -311,7 +311,10 @@ fn test_screw_compressor_preset_config() {
|
||||
std::fs::write(&config_path, json).unwrap();
|
||||
|
||||
let config = ScenarioConfig::from_file(&config_path);
|
||||
assert!(config.is_ok(), "Config with preset should parse successfully");
|
||||
assert!(
|
||||
config.is_ok(),
|
||||
"Config with preset should parse successfully"
|
||||
);
|
||||
|
||||
let config = config.unwrap();
|
||||
let params = &config.circuits[0].components[0].params;
|
||||
@@ -391,8 +394,8 @@ fn test_screw_compressor_grasso_preset_config() {
|
||||
fn test_ac2_frequency_ratio_set_correctly_by_cli() {
|
||||
use entropyk_components::{
|
||||
polynomials::Polynomial2D,
|
||||
screw_economizer_compressor::{ScrewEconomizerCompressor, ScrewPerformanceCurves},
|
||||
port::{FluidId, Port},
|
||||
screw_economizer_compressor::{ScrewEconomizerCompressor, ScrewPerformanceCurves},
|
||||
};
|
||||
use entropyk_core::{Enthalpy, Pressure};
|
||||
|
||||
@@ -464,7 +467,11 @@ fn test_ac1_mchx_ua_nominal_parsed_from_config() {
|
||||
let comp = &config.circuits[0].components[0];
|
||||
|
||||
// AC1: ua_nominal_kw_k field parsed correctly
|
||||
assert_eq!(comp.ua_nominal_kw_k, Some(8.5), "ua_nominal_kw_k should be 8.5 kW/K");
|
||||
assert_eq!(
|
||||
comp.ua_nominal_kw_k,
|
||||
Some(8.5),
|
||||
"ua_nominal_kw_k should be 8.5 kW/K"
|
||||
);
|
||||
assert_eq!(comp.fan_speed, Some(1.0));
|
||||
assert_eq!(comp.air_inlet_temp_c, Some(35.0));
|
||||
}
|
||||
@@ -472,8 +479,8 @@ fn test_ac1_mchx_ua_nominal_parsed_from_config() {
|
||||
/// AC2: Given fan_speed=0.64, n_air_exponent=0.5, UA_eff ≈ UA_nom × √0.64 = UA_nom × 0.8.
|
||||
#[test]
|
||||
fn test_ac2_fan_speed_064_yields_ua_eff_08() {
|
||||
use entropyk_components::heat_exchanger::MchxCondenserCoil;
|
||||
use approx::assert_relative_eq;
|
||||
use entropyk_components::heat_exchanger::MchxCondenserCoil;
|
||||
|
||||
let ua_nominal = 8_500.0; // W/K (8.5 kW/K)
|
||||
let n_air = 0.5;
|
||||
@@ -485,7 +492,7 @@ fn test_ac2_fan_speed_064_yields_ua_eff_08() {
|
||||
|
||||
// AC2: UA_eff ≈ UA_nom × 0.64^0.5 = UA_nom × 0.8
|
||||
let expected_ua = ua_nominal * 0.8; // 0.64^0.5 = 0.8
|
||||
// Allow 5% tolerance for density correction at 35°C
|
||||
// Allow 5% tolerance for density correction at 35°C
|
||||
let ua_eff = coil.ua_effective();
|
||||
assert_relative_eq!(ua_eff, expected_ua, epsilon = expected_ua * 0.05);
|
||||
}
|
||||
@@ -519,7 +526,10 @@ fn test_ac3_condenser_bank_2x2_generates_4_components() {
|
||||
let bank_comp = &config.circuits[0].components[0];
|
||||
|
||||
// Verify bank config parsed
|
||||
let bank = bank_comp.condenser_bank.as_ref().expect("condenser_bank must be present");
|
||||
let bank = bank_comp
|
||||
.condenser_bank
|
||||
.as_ref()
|
||||
.expect("condenser_bank must be present");
|
||||
assert_eq!(bank.circuits, 2);
|
||||
assert_eq!(bank.coils_per_circuit, 2);
|
||||
|
||||
@@ -742,11 +752,18 @@ fn test_bphx_evaporator_and_condenser_config_parsing() {
|
||||
|
||||
let result = run_simulation(&config_path, None, false).unwrap();
|
||||
|
||||
// create_component must accept both types (no "Unknown component type").
|
||||
// create_component must accept both types. Two distinct assertions:
|
||||
// (a) no "Unknown component type" — both Bphx types must be registered.
|
||||
// (b) no "Failed to create component" — construction must succeed, not just be recognised.
|
||||
if let Some(ref err) = result.error {
|
||||
assert!(
|
||||
!err.contains("Unknown component type"),
|
||||
"BphxEvaporator and BphxCondenser must be supported: {}",
|
||||
"BphxEvaporator and BphxCondenser must be registered in create_component: {}",
|
||||
err
|
||||
);
|
||||
assert!(
|
||||
!err.contains("Failed to create component"),
|
||||
"BphxEvaporator/BphxCondenser construction must not fail: {}",
|
||||
err
|
||||
);
|
||||
}
|
||||
@@ -754,10 +771,52 @@ fn test_bphx_evaporator_and_condenser_config_parsing() {
|
||||
// We expect Error or NonConverged (edges empty -> topology/finalization failure), not config parse failure.
|
||||
match result.status {
|
||||
SimulationStatus::Error => {
|
||||
// Failure is expected (e.g. isolated nodes); config parsing succeeded.
|
||||
// Failure is expected (e.g. isolated nodes); config parsing and construction succeeded.
|
||||
}
|
||||
SimulationStatus::NonConverged | SimulationStatus::Converged | SimulationStatus::Timeout => {
|
||||
SimulationStatus::NonConverged
|
||||
| SimulationStatus::Converged
|
||||
| SimulationStatus::Timeout => {
|
||||
// Also acceptable if we get to solver stage.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Story 15-4 — Integration: BphxEvaporator and BphxCondenser in bounded circuits
|
||||
/// (RefrigerantSource → Bphx → RefrigerantSink) must reach the solver stage.
|
||||
/// Validates that config parsing, component construction, AND edge routing all succeed.
|
||||
#[test]
|
||||
fn test_bphx_bounded_circuit_reaches_solver_stage() {
|
||||
use entropyk_cli::run::run_simulation;
|
||||
|
||||
let example = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("examples/bphx_evaporator_condenser.json");
|
||||
|
||||
if !example.exists() {
|
||||
panic!(
|
||||
"Test fixture missing: {} — this test requires the example file to exist",
|
||||
example.display()
|
||||
);
|
||||
}
|
||||
|
||||
let result = run_simulation(&example, None, false).unwrap();
|
||||
|
||||
// Three-gate assertion: config → construction → edge routing must all succeed.
|
||||
if let Some(ref err) = result.error {
|
||||
assert!(
|
||||
!err.contains("Unknown component type"),
|
||||
"[Gate 1] Bphx type not registered: {}",
|
||||
err
|
||||
);
|
||||
assert!(
|
||||
!err.contains("Failed to create component"),
|
||||
"[Gate 2] Bphx construction failed: {}",
|
||||
err
|
||||
);
|
||||
assert!(
|
||||
!err.contains("Failed to add edge") && !err.contains("Edge references unknown"),
|
||||
"[Gate 3] Edge routing failed: {}",
|
||||
err
|
||||
);
|
||||
// Any remaining error (e.g. solver non-convergence) is acceptable.
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user