Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AVL integration #295

Merged
merged 118 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
8670a10
new CPACS files
GBenedett May 14, 2024
b7a810b
PyAVL files
May 14, 2024
21b1bc5
modify commonxpath and workflow
May 14, 2024
f0f7cef
subprocess_test
May 14, 2024
a6dd473
add stability derivatives
May 14, 2024
6f25601
boolean fuselage integration
May 14, 2024
ca25d29
clean the code
May 14, 2024
e0ea953
clean code
May 14, 2024
dace8e1
gui distribution
May 14, 2024
6820b13
remove log avl command
Romain-Gauthier May 14, 2024
504ec04
PyAVL installation script
GBenedett Jun 3, 2024
5cac539
euler config template
GBenedett Jun 3, 2024
7b34358
pyavl installation update
GBenedett Jun 3, 2024
aa39f68
labar default mesh
GBenedett Jun 3, 2024
7d99eec
plot.ps to plot.pdf
Romain-Gauthier Jun 5, 2024
f19fd77
Merge branch 'add_PyAVL' of https://github.com/cfsengineering/CEASIOM…
Romain-Gauthier Jun 5, 2024
940ff2e
improve lift distribution plot
Romain-Gauthier Jun 5, 2024
94b52c0
pyavl installation script
GBenedett Jun 5, 2024
fd326b9
mod
GBenedett Jun 5, 2024
b8d8b24
test mod
GBenedett Jun 5, 2024
2ba1a65
test template removed
GBenedett Jun 5, 2024
8da9f66
flake error
GBenedett Jun 5, 2024
53adecd
su2config test
GBenedett Jun 5, 2024
14c0e3a
flake error
GBenedett Jun 5, 2024
d6d977c
add avl pytest
Romain-Gauthier Jun 6, 2024
57dde34
add pytest avlresults
Romain-Gauthier Jun 7, 2024
6a9ebc6
flake
GBenedett Jun 7, 2024
5fd48d3
remove unused import
GBenedett Jun 7, 2024
277c55e
run avl test
GBenedett Jun 7, 2024
dca91d8
avl
GBenedett Jun 7, 2024
d073356
installation
GBenedett Jun 7, 2024
38df335
integration test 5
GBenedett Jun 7, 2024
891b9e9
avl installation
GBenedett Jun 7, 2024
17b3dc9
avl installation
GBenedett Jun 7, 2024
030a7cf
readme
Romain-Gauthier Jun 7, 2024
d001a65
correct readme
Romain-Gauthier Jun 7, 2024
8ae015b
integration test
GBenedett Jun 7, 2024
8126c7b
error integration test
GBenedett Jun 7, 2024
2d1b08e
group changed
GBenedett Jun 7, 2024
ab2cce4
ft commented
GBenedett Jun 7, 2024
9c31fa3
avl execution location changed
GBenedett Jun 7, 2024
d9e1340
pdf in test
GBenedett Jun 7, 2024
68fb43c
run
GBenedett Jun 7, 2024
59e2307
subprocess
GBenedett Jun 7, 2024
720b905
test
GBenedett Jun 7, 2024
378e6b7
test
GBenedett Jun 7, 2024
1eec7ba
ps2pdf package added
GBenedett Jun 7, 2024
039d4e2
ghostscript
GBenedett Jun 7, 2024
b94b0f1
test
GBenedett Jun 7, 2024
5c49b2b
cpacs aeromap save
Romain-Gauthier Jun 11, 2024
bc8bc54
a
GBenedett Jun 11, 2024
7d11079
no pdf conversion
GBenedett Jun 11, 2024
9ad0583
test joinpath
Romain-Gauthier Jun 11, 2024
f409d54
joinpath
Romain-Gauthier Jun 11, 2024
ff94cca
print wkdir
Romain-Gauthier Jun 11, 2024
0900344
debugging test results files
GBenedett Jun 11, 2024
8d29651
AoA change
Romain-Gauthier Jun 11, 2024
fafa15d
test
GBenedett Jun 11, 2024
c31c5fe
test
GBenedett Jun 11, 2024
62b636f
test ft_template
Romain-Gauthier Jun 11, 2024
3341cda
Merge branch 'add_PyAVL' of https://github.com/cfsengineering/CEASIOM…
Romain-Gauthier Jun 11, 2024
af8917c
tmp_path
GBenedett Jun 11, 2024
0a4e83c
FT_TEMPLATE
GBenedett Jun 11, 2024
5610b2d
test avlresults
Romain-Gauthier Jun 11, 2024
90ac3b9
FT_TEMPLATE
Romain-Gauthier Jun 11, 2024
b1d61c1
delete directory
Romain-Gauthier Jun 11, 2024
03f5057
check directory
Romain-Gauthier Jun 11, 2024
60dc97f
test plot
Romain-Gauthier Jun 11, 2024
ce855b6
print all path files
Romain-Gauthier Jun 11, 2024
3f029af
print path file
Romain-Gauthier Jun 11, 2024
16863ec
remove ft and plot tests
Romain-Gauthier Jun 11, 2024
0d37ee6
path definition
Romain-Gauthier Jun 11, 2024
788ffe6
test_result_files
GBenedett Jun 12, 2024
d12bdaa
loop results + pdf
Romain-Gauthier Jun 12, 2024
6d91025
mkdir and delete dir test
GBenedett Jun 12, 2024
bf2edc9
no aerocoeff
GBenedett Jun 12, 2024
df5d4da
no get_avl_results and no saveaero
GBenedett Jun 12, 2024
253fe28
sav_fig
GBenedett Jun 12, 2024
d1cf827
automatic wetted area
GBenedett Jun 12, 2024
7402abe
test plot_lift_distribution
Romain-Gauthier Jun 12, 2024
2a8a2d5
test_get_option_settings
Romain-Gauthier Jun 12, 2024
9e0c990
clean test_get_option_settings
Romain-Gauthier Jun 12, 2024
3ba8739
skip integration test for avl
GBenedett Jun 12, 2024
41129a1
test
GBenedett Jun 12, 2024
a24786a
ps2pdfwr
GBenedett Jun 12, 2024
773348c
call instead of run
GBenedett Jun 12, 2024
8d4811a
shell = True
GBenedett Jun 12, 2024
7aef5db
Shell_true removed
GBenedett Jun 12, 2024
0789a38
check=True
GBenedett Jun 12, 2024
e65ecf5
workaround shee=true
GBenedett Jun 12, 2024
ad44557
run instead of call
GBenedett Jun 12, 2024
f544168
shell true
GBenedett Jun 12, 2024
3057b6b
run and shell ture
GBenedett Jun 12, 2024
cefeb16
integration test 5
GBenedett Jun 12, 2024
72b0f3e
run avl instead of xvfb
GBenedett Jun 12, 2024
1e7965c
test write command
Romain-Gauthier Jun 12, 2024
487d2d4
Merge branch 'add_PyAVL' of https://github.com/cfsengineering/CEASIOM…
Romain-Gauthier Jun 12, 2024
881bfcc
shell=true removed
GBenedett Jun 12, 2024
342a1df
codacy imports
GBenedett Jun 12, 2024
cc5b82d
correct test write command
Romain-Gauthier Jun 12, 2024
22810cd
Merge branch 'add_PyAVL' of https://github.com/cfsengineering/CEASIOM…
Romain-Gauthier Jun 12, 2024
b2acbf5
change "not in"
Romain-Gauthier Jun 12, 2024
19b7cef
print ft file path
Romain-Gauthier Jun 12, 2024
6f285a8
print case dir path
Romain-Gauthier Jun 12, 2024
c029cf6
print all paths in case dir
Romain-Gauthier Jun 12, 2024
ab521c8
print all paths
Romain-Gauthier Jun 12, 2024
ec5cd6b
print command file
Romain-Gauthier Jun 12, 2024
a84f2aa
print case dir
Romain-Gauthier Jun 12, 2024
4f03ab2
print paths with "ft"
Romain-Gauthier Jun 12, 2024
3fca8f0
print pdf path
Romain-Gauthier Jun 12, 2024
85af659
remove bg run
Romain-Gauthier Jun 12, 2024
cd331a7
look for ft.txt path
Romain-Gauthier Jun 12, 2024
aadb0cd
print ".txt" path
Romain-Gauthier Jun 12, 2024
1274a4a
save_plots = False
Romain-Gauthier Jun 13, 2024
2ef4254
print command file content
Romain-Gauthier Jun 13, 2024
13db42a
ft file saving path
Romain-Gauthier Jun 13, 2024
5c83c04
remove prints
Romain-Gauthier Jun 13, 2024
7237a8f
comment ##
Romain-Gauthier Jun 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/integrationtests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ jobs:
shell: bash -l {0}
run: installation/Ubuntu/install_sumo.sh

- name: Install AVL
shell: bash -l {0}
run: installation/Ubuntu/install_pyavl.sh

- name: Install SU2
shell: bash -l {0}
run: installation/Ubuntu/install_su2.sh
Expand Down
6 changes: 5 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ Other resources that could the useful.

#### SUMO

- [SUMO website](https://www.larosterna.com/products/open-source)
- [SUMO website](https://www.larosterna.com/oss/)

#### AVL

- [AVL website](https://web.mit.edu/drela/Public/web/avl/)

#### SU2

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Follow the [test cases](#test-cases) to discover the different way of using CEAS

```mermaid
graph LR;
PyTornado-->SaveAeroCoefficients;
PyAVL-->SaveAeroCoefficients;
```

</div>
Expand Down Expand Up @@ -134,6 +134,7 @@ warning: : The module does not work completely as expected. It is not a bug, but

- [CLCalculator](ceasiompy/CLCalculator/README.md) :heavy_check_mark:
- [PyTornado](ceasiompy/PyTornado/README.md) :heavy_check_mark:
- [PyAVL](ceasiompy/PyAVL/README.md) :heavy_check_mark:
- [SU2Run](ceasiompy/SU2Run/README.md) :heavy_check_mark:
- [SkinFriction](ceasiompy/SkinFriction/README.md) :heavy_check_mark:
- [SaveAeroCoefficients](ceasiompy/SaveAeroCoefficients/README.md) :heavy_check_mark:
Expand Down
68 changes: 68 additions & 0 deletions ceasiompy/PyAVL/README.md
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 added ceasiompy/PyAVL/__init__.py
Empty file.
118 changes: 118 additions & 0 deletions ceasiompy/PyAVL/__specs__.py
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",
)
129 changes: 129 additions & 0 deletions ceasiompy/PyAVL/avlrun.py
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)
Binary file added ceasiompy/PyAVL/files/avl_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ceasiompy/PyAVL/files/avl_example_loads.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ceasiompy/PyAVL/files/avl_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions ceasiompy/PyAVL/files/template.mass
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
Loading
Loading