feat(python): implement python bindings for all components and solvers
This commit is contained in:
@@ -305,8 +305,21 @@ impl Pump<Connected> {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
// Handle zero flow
|
||||
if flow_m3_per_s <= 0.0 {
|
||||
// Handle negative flow gracefully by using a linear extrapolation from Q=0
|
||||
// to prevent polynomial extrapolation issues with quadratic/cubic terms
|
||||
if flow_m3_per_s < 0.0 {
|
||||
let h0 = self.curves.head_at_flow(0.0);
|
||||
let h_eps = self.curves.head_at_flow(1e-6);
|
||||
let dh_dq = (h_eps - h0) / 1e-6;
|
||||
|
||||
let head_m = h0 + dh_dq * flow_m3_per_s;
|
||||
let actual_head = AffinityLaws::scale_head(head_m, self.speed_ratio);
|
||||
const G: f64 = 9.80665; // m/s²
|
||||
return self.fluid_density_kg_per_m3 * G * actual_head;
|
||||
}
|
||||
|
||||
// Handle exactly zero flow
|
||||
if flow_m3_per_s == 0.0 {
|
||||
// At zero flow, use the shut-off head scaled by speed
|
||||
let head_m = self.curves.head_at_flow(0.0);
|
||||
let actual_head = AffinityLaws::scale_head(head_m, self.speed_ratio);
|
||||
|
||||
Reference in New Issue
Block a user