From b56b7ebc0e1983dd49c8a41c174f9f21dd1a3bc6 Mon Sep 17 00:00:00 2001 From: GBenedett Date: Thu, 18 Jan 2024 15:46:55 +0100 Subject: [PATCH] spec file for edge --- ceasiompy/EdgeRun/__specs__.py | 255 ++-------------------------- ceasiompy/EdgeRun/moduletemplate.py | 207 ---------------------- ceasiompy/utils/commonxpath.py | 1 + 3 files changed, 15 insertions(+), 448 deletions(-) delete mode 100644 ceasiompy/EdgeRun/moduletemplate.py diff --git a/ceasiompy/EdgeRun/__specs__.py b/ceasiompy/EdgeRun/__specs__.py index 907255fd1..d86028ab2 100644 --- a/ceasiompy/EdgeRun/__specs__.py +++ b/ceasiompy/EdgeRun/__specs__.py @@ -4,37 +4,23 @@ from ceasiompy.utils.commonxpath import ( AEROPERFORMANCE_XPATH, GEOM_XPATH, - PROP_XPATH, RANGE_XPATH, REF_XPATH, - EDGE_ACTUATOR_DISK_XPATH, EDGE_AEROMAP_UID_XPATH, - EDGE_BC_FARFIELD_XPATH, - EDGE_BC_WALL_XPATH, EDGE_CFL_NB_XPATH, - EDGE_CFL_ADAPT_XPATH, - EDGE_CFL_ADAPT_PARAM_DOWN_XPATH, - EDGE_CFL_ADAPT_PARAM_UP_XPATH, - EDGE_CFL_MIN_XPATH, - EDGE_CFL_MAX_XPATH, - EDGE_CONTROL_SURF_XPATH, - EDGE_DAMPING_DER_XPATH, - EDGE_EXTRACT_LOAD_XPATH, EDGE_FIXED_CL_XPATH, EDGE_MAX_ITER_XPATH, EDGE_MG_LEVEL_XPATH, EDGE_NB_CPU_XPATH, - EDGE_ROTATION_RATE_XPATH, - EDGE_TARGET_CL_XPATH, - EDGE_UPDATE_WETTED_AREA_XPATH, EDGE_MESH_XPATH, + EDGE_SOLVER, ) from ceasiompy.utils.moduleinterfaces import CPACSInOut # ===== Module Status ===== # True if the module is active # False if the module is disabled (not working or not ready) -module_status = False +module_status = True # ===== Results directory path ===== @@ -58,18 +44,6 @@ gui_group="Aeromap settings", ) -# cpacs_inout.add_input( -# var_name="mesh_upload", -# var_type=str, -# default_value="your path", -# unit=None, -# descr="Name of the mesh to upload", -# xpath=SU2MESH_XPATH, -# gui=True, -# gui_name="Path of the mesh", -# gui_group="Mesh upload", -# ) - cpacs_inout.add_input( var_name="ref_len", var_type=float, @@ -131,18 +105,6 @@ gui_group="If fixed CL", ) -cpacs_inout.add_input( - var_name="target_cl", - var_type=float, - default_value=1.0, - unit="1", - descr="Value of CL to achieve to have a level flight with the given conditions", - xpath=EDGE_TARGET_CL_XPATH, - gui=False, - gui_name=None, - gui_group=None, -) - cpacs_inout.add_input( var_name="fixed_cl", var_type=str, @@ -155,42 +117,6 @@ gui_group=None, ) -cpacs_inout.add_input( - var_name="damping_der", - var_type=bool, - default_value=False, - unit="1", - descr="To check if damping derivatives should be calculated or not", - xpath=EDGE_DAMPING_DER_XPATH, - gui=True, - gui_name="Damping Derivatives", - gui_group="Aeromap Options", -) - -cpacs_inout.add_input( - var_name="rotation_rate", - var_type=float, - default_value=1.0, - unit="rad/s", - descr="Rotation rate use to calculate damping derivatives", - xpath=EDGE_ROTATION_RATE_XPATH, - gui=True, - gui_name="Rotation Rate", - gui_group="Aeromap Options", -) - -cpacs_inout.add_input( - var_name="control_surf", - var_type=bool, - default_value=False, - unit="1", - descr="To check if control surfaces deflections should be calculated or not", - xpath=EDGE_CONTROL_SURF_XPATH, - gui=True, - gui_name="Control Surfaces", - gui_group="Aeromap Options", -) - cpacs_inout.add_input( var_name="nb_proc", var_type=int, @@ -227,66 +153,6 @@ gui_group="EDGE Parameters", ) -cpacs_inout.add_input( - var_name="cfl_adapt", - var_type=bool, - default_value=False, - unit="1", - descr="CFL Adaptation", - xpath=EDGE_CFL_ADAPT_XPATH, - gui=True, - gui_name="CFL Adaptation", - gui_group="EDGE Parameters", -) - -cpacs_inout.add_input( - var_name="cfl_adapt_param_factor_down", - var_type=float, - default_value=0.5, - unit="1", - descr="CFL Adaptation Factor Down", - xpath=EDGE_CFL_ADAPT_PARAM_DOWN_XPATH, - gui=True, - gui_name="CFL Adaptation Factor Down", - gui_group="EDGE Parameters", -) - -cpacs_inout.add_input( - var_name="cfl_adapt_param_factor_up", - var_type=float, - default_value=1.5, - unit="1", - descr="CFL Adaptation Factor Up", - xpath=EDGE_CFL_ADAPT_PARAM_UP_XPATH, - gui=True, - gui_name="CFL Adaptation Factor Up", - gui_group="EDGE Parameters", -) - -cpacs_inout.add_input( - var_name="cfl_adapt_param_min", - var_type=float, - default_value=0.5, - unit="1", - descr="CFL Minimum Value", - xpath=EDGE_CFL_MIN_XPATH, - gui=True, - gui_name="CFL Min Value", - gui_group="EDGE Parameters", -) - -cpacs_inout.add_input( - var_name="cfl_adapt_param_max", - var_type=float, - default_value=100, - unit="1", - descr="CFL Maximum Value", - xpath=EDGE_CFL_MAX_XPATH, - gui=True, - gui_name="CFL Max Value", - gui_group="EDGE Parameters", -) - cpacs_inout.add_input( var_name="mg_level", var_type=int, @@ -299,6 +165,18 @@ gui_group="EDGE Parameters", ) +cpacs_inout.add_input( + var_name="calculation_type", + var_type=list, + default_value=["RANS", "Euler"], + unit="1", + descr="Chose if perform a RANS or an Euler calculation", + xpath=EDGE_SOLVER, + gui=True, + gui_name="Solver for calculation", + gui_group="EDGE parameters", +) + cpacs_inout.add_input( var_name="EDGE_mesh_path", var_type="pathtype", @@ -311,93 +189,6 @@ gui_group="Inputs", ) -cpacs_inout.add_input( - var_name="update_wetted_area", - var_type=bool, - default_value=False, - unit="1", - descr="Option to update the wetted area from the latest EDGE result.", - xpath=EDGE_UPDATE_WETTED_AREA_XPATH, - gui=True, - gui_name="Update Wetted Area", - gui_group="Results", -) - -cpacs_inout.add_input( - var_name="check_extract_loads", - var_type=bool, - default_value=False, - unit="1", - descr="Option to extract loads (forces in each point) from results", - xpath=EDGE_EXTRACT_LOAD_XPATH, - gui=True, - gui_name="Extract loads", - gui_group="Results", -) - -# Actuator disk - -cpacs_inout.add_input( - var_name="include_actuator_disk", - var_type=bool, - default_value=False, - unit="1", - descr="To check if actuator disk(s) should be included in the EDGE calculation", - xpath=EDGE_ACTUATOR_DISK_XPATH, - gui=True, - gui_name="Include actuator disk(s)", - gui_group="Actuator disk", -) - -cpacs_inout.add_input( - var_name="thrust", - var_type=float, - default_value=3000, - unit="N", - descr="Aircraft thrust", - xpath=PROP_XPATH + "/propeller/thrust", - gui=True, - gui_name="Thrust", - gui_group="Actuator disk", -) - -# cpacs_inout.add_input( -# var_name="n", -# var_type=float, -# default_value=33, -# unit="1/s", -# descr="Propeller rotational velocity", -# xpath=PROP_XPATH + "/propeller/rotational_velocity", -# gui=True, -# gui_name="Rotational velocity setting", -# gui_group="Actuator disk", -# ) - -cpacs_inout.add_input( - var_name="prandtl", - var_type=bool, - default_value=False, - unit=None, - descr="Enable or disable the tip loss correction of Prandtl", - xpath=PROP_XPATH + "/propeller/blade/loss", - gui=True, - gui_name="Tip loss correction", - gui_group="Actuator disk", -) - -# cpacs_inout.add_input( -# var_name="blades_number", -# var_type=int, -# default_value=3, -# unit=None, -# descr="Number of propeller blades", -# xpath=PROP_XPATH + "/propeller/bladeNumber", -# gui=True, -# gui_name="Propeller blades numbers", -# gui_group="Actuator disk", -# ) - - # ----- Output ----- cpacs_inout.add_output( @@ -409,24 +200,6 @@ xpath=GEOM_XPATH + "/analyses/wettedArea", ) -cpacs_inout.add_output( - var_name="bc_wall_list", - var_type=list, - default_value=None, - unit="1", - descr="Wall boundary conditions found in the EDGE mesh", - xpath=EDGE_BC_WALL_XPATH, -) - -cpacs_inout.add_output( - var_name="bc_farfield_list", - var_type=list, - default_value=None, - unit="1", - descr="Farfield boundary conditions found in the EDGE mesh (for off engines)", - xpath=EDGE_BC_FARFIELD_XPATH, -) - cpacs_inout.add_output( var_name="aeromap_EDGE", # name to change... # var_type=CPACS_aeroMap, # no type pour output, would it be useful? diff --git a/ceasiompy/EdgeRun/moduletemplate.py b/ceasiompy/EdgeRun/moduletemplate.py deleted file mode 100644 index fe0a536d9..000000000 --- a/ceasiompy/EdgeRun/moduletemplate.py +++ /dev/null @@ -1,207 +0,0 @@ -""" -CEASIOMpy: Conceptual Aircraft Design Software - -Developed by CFS ENGINEERING, 1015 Lausanne, Switzerland - -Small description of the script - -Python version: >=3.8 - -| Author: Name -| Creation: YEAR-MONTH-DAY - -TODO: - - * Things to improve ... - * Things to add ... - -""" - -# ================================================================================================= -# IMPORTS -# ================================================================================================= - -from pathlib import Path - - -from ambiance import Atmosphere -from ceasiompy.ModuleTemplate.func.subfunc import my_subfunc -from ceasiompy.utils.ceasiomlogger import get_logger -from ceasiompy.utils.moduleinterfaces import ( - check_cpacs_input_requirements, - get_toolinput_file_path, - get_tooloutput_file_path, -) -from ceasiompy.utils.commonxpath import FUSELAGES_XPATH -from cpacspy.cpacsfunctions import ( - add_float_vector, - add_string_vector, - add_uid, - copy_branch, - create_branch, - get_float_vector, - get_string_vector, - get_tigl_configuration, - get_uid, - get_value, - get_value_or_default, - get_xpath_parent, - open_tigl, - open_tixi, -) - -log = get_logger() - -MODULE_DIR = Path(__file__).parent -MODULE_NAME = MODULE_DIR.name - - -# ================================================================================================= -# CLASSES -# ================================================================================================= - - -class MyClass: - """ - Description of the class - - Attributes: - var_a (float): Argument a [unit] - var_b (float): Argument b [unit] - - .. seealso:: - - See some other source - - """ - - def __init__(self, a=1.1, b=2.2): - self.var_a = a - self.var_b = b - self.var_c = 0.0 - - def add_my_var(self): - """This methode will sum up var_a and var_b in var_c""" - - self.var_c = self.var_a + self.var_b - - -# ================================================================================================= -# FUNCTIONS -# ================================================================================================= - - -def sum_funcion(arg1, arg2): - """Function to calculate ... - - Function 'sum_funcion' return the total of arg1 and arg2, after it convert - arg1 into an float. - - Source: - * Reference paper or book, with author and date - - Args: - arg1 (interger): Argument 1 [unit] - arg2 (float): Argument 2 [unit] - - Returns: - total (float): Output1 [unit] - - .. warning:: - - Example of warning - """ - - if not isinstance(arg1, int): - raise ValueError("arg1 is not an integer") - - # Use of a subfunction here - print(my_subfunc("test1", "test2")) - - total = float(arg1) + arg2 - - return total - - -def get_fuselage_scaling(cpacs_path, cpacs_out_path): - """Function to get fuselage scaling along x,y,z axis. - - Function 'get_fuselage_scaling' return the value of the scaling for the - fuselage. (This is an example function just to show usage of CPACS and tixi) - - Source: - * Reference paper or book, with author and date - - Args: - cpacs_path (Path): Path to CPACS file - cpacs_out_path (Path):Path to CPACS output file - - Returns: - Tuple with fuselage scaling - - * x (float): Scaling on x [-] - * y (float): Scaling on y [-] - * z (float): Scaling on z [-] - """ - - # Open TIXI handle - tixi = open_tixi(cpacs_path) - - # Create xpaths - SCALING_XPATH = "/fuselage/transformation/scaling" - - x_fus_scaling_xpath = FUSELAGES_XPATH + SCALING_XPATH + "/x" - y_fus_scaling_xpath = FUSELAGES_XPATH + SCALING_XPATH + "/y" - z_fus_scaling_xpath = FUSELAGES_XPATH + SCALING_XPATH + "/z" - - # Get values - x = get_value(tixi, x_fus_scaling_xpath) - y = get_value(tixi, y_fus_scaling_xpath) - z = get_value(tixi, z_fus_scaling_xpath) - - # Log - log.info("Fuselage x scaling is : " + str(x)) - log.info("Fuselage y scaling is : " + str(y)) - log.info("Fuselage z scaling is : " + str(z)) - - # Close TIXI handle and save the CPACS file - tixi.save(str(cpacs_out_path)) - - return (x, y, z) - - -# ================================================================================================= -# MAIN -# ================================================================================================= - - -def main(cpacs_path, cpacs_out_path): - - log.info("----- Start of " + MODULE_NAME + " -----") - - check_cpacs_input_requirements(cpacs_path) - - # Define other inputs value - my_value1 = 6 - my_value2 = 5.5 - - # Call 'sum_function' - my_total = sum_funcion(my_value1, my_value2) - log.info("My total is equal to: " + str(my_total)) - - # Call a function which use CPACS inputs - x, y, z = get_fuselage_scaling(cpacs_path, cpacs_out_path) - log.info("Value x,y,z as been calculated") - log.info("x = " + str(x)) - log.info("y = " + str(y)) - log.info("z = " + str(z)) - - 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) diff --git a/ceasiompy/utils/commonxpath.py b/ceasiompy/utils/commonxpath.py index e0788d134..18ed4aa47 100644 --- a/ceasiompy/utils/commonxpath.py +++ b/ceasiompy/utils/commonxpath.py @@ -151,6 +151,7 @@ EDGE_CFL_NB_XPATH = EDGE_XPATH + "/settings/cflNumber/value" EDGE_MG_LEVEL_XPATH = EDGE_XPATH + "/settings/multigridLevel" EDGE_FIXED_CL_XPATH = EDGE_XPATH + "/fixedCL" +EDGE_SOLVER = EDGE_XPATH + "/solver" # RANGE RANGE_LD_RATIO_XPATH = CEASIOMPY_XPATH + "/ranges/lDRatio"