pub type Temperature = Measurement<f32, TemperatureUnit>;Aliased Type§
pub struct Temperature { /* private fields */ }Implementations§
Source§impl Temperature
impl Temperature
pub fn k(value: f32) -> Self
Sourcepub fn c(value: f32) -> Self
pub fn c(value: f32) -> Self
Examples found in repository?
examples/flightplanner.rs (line 67)
38fn main() -> Result<()> {
39 // Performance setting with 65% load in cruise. This is the performance
40 // profile of a Cessna C172 with an TAE125-02-114 Diesel engine.
41 let perf = Performance::from_fn(
42 |vd| {
43 let tas = if *vd >= VerticalDistance::Altitude(10000) {
44 Speed::kt(114.0)
45 } else if *vd >= VerticalDistance::Altitude(8000) {
46 Speed::kt(112.0)
47 } else if *vd >= VerticalDistance::Altitude(6000) {
48 Speed::kt(110.0)
49 } else if *vd >= VerticalDistance::Altitude(4000) {
50 Speed::kt(109.0)
51 } else {
52 Speed::kt(107.0)
53 };
54
55 let ff = FuelFlow::PerHour(diesel!(Volume::l(21.0)));
56
57 (tas, ff)
58 },
59 // The data end at 10000 ft so we don't need to create the Performance
60 // with more values.
61 VerticalDistance::Altitude(10000),
62 );
63
64 let takeoff_perf = TakeoffLandingPerformance::builder(vec![
65 (
66 VerticalDistance::PressureAltitude(0),
67 Temperature::c(0.0),
68 Length::ft(845.0),
69 Length::ft(1510.0),
70 ),
71 (
72 VerticalDistance::PressureAltitude(0),
73 Temperature::c(10.0),
74 Length::ft(910.0),
75 Length::ft(1625.0),
76 ),
77 (
78 VerticalDistance::PressureAltitude(0),
79 Temperature::c(20.0),
80 Length::ft(980.0),
81 Length::ft(1745.0),
82 ),
83 (
84 VerticalDistance::PressureAltitude(0),
85 Temperature::c(30.0),
86 Length::ft(1055.0),
87 Length::ft(1875.0),
88 ),
89 (
90 VerticalDistance::PressureAltitude(0),
91 Temperature::c(40.0),
92 Length::ft(1135.0),
93 Length::ft(2015.0),
94 ),
95 ])
96 .factors(vec![
97 // Decrease distances 10% for each 9 knots headwind. For operation
98 // with tail winds up to 10 knots, increase distances by 10% for
99 // each 2 knots.
100 AlteringFactor::DecreaseHeadwind(FactorOfEffect::Rate {
101 numerator: 0.1,
102 denominator: Speed::kt(9.0),
103 }),
104 AlteringFactor::IncreaseTailwind(FactorOfEffect::Rate {
105 numerator: 0.1,
106 denominator: Speed::kt(2.0),
107 }),
108 // For operation on dry, grass runway, increase distances by 15% of
109 // the "ground roll" figure.
110 AlteringFactor::IncreaseRWYCC(HashMap::from([
111 ((None, Some(RunwaySurface::Grass)), 0.15), // we'll add 15% on any grass
112 ])),
113 ])
114 .build();
115
116 let aircraft = Aircraft::builder()
117 .registration("N12345".to_string())
118 .stations(vec![
119 Station::new(Length::m(0.94), Some(String::from("front seats"))),
120 Station::new(Length::m(1.85), Some(String::from("back seats"))),
121 Station::new(
122 Length::m(2.41),
123 Some(String::from("first cargo compartment")),
124 ),
125 Station::new(
126 Length::m(3.12),
127 Some(String::from("second cargo compartment")),
128 ),
129 ])
130 .empty_mass(Mass::kg(807.0))
131 .empty_balance(Length::m(1.0))
132 .fuel_type(FuelType::Diesel)
133 .tanks(vec![FuelTank::new(Volume::l(168.8), Length::m(1.22))])
134 .cg_envelope(vec![
135 CGLimit::new(Mass::kg(0.0), Length::m(0.89)),
136 CGLimit::new(Mass::kg(885.0), Length::m(0.89)),
137 CGLimit::new(Mass::kg(1111.0), Length::m(1.02)),
138 CGLimit::new(Mass::kg(1111.0), Length::m(1.20)),
139 CGLimit::new(Mass::kg(0.0), Length::m(1.20)),
140 ])
141 .build()
142 .expect("all required aircraft parameter should be configured");
143
144 let mut fms = FMS::new();
145
146 // read the ARINC database
147 let ed_nd = NavigationData::try_from_arinc424(ARINC_424_RECORDS)?;
148
149 fms.modify_nd(|nd| nd.append(ed_nd))?;
150
151 // decode a route from EDDH to EDHF with winds at 20 kt from 290° and
152 // cruising speed of 107 kt and an altitude of 2500 ft. Takeoff runway in
153 // EDDH is runway 33 and landing runway in EDHF is 20.
154 fms.decode("29020KT N0107 A0250 EDDH33 N2 N1 DCT EDHF20".to_string())?;
155
156 // Now we can enter some data into the flight planning to get a fuel planning
157 // and mass & balance calculation.
158 let mut builder = FlightPlanning::builder();
159
160 builder
161 .aircraft(aircraft)
162 .mass(vec![
163 // we're in the front
164 Mass::kg(80.0),
165 // and no mass on the other stations
166 Mass::kg(0.0),
167 Mass::kg(0.0),
168 Mass::kg(0.0),
169 ])
170 .policy(FuelPolicy::ManualFuel(diesel!(Volume::l(80.0))))
171 .taxi(diesel!(Volume::l(10.0)))
172 .reserve(Reserve::Manual(Duration::s(1800))) // 30 min
173 .perf(perf)
174 .takeoff_perf(takeoff_perf)
175 // we use the route's wind so no need to specify it here
176 .origin_rwycc(RunwayConditionCode::Six)
177 .origin_temperature(Temperature::c(20.0));
178
179 fms.set_flight_planning(builder)?;
180
181 println!("{}", fms.print(40));
182
183 Ok(())
184}