2023 The 9th Dimensional Cup Question A Modeling Analysis, Senior Xiaolu leads the team to guide all code articles and ideas

I am senior Xiaolu, studying at Shanghai Jiao Tong University. So far, I have helped more than 200 people complete modeling and idea building~

This time I will take you to experience question A of the 9th Dimensional Cup!
Insert image description here

Problem restatement

Question 1: Establish attitude angle model

background:

The flight of a helicopter is affected by a variety of forces, including coaxial rigid rotors, propellers, elevators, rudders, etc. In different flight modes, these components have different effects on the attitude angle of the helicopter.

Task:
  1. Modeling task: Based on the given parameters, establish a pitch angle model of the helicopter, taking into account the influence of the coaxial rigid rotor, propeller, elevator and rudder on the pitch angle.
  2. Model verification: Provides the helicopter under initial flight conditions (elevation 3000 meters, forward speed 80 m/s, vertical ascent speed 2 m/s, initial pitch, yaw, The values ​​of the attitude angle at 5 seconds, 10 seconds and 20 seconds (the yaw angle is 0 degrees respectively).

Question 2: Establish an attitude angle change model

background:

During the flight of the helicopter, its attitude angle will change with time. Moments on different components cause changes in roll, pitch and yaw.

Task:
  1. Modeling task: Based on the given parameters, establish a model of the change of helicopter roll, pitch and yaw angle, considering the coaxial rigid rotor, propeller thruster, elevator and rudder Impact.
  2. Model verification: Provides the helicopter under initial flight conditions (elevation 3000 meters, forward speed 80 m/s, vertical ascent speed 0.2 m/s, initial roll, pitch, The values ​​of the attitude angle at 5 seconds, 10 seconds and 20 seconds (the yaw angle is 0 degrees respectively).

Question Three: Design Maneuvering Characteristics

background:

In low-speed and high-speed flight modes, the helicopter needs to meet the horizontal flight mission, that is, maintain a zero attitude angle. The maneuvering characteristics of each component play a key role in different flight modes.

Task:
  1. Maneuvering design: According to the low-speed and high-speed flight characteristics, the maneuvering range of the coaxial rigid rotor, propeller thruster, elevator and rudder is designed to meet the horizontal flight mission.
  2. Model verification: Provide the values ​​of the attitude angle of the helicopter at 5 seconds, 10 seconds and 20 seconds in two flight modes (the initial flight conditions are the same).

Question 4: Accelerate maneuver mission design

background:

The helicopter needs to perform an acceleration maneuver task by adjusting the control input to uniformly increase the forward flight speed from 80 m/s to 180 m/s within 20 seconds.

Task:
  1. Dynamic design: Design the dynamic values ​​of each control input to achieve forward acceleration and level flight (zero attitude angle), taking into account maneuvering characteristics in low-speed and high-speed flight.
  2. Model verification: Provide the attitude angle of the helicopter at 5 seconds, 10 seconds and 20 seconds under initial flight conditions (elevation 3000 meters, vertical ascent speed 0.2 m/s) value.

Modeling ideas

Question one

1. Basic dynamic equation:

In the pitching motion of the helicopter, we can use the Newton-Euler equation to express:

I y ⋅ q ˙ = ∑ τ y I_y \cdot \dot{q} = \sum \tau_y Iyq˙=ty

in:

  • I y I_y Iyis the moment of inertia about the pitch axis;
  • q ˙ \dot{q} q˙ is elevation velocity;
    - ∑ τ y \sum \tau_y tyis the sum of all moments in the pitch direction.
2. Moment of each component:

Taking into account the influence of each component of the helicopter on the pitch angle, we can expand the moment term to the sum of the contributions of each component:

∑ τ y = τ rotors + τ propeller + τ elevator + τ rudder \sum \tau_y = \tau_{\text{rotors}} + \tau_{\text{propeller}} + \tau_{\text{elevator}} + \tau_{\text{rudder}}ty=trotors+tpropeller+televator+trudder

Among them:
- τ rotors \tau_{\text{rotors}} trotors is the aerodynamic moment generated by the coaxial rigid rotor;
- τ propeller \tau_{\text{propeller}} tpropelleris the thrust moment generated by the propeller;

  • τ elevator \tau_{\text{elevator}}televatoris the control torque generated by the elevator;
  • τ rudder \tau_{\text{rudder}} trudderis the control torque generated by the rudder.
3. Gutai construction model:

When doing specific modeling, it is necessary to use aerodynamic and dynamic principles to mathematically express the torque of each component. This may include consideration of rotor aerodynamic moments, propeller thrust, elevator and rudder control inputs, etc.

For example, for the aerodynamic moment of a coaxial rigid rotor, the following general form can be considered:

τ rotors = k rotors ⋅ q ˙ \tau_{\text{rotors}} = k_{\text{rotors}} \cdot \dot{q} trotors=krotorsq˙

In that, k rotors k_{\text{rotors}} krotorsis a proportional constant related to aerodynamic characteristics.

Similarly, the moments for other components also need to be specifically modeled.

4. Mathematical model matching:

Substituting the above specific expressions of the moment of each component into the basic dynamic equation, the complete pitch angle dynamic equation is obtained.

I y ⋅ q ˙ = τ rotors + τ propeller + τ elevator + τ rudder I_y \cdot \dot{q} = \tau_{\text{rotors}} + \tau_{\text{propeller}} + \tau_{\text{elevator}} + \tau_{\text{rudder}} Iyq˙=trotors+tpropeller+televator+trudder

5. Numerical simulation verification:

Use numerical simulation tools, such as numerical integrators, to verify the established mathematical model and observe the change of the helicopter's pitch angle with time under given initial conditions.

import numpy as np
from scipy.integrate import solve_ivp
import matplotlib.pyplot as plt

# 定义直升机俯仰角动力学方程
def pitch_dynamics(t, y):
    # y: [pitch, pitch_rate]
    pitch, pitch_rate = y
    
    # 参数设定(示例值,实际应根据直升机具体参数进行调整)
    I_y = 1000.0  # 绕俯仰轴的惯性矩
    k_rotors = 10.0  # 共轴刚性转子的气动力矩比例常数
    k_propeller = 5.0  # 螺旋桨推进器的推力力矩比例常数
    k_elevator = 2.0  # 升降舵的控制力矩比例常数
    k_rudder = 2.0  # 方向舵的控制力矩比例常数
    
    # 各组件的力矩
    rotors_torque = k_rotors * pitch_rate
    propeller_torque = k_propeller * pitch_rate
    elevator_torque = k_elevator * pitch_rate
    rudder_torque = k_rudder * pitch_rate
    
    # 动力学方程
    pitch_acceleration = (rotors_torque + propeller_torque + elevator_torque + rudder_torque) / I_y

    return [pitch_rate, pitch_acceleration]

# 初始条件
initial_conditions = [0.0, 0.0]  # 初始俯仰角为0,初始角速度为0

# 时间范围
time_span = (0, 20)

# 数值模拟
solution = solve_ivp(
    fun=pitch_dynamics,
    t_span=time_span,

Question 2

To establish the model for question 2, it is necessary to consider the moment model of the roll, pitch and yaw of the helicopter in flight. We can use Euler angles to describe the attitude of the helicopter, including roll angle, pitch angle and yaw angle.

1. Kinetic equations

In the roll, pitch and yaw motion of the aircraft, the Newton-Euler equation can be expressed as:

I x ⋅ p ˙ = ( I y − I z ) ⋅ q ⋅ r + τ control-roll I_x \cdot \dot{p} = (I_y - I_z) \cdot q \cdot r + \tau_{\text{control-roll}} Ixp˙=(IyIz)qr+tcontrol-roll

I y ⋅ q ˙ = ( I z − I x ) ⋅ p ⋅ r + τ control-pitch I_y \cdot \dot{q} = (I_z - I_x) \cdot p \cdot r + \tau_{\text{control-pitch}} Iyq˙=(IzIx)pr+tcontrol-pitch

I z ⋅ r ˙ = ( I x − I y ) ⋅ p ⋅ q + τ control-yaw I_z \cdot \dot{r} = (I_x - I_y) \cdot p \cdot q + \tau_{\text{control-yaw}} Izr˙=(IxIy)pq+tcontrol-yaw

in:

  • I x , I y , I z I_x, I_y, I_z Ix,Iy,Izare the moments of inertia around the X, Y, and Z axes respectively;
  • p , q , r p, q, r p,q,r is the roll, pitch and yaw angular velocity;
  • τ control-roll , τ control-pitch , τ control-yaw \tau_{\text{control-roll}}, \tau_{\text{control-pitch}}, \tau_{\text{control-yaw}} tcontrol-roll,tcontrol-pitch,tcontrol-yaware the moments generated by roll, pitch and yaw control respectively.

2. Moment of each component

Consider the influence of various components on the helicopter on the moment:

Roll control:

τ control-roll = k elevator ⋅ δ elevator \tau_{\text{control-roll}} = k_{\text{elevator}} \cdot \delta_{\text{elevator}} tcontrol-roll=kelevatordelevator

Pitch control:

τ control-pitch = k elevator ⋅ δ elevator \tau_{\text{control-pitch}} = k_{\text{elevator}} \cdot \delta_{\text{elevator}} tcontrol-pitch=kelevatordelevator

Yaw control:

τ control-yaw = k rudder ⋅ δ rudder \tau_{\text{control-yaw}} = k_{\text{rudder}} \cdot \delta_{\text{rudder}} tcontrol-yaw=krudderdrudder

in:

  • k elevator , k rudder k_{\text{elevator}}, k_{\text{rudder}} kelevator,krudderis a constant related to the control efficiency of the elevator and rudder;
  • δ elevator , δ rudder \delta_{\text{elevator}}, \delta_{\text{rudder}} delevator,drudderis the corresponding control input.

3. Mathematical model

Integrating the above equations, we get the dynamic equations for roll, pitch and yaw:

I x ⋅ p ˙ = ( I y − I z ) ⋅ q ⋅ r + k elevator ⋅ δ elevator I_x \cdot \dot{p} = (I_y - I_z) \cdot q \cdot r + k_{\text{elevator}} \cdot \delta_{\text{elevator}} Ixp˙=(IyIz)qr+kelevatordelevator

I y ⋅ q ˙ = ( I z − I x ) ⋅ p ⋅ r + k elevator ⋅ δ elevator I_y \cdot \dot{q} = (I_z - I_x) \cdot p \cdot r + k_{\text{elevator}} \cdot \delta_{\text{elevator}} Iyq˙=(IzIx)pr+kelevatordelevator

KaTeX parse error: Expected '}', got 'EOF' at end of input: …_{\text{rudder}

4. Numerical simulation

Use numerical simulation tools, such as ODE solvers, to simulate the evolution of the helicopter's roll, pitch, and yaw angles over time given initial conditions and control inputs.

5. Code

import numpy as np
from scipy.integrate import solve_ivp
import matplotlib.pyplot as plt

# 定义直升机姿态角动力学方程
def attitude_dynamics(t, y, elevator_input, rudder_input):
    # y: [roll, pitch, yaw, roll_rate, pitch_rate, yaw_rate]
    roll, pitch, yaw, roll_rate, pitch_rate, yaw_rate = y
    
    # 参数设定
    I_x, I_y, I_z = 1000.0, 1500.0, 2000.0  # 代表绕各轴的惯性矩,实际应根据直升机参数调整
    k_elevator, k_rudder = 2.0, 2.0  # 控制效率常数
    
    # 控制输入
    delta_elevator = elevator_input(t)
    delta_rudder = rudder_input(t)
    
    # 力矩模型
    control_roll_torque = k_elevator * delta_elevator
    control_pitch_torque = k_elevator * delta_elevator
    control_yaw_torque = k_rudder * delta_rudder
    
    # 动力学方程
    roll_acceleration = ((I_y - I_z) * pitch_rate * yaw_rate + control_roll_torque) / I_x
    pitch_acceleration = ((I_z - I_x) * roll_rate * yaw_rate + control_pitch_torque) / I_y
    yaw_acceleration = ((I_x - I_y) * roll_rate * pitch_rate + control_yaw_torque) / I_z

    return [roll_rate, pitch_rate, yaw_rate, roll_acceleration, pitch_acceleration, yaw_acceleration]

# 初始条件
initial_conditions = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]  # 初始角度为0,初始角速度为0

# 时间范围
time_span = (0, 20)

# 控制输入函数(示例,可以根据需要更改)
def elevator_input(t):
#见完整代码

Question three

Question three requires that based on the maneuvering characteristics of the helicopter in low-speed and high-speed flight, the maneuvering range of each component is designed to meet the needs of the helicopter in horizontal flight missions. Here we can use optimal control theory, which is divided into two stages: low-speed flight and high-speed flight.

1. Flying at low speed

a. Meet horizontal flight tasks

When flying at low speed, the horizontal flight task is to maintain a zero attitude angle. We can use optimal control theory to maintain a zero attitude angle when the helicopter is flying horizontally at low speeds by adjusting the control input to each component.

b. Design the maneuverability of each component

Level flight missions are achieved by adjusting the control inputs to each component, such as adjusting the deflection angles of the elevator and rudder. This involves designing appropriate control input amplitude and frequency.

2. High-speed flight

a. Meet horizontal flight tasks

When flying at high speed, it is also necessary to meet the horizontal flight task, that is, to maintain a zero attitude angle.

b. Design the maneuverability of each component

At high speeds, where maneuvering requirements may be more complex, we need to adjust the control inputs to each component to meet the level flight mission. This may involve larger control input amplitudes and higher frequencies.

3. Mathematical modeling

Using optimal control theory, an optimization problem can be formulated with the goal of minimizing the magnitude of the control input while satisfying the constraints of a horizontal flight mission. This can be achieved by setting a performance metric such as minimizing the sum of squares of the control inputs.

4. Code implementation

The specific implementation involves the use of mathematical tools and algorithms from optimal control theory, such as Pontryagin's maximum principle, etc. This may require the use of specialized optimization libraries, such as the optimization tools in SciPy.

import numpy as np
from scipy.integrate import solve_ivp
import scipy.optimize as optimize
import matplotlib.pyplot as plt

# 定义目标函数
def cost_function(inputs):
    # inputs: 控制输入向量
    # 模拟直升机在给定控制输入下的姿态角演化
    # 这里假设存在一个模拟函数 simulate_attitude(inputs),返回姿态角随时间的演化
    simulated_attitude = simulate_attitude(inputs)
    
    # 计算性能指标,例如姿态角偏差的平方和
    target_attitude = np.zeros_like(simulated_attitude)  # 零姿态角作为目标
    cost = np.sum((simulated_attitude - target_attitude)**2)
    
    return cost

# 定义约束条件,例如水平飞行任务的约束条件
def horizontal_flight_constraint(inputs):
    # inputs: 控制输入向量
    # 返回水平飞行任务的约束条件,可以是姿态角的某个范围或其他条件
    # 这里简化为控制输入的幅度不能超过某个阈值
    return np.sum(np.abs(inputs)) - max_input_threshold

# 模拟函数,用于计算在给定控制输入下直升机的姿态角演化
def simulate_attitude(inputs):
    # 使用ODE求解器模拟直升机姿态角的演化
    # 这里假设存在一个 attitude_dynamics 函数表示直升机的姿态动力学方程
    solution = solve_ivp(attitude_dynamics, time_span, initial_conditions, args=(inputs,), method='RK45', dense_output=True)
    
    # 获取模拟结果
    simulated_attitude = solution.sol(t_eval)
    
    return simulated_attitude

# 初始控制输入猜测值
initial_guess = np.array([0.1, 0.1, 0.1, ...])

# 控制输入的约束条件
max_input_threshold = 1.0
constraints = {
    
    'type': 'eq', 'fun': horizontal_flight_constraint}

# 设置优化问题
optimization_problem = optimize.minimize(cost_function, initial_guess, constraints=constraints)

# 获取优化结果
optimal_inputs = optimization_problem.x

Question 4: Helicopter acceleration maneuver mission

1. Goal:

The dynamic value of each control input is designed so that the helicopter accelerates uniformly within 20 seconds, increasing the flight speed from 80 m/s to 180 m/s while maintaining level flight (zero attitude angle).

2. Modeling ideas:

a. Mathematics construction:

  • Using optimal control theory, the evolution of the helicopter's attitude angle over time is considered.
  • Define an objective function, such as the sum of squares of attitude angle deviations, to represent the performance index.
  • Establish the attitude dynamics equation and consider the influence of control input on attitude angle.

b. Control input dynamic adjustment:

  • Dynamically adjust each control input to achieve forward acceleration of the helicopter.
  • According to the acceleration requirements, adjust the amplitude and frequency of the control input.
3. Detailed ideas:
  1. Create the objective function:

    • Fixed standard function, example J = ∑ i = 1 N ( θ i − θ i , target ) 2 J = \sum_{i=1}^{N} ( \theta_i - \theta_{i,\text{target}} )^2 J=i=1N(θiii,target)2, inside θ i \theta_i ii represents the attitude angle, N N N Display time number of steps, θ i , target \theta_{i,\text{target}} ii,targetRepresents the target attitude angle.
  2. Simulate attitude angle evolution:

    • Use the ODE solver to simulate the evolution of the helicopter attitude angle.
    • Through the attitude dynamics equation, the influence of the control input on the attitude angle is considered.
  3. Control input dynamic adjustment:

    • During the simulation, each control input is dynamically adjusted to meet the demand for forward acceleration.
    • Dynamically adjust the amplitude and frequency of the control input based on the acceleration target.
  4. Optimization problem solving:

    • Use optimization algorithms, such as the optimization tools in the SciPy library, to find the minimum value of the objective function.
    • Initial control input guesses can be set heuristically or based on the problem context.
  5. Simulate the attitude angle evolution under optimal control input:

    • The optimal control input obtained from the solution is used to simulate the attitude angle evolution of the helicopter in the acceleration maneuver task.
  6. Visualization of results:

    • Plot the simulation results to show the change of helicopter attitude angle over time.
    • Check whether the results meet the forward acceleration and level flight tasks.
4. Code implementation:
import numpy as np
from scipy.integrate import solve_ivp
import scipy.optimize as optimize
import matplotlib.pyplot as plt

# 假设直升机的动力学方程和控制特性如下

# 控制输入:每个控制输入表示直升机不同部分的控制量
# 例如:inputs = [main_rotor_pitch, tail_rotor_pitch, ...]

# 目标函数
def cost_function(inputs):
    # 模拟直升机在给定控制输入下的姿态角演化
    simulated_attitude = simulate_attitude(inputs)
    
    # 计算性能指标,例如姿态角偏差的平方和
    target_attitude = np.zeros_like(simulated_attitude)  # 零姿态角作为目标
    cost = np.sum((simulated_attitude - target_attitude)**2)
    
    return cost

# 模拟函数
def simulate_attitude(inputs):
    # 使用ODE求解器模拟直升机姿态角的演化
    solution = solve_ivp(attitude_dynamics, time_span, initial_conditions, args=(inputs,), method='RK45', dense_output=True)
    
    # 获取模拟结果
    simulated_attitude = solution.sol(t_eval)
    
    return simulated_attitude

# 姿态动力学方程
def attitude_dynamics(t, y, inputs):
    # y: [roll, pitch, yaw, roll_rate, pitch_rate, yaw_rate]
    # 根据控制输入计算每个控制力和力矩
    
    # 控制输入的动态调整
    # 这里可以根据加速度的需求动态调整控制输入,实现前向加速度
    
    # 姿态动力学方程
    # 这里假设存在合适的动力学方程,需要根据直升机的具体参数和特性进行实现
    roll_acceleration = 0.0  # 根据实际情况计算
    pitch_acceleration = 0.0  # 根据实际情况计算
    yaw_acceleration = 0.0  # 根据实际情况计算
    
    return [roll_rate, pitch_rate, yaw_rate, roll_acceleration, pitch_acceleration, yaw_acceleration]

# 初始控制输入猜测值
initial_guess = np.array([0.1, 0.1, 0.1, ...])

# 时间范围
time_span = (0, 20)

# 优化问题求解
optimization_problem = optimize.minimize(cost_function, initial_guess, method='SLSQP')

# 获取优化结果
optimal_inputs = optimization_problem.x

# 模拟最优控制输入下的姿态角演化
simulated_attitude = simulate_attitude(optimal_inputs)

# 绘制结果
plt.figure(figsize=(12, 8))
plt.plot(t_eval, np.degrees(simulated_attitude[0]), label='Roll Angle (deg)')
plt.plot(t_eval, np.degrees(simulated_attitude[1]), label='Pitch Angle (deg)')
plt.plot(t_eval, np.degrees(simulated_attitude[2]), label='Yaw Angle (deg)')

For more complete ideas and codes, see here:
2023 9th Dimensional Cup Question A Modeling Analysis, led by Senior Xiaolu

Guess you like

Origin blog.csdn.net/Tech_deer/article/details/134436549