- The solution is written fully in Python and it aimes to optimize the material distribution of a simplified aircraft wing cross-section to minimize its weight while satisfying structural constraints. The wing is modeled as a thin-walled rectangular section subjected to an aerodynamic lift load.
- It is essential to select the thickness and fiber orientation of composite material elements (skin and spars) to ensure the structure can withstand stress, buckling, and displacement constraints, and maintain a minimum natural frequency.
material_properties.py
:- Defines the
Material
class for composite material properties. - Computes the stiffness matrix for FEA.
- Defines the
wing_geometry.py
:- Defines the
WingGeometry
class to generate a 2D quadrilateral mesh for the wing cross-section. - Manages geometric parameters and spar positions.
- Defines the
fea_solver.py
:- Implements the
FEASolver
class for finite element analysis. - Computes displacements, stresses, and checks constraints.
- Implements the
aco_optimizer.py
:- Defines the
ACOOptimizer
class for optimizing material properties, spar positions, and ply layups using ACO. - Evaluates solutions via FEA and updates pheromone trails.
- Defines the
main.py
:- Orchestrates the optimization process.
- Generates visualizations and outputs.
Models composite material properties and computes the stiffness matrix for FEA.
- Class
Material
:- Initialization:
- Parameters:
E1
(Young’s modulus in fiber direction, 135 GPa),E2
(transverse modulus, 10 GPa),G12
(shear modulus, 5 GPa),nu12
(Poisson’s ratio, 0.3),density
(1600 kg/m³),sigma_y
(yield stress, 1200 MPa). - Computes
nu21
(transverse Poisson’s ratio) asnu21 = nu12 * E2 / E1
. - Logs initialization details.
- Parameters:
- Method
get_stiffness_matrix(theta)
:- Computes stiffness matrix
Q
for fiber angletheta
(degrees). - Steps:
- Converts
theta
to radians. - Builds compliance matrix
S
(1/E1
,1/E2
,-nu12/E1
,1/G12
). - Applies transformation matrix
T
to rotateS
to global coordinates. - Inverts transformed
S
to getQ
.
- Converts
- Includes error handling with logging.
- Computes stiffness matrix
- Initialization:
- Logic:
- The stiffness matrix relates stresses to strains, enabling FEA.
- Fiber orientation transformation supports optimization of fiber angles.
Generates a 2D quadrilateral mesh for the wing cross-section.
- Class
WingGeometry
:- Initialization:
- Parameters:
span
(10 m),chord
(2 m),num_elements_x
(8),num_elements_y
(3),spar_positions
([0.5, 1.5] m). - Sets
thickness
as 5% of chord (0.1 m). - Computes element sizes (
element_size_x = chord / num_elements_x
,element_size_y = thickness / num_elements_y
). - Calls
generate_mesh()
.
- Parameters:
- Method
generate_mesh()
:- Creates a grid of nodes.
- Defines quadrilateral elements.
- Identifies spar elements at
spar_positions
. - Returns nodes, elements, and spar indices.
- Method
get_element_areas()
:- Computes element areas as
element_size_x * element_size_y
for weight calculations.
- Computes element areas as
- Initialization:
- Logic:
- The mesh represents a 2D wing cross-section, with spars as structural reinforcements.
- Optimizable spar positions enhance stiffness.
- Error handling ensures valid mesh generation.
Performs FEA to evaluate structural performance.
- Class
FEASolver
:- Initialization:
- Takes
wing_geometry
andmaterial
. - Sets DOF per node (2: x, y displacements) and total DOF (
nodes * 2
). - Validates mesh (checks Jacobian determinants).
- Takes
- Key Methods:
assemble_global_stiffness(thicknesses, thetas)
:- Sums element stiffness matrices (from
element_stiffness
) into globalK
.
- Sums element stiffness matrices (from
assemble_global_mass(thicknesses)
:- Builds global mass matrix
M
for frequency analysis.
- Builds global mass matrix
element_stiffness(element, thickness, theta)
:- Computes element stiffness using Gaussian quadrature, material stiffness
D
, and shape function derivativesB
.
- Computes element stiffness using Gaussian quadrature, material stiffness
element_mass(element, thickness)
:- Computes element mass using density and geometry.
shape_functions_and_derivatives(element, xi, eta)
:- Computes shape function derivatives and Jacobian for coordinate mapping.
apply_boundary_conditions(K, F, M)
:- Fixes wing root nodes (y=0).
apply_loads()
:- Applies 3000 N lift to top nodes with a parabolic distribution.
check_buckling(thicknesses, stresses)
:- Checks Euler buckling (spars) and plate buckling (skin).
check_frequency(K, M)
:- Computes lowest natural frequency via eigenvalue analysis.
solve(thicknesses, thetas)
:- Assembles
K
,M
, applies loads and boundary conditions, solvesK u = F
, computes stresses, and checks feasibility (stress, displacement, buckling, frequency).
- Assembles
- Initialization:
- Logic:
- FEA evaluates wing response to loads, ensuring:
- Stress ≤
sigma_y
. - Displacement ≤ 0.15 m.
- No buckling.
- Adequate frequency.
- Stress ≤
- Sparse matrices optimize computation.
- FEA evaluates wing response to loads, ensuring:
Optimizes wing design using ACO to minimize weight.
- Class
ACOOptimizer
:- Initialization:
- Parameters:
wing_geometry
,fea_solver
,num_ants
(20),max_iterations
(30),rho
(0.3),alpha
(3.0),beta
(2.0). - Defines options:
- Skin thickness: [30, 35, 40, 45] mm.
- Spar thickness: [100, 120, 140, 160] mm.
- Fiber angles: [0, 30, 45, 60, 90] degrees.
E1
: [170, 200, 230] GPa.- Density: [1400, 1600, 1800] kg/m³.
nu12
: [0.25, 0.3, 0.35].G12
: [8, 9, 10] GPa.- Spar positions: [0.2, 1.0, 1.8] m.
- Layup angles: [0, 45, 90] degrees.
- Initializes pheromones with biases (e.g., thicker elements, non-zero angles).
- Sets heuristics (
eta_
) inversely proportional to magnitudes.
- Parameters:
- Key Methods:
construct_solution()
:- Each ant selects values based on pheromone and heuristic probabilities.
- Ensures spar positions are ≥1.4 m apart.
- Adds 5% random perturbations.
evaluate_solution(...)
:- Updates wing geometry and material properties.
- Runs FEA to compute weight, stresses, displacement, frequency.
- Applies penalties for constraint violations.
update_pheromones(solutions, weights, frequencies)
:- Evaporates pheromones (
* (1 - rho)
). - Deposits pheromones for the best solution (
1/weight
).
- Evaporates pheromones (
optimize()
:- Runs ACO:
- Constructs solutions.
- Evaluates via FEA.
- Updates pheromones.
- Tracks best design.
- Runs ACO:
- Initialization:
- Logic:
- ACO uses pheromone trails to guide optimization.
- Penalties discourage infeasible solutions.
- Balances exploration (randomness, heuristics) and exploitation (pheromones).
Integrates modules, runs optimization, and visualizes results.
- Function
main()
:- Initializes components (
WingGeometry
,Material
,FEASolver
,ACOOptimizer
). - Runs optimization and final FEA.
- Generates outputs.
- Initializes components (
- Visualization Functions:
plot_solution()
: Plots thickness, angles,E1
, density,nu12
,G12
, stress, displacement.save_solution_csv()
: Saves nodes, elements, solution data to CSV.plot_convergence()
: Plots best weight over iterations.plot_feasibility()
: Plots feasible solutions per constraint.plot_buckling_penalty()
: Plots buckling penalties.plot_spar_positions()
: Visualizes spar locations.sensitivity_analysis()
: Tests weight sensitivity to frequency constraints (0.5, 1.0, 1.5 Hz).
- Logic:
- Coordinates optimization and analysis.
- Visualizations provide design insights.
- Sensitivity analysis explores trade-offs.
![]() |
![]() |
---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Check the webpage about the solution and its implementation