forked from flybywiresim/aircraft
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce a380_systems and a380_systems_wasm projects (flybywir…
…esim#7482) * chore: formatting * cargo fmt * don't borrow ref that is immediately dereferenced * remove file added by accident Co-authored-by: David Walschots <[email protected]> Co-authored-by: crocket63 <[email protected]> Co-authored-by: Miquel Juhe <[email protected]> Co-authored-by: Andreas Guther <[email protected]> Co-authored-by: BBK <[email protected]> Co-authored-by: lukecologne <[email protected]> Co-authored-by: Pascal Störzbach <[email protected]> Co-authored-by: Michael Corcoran <[email protected]> Co-authored-by: Benedict Etzel <[email protected]> Co-authored-by: Johan Bouveng <[email protected]> Co-authored-by: Tyler Knox <[email protected]> Co-authored-by: omrygin <[email protected]> Co-authored-by: Shaye Garg <[email protected]> Co-authored-by: Erick Torres <[email protected]>
- Loading branch information
1 parent
9a216df
commit 8e287a1
Showing
28 changed files
with
21,819 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "a380_systems" | ||
version = "0.1.0" | ||
authors = ["FlyByWire Simulations"] | ||
edition = "2018" | ||
|
||
[dependencies] | ||
uom = "0.33.0" | ||
rand = "0.8.0" | ||
nalgebra = "0.25.0" | ||
ntest = "0.7.2" | ||
systems = { path = "../systems" } | ||
|
||
[dev-dependencies] | ||
rstest = "0.10.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
use systems::{ | ||
accept_iterable, | ||
air_conditioning::{ | ||
acs_controller::{Pack, PackFlowController}, | ||
cabin_air::CabinZone, | ||
AirConditioningSystem, DuctTemperature, PackFlow, PackFlowControllers, ZoneType, | ||
}, | ||
pressurization::PressurizationOverheadPanel, | ||
shared::{ | ||
Cabin, ElectricalBusType, EngineBleedPushbutton, EngineCorrectedN1, EngineFirePushButtons, | ||
EngineStartState, GroundSpeed, LgciuWeightOnWheels, PackFlowValveState, PneumaticBleed, | ||
}, | ||
simulation::{InitContext, SimulationElement, SimulationElementVisitor, UpdateContext}, | ||
}; | ||
use uom::si::{f64::*, mass_rate::kilogram_per_second, volume::cubic_meter}; | ||
|
||
pub(super) struct A380AirConditioning { | ||
a380_cabin: A380Cabin, | ||
a380_air_conditioning_system: AirConditioningSystem<3>, | ||
} | ||
|
||
impl A380AirConditioning { | ||
pub fn new(context: &mut InitContext) -> Self { | ||
let cabin_zones: [ZoneType; 3] = | ||
[ZoneType::Cockpit, ZoneType::Cabin(1), ZoneType::Cabin(2)]; | ||
|
||
Self { | ||
a380_cabin: A380Cabin::new(context), | ||
a380_air_conditioning_system: AirConditioningSystem::new( | ||
context, | ||
cabin_zones, | ||
vec![ | ||
ElectricalBusType::DirectCurrent(1), | ||
ElectricalBusType::AlternatingCurrent(1), | ||
], | ||
vec![ | ||
ElectricalBusType::DirectCurrent(2), | ||
ElectricalBusType::AlternatingCurrent(2), | ||
], | ||
), | ||
} | ||
} | ||
|
||
pub fn update( | ||
&mut self, | ||
context: &UpdateContext, | ||
adirs: &impl GroundSpeed, | ||
engines: [&impl EngineCorrectedN1; 2], | ||
engine_fire_push_buttons: &impl EngineFirePushButtons, | ||
pneumatic: &(impl EngineStartState + PackFlowValveState + PneumaticBleed), | ||
pneumatic_overhead: &impl EngineBleedPushbutton, | ||
pressurization: &impl Cabin, | ||
pressurization_overhead: &PressurizationOverheadPanel, | ||
lgciu: [&impl LgciuWeightOnWheels; 2], | ||
) { | ||
self.a380_air_conditioning_system.update( | ||
context, | ||
adirs, | ||
engines, | ||
engine_fire_push_buttons, | ||
pneumatic, | ||
pneumatic_overhead, | ||
pressurization, | ||
pressurization_overhead, | ||
lgciu, | ||
); | ||
self.a380_cabin.update( | ||
context, | ||
&self.a380_air_conditioning_system, | ||
&self.a380_air_conditioning_system, | ||
pressurization, | ||
); | ||
} | ||
} | ||
|
||
impl PackFlowControllers<3> for A380AirConditioning { | ||
fn pack_flow_controller(&self, pack_id: Pack) -> PackFlowController<3> { | ||
self.a380_air_conditioning_system | ||
.pack_flow_controller(pack_id) | ||
} | ||
} | ||
|
||
impl SimulationElement for A380AirConditioning { | ||
fn accept<T: SimulationElementVisitor>(&mut self, visitor: &mut T) { | ||
self.a380_cabin.accept(visitor); | ||
self.a380_air_conditioning_system.accept(visitor); | ||
|
||
visitor.visit(self); | ||
} | ||
} | ||
|
||
struct A380Cabin { | ||
cabin_zone: [CabinZone<2>; 3], | ||
} | ||
|
||
impl A380Cabin { | ||
// TODO: Improve volume according to specs | ||
const A380_CABIN_VOLUME_CUBIC_METER: f64 = 200.; // m3 | ||
const A380_COCKPIT_VOLUME_CUBIC_METER: f64 = 10.; // m3 | ||
|
||
fn new(context: &mut InitContext) -> Self { | ||
Self { | ||
cabin_zone: [ | ||
CabinZone::new( | ||
context, | ||
ZoneType::Cockpit, | ||
Volume::new::<cubic_meter>(Self::A380_COCKPIT_VOLUME_CUBIC_METER), | ||
2, | ||
None, | ||
), | ||
CabinZone::new( | ||
context, | ||
ZoneType::Cabin(1), | ||
Volume::new::<cubic_meter>(Self::A380_CABIN_VOLUME_CUBIC_METER / 2.), | ||
0, | ||
Some([(1, 6), (7, 13)]), | ||
), | ||
CabinZone::new( | ||
context, | ||
ZoneType::Cabin(2), | ||
Volume::new::<cubic_meter>(Self::A380_CABIN_VOLUME_CUBIC_METER / 2.), | ||
0, | ||
Some([(14, 21), (22, 29)]), | ||
), | ||
], | ||
} | ||
} | ||
|
||
fn update( | ||
&mut self, | ||
context: &UpdateContext, | ||
duct_temperature: &impl DuctTemperature, | ||
pack_flow: &impl PackFlow, | ||
pressurization: &impl Cabin, | ||
) { | ||
let flow_rate_per_cubic_meter: MassRate = MassRate::new::<kilogram_per_second>( | ||
pack_flow.pack_flow().get::<kilogram_per_second>() | ||
/ (Self::A380_CABIN_VOLUME_CUBIC_METER + Self::A380_COCKPIT_VOLUME_CUBIC_METER), | ||
); | ||
for zone in self.cabin_zone.iter_mut() { | ||
zone.update( | ||
context, | ||
duct_temperature, | ||
flow_rate_per_cubic_meter, | ||
pressurization, | ||
); | ||
} | ||
} | ||
} | ||
|
||
impl SimulationElement for A380Cabin { | ||
fn accept<T: SimulationElementVisitor>(&mut self, visitor: &mut T) { | ||
accept_iterable!(self.cabin_zone, visitor); | ||
|
||
visitor.visit(self); | ||
} | ||
} |
Oops, something went wrong.