Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bleed): Implement wing anti ice system #2

Open
wants to merge 59 commits into
base: bleed
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
a739f02
change gamma to heat_capacity_ratio
omrygin Aug 27, 2021
91cc942
basics of wind anti ice
omrygin Aug 28, 2021
10a9021
preliminary tests plus commentary
omrygin Aug 29, 2021
74b2a8c
first implementation of pressure regulation
omrygin Aug 29, 2021
fee3a0a
implement on ground test logic
omrygin Aug 30, 2021
164812d
some updates
omrygin Aug 31, 2021
74968ed
first insim test
omrygin Aug 31, 2021
971706e
minor comments
omrygin Aug 31, 2021
d245ef0
Merge precooler
omrygin Aug 31, 2021
dde198a
more adaptations to precooler
omrygin Aug 31, 2021
f57392f
pushbutton on light is now coded
omrygin Aug 31, 2021
55845d5
git fixes
omrygin Aug 31, 2021
8576936
git fixes
omrygin Aug 31, 2021
f493c58
git fixes
omrygin Aug 31, 2021
1216343
git fixes
omrygin Aug 31, 2021
c23f637
fix on light not going off
omrygin Aug 31, 2021
6fe8370
changed static exhaust cooling
omrygin Aug 31, 2021
7ec4aec
changes to temperature
omrygin Sep 6, 2021
9ea9661
Merge branch 'bleed' of https://github.com/BlueberryKing/a32nx into b…
omrygin Sep 6, 2021
4a4a819
several semantic changes
omrygin Sep 7, 2021
c13ef8d
simvar changes and doc
omrygin Sep 7, 2021
f8fb8b8
small test changes
omrygin Sep 7, 2021
4595550
valves are now pneumatically operated + small changes
omrygin Sep 7, 2021
ae5267b
minor changes
omrygin Sep 12, 2021
f65595f
git fix
omrygin Sep 17, 2021
f1a2d30
git fixes
omrygin Sep 17, 2021
0d49f06
git fixes
omrygin Sep 17, 2021
9f5220d
git fixes
omrygin Sep 17, 2021
95a45cd
git fixes
omrygin Sep 17, 2021
9c475f9
change ECAM WAI indication simvar
omrygin Sep 17, 2021
b19f983
Merge branch 'bleed' into bleed-wing_anti_ice
omrygin Sep 18, 2021
5f8736f
Update src/systems/a320_systems/src/pneumatic/wing_anti_ice.rs
omrygin Sep 24, 2021
554221a
Update src/systems/a320_systems/src/pneumatic/wing_anti_ice.rs
omrygin Sep 24, 2021
722377d
Update src/systems/a320_systems/src/pneumatic.rs
omrygin Sep 24, 2021
2470021
Update src/systems/a320_systems/src/pneumatic.rs
omrygin Sep 24, 2021
604439d
Update src/systems/a320_systems/src/pneumatic.rs
omrygin Sep 24, 2021
33dd8fa
Update src/systems/a320_systems/src/pneumatic/wing_anti_ice.rs
omrygin Sep 24, 2021
07d7577
Apply suggestions from code review
omrygin Sep 24, 2021
7469c27
Apply suggestions from code review
omrygin Sep 24, 2021
abdc512
Apply suggestions from code review
omrygin Sep 24, 2021
4efbacf
Apply suggestions from code review
omrygin Sep 24, 2021
178d9d2
Update src/systems/a320_systems/src/pneumatic/wing_anti_ice.rs
omrygin Sep 24, 2021
bd0b168
Update src/systems/a320_systems/src/pneumatic/wing_anti_ice.rs
omrygin Sep 24, 2021
1c6c795
Update src/systems/a320_systems/src/pneumatic/wing_anti_ice.rs
omrygin Sep 24, 2021
ac657d8
Update src/systems/a320_systems/src/pneumatic/wing_anti_ice.rs
omrygin Sep 24, 2021
a4546fa
Update src/systems/a320_systems/src/pneumatic/wing_anti_ice.rs
omrygin Sep 24, 2021
c8de894
Apply suggestions from code review
omrygin Sep 24, 2021
b9e5872
Apply suggestions from code review
omrygin Sep 24, 2021
0483b2f
Update src/systems/a320_systems/src/pneumatic/wing_anti_ice.rs
omrygin Sep 24, 2021
3bfd38e
Update src/systems/a320_systems/src/pneumatic/wing_anti_ice.rs
omrygin Sep 24, 2021
8edea98
Update src/systems/a320_systems/src/pneumatic/wing_anti_ice.rs
omrygin Sep 24, 2021
c7c7d3c
Apply suggestions from code review
omrygin Sep 24, 2021
e1edb7f
Apply suggestions from code review
omrygin Sep 24, 2021
43dd820
Apply suggestions from code review
omrygin Sep 24, 2021
64810f7
Apply suggestions from code review
omrygin Sep 24, 2021
5bf193d
Update src/systems/a320_systems/src/pneumatic/wing_anti_ice.rs
omrygin Sep 24, 2021
9ce9ff9
Apply suggestions from code review
omrygin Sep 24, 2021
07bd95c
Apply suggestions from code review
omrygin Sep 24, 2021
16f10e0
Apply suggestions from code review
omrygin Sep 24, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ node_modules
/target
/src/instruments/src/EFB/web/
/src/systems/target/
/src/systems/systems/target/
/src/systems/a320_systems/target/
/src/systems/a320_systems_wasm/target/
Comment on lines +46 to +48
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if these are required here and I don't want to start ignoring things I don't know about. Is it possible that these were created by some erroneous build command?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are generated by a rust analyzer used in VScode. These files are what made me lose faith in git. They don't hold any thing that can ruin the build

/src/systems/a320_hydraulic_simulation_graphs/*.png
!igniter.config.mjs
.igniter
Expand Down
32 changes: 32 additions & 0 deletions docs/a320-simvars.md
Original file line number Diff line number Diff line change
Expand Up @@ -1917,3 +1917,35 @@ In the variables below, {number} should be replaced with one item in the set: {
- {number}
- 1
- 2

- A32NX_PNEU_WING_ANTI_ICE_SYSTEM_ON:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- A32NX_PNEU_WING_ANTI_ICE_SYSTEM_ON:
- A32NX_PNEU_WING_ANTI_ICE_PB_IS_ON:

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By renaming these, we can use the already existing OnOffFaultPushButton. I have elaborated on this further below.

- Indicates wheter the wing anti ice system is on
- Bool

- A32NX_PNEU_WING_ANTI_ICE_HAS_FAULT:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- A32NX_PNEU_WING_ANTI_ICE_HAS_FAULT:
- A32NX_PNEU_WING_ANTI_ICE_PB_HAS_FAULT:

- Indicates wheter the wing anti ice system has a fault
- Bool

- A32NX_PNEU_LEFT_WING_ANTI_ICE_CONSUMER_PRESSURE:
- Pressure in the left wing anti ice pipe
- PSI

- A32NX_PNEU_RIGHT_WING_ANTI_ICE_CONSUMER_PRESSURE:
- Pressure in the right wing anti ice pipe
- PSI

- A32NX_PNEU_LEFT_WING_ANTI_ICE_CONSUMER_TEMPERATURE:
- Temperature in the left wing anti ice pipe
- Degree celsius

- A32NX_PNEU_RIGHT_WING_ANTI_ICE_CONSUMER_TEMPERATURE:
- Temperature in the right wing anti ice pipe
- Degree celsius

- A32NX_LEFT_WING_ANTI_ICE_VALVE_OPEN:
- Indicates whether the left wing anti ice valve is open
- Bool

- A32NX_RIGHT_WING_ANTI_ICE_VALVE_OPEN:
- Indicates whether the right wing anti ice valve is open
- Bool
Comment on lines +1929 to +1951
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be smart to use 1 and 2 instead of LEFT and RIGHT. This is what's being done for most systems present on both sides of the aircraft. It makes looping over them easier. I suggest this:

  • A32NX_PNEU_LEFT_WING_ANTI_ICE_CONSUMER_PRESSURE -> A32NX_PNEU_WING_ANTI_ICE_1_CONSUMER_PRESSURE
  • A32NX_PNEU_RIGHT_WING_ANTI_ICE_CONSUMER_PRESSURE -> A32NX_PNEU_WING_ANTI_ICE_2_CONSUMER_PRESSURE
  • A32NX_PNEU_LEFT_WING_ANTI_ICE_CONSUMER_TEMPERATURE -> A32NX_PNEU_WING_ANTI_ICE_1_CONSUMER_TEMPERATURE
  • A32NX_PNEU_RIGHT_WING_ANTI_ICE_CONSUMER_TEMPERATURE -> A32NX_PNEU_WING_ANTI_ICE_2_CONSUMER_TEMPERATURE
  • A32NX_LEFT_WING_ANTI_ICE_VALVE_OPEN -> A32NX_WING_ANTI_ICE_1_VALVE_OPEN
  • A32NX_RIGHT_WING_ANTI_ICE_VALVE_OPEN -> A32NX_WING_ANTI_ICE_2_VALVE_OPEN

Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ var A320_Neo_LowerECAM_BLEED;
const apuSwitchState = SimVar.GetSimVarValue("L:A32NX_OVHD_APU_MASTER_SW_PB_IS_ON", "Bool") || SimVar.GetSimVarValue("L:A32NX_OVHD_PNEU_APU_BLEED_PB_IS_ON", "Bool");
const fadecStatus = [SimVar.GetSimVarValue("L:A32NX_FADEC_POWERED_ENG1", "bool"), SimVar.GetSimVarValue("L:A32NX_FADEC_POWERED_ENG1", "bool")];
const groundSpeed = SimVar.GetSimVarValue("GPS GROUND SPEED", "Meters per second");
const wingAntiInceState = SimVar.GetSimVarValue("STRUCTURAL DEICE SWITCH", "bool");
const wingAntiInceState = SimVar.GetSimVarValue("L:A32NX_PNEU_WING_ANTI_ICE_SYSTEM_ON", "bool");
const packRequestedlvl = Math.min(...[SimVar.GetSimVarValue("L:A320_Neo_AIRCOND_LVL_1", "number"),
SimVar.GetSimVarValue("L:A320_Neo_AIRCOND_LVL_2", "number"),
SimVar.GetSimVarValue("L:A320_Neo_AIRCOND_LVL_3", "number")]);
Expand Down
3 changes: 2 additions & 1 deletion src/behavior/src/A32NX_Interior_Misc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@
<Template Name="FBW_Airbus_AntiIce_Wing">
<UseTemplate Name="FBW_Push_Toggle">
<TOOLTIPID>%((A:STRUCTURAL DEICE SWITCH, Bool))%{if}TT:COCKPIT.TOOLTIPS.DEICE_WINGS_ON%{else}TT:COCKPIT.TOOLTIPS.DEICE_WINGS_OFF%{end}</TOOLTIPID>
<SEQ2_CODE>(A:STRUCTURAL DEICE SWITCH, Bool)</SEQ2_CODE>
<SEQ1_CODE>(L:A32NX_PNEU_WING_ANTI_ICE_HAS_FAULT, Bool)</SEQ1_CODE>
<SEQ2_CODE>(L:A32NX_PNEU_WING_ANTI_ICE_SYSTEM_ON, Bool)</SEQ2_CODE>
<LEFT_SINGLE_CODE>(&gt;K:TOGGLE_STRUCTURAL_DEICE)</LEFT_SINGLE_CODE>
</UseTemplate>
</Template>
Expand Down
46 changes: 35 additions & 11 deletions src/systems/a320_systems/src/pneumatic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,27 @@ use uom::si::{
};

use systems::{
hydraulic::Fluid,
overhead::{AutoOffFaultPushButton, OnOffFaultPushButton},
hydraulic::Fluid,
overhead::{AutoOffFaultPushButton, OnOffFaultPushButton},
pneumatic::{
ApuCompressionChamberController, CompressionChamber, ConstantConsumerController,
ControllablePneumaticValve, ControlledPneumaticValveSignal, CrossBleedValveSelectorKnob,
CrossBleedValveSelectorMode, DefaultConsumer, DefaultPipe, DefaultValve,
EngineCompressionChamberController, EngineState, HeatExchanger, PneumaticContainer,
PneumaticContainerWithValve, TargetPressureSignal, VariableVolumeContainer,
PneumaticContainerWithValve, TargetPressureSignal, VariableVolumeContainer,WingAntiIcePushButtonMode,WingAntiIcePushButton,
},
shared::{
ControllerSignal, DelayedTrueLogicGate, EngineCorrectedN1, EngineCorrectedN2,
EngineFirePushButtons, PneumaticValve,
ControllerSignal, EngineCorrectedN1, EngineCorrectedN2, EngineFirePushButtons,
PneumaticValve,
},
simulation::{
Read, SimulationElement, SimulationElementVisitor, SimulatorReader, SimulatorWriter, Write,
},
};

mod wing_anti_ice;
use wing_anti_ice::*;

use pid::Pid;

struct IntermediatePressureValveSignal {
Expand Down Expand Up @@ -215,11 +218,13 @@ pub struct A320Pneumatic {
apu: CompressionChamber,
apu_bleed_air_valve: DefaultValve,
apu_bleed_air_controller: ApuCompressionChamberController,

//Wing anti ice
wing_anti_ice: WingAntiIceComplex,

green_hydraulic_reservoir_with_valve: PneumaticContainerWithValve<VariableVolumeContainer>,
blue_hydraulic_reservoir_with_valve: PneumaticContainerWithValve<VariableVolumeContainer>,
yellow_hydraulic_reservoir_with_valve: PneumaticContainerWithValve<VariableVolumeContainer>,

packs: [PackComplex; 2],
}
impl A320Pneumatic {
Expand All @@ -240,6 +245,8 @@ impl A320Pneumatic {
apu: CompressionChamber::new(Volume::new::<cubic_meter>(1.)),
apu_bleed_air_valve: DefaultValve::new_closed(),
apu_bleed_air_controller: ApuCompressionChamberController::new(),

wing_anti_ice: WingAntiIceComplex::new(),
// TODO: I don't like how I have to initialize these containers independently of the actual reservoirs.
// If the volumes of the reservoirs were to be changed in the hydraulics code, we would have to manually change them here as well
green_hydraulic_reservoir_with_valve: PneumaticContainerWithValve::new(
Expand Down Expand Up @@ -324,6 +331,8 @@ impl A320Pneumatic {
hydraulics.fake_yellow_reservoir(),
);


self.wing_anti_ice.update(context, &mut self.engine_systems, overhead_panel.wing_anti_ice.mode());
let (left, right) = self.engine_systems.split_at_mut(1);
self.apu_bleed_air_valve
.update_move_fluid(context, &mut self.apu, &mut left[0]);
Expand All @@ -337,7 +346,6 @@ impl A320Pneumatic {
.update_flow_through_valve(context, &mut left[0]);
self.yellow_hydraulic_reservoir_with_valve
.update_flow_through_valve(context, &mut left[0]);

self.packs[0].update(context, &mut left[0]);
self.packs[1].update(context, &mut right[0]);
}
Expand Down Expand Up @@ -405,6 +413,7 @@ impl SimulationElement for A320Pneumatic {
}

self.fadec.accept(visitor);
self.wing_anti_ice.accept(visitor);

for pack in self.packs.iter_mut() {
pack.accept(visitor)
Expand Down Expand Up @@ -802,7 +811,7 @@ impl ControllerSignal<FaultLightSignal> for EngineBleedFaultLightMonitor {
}
}

struct EngineBleedAirSystem {
pub struct EngineBleedAirSystem {
number: usize,
fan_compression_chamber_controller: EngineCompressionChamberController, // Controls pressure just behind the main fan
ip_compression_chamber_controller: EngineCompressionChamberController,
Expand Down Expand Up @@ -904,7 +913,7 @@ impl EngineBleedAirSystem {
self.engine_starter_consumer
.update(&self.engine_starter_consumer_controller);

// Update valves (open amount)
// Update valves (open amount)
self.ip_valve.update_open_amount(ipv_controller);
self.hp_valve.update_open_amount(hpv_controller);
self.pr_valve.update_open_amount(prv_controller);
Expand Down Expand Up @@ -1116,13 +1125,18 @@ impl PneumaticContainer for EngineBleedAirSystem {
fn update_temperature(&mut self, temperature: TemperatureInterval) {
self.precooler_outlet_pipe.update_temperature(temperature);
}

fn update_pressure_only(&mut self, volume: Volume) {
self.precooler_outlet_pipe.update_pressure_only(volume);
}
}

pub struct A320PneumaticOverheadPanel {
apu_bleed: OnOffFaultPushButton,
cross_bleed: CrossBleedValveSelectorKnob,
engine_1_bleed: AutoOffFaultPushButton,
engine_2_bleed: AutoOffFaultPushButton,
wing_anti_ice: WingAntiIcePushButton,
}
impl A320PneumaticOverheadPanel {
pub fn new() -> Self {
Expand All @@ -1131,6 +1145,7 @@ impl A320PneumaticOverheadPanel {
cross_bleed: CrossBleedValveSelectorKnob::new_auto(),
engine_1_bleed: AutoOffFaultPushButton::new_auto("PNEU_ENG_1_BLEED"),
engine_2_bleed: AutoOffFaultPushButton::new_auto("PNEU_ENG_2_BLEED"),
wing_anti_ice: WingAntiIcePushButton::new_off(),
}
}

Expand All @@ -1142,6 +1157,13 @@ impl A320PneumaticOverheadPanel {
self.cross_bleed.mode()
}

pub fn wing_anti_ice_is_on(&self) -> bool {
match self.wing_anti_ice.mode() {
WingAntiIcePushButtonMode::Off => false,
_ => true
}
}

pub fn engine_bleed_pb_is_auto(&self, engine_number: usize) -> bool {
match engine_number {
1 => self.engine_1_bleed.is_auto(),
Expand Down Expand Up @@ -1172,7 +1194,7 @@ impl SimulationElement for A320PneumaticOverheadPanel {
self.cross_bleed.accept(visitor);
self.engine_1_bleed.accept(visitor);
self.engine_2_bleed.accept(visitor);

self.wing_anti_ice.accept(visitor);
visitor.visit(self);
}
}
Expand Down Expand Up @@ -1584,6 +1606,7 @@ mod tests {
self.query(|a| a.pneumatic.apu_bleed_air_valve.is_open())
}


fn set_engine_bleed_push_button_off(mut self, number: usize) -> Self {
self.write(&format!("OVHD_PNEU_ENG_{}_BLEED_PB_IS_AUTO", number), false);

Expand Down Expand Up @@ -1691,7 +1714,7 @@ mod tests {

let mut test_bed = test_bed_with()
.in_isa_atmosphere(alt)
.idle_eng1()
.stop_eng1()
.stop_eng2()
.both_packs_auto()
// .set_bleed_air_running()
Expand Down Expand Up @@ -2279,5 +2302,6 @@ mod tests {
CrossBleedValveSelectorMode::Shut
);
}

}
}
Loading