Skip to content

Commit

Permalink
I reformatted with Black again.
Browse files Browse the repository at this point in the history
  • Loading branch information
camUrban committed Dec 4, 2024
1 parent 474f1e3 commit 2796e4f
Show file tree
Hide file tree
Showing 46 changed files with 5,456 additions and 2,297 deletions.
108 changes: 77 additions & 31 deletions benchmarks/unsteady_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,59 +9,105 @@
num_chordwise_panels = 5
num_spanwise_panels = 20

example_airplane = ps.geometry.Airplane(name="Example Airplane", wings=[
ps.geometry.Wing(name="Main Wing", symmetric=True,
num_chordwise_panels=num_chordwise_panels, chordwise_spacing="uniform",
wing_cross_sections=[
ps.geometry.WingCrossSection(num_spanwise_panels=num_spanwise_panels,
spanwise_spacing="uniform", chord=1.75,
airfoil=ps.geometry.Airfoil(name="naca0000", ), ),
ps.geometry.WingCrossSection(num_spanwise_panels=num_spanwise_panels,
spanwise_spacing="uniform", x_le=0.625, y_le=5.0, chord=0.5,
airfoil=ps.geometry.Airfoil(name="naca0000", ), ), ], ), ], )
example_airplane = ps.geometry.Airplane(
name="Example Airplane",
wings=[
ps.geometry.Wing(
name="Main Wing",
symmetric=True,
num_chordwise_panels=num_chordwise_panels,
chordwise_spacing="uniform",
wing_cross_sections=[
ps.geometry.WingCrossSection(
num_spanwise_panels=num_spanwise_panels,
spanwise_spacing="uniform",
chord=1.75,
airfoil=ps.geometry.Airfoil(
name="naca0000",
),
),
ps.geometry.WingCrossSection(
num_spanwise_panels=num_spanwise_panels,
spanwise_spacing="uniform",
x_le=0.625,
y_le=5.0,
chord=0.5,
airfoil=ps.geometry.Airfoil(
name="naca0000",
),
),
],
),
],
)

upper_wing_root_wing_cross_section_movement = ps.movement.WingCrossSectionMovement(
base_wing_cross_section=example_airplane.wings[0].wing_cross_sections[0], )
base_wing_cross_section=example_airplane.wings[0].wing_cross_sections[0],
)

upper_wing_tip_wing_cross_section_movement = ps.movement.WingCrossSectionMovement(
base_wing_cross_section=example_airplane.wings[0].wing_cross_sections[1],
sweeping_amplitude=15.0, sweeping_period=1 / flapping_frequency,
sweeping_spacing="sine", pitching_amplitude=5.0,
pitching_period=1 / flapping_frequency, pitching_spacing="sine",
heaving_amplitude=5.0, heaving_period=1 / flapping_frequency,
heaving_spacing="sine", )

upper_wing_movement = ps.movement.WingMovement(base_wing=example_airplane.wings[0],
wing_cross_sections_movements=[upper_wing_root_wing_cross_section_movement,
upper_wing_tip_wing_cross_section_movement, ], )
sweeping_amplitude=15.0,
sweeping_period=1 / flapping_frequency,
sweeping_spacing="sine",
pitching_amplitude=5.0,
pitching_period=1 / flapping_frequency,
pitching_spacing="sine",
heaving_amplitude=5.0,
heaving_period=1 / flapping_frequency,
heaving_spacing="sine",
)

upper_wing_movement = ps.movement.WingMovement(
base_wing=example_airplane.wings[0],
wing_cross_sections_movements=[
upper_wing_root_wing_cross_section_movement,
upper_wing_tip_wing_cross_section_movement,
],
)

del upper_wing_root_wing_cross_section_movement
del upper_wing_tip_wing_cross_section_movement

airplane_movement = ps.movement.AirplaneMovement(base_airplane=example_airplane,
wing_movements=[upper_wing_movement], )
airplane_movement = ps.movement.AirplaneMovement(
base_airplane=example_airplane,
wing_movements=[upper_wing_movement],
)

del upper_wing_movement

example_operating_point = ps.operating_point.OperatingPoint(density=1.225, beta=0.0,
velocity=10.0, alpha=0.0, )
example_operating_point = ps.operating_point.OperatingPoint(
density=1.225,
beta=0.0,
velocity=10.0,
alpha=0.0,
)

operating_point_movement = ps.movement.OperatingPointMovement(
base_operating_point=example_operating_point, )
base_operating_point=example_operating_point,
)

movement = ps.movement.Movement(airplane_movements=[airplane_movement],
operating_point_movement=operating_point_movement, )
movement = ps.movement.Movement(
airplane_movements=[airplane_movement],
operating_point_movement=operating_point_movement,
)

del airplane_movement
del operating_point_movement

example_problem = ps.problems.UnsteadyProblem(movement=movement,
only_final_results=True)
example_problem = ps.problems.UnsteadyProblem(
movement=movement, only_final_results=True
)

example_solver = (
ps.unsteady_ring_vortex_lattice_method.UnsteadyRingVortexLatticeMethodSolver(
unsteady_problem=example_problem, ))
unsteady_problem=example_problem,
)
)

del example_problem

example_solver.run(prescribed_wake=True, calculate_streamlines=False, )
example_solver.run(
prescribed_wake=True,
calculate_streamlines=False,
)
106 changes: 76 additions & 30 deletions benchmarks/unsteady_benchmark_converge.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,59 +4,105 @@
num_chordwise_panels = 5
num_spanwise_panels = 20

example_airplane = ps.geometry.Airplane(name="Example Airplane", wings=[
ps.geometry.Wing(name="Main Wing", symmetric=True,
num_chordwise_panels=num_chordwise_panels, chordwise_spacing="uniform",
wing_cross_sections=[
ps.geometry.WingCrossSection(num_spanwise_panels=num_spanwise_panels,
spanwise_spacing="uniform", chord=1.75,
airfoil=ps.geometry.Airfoil(name="naca0000", ), ),
ps.geometry.WingCrossSection(num_spanwise_panels=num_spanwise_panels,
spanwise_spacing="uniform", x_le=0.625, y_le=5.0, chord=0.5,
airfoil=ps.geometry.Airfoil(name="naca0000", ), ), ], ), ], )
example_airplane = ps.geometry.Airplane(
name="Example Airplane",
wings=[
ps.geometry.Wing(
name="Main Wing",
symmetric=True,
num_chordwise_panels=num_chordwise_panels,
chordwise_spacing="uniform",
wing_cross_sections=[
ps.geometry.WingCrossSection(
num_spanwise_panels=num_spanwise_panels,
spanwise_spacing="uniform",
chord=1.75,
airfoil=ps.geometry.Airfoil(
name="naca0000",
),
),
ps.geometry.WingCrossSection(
num_spanwise_panels=num_spanwise_panels,
spanwise_spacing="uniform",
x_le=0.625,
y_le=5.0,
chord=0.5,
airfoil=ps.geometry.Airfoil(
name="naca0000",
),
),
],
),
],
)

upper_wing_root_wing_cross_section_movement = ps.movement.WingCrossSectionMovement(
base_wing_cross_section=example_airplane.wings[0].wing_cross_sections[0], )
base_wing_cross_section=example_airplane.wings[0].wing_cross_sections[0],
)

upper_wing_tip_wing_cross_section_movement = ps.movement.WingCrossSectionMovement(
base_wing_cross_section=example_airplane.wings[0].wing_cross_sections[1],
sweeping_amplitude=15.0, sweeping_period=1 / flapping_frequency,
sweeping_spacing="sine", pitching_amplitude=5.0,
pitching_period=1 / flapping_frequency, pitching_spacing="sine",
heaving_amplitude=5.0, heaving_period=1 / flapping_frequency,
heaving_spacing="sine", )
sweeping_amplitude=15.0,
sweeping_period=1 / flapping_frequency,
sweeping_spacing="sine",
pitching_amplitude=5.0,
pitching_period=1 / flapping_frequency,
pitching_spacing="sine",
heaving_amplitude=5.0,
heaving_period=1 / flapping_frequency,
heaving_spacing="sine",
)

upper_wing_movement = ps.movement.WingMovement(base_wing=example_airplane.wings[0],
wing_cross_sections_movements=[upper_wing_root_wing_cross_section_movement,
upper_wing_tip_wing_cross_section_movement, ], )
upper_wing_movement = ps.movement.WingMovement(
base_wing=example_airplane.wings[0],
wing_cross_sections_movements=[
upper_wing_root_wing_cross_section_movement,
upper_wing_tip_wing_cross_section_movement,
],
)

del upper_wing_root_wing_cross_section_movement
del upper_wing_tip_wing_cross_section_movement

airplane_movement = ps.movement.AirplaneMovement(base_airplane=example_airplane,
wing_movements=[upper_wing_movement], )
airplane_movement = ps.movement.AirplaneMovement(
base_airplane=example_airplane,
wing_movements=[upper_wing_movement],
)

del example_airplane
del upper_wing_movement

example_operating_point = ps.operating_point.OperatingPoint(density=1.225, beta=0.0,
velocity=10.0, alpha=0.0, )
example_operating_point = ps.operating_point.OperatingPoint(
density=1.225,
beta=0.0,
velocity=10.0,
alpha=0.0,
)

operating_point_movement = ps.movement.OperatingPointMovement(
base_operating_point=example_operating_point, )
base_operating_point=example_operating_point,
)

del example_operating_point

movement = ps.movement.Movement(airplane_movements=[airplane_movement],
operating_point_movement=operating_point_movement, )
movement = ps.movement.Movement(
airplane_movements=[airplane_movement],
operating_point_movement=operating_point_movement,
)

del airplane_movement
del operating_point_movement

ps.convergence.analyze_unsteady_convergence(ref_movement=movement, prescribed_wake=True,
free_wake=True, num_cycles_bounds=(1, 3), num_chords_bounds=None,
panel_aspect_ratio_bounds=(4, 1), num_chordwise_panels_bounds=(5, 10),
convergence_criteria=5.0, )
ps.convergence.analyze_unsteady_convergence(
ref_movement=movement,
prescribed_wake=True,
free_wake=True,
num_cycles_bounds=(1, 3),
num_chords_bounds=None,
panel_aspect_ratio_bounds=(4, 1),
num_chordwise_panels_bounds=(5, 10),
convergence_criteria=5.0,
)

# Converged result:
# wake=false
Expand Down
74 changes: 59 additions & 15 deletions examples/analyze_steady_trim_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,55 @@

# Create an airplane object. Read through the solver examples for more details on
# creating this object.
default_airplane = ps.geometry.Airplane(weight=250, wings=[
ps.geometry.Wing(symmetric=True, wing_cross_sections=[
ps.geometry.WingCrossSection(airfoil=ps.geometry.Airfoil(name="naca2412", ), ),
ps.geometry.WingCrossSection(x_le=0.0, y_le=5.0, z_le=0.0, chord=1.0,
airfoil=ps.geometry.Airfoil(name="naca2412", ), ), ], ),
ps.geometry.Wing(x_le=7.50, z_le=0.25, symmetric=True, wing_cross_sections=[
ps.geometry.WingCrossSection(x_le=0.0, y_le=0.0, chord=0.5, twist=-5.0,
airfoil=ps.geometry.Airfoil(name="naca0012", ), ),
ps.geometry.WingCrossSection(x_le=0.0, y_le=1.0, chord=0.5, twist=-5.0,
airfoil=ps.geometry.Airfoil(name="naca0012", ), ), ], ), ], )
default_airplane = ps.geometry.Airplane(
weight=250,
wings=[
ps.geometry.Wing(
symmetric=True,
wing_cross_sections=[
ps.geometry.WingCrossSection(
airfoil=ps.geometry.Airfoil(
name="naca2412",
),
),
ps.geometry.WingCrossSection(
x_le=0.0,
y_le=5.0,
z_le=0.0,
chord=1.0,
airfoil=ps.geometry.Airfoil(
name="naca2412",
),
),
],
),
ps.geometry.Wing(
x_le=7.50,
z_le=0.25,
symmetric=True,
wing_cross_sections=[
ps.geometry.WingCrossSection(
x_le=0.0,
y_le=0.0,
chord=0.5,
twist=-5.0,
airfoil=ps.geometry.Airfoil(
name="naca0012",
),
),
ps.geometry.WingCrossSection(
x_le=0.0,
y_le=1.0,
chord=0.5,
twist=-5.0,
airfoil=ps.geometry.Airfoil(
name="naca0012",
),
),
],
),
],
)

# Create an operating point object for this example's problem. Be sure to specify an
# external thrust because this aircraft is not flapping, and will therefore generate
Expand All @@ -30,15 +69,20 @@
default_operating_point = ps.operating_point.OperatingPoint(external_thrust=5)

# Construct this example's problem object.
default_problem = ps.problems.SteadyProblem(airplanes=[default_airplane],
operating_point=default_operating_point)
default_problem = ps.problems.SteadyProblem(
airplanes=[default_airplane], operating_point=default_operating_point
)

# Call the analyze_steady_trim function to search for a trim condition (thrust
# balances drag, weight balances lift, and all moments are close to zero) within a
# certain set of bounds.
trim_conditions = ps.trim.analyze_steady_trim(problem=default_problem,
velocity_bounds=(5, 15), alpha_bounds=(-10, 10), beta_bounds=(-1, 1),
external_thrust_bounds=(0, 10), )
trim_conditions = ps.trim.analyze_steady_trim(
problem=default_problem,
velocity_bounds=(5, 15),
alpha_bounds=(-10, 10),
beta_bounds=(-1, 1),
external_thrust_bounds=(0, 10),
)

# Log the trim conditions. If these display "nan", then the trim function couldn't
# find a trimmed state.
Expand Down
Loading

0 comments on commit 2796e4f

Please sign in to comment.