Snapshot WIP: solver HP epic progress, BPHX/HX physics, BMAD skill refresh.
Some checks failed
CI / check (push) Has been cancelled
Some checks failed
CI / check (push) Has been cancelled
Capture uncommitted solver robustness work (regularization, domain errors, linear solver lifecycle, tube DP/MSH), web workbench updates, and synced BMAD skills across IDE agent folders before starting BPHX pressure-drop. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -28,12 +28,11 @@ pub fn load_model() -> Result<(String, String), String> {
|
||||
|
||||
let model_path = env::var("ENTROPYK_FMU_MODEL")
|
||||
.map_err(|_| "no embedded model and ENTROPYK_FMU_MODEL env var not set".to_string())?;
|
||||
let io_path = env::var("ENTROPYK_FMU_IO")
|
||||
.map_err(|_| "ENTROPYK_FMU_IO env var not set".to_string())?;
|
||||
let io_path =
|
||||
env::var("ENTROPYK_FMU_IO").map_err(|_| "ENTROPYK_FMU_IO env var not set".to_string())?;
|
||||
|
||||
let model = std::fs::read_to_string(&model_path)
|
||||
.map_err(|e| format!("read {model_path}: {e}"))?;
|
||||
let io = std::fs::read_to_string(&io_path)
|
||||
.map_err(|e| format!("read {io_path}: {e}"))?;
|
||||
let model =
|
||||
std::fs::read_to_string(&model_path).map_err(|e| format!("read {model_path}: {e}"))?;
|
||||
let io = std::fs::read_to_string(&io_path).map_err(|e| format!("read {io_path}: {e}"))?;
|
||||
Ok((model, io))
|
||||
}
|
||||
|
||||
@@ -350,4 +350,3 @@ pub unsafe extern "C" fn fmi2GetLastError() -> fmi2String {
|
||||
None => std::ptr::null(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#![allow(non_camel_case_types)]
|
||||
#![allow(non_snake_case)]
|
||||
#![allow(non_upper_case_globals)]
|
||||
#![allow(clippy::missing_safety_doc)]
|
||||
#![allow(clippy::const_is_empty)]
|
||||
|
||||
pub mod embedded;
|
||||
pub mod fmi2;
|
||||
|
||||
@@ -58,8 +58,8 @@ impl FmuInstance {
|
||||
/// Parse the model JSON and the IO-map JSON. Both are bundled inside the
|
||||
/// `.fmu` (model under `resources/`, IO-map under `resources/fmu_io.json`).
|
||||
pub fn new(config_json: &str, io_json: &str) -> Result<Self, String> {
|
||||
let config = ScenarioConfig::from_json(config_json)
|
||||
.map_err(|e| format!("model JSON: {e}"))?;
|
||||
let config =
|
||||
ScenarioConfig::from_json(config_json).map_err(|e| format!("model JSON: {e}"))?;
|
||||
let io: FmuIoSpec =
|
||||
serde_json::from_str(io_json).map_err(|e| format!("IO-map JSON: {e}"))?;
|
||||
|
||||
@@ -201,10 +201,12 @@ fn extract_output(result: &SimulationResult, out: &IoOutput) -> f64 {
|
||||
"q_cooling_kw" => perf.and_then(|p| p.q_cooling_kw).unwrap_or(f64::NAN),
|
||||
"q_heating_kw" => perf.and_then(|p| p.q_heating_kw).unwrap_or(f64::NAN),
|
||||
"compressor_power_kw" => perf.and_then(|p| p.compressor_power_kw).unwrap_or(f64::NAN),
|
||||
"pressure_bar" => find_edge(result, out.edge).map(|e| e.pressure_bar).unwrap_or(f64::NAN),
|
||||
"enthalpy_kj_kg" => {
|
||||
find_edge(result, out.edge).map(|e| e.enthalpy_kj_kg).unwrap_or(f64::NAN)
|
||||
}
|
||||
"pressure_bar" => find_edge(result, out.edge)
|
||||
.map(|e| e.pressure_bar)
|
||||
.unwrap_or(f64::NAN),
|
||||
"enthalpy_kj_kg" => find_edge(result, out.edge)
|
||||
.map(|e| e.enthalpy_kj_kg)
|
||||
.unwrap_or(f64::NAN),
|
||||
"mass_flow_kg_s" => find_edge(result, out.edge)
|
||||
.and_then(|e| e.mass_flow_kg_s)
|
||||
.unwrap_or(f64::NAN),
|
||||
@@ -215,7 +217,10 @@ fn extract_output(result: &SimulationResult, out: &IoOutput) -> f64 {
|
||||
}
|
||||
}
|
||||
|
||||
fn find_edge<'a>(result: &'a SimulationResult, edge: Option<usize>) -> Option<&'a entropyk_cli::run::StateEntry> {
|
||||
fn find_edge(
|
||||
result: &SimulationResult,
|
||||
edge: Option<usize>,
|
||||
) -> Option<&entropyk_cli::run::StateEntry> {
|
||||
let edge = edge?;
|
||||
result.state.as_ref()?.iter().find(|e| e.edge == edge)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user