-
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.
- Loading branch information
GuidoValli97
committed
May 14, 2024
1 parent
8670a10
commit b7a810b
Showing
10 changed files
with
1,457 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
<img align="right" height="70" src="../../documents/logos/CEASIOMpy_banner_main.png"> | ||
|
||
# ModuleTemplate | ||
|
||
**Categories:** Template module, Example, Illustration | ||
|
||
**State**: :heavy_check_mark: | ||
|
||
This is a template module. Its purpose is to illustrate how other modules of CEASIOMpy should be structured, set up and documented. | ||
|
||
<p align="center"> | ||
<img height="160" src="files/Spirit_of_St._Louis.jpg"> | ||
</p> | ||
|
||
Example picture. Image in the public domain, from [Wikimedia Commons](https://commons.wikimedia.org/wiki/File:Spirit_of_St._Louis.jpg) | ||
|
||
## Inputs | ||
|
||
ModuleTemplate needs no inputs. | ||
|
||
## Analyses | ||
|
||
ModuleTemplate computes nothing. | ||
|
||
## Outputs | ||
|
||
ModuleTemplate outputs nothing. | ||
|
||
## Installation or requirements | ||
|
||
ModuleTemplate is a native CEASIOMpy module, hence it is available and installed by default. | ||
|
||
## Limitations | ||
|
||
ModuleTemplate is limited in every aspect. | ||
|
||
## More information | ||
|
||
* <https://en.wikipedia.org/wiki/Spirit_of_St._Louis> |
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,90 @@ | ||
from ceasiompy.utils.moduleinterfaces import CPACSInOut | ||
from ceasiompy.utils.commonxpath import CEASIOMPY_XPATH, AVL_PLOT_XPATH, AVL_VORTEX_DISTR_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 | ||
|
||
# ===== CPACS inputs and outputs ===== | ||
|
||
cpacs_inout = CPACSInOut() | ||
|
||
include_gui = True | ||
|
||
RESULTS_DIR = Path("Results", "PyAVL") | ||
|
||
# ----- 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="/cpacs/toolspecific/CEASIOMpy/aerodynamics/avl/aeroMapUID", | ||
gui=True, | ||
gui_name="__AEROMAP_SELECTION", | ||
gui_group="Aeromap settings", | ||
) | ||
|
||
cpacs_inout.add_input( | ||
var_name="other_var", | ||
var_type=float, | ||
default_value=1.0, | ||
unit=None, | ||
descr="Must be in the range [-3.0 ; +3.0]", | ||
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="other_var", | ||
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="other_var", | ||
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="other_var", | ||
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", | ||
) |
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,126 @@ | ||
""" | ||
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(["avl"], | ||
stdin=open(str(command_path), "r")) | ||
|
||
source_force_path = str(Path.cwd()) | ||
for force_file in ["ft", "fn", "fs", "fe"]: | ||
Path(source_force_path + "/" + force_file | ||
+ ".txt").rename(str(case_dir_path) + "/" + force_file + ".txt") | ||
|
||
if save_fig: | ||
source_plot_path = str(Path.cwd()) + "/plot.ps" | ||
Path(source_plot_path).rename(str(case_dir_path) + "/plot.ps") | ||
|
||
# ================================================================================================= | ||
# MAIN | ||
# ================================================================================================= | ||
|
||
|
||
def main(cpacs_path, cpacs_out_path): | ||
log.info("----- Start of " + MODULE_NAME + " -----") | ||
|
||
results_dir = get_results_directory(module_name='PyAVL') | ||
run_avl(cpacs_path, wkdir=results_dir) | ||
|
||
get_avl_results(cpacs_path, cpacs_out_path, wkdir=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) |
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.