def test_stationary_condition_trimming_Cessna172_ISA1972_NoWind_VerticalConstant( TAS, h0, turn_rate, gamma): import numpy as np from pyfme.aircrafts import Cessna172 from pyfme.environment.environment import Environment from pyfme.environment.atmosphere import ISA1976 from pyfme.environment.gravity import VerticalConstant from pyfme.environment.wind import NoWind from pyfme.models.state import EarthPosition from pyfme.utils.trimmer import steady_state_trim aircraft = Cessna172() atmosphere = ISA1976() gravity = VerticalConstant() wind = NoWind() environment = Environment(atmosphere, gravity, wind) # Initial conditions. psi0 = 1.0 # rad x0, y0 = 0, 0 # m pos0 = EarthPosition(x0, y0, h0) controls0 = { 'delta_elevator': 0.05, 'delta_aileron': 0.2 * np.sign(turn_rate), 'delta_rudder': 0.2 * np.sign(turn_rate), 'delta_t': 0.5, } trimmed_state, trimmed_controls = steady_state_trim( aircraft, environment, pos0, psi0, TAS, controls0, gamma, turn_rate, ) # Acceleration np.testing.assert_almost_equal(trimmed_state.acceleration.value, np.zeros_like( trimmed_state.acceleration.value), decimal=2) # Angular acceleration np.testing.assert_almost_equal(trimmed_state.angular_accel.value, np.zeros_like( trimmed_state.angular_accel.value), decimal=2)
def test_simulation(): atmosphere = ISA1976() gravity = VerticalConstant() wind = NoWind() environment = Environment(atmosphere, gravity, wind) aircraft = Cessna172() initial_position = EarthPosition(0, 0, 1000) controls_0 = { 'delta_elevator': 0.05, 'delta_aileron': 0, 'delta_rudder': 0, 'delta_t': 0.5, } trimmed_state, trimmed_controls = steady_state_trim(aircraft, environment, initial_position, psi=1, TAS=50, controls=controls_0) system = EulerFlatEarth(t0=0, full_state=trimmed_state) controls = { 'delta_elevator': Doublet(2, 1, 0.1, trimmed_controls['delta_elevator']), 'delta_aileron': Constant(trimmed_controls['delta_aileron']), 'delta_rudder': Constant(trimmed_controls['delta_rudder']), 'delta_t': Constant(trimmed_controls['delta_t']) } simulation = Simulation(aircraft, system, environment, controls) simulation.propagate(10)
import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from pyfme.aircrafts import Cessna172 from pyfme.environment.environment import Environment from pyfme.environment.atmosphere import ISA1976 from pyfme.environment.gravity import VerticalConstant from pyfme.environment.wind import NoWind from pyfme.models.systems import EulerFlatEarth from pyfme.simulator import BatchSimulation from pyfme.utils.trimmer import steady_state_flight_trimmer aircraft = Cessna172() atmosphere = ISA1976() gravity = VerticalConstant() wind = NoWind() environment = Environment(atmosphere, gravity, wind) # Initial conditions. TAS = 45 # m/s h0 = 3000 # m psi0 = 1.0 # rad x0, y0 = 0, 0 # m turn_rate = 0.005 # rad/s gamma0 = 0.0 # rad system = EulerFlatEarth(lat=0, lon=0, h=h0, psi=psi0, x_earth=x0, y_earth=y0) not_trimmed_controls = {