{"id":27882990,"url":"https://github.com/kmoraza/aco-based_optimized_aircraft_wing_material_distribution--python_approach","last_synced_at":"2025-05-05T06:10:56.177Z","repository":{"id":289855842,"uuid":"972325358","full_name":"KMORaza/ACO-based_Optimized_Aircraft_Wing_Material_Distribution--Python_approach","owner":"KMORaza","description":"Optimizing Aircraft Wing Material Distribution using Ant Colony Optimization (ACO)","archived":false,"fork":false,"pushed_at":"2025-04-25T11:39:19.000Z","size":987,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-25T12:33:22.305Z","etag":null,"topics":["aerodynamics","aircraft-design","aircraft-performance","ant-colony-algorithm","ant-colony-optimization","finite-element-analysis","finite-element-methods","mathematics","mechanical-engineering","physics"],"latest_commit_sha":null,"homepage":"https://optimized-aircraft-wing-design-py-aco.netlify.app/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KMORaza.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-24T22:30:05.000Z","updated_at":"2025-04-25T11:39:22.000Z","dependencies_parsed_at":"2025-04-25T12:44:25.336Z","dependency_job_id":null,"html_url":"https://github.com/KMORaza/ACO-based_Optimized_Aircraft_Wing_Material_Distribution--Python_approach","commit_stats":null,"previous_names":["kmoraza/aco-based_optimized_aircraft_wing_material_distribution--python_approach"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KMORaza%2FACO-based_Optimized_Aircraft_Wing_Material_Distribution--Python_approach","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KMORaza%2FACO-based_Optimized_Aircraft_Wing_Material_Distribution--Python_approach/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KMORaza%2FACO-based_Optimized_Aircraft_Wing_Material_Distribution--Python_approach/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KMORaza%2FACO-based_Optimized_Aircraft_Wing_Material_Distribution--Python_approach/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KMORaza","download_url":"https://codeload.github.com/KMORaza/ACO-based_Optimized_Aircraft_Wing_Material_Distribution--Python_approach/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252448587,"owners_count":21749495,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aerodynamics","aircraft-design","aircraft-performance","ant-colony-algorithm","ant-colony-optimization","finite-element-analysis","finite-element-methods","mathematics","mechanical-engineering","physics"],"created_at":"2025-05-05T06:10:55.780Z","updated_at":"2025-05-05T06:10:56.162Z","avatar_url":"https://github.com/KMORaza.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Optimizing Aircraft Wing Material Distribution using Ant Colony Optimization\n\n* 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.\n* 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.\n---\n\n### Structure\n\n\n1. **`material_properties.py`**:\n   - Defines the `Material` class for composite material properties.\n   - Computes the stiffness matrix for FEA.\n2. **`wing_geometry.py`**:\n   - Defines the `WingGeometry` class to generate a 2D quadrilateral mesh for the wing cross-section.\n   - Manages geometric parameters and spar positions.\n3. **`fea_solver.py`**:\n   - Implements the `FEASolver` class for finite element analysis.\n   - Computes displacements, stresses, and checks constraints.\n4. **`aco_optimizer.py`**:\n   - Defines the `ACOOptimizer` class for optimizing material properties, spar positions, and ply layups using ACO.\n   - Evaluates solutions via FEA and updates pheromone trails.\n5. **`main.py`**:\n   - Orchestrates the optimization process.\n   - Generates visualizations and outputs.\n\n---\n\n### Logic \u0026 Functionality\n\n#### 1. `material_properties.py`\nModels composite material properties and computes the stiffness matrix for FEA.\n\n- **Class `Material`**:\n  - **Initialization**:\n    - 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).\n    - Computes `nu21` (transverse Poisson’s ratio) as `nu21 = nu12 * E2 / E1`.\n    - Logs initialization details.\n  - **Method `get_stiffness_matrix(theta)`**:\n    - Computes stiffness matrix `Q` for fiber angle `theta` (degrees).\n    - Steps:\n      1. Converts `theta` to radians.\n      2. Builds compliance matrix `S` (`1/E1`, `1/E2`, `-nu12/E1`, `1/G12`).\n      3. Applies transformation matrix `T` to rotate `S` to global coordinates.\n      4. Inverts transformed `S` to get `Q`.\n    - Includes error handling with logging.\n- **Logic**:\n  - The stiffness matrix relates stresses to strains, enabling FEA.\n  - Fiber orientation transformation supports optimization of fiber angles.\n\n#### 2. `wing_geometry.py`\nGenerates a 2D quadrilateral mesh for the wing cross-section.\n\n- **Class `WingGeometry`**:\n  - **Initialization**:\n    - Parameters: `span` (10 m), `chord` (2 m), `num_elements_x` (8), `num_elements_y` (3), `spar_positions` ([0.5, 1.5] m).\n    - Sets `thickness` as 5% of chord (0.1 m).\n    - Computes element sizes (`element_size_x = chord / num_elements_x`, `element_size_y = thickness / num_elements_y`).\n    - Calls `generate_mesh()`.\n  - **Method `generate_mesh()`**:\n    - Creates a grid of nodes.\n    - Defines quadrilateral elements.\n    - Identifies spar elements at `spar_positions`.\n    - Returns nodes, elements, and spar indices.\n  - **Method `get_element_areas()`**:\n    - Computes element areas as `element_size_x * element_size_y` for weight calculations.\n- **Logic**:\n    - The mesh represents a 2D wing cross-section, with spars as structural reinforcements.\n    - Optimizable spar positions enhance stiffness.\n    - Error handling ensures valid mesh generation.\n\n#### 3. `fea_solver.py`\nPerforms FEA to evaluate structural performance.\n\n- **Class `FEASolver`**:\n  - **Initialization**:\n    - Takes `wing_geometry` and `material`.\n    - Sets DOF per node (2: x, y displacements) and total DOF (`nodes * 2`).\n    - Validates mesh (checks Jacobian determinants).\n  - **Key Methods**:\n    - **`assemble_global_stiffness(thicknesses, thetas)`**:\n      - Sums element stiffness matrices (from `element_stiffness`) into global `K`.\n    - **`assemble_global_mass(thicknesses)`**:\n      - Builds global mass matrix `M` for frequency analysis.\n    - **`element_stiffness(element, thickness, theta)`**:\n      - Computes element stiffness using Gaussian quadrature, material stiffness `D`, and shape function derivatives `B`.\n    - **`element_mass(element, thickness)`**:\n      - Computes element mass using density and geometry.\n    - **`shape_functions_and_derivatives(element, xi, eta)`**:\n      - Computes shape function derivatives and Jacobian for coordinate mapping.\n    - **`apply_boundary_conditions(K, F, M)`**:\n      - Fixes wing root nodes (y=0).\n    - **`apply_loads()`**:\n      - Applies 3000 N lift to top nodes with a parabolic distribution.\n    - **`check_buckling(thicknesses, stresses)`**:\n      - Checks Euler buckling (spars) and plate buckling (skin).\n    - **`check_frequency(K, M)`**:\n      - Computes lowest natural frequency via eigenvalue analysis.\n    - **`solve(thicknesses, thetas)`**:\n      - Assembles `K`, `M`, applies loads and boundary conditions, solves `K u = F`, computes stresses, and checks feasibility (stress, displacement, buckling, frequency).\n- **Logic**:\n  - FEA evaluates wing response to loads, ensuring:\n    - Stress ≤ `sigma_y`.\n    - Displacement ≤ 0.15 m.\n    - No buckling.\n    - Adequate frequency.\n  - Sparse matrices optimize computation.\n\n#### 4. `aco_optimizer.py`\nOptimizes wing design using ACO to minimize weight.\n\n\n- **Class `ACOOptimizer`**:\n  - **Initialization**:\n    - Parameters: `wing_geometry`, `fea_solver`, `num_ants` (20), `max_iterations` (30), `rho` (0.3), `alpha` (3.0), `beta` (2.0).\n    - Defines options:\n      - Skin thickness: [30, 35, 40, 45] mm.\n      - Spar thickness: [100, 120, 140, 160] mm.\n      - Fiber angles: [0, 30, 45, 60, 90] degrees.\n      - `E1`: [170, 200, 230] GPa.\n      - Density: [1400, 1600, 1800] kg/m³.\n      - `nu12`: [0.25, 0.3, 0.35].\n      - `G12`: [8, 9, 10] GPa.\n      - Spar positions: [0.2, 1.0, 1.8] m.\n      - Layup angles: [0, 45, 90] degrees.\n    - Initializes pheromones with biases (e.g., thicker elements, non-zero angles).\n    - Sets heuristics (`eta_`) inversely proportional to magnitudes.\n  - **Key Methods**:\n    - **`construct_solution()`**:\n      - Each ant selects values based on pheromone and heuristic probabilities.\n      - Ensures spar positions are ≥1.4 m apart.\n      - Adds 5% random perturbations.\n    - **`evaluate_solution(...)`**:\n      - Updates wing geometry and material properties.\n      - Runs FEA to compute weight, stresses, displacement, frequency.\n      - Applies penalties for constraint violations.\n    - **`update_pheromones(solutions, weights, frequencies)`**:\n      - Evaporates pheromones (`* (1 - rho)`).\n      - Deposits pheromones for the best solution (`1/weight`).\n    - **`optimize()`**:\n      - Runs ACO:\n        1. Constructs solutions.\n        2. Evaluates via FEA.\n        3. Updates pheromones.\n        4. Tracks best design.\n- **Logic**:\n  - ACO uses pheromone trails to guide optimization.\n  - Penalties discourage infeasible solutions.\n  - Balances exploration (randomness, heuristics) and exploitation (pheromones).\n\n#### 5. `main.py`\nIntegrates modules, runs optimization, and visualizes results.\n\n\n- **Function `main()`**:\n  - Initializes components (`WingGeometry`, `Material`, `FEASolver`, `ACOOptimizer`).\n  - Runs optimization and final FEA.\n  - Generates outputs.\n- **Visualization Functions**:\n  - **`plot_solution()`**: Plots thickness, angles, `E1`, density, `nu12`, `G12`, stress, displacement.\n  - **`save_solution_csv()`**: Saves nodes, elements, solution data to CSV.\n  - **`plot_convergence()`**: Plots best weight over iterations.\n  - **`plot_feasibility()`**: Plots feasible solutions per constraint.\n  - **`plot_buckling_penalty()`**: Plots buckling penalties.\n  - **`plot_spar_positions()`**: Visualizes spar locations.\n  - **`sensitivity_analysis()`**: Tests weight sensitivity to frequency constraints (0.5, 1.0, 1.5 Hz).\n- **Logic**:\n  - Coordinates optimization and analysis.\n  - Visualizations provide design insights.\n  - Sensitivity analysis explores trade-offs.\n\n---\n\n| ![](https://github.com/KMORaza/ACO-based_Optimized_Aircraft_Wing_Material_Distribution--Python_approach/blob/main/ACO-based%20Optimized%20Aircraft%20Wing%20Material%20Distribution/extended%20solution/convergence_plot.png) | ![](https://github.com/KMORaza/ACO-based_Optimized_Aircraft_Wing_Material_Distribution--Python_approach/blob/main/ACO-based%20Optimized%20Aircraft%20Wing%20Material%20Distribution/extended%20solution/spar_position_plot.png?raw=true)\n|--|--|\n| ![](https://github.com/KMORaza/ACO-based_Optimized_Aircraft_Wing_Material_Distribution--Python_approach/blob/main/ACO-based%20Optimized%20Aircraft%20Wing%20Material%20Distribution/extended%20solution/stress_histogram.png?raw=true) | ![](https://github.com/KMORaza/ACO-based_Optimized_Aircraft_Wing_Material_Distribution--Python_approach/blob/main/ACO-based%20Optimized%20Aircraft%20Wing%20Material%20Distribution/extended%20solution/wing_E1_plot.png?raw=true) |\n| ![](https://github.com/KMORaza/ACO-based_Optimized_Aircraft_Wing_Material_Distribution--Python_approach/blob/main/ACO-based%20Optimized%20Aircraft%20Wing%20Material%20Distribution/extended%20solution/wing_G12_plot.png?raw=true) | ![](https://github.com/KMORaza/ACO-based_Optimized_Aircraft_Wing_Material_Distribution--Python_approach/blob/main/ACO-based%20Optimized%20Aircraft%20Wing%20Material%20Distribution/extended%20solution/wing_density_plot.png?raw=true) |\n| ![](https://github.com/KMORaza/ACO-based_Optimized_Aircraft_Wing_Material_Distribution--Python_approach/blob/main/ACO-based%20Optimized%20Aircraft%20Wing%20Material%20Distribution/extended%20solution/wing_displacement_plot.png?raw=true) | ![](https://github.com/KMORaza/ACO-based_Optimized_Aircraft_Wing_Material_Distribution--Python_approach/blob/main/ACO-based%20Optimized%20Aircraft%20Wing%20Material%20Distribution/extended%20solution/wing_nu12_plot.png?raw=true) |\n| ![](https://github.com/KMORaza/ACO-based_Optimized_Aircraft_Wing_Material_Distribution--Python_approach/blob/main/ACO-based%20Optimized%20Aircraft%20Wing%20Material%20Distribution/extended%20solution/wing_stress_plot.png?raw=true) | ![](https://github.com/KMORaza/ACO-based_Optimized_Aircraft_Wing_Material_Distribution--Python_approach/blob/main/ACO-based%20Optimized%20Aircraft%20Wing%20Material%20Distribution/extended%20solution/wing_theta_plot.png?raw=true) |\n\n---\n\n_Check the_ [__*webpage*__](https://optimized-aircraft-wing-design-py-aco.netlify.app/) _about the solution and its implementation_\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkmoraza%2Faco-based_optimized_aircraft_wing_material_distribution--python_approach","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkmoraza%2Faco-based_optimized_aircraft_wing_material_distribution--python_approach","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkmoraza%2Faco-based_optimized_aircraft_wing_material_distribution--python_approach/lists"}