use crate::lifting_line::prelude::*;
use crate::lifting_line::simulation_builder::{
SimulationBuilder,
SimulationSettings
};
use super::test_setup::RectangularWing;
#[test]
fn moment_test() {
let aspect_ratio = 5.0;
let cl_zero_angle = 0.5;
let angle_of_attack = 0.0;
let line_force_model_builder = RectangularWing {
aspect_ratio,
cl_zero_angle,
angle_of_attack,
negative_span_orientation: true,
..Default::default()
}.build();
let freestream_velocity = SpatialVector::from([1.2, 0.0, 0.0]);
let mut sim = SimulationBuilder {
line_force_model: line_force_model_builder,
simulation_settings: SimulationSettings::default()
}.build();
let freestream_velocity_points = sim.get_freestream_velocity_points();
let input_freestream_velocity = vec![freestream_velocity; freestream_velocity_points.len()];
let result = sim.do_step(
0.0,
1.0,
&input_freestream_velocity
);
let force = result.integrated_forces_sum();
let moment = result.integrated_moments_sum();
let cl = force[1] / sim.line_force_model.total_force_factor(freestream_velocity.length());
dbg!(cl);
assert!(force[1] < 0.0, "Sign of the force in the y direction is wrong: {}", force[1]);
assert!(moment[0] < 0.0, "Sign of the moment in the x direction is wrong: {}", moment[0]);
let moment_arm = -moment[0] / force[1];
let moment_arm_theory = -2.5;
let error = (moment_arm - moment_arm_theory).abs();
assert!(error < 0.001, "Moment arm error. Moment arm = {}", moment_arm);
}