diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index c7798b4ef1f..88e7e574a2d 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -76,6 +76,7 @@ 1. [A32NX] Fixed appearance of FCU decals on MSFS2024 - @tracernz (Mike) 1. [FMS] Fixed issue with airport loading timing out on MSFS2024 - @tracernz (Mike) 1. [A32NX] Fixed APU fire detection - @tracernz (Mike) +1. [A380X/COND] Fix wasm crash during rapid decompression - @mjuhe (Miquel Juhe) ## 0.12.0 diff --git a/fbw-a380x/src/wasm/systems/a380_systems/src/air_conditioning/cpiom_b.rs b/fbw-a380x/src/wasm/systems/a380_systems/src/air_conditioning/cpiom_b.rs index 7b43a635435..3c74e7000d6 100644 --- a/fbw-a380x/src/wasm/systems/a380_systems/src/air_conditioning/cpiom_b.rs +++ b/fbw-a380x/src/wasm/systems/a380_systems/src/air_conditioning/cpiom_b.rs @@ -1287,7 +1287,11 @@ impl CabinPressureControlSystemApplication { && (altimeter_setting.unwrap_or_default().get::() - Air::P_0).abs() > f64::EPSILON) { - altimeter_setting.unwrap() + if altimeter_setting.unwrap() == Pressure::default() { + Pressure::new::(Air::P_0) + } else { + altimeter_setting.unwrap() + } } else { Pressure::new::(Air::P_0) } diff --git a/fbw-a380x/src/wasm/systems/a380_systems/src/air_conditioning/local_controllers/full_digital_agu_controller.rs b/fbw-a380x/src/wasm/systems/a380_systems/src/air_conditioning/local_controllers/full_digital_agu_controller.rs index 233d3edbbd8..18cada96547 100644 --- a/fbw-a380x/src/wasm/systems/a380_systems/src/air_conditioning/local_controllers/full_digital_agu_controller.rs +++ b/fbw-a380x/src/wasm/systems/a380_systems/src/air_conditioning/local_controllers/full_digital_agu_controller.rs @@ -363,7 +363,7 @@ impl PackFlowController { if self.should_open_fcv { self.pid - .change_setpoint(pack_flow_demand.get::()); + .change_setpoint(pack_flow_demand.get::().max(0.)); self.pid.next_control_output( self.pack_flow.get::(), Some(context.delta()), diff --git a/fbw-a380x/src/wasm/systems/a380_systems/src/air_conditioning/mod.rs b/fbw-a380x/src/wasm/systems/a380_systems/src/air_conditioning/mod.rs index e95b03b9e78..9594beaf74b 100644 --- a/fbw-a380x/src/wasm/systems/a380_systems/src/air_conditioning/mod.rs +++ b/fbw-a380x/src/wasm/systems/a380_systems/src/air_conditioning/mod.rs @@ -385,7 +385,7 @@ pub(super) struct A380AirConditioningSystem { } impl A380AirConditioningSystem { - const CAB_FAN_DESIGN_FLOW_RATE_L_S: f64 = 550.; // litres/sec + const CAB_FAN_DESIGN_FLOW_RATE_L_S: f64 = 1250.; // litres/sec fn new(context: &mut InitContext, cabin_zones: &[ZoneType; 18]) -> Self { Self { diff --git a/fbw-common/src/wasm/systems/systems/src/air_conditioning/acs_controller.rs b/fbw-common/src/wasm/systems/systems/src/air_conditioning/acs_controller.rs index 7141b70a56a..e49c7b5c34a 100644 --- a/fbw-common/src/wasm/systems/systems/src/air_conditioning/acs_controller.rs +++ b/fbw-common/src/wasm/systems/systems/src/air_conditioning/acs_controller.rs @@ -693,8 +693,8 @@ impl ZoneController { pressurization: &impl CabinAltitude, zone_measured_temperature: ThermodynamicTemperature, ) -> ThermodynamicTemperature { - let altitude_correction: f64 = - pressurization.altitude().get::() * Self::K_ALTITUDE_CORRECTION_DEG_PER_FEET; + let altitude_correction: f64 = pressurization.altitude().get::().max(0.) + * Self::K_ALTITUDE_CORRECTION_DEG_PER_FEET; let corrected_selected_temp: f64 = self.zone_selected_temperature.get::() + altitude_correction; diff --git a/fbw-common/src/wasm/systems/systems/src/air_conditioning/mod.rs b/fbw-common/src/wasm/systems/systems/src/air_conditioning/mod.rs index d98e4c2ce1f..d3ea71eccce 100644 --- a/fbw-common/src/wasm/systems/systems/src/air_conditioning/mod.rs +++ b/fbw-common/src/wasm/systems/systems/src/air_conditioning/mod.rs @@ -7,7 +7,7 @@ use crate::{ ControllablePneumaticValve, PneumaticContainer, PneumaticPipe, PneumaticValveSignal, }, shared::{ - arinc429::Arinc429Word, low_pass_filter::LowPassFilter, AverageExt, CabinSimulation, + arinc429::Arinc429Word, low_pass_filter::LowPassFilter, AverageExt, CabinSimulation, Clamp, ConsumePower, ControllerSignal, ElectricalBusType, ElectricalBuses, }, simulation::{ @@ -534,10 +534,15 @@ impl CabinFan { let mass_flow: f64 = (self.outlet_air.pressure().get::() * self.design_flow_rate.get::()) / (Air::R * self.outlet_air.temperature().get::()); + let max_mass_flow = mass_flow * Self::FAN_EFFICIENCY; // If we have flow demand calculated, we assign this directly to the fan flow // This is a simplification, we could model the fans, send the signal and read the output recirculation_flow_demand - .unwrap_or(MassRate::new::(mass_flow) * Self::FAN_EFFICIENCY) + .unwrap_or(MassRate::new::(max_mass_flow)) + .clamp( + MassRate::default(), + MassRate::new::(max_mass_flow), + ) } pub fn has_fault(&self) -> bool {