-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cpacs convert to AVL format AVL added to CEASIOMpy as PyAVL module New CPACS files added to the hangar
- Loading branch information
Showing
40 changed files
with
40,696 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
|
||
<img align="right" height="70" src="../../documents/logos/CEASIOMpy_banner_aero.png"> | ||
|
||
# PyAVL | ||
|
||
**Categories:** Aerodynamics, vortex lattice method, low-fidelity. | ||
|
||
**State**: :heavy_check_mark: | ||
|
||
<img align="right" height="120" src="files/avl_logo.png"> | ||
|
||
`PyAVL` module is a launcher for the [Athena Vortex Lattice (AVL)](https://web.mit.edu/drela/Public/web/avl/) solver, developed by M. Drela and H. Youngren at MIT. It is a vortex lattice method (VLM) solver for low-fidelity aerodynamic computations. | ||
|
||
## Inputs | ||
|
||
`PyAVL` takes as input a CPACS file, the aircraft geometry is read to create the VLM model for the wings and fuselage. The flight conditions have to be defined within an aeromap, as well as the number of vortex panels to use. | ||
|
||
<p align="center"> | ||
<img height="340" src="files/avl_example.png"> | ||
</p> | ||
<p align="center"> | ||
Example of AVL geometry model. | ||
</p> | ||
|
||
## Analyses | ||
|
||
`PyAVL` computes the aerodynamic coefficients of an aircraft for a given aeromap and writes the results in a CPACS file. It calculates the total forces on the aircraft, the forces on individual surfaces, the forces on wing strips, and the forces on each panel. The stability derivatives can also be computed. | ||
|
||
## Outputs | ||
|
||
`PyAVL` outputs a CPACS file with the aerodynamic coefficients added in the aeromap. The settings of the simulation (number of chordwise/spanwise vortices, vortex distribution) are saved. The following force files are saved: | ||
- `ft.txt`: Total Forces. | ||
- `fn.txt`: Surface Forces. | ||
- `fs.txt`: Strip Forces. | ||
- `fe.txt`: Element Forces (vortex strength). | ||
|
||
The following plots are generated: | ||
- `plot.pdf`: it contains a plot of the initial AVL geometry model, and a plot with the aerodynamic loads on the aircraft. | ||
- `lift_distribution.png`: plot of the lift distribution along the span. | ||
|
||
<p align="center"> | ||
<img height="340" src="files/avl_example_loads.png"> | ||
</p> | ||
<p align="center"> | ||
Example of aerodynamic loads computed by AVL. | ||
</p> | ||
|
||
|
||
## Installation or requirements | ||
|
||
Following the automatic installation procedure on the [CEASIOMpy installation page](../../installation/INSTALLATION.md) should install `PyAVL` automatically with the other tools. | ||
|
||
## Limitations | ||
|
||
`PyAVL` uses a Vortex Lattice Method solver: | ||
- The flow is quasi-steady and ideal: incompressible, irrotational, and inviscid. | ||
- The flow is low-subsonic: [Prandlt-Glauert transformation](https://en.wikipedia.org/wiki/Prandtl%E2%80%93Glauert_transformation) is used to adapt the equations up to Mach 0.6. | ||
- Lifting surfaces are assumed to be thin, the thickness is not taken into account. | ||
- The angle of attack and sideslip must be small. | ||
- Viscous effects, turbulence or boundary layer phenomena are not solved at all. | ||
|
||
## More information | ||
|
||
- [AVL documentation.](https://web.mit.edu/drela/Public/web/avl/AVL_User_Primer.pdf) | ||
- [AVL website.](https://web.mit.edu/drela/Public/web/avl/) | ||
- [Flight Vehicule Aerodynamics](https://mitpress.mit.edu/9780262526449/flight-vehicle-aerodynamics/) by M. Drela. | ||
- [Low-Speed Aerodynamics](https://www.cambridge.org/core/books/lowspeed-aerodynamics/077FAF851C4582F1B7593809752C44AE) by J. Katz and A. Plotkin. | ||
- [Aerodynamics for Engineers](https://www.cambridge.org/highereducation/books/aerodynamics-for-engineers/C8AAC9F38F0781CA38AB65FA85E61CCF#overview) by J. Bertin. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
from ceasiompy.utils.moduleinterfaces import CPACSInOut | ||
from ceasiompy.utils.commonxpath import ( | ||
CEASIOMPY_XPATH, | ||
AVL_PLOT_XPATH, | ||
AVL_VORTEX_DISTR_XPATH, | ||
AVL_FUSELAGE_XPATH, | ||
AVL_AEROMAP_UID_XPATH, | ||
AEROPERFORMANCE_XPATH, | ||
) | ||
from pathlib import Path | ||
|
||
# ===== Module Status ===== | ||
# True if the module is active | ||
# False if the module is disabled (not working or not ready) | ||
module_status = True # Because it is just an example not a real module | ||
|
||
# ===== Results directory path ===== | ||
|
||
RESULTS_DIR = Path("Results", "PyAVL") | ||
|
||
# ===== CPACS inputs and outputs ===== | ||
|
||
cpacs_inout = CPACSInOut() | ||
|
||
# ----- Input ----- | ||
|
||
# * In the following example we add three (!) new entries to 'cpacs_inout' | ||
# * Try to use (readable) loops instead of copy-pasting three almost same entries :) | ||
cpacs_inout.add_input( | ||
var_name="aeromap_uid", | ||
var_type=list, | ||
default_value=None, | ||
unit=None, | ||
descr="Name of the aero map to calculate", | ||
xpath=AVL_AEROMAP_UID_XPATH, | ||
gui=True, | ||
gui_name="__AEROMAP_SELECTION", | ||
gui_group="Aeromap settings", | ||
) | ||
|
||
cpacs_inout.add_input( | ||
var_name="integrate_fuselage", | ||
var_type=bool, | ||
default_value=False, | ||
unit=None, | ||
descr="Select to integrate the fuselage in the AVL model", | ||
xpath=AVL_FUSELAGE_XPATH, | ||
gui=True, | ||
gui_name="Integrate fuselage", | ||
gui_group="Fuselage", | ||
) | ||
|
||
cpacs_inout.add_input( | ||
var_name="panel_distribution", | ||
var_type=list, | ||
default_value=["cosine", "sine", "equal"], | ||
unit=None, | ||
descr=("Select the type of distribution"), | ||
xpath=AVL_VORTEX_DISTR_XPATH + "/Distribution", | ||
gui=True, | ||
gui_name="Choice of distribution", | ||
gui_group="Vortex Lattice Spacing Distributions", | ||
) | ||
|
||
cpacs_inout.add_input( | ||
var_name="chordwise_vort", | ||
var_type=int, | ||
default_value=20, | ||
unit=None, | ||
descr="Select the number of chordwise vortices", | ||
xpath=AVL_VORTEX_DISTR_XPATH + "/Nchordwise", | ||
gui=True, | ||
gui_name="Number of chordwise vortices", | ||
gui_group="Vortex Lattice Spacing Distributions", | ||
) | ||
|
||
cpacs_inout.add_input( | ||
var_name="spanwise_vort", | ||
var_type=int, | ||
default_value=50, | ||
unit=None, | ||
descr="Select the number of spanwise vortices", | ||
xpath=AVL_VORTEX_DISTR_XPATH + "/Nspanwise", | ||
gui=True, | ||
gui_name="Number of spanwise vortices", | ||
gui_group="Vortex Lattice Spacing Distributions", | ||
) | ||
|
||
cpacs_inout.add_input( | ||
var_name="save_plots", | ||
var_type=bool, | ||
default_value=False, | ||
unit=None, | ||
descr="Select to save geometry and results plots", | ||
xpath=AVL_PLOT_XPATH, | ||
gui=True, | ||
gui_name="Save plots", | ||
gui_group="Plots", | ||
) | ||
|
||
# ----- Output ----- | ||
|
||
cpacs_inout.add_output( | ||
var_name="output", | ||
default_value=None, | ||
unit="1", | ||
descr="Description of the output", | ||
xpath=CEASIOMPY_XPATH + "/test/myOutput", | ||
) | ||
|
||
cpacs_inout.add_output( | ||
var_name="aeromap_avl", # name to change... | ||
# var_type=CPACS_aeroMap, # no type pour output, would it be useful? | ||
default_value=None, | ||
unit="-", | ||
descr="aeroMap with aero coefficients calculated by AVL", | ||
xpath=AEROPERFORMANCE_XPATH + "/aeroMap/aeroPerformanceMap", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
""" | ||
CEASIOMpy: Conceptual Aircraft Design Software | ||
Developed by CFS ENGINEERING, 1015 Lausanne, Switzerland | ||
Script to run AVL calculations in CEASIOMpy. | ||
AVL allows to perform aerodynamic analyses using | ||
the vortex-lattice method (VLM) | ||
Python version: >=3.8 | ||
| Author: Romain Gauthier | ||
| Creation: 2024-03-14 | ||
TODO: | ||
* Things to improve ... | ||
""" | ||
|
||
# ============================================================================== | ||
# IMPORTS | ||
# ============================================================================== | ||
from ceasiompy.utils.ceasiomlogger import get_logger | ||
from ceasiompy.utils.moduleinterfaces import get_toolinput_file_path, get_tooloutput_file_path | ||
from ceasiompy.PyAVL.func.cpacs2avl import convert_cpacs_to_avl | ||
from ceasiompy.PyAVL.func.avlconfig import ( | ||
write_command_file, | ||
get_aeromap_conditions, | ||
get_option_settings, | ||
) | ||
from ceasiompy.PyAVL.func.avlresults import get_avl_results | ||
from ceasiompy.utils.ceasiompyutils import get_results_directory | ||
|
||
import subprocess | ||
from pathlib import Path | ||
from ambiance import Atmosphere | ||
|
||
|
||
log = get_logger() | ||
|
||
MODULE_DIR = Path(__file__).parent | ||
MODULE_NAME = MODULE_DIR.name | ||
|
||
# ================================================================================================= | ||
# CLASSES | ||
# ================================================================================================= | ||
|
||
|
||
# ================================================================================================= | ||
# FUNCTIONS | ||
# ================================================================================================= | ||
def run_avl(cpacs_path, wkdir): | ||
"""Function to run AVL. | ||
Function 'run_avl' runs AVL calculations using a CPACS file | ||
as input. | ||
Args: | ||
cpacs_path (Path) : path to the CPACS input file | ||
wkdir (Path) : path to the working directory | ||
""" | ||
|
||
alt_list, mach_list, aoa_list, aos_list = get_aeromap_conditions(cpacs_path) | ||
save_fig, _, _, _, _ = get_option_settings(cpacs_path) | ||
|
||
for i_case in range(len(alt_list)): | ||
alt = alt_list[i_case] | ||
mach = mach_list[i_case] | ||
aoa = aoa_list[i_case] | ||
aos = aos_list[i_case] | ||
Atm = Atmosphere(alt) | ||
|
||
density = Atm.density[0] | ||
velocity = Atm.speed_of_sound[0] * mach | ||
g = Atm.grav_accel[0] | ||
|
||
case_dir_name = ( | ||
f"Case{str(i_case).zfill(2)}_alt{alt}_mach{round(mach, 2)}" | ||
f"_aoa{round(aoa, 1)}_aos{round(aos, 1)}" | ||
) | ||
|
||
Path(wkdir, case_dir_name).mkdir(exist_ok=True) | ||
case_dir_path = Path(wkdir, case_dir_name) | ||
|
||
avl_path = convert_cpacs_to_avl(cpacs_path, wkdir=case_dir_path) | ||
|
||
command_path = write_command_file( | ||
avl_path, | ||
case_dir_path, | ||
save_plots=save_fig, | ||
alpha=aoa, | ||
beta=aos, | ||
mach_number=mach, | ||
ref_velocity=velocity, | ||
ref_density=density, | ||
g_acceleration=g, | ||
) | ||
|
||
subprocess.run(["xvfb-run", "avl"], stdin=open(str(command_path), "r"), cwd=case_dir_path) | ||
|
||
if save_fig: | ||
if not Path(case_dir_path, "plot.ps").exists(): | ||
raise FileNotFoundError("File 'plot.ps' does not exist.") | ||
|
||
subprocess.run(["ps2pdf", "plot.ps", "plot.pdf"], cwd=case_dir_path) | ||
subprocess.run(["rm", "plot.ps"], cwd=case_dir_path) | ||
|
||
|
||
# ================================================================================================= | ||
# MAIN | ||
# ================================================================================================= | ||
|
||
|
||
def main(cpacs_path, cpacs_out_path): | ||
log.info("----- Start of " + MODULE_NAME + " -----") | ||
|
||
results_dir = get_results_directory("PyAVL") | ||
run_avl(cpacs_path, results_dir) | ||
get_avl_results(cpacs_path, cpacs_out_path, results_dir) | ||
|
||
log.info("----- End of " + MODULE_NAME + " -----") | ||
|
||
|
||
if __name__ == "__main__": | ||
cpacs_path = get_toolinput_file_path(MODULE_NAME) | ||
cpacs_out_path = get_tooloutput_file_path(MODULE_NAME) | ||
|
||
main(cpacs_path, cpacs_out_path) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#------------------------------------------------- | ||
# N+3 Config D8-1 | ||
# | ||
# Dimensional unit and parameter data. | ||
# Mass & Inertia breakdown. | ||
#------------------------------------------------- | ||
|
||
# Names and scalings for units to be used for trim and eigenmode calculations. | ||
# The Lunit and Munit values scale the mass, xyz, and inertia table data below. | ||
# Lunit value will also scale all lengths and areas in the AVL input file. | ||
Lunit = 1.0 m | ||
Munit = 1.0 kg | ||
Tunit = 1.0 s | ||
|
||
#------------------------- | ||
# Gravity and density to be used as default values in trim setup. | ||
# Must be in the units given above. | ||
g = 9.81 | ||
rho = 1.2 |
Oops, something went wrong.