From c7ccbb01b9238f2b3b8c2bbb6f4d8b1567bcbd43 Mon Sep 17 00:00:00 2001 From: GBenedett Date: Wed, 10 Jan 2024 13:10:28 +0100 Subject: [PATCH] re modulation --- ceasiompy/EdgeRun/README.md | 40 ++ ceasiompy/EdgeRun/ToolInput/.keep | 1 + ceasiompy/EdgeRun/ToolOutput/.keep | 1 + ceasiompy/EdgeRun/__init__.py | 0 ceasiompy/EdgeRun/__specs__.py | 63 ++ ceasiompy/EdgeRun/func/edgeconfig.py | 88 ++- ceasiompy/EdgeRun/moduletemplate.py | 207 +++++++ .../tests/ToolInput/simpletest_cpacs.xml | 576 ++++++++++++++++++ ceasiompy/EdgeRun/tests/ToolOutput/.keep | 1 + .../{tests_edgeconfig => }/test_edgerun.py | 17 +- .../02_\342\232\231\357\270\217_Settings.py" | 11 - 11 files changed, 955 insertions(+), 50 deletions(-) create mode 100644 ceasiompy/EdgeRun/README.md create mode 100644 ceasiompy/EdgeRun/ToolInput/.keep create mode 100644 ceasiompy/EdgeRun/ToolOutput/.keep create mode 100644 ceasiompy/EdgeRun/__init__.py create mode 100644 ceasiompy/EdgeRun/__specs__.py create mode 100644 ceasiompy/EdgeRun/moduletemplate.py create mode 100644 ceasiompy/EdgeRun/tests/ToolInput/simpletest_cpacs.xml create mode 100644 ceasiompy/EdgeRun/tests/ToolOutput/.keep rename ceasiompy/EdgeRun/tests/{tests_edgeconfig => }/test_edgerun.py (81%) diff --git a/ceasiompy/EdgeRun/README.md b/ceasiompy/EdgeRun/README.md new file mode 100644 index 000000000..f20754ecf --- /dev/null +++ b/ceasiompy/EdgeRun/README.md @@ -0,0 +1,40 @@ + + + +# 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. + +

+ +

+ +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 + +* diff --git a/ceasiompy/EdgeRun/ToolInput/.keep b/ceasiompy/EdgeRun/ToolInput/.keep new file mode 100644 index 000000000..8d1c8b69c --- /dev/null +++ b/ceasiompy/EdgeRun/ToolInput/.keep @@ -0,0 +1 @@ + diff --git a/ceasiompy/EdgeRun/ToolOutput/.keep b/ceasiompy/EdgeRun/ToolOutput/.keep new file mode 100644 index 000000000..8d1c8b69c --- /dev/null +++ b/ceasiompy/EdgeRun/ToolOutput/.keep @@ -0,0 +1 @@ + diff --git a/ceasiompy/EdgeRun/__init__.py b/ceasiompy/EdgeRun/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/ceasiompy/EdgeRun/__specs__.py b/ceasiompy/EdgeRun/__specs__.py new file mode 100644 index 000000000..fe73a31de --- /dev/null +++ b/ceasiompy/EdgeRun/__specs__.py @@ -0,0 +1,63 @@ +from ceasiompy.utils.moduleinterfaces import CPACSInOut +from ceasiompy.utils.commonxpath import CEASIOMPY_XPATH, FUSELAGES_XPATH + +# ===== Module Status ===== +# True if the module is active +# False if the module is disabled (not working or not ready) +module_status = False # Because it is just an example not a real module + +# ===== CPACS inputs and outputs ===== + +cpacs_inout = CPACSInOut() + +include_gui = False + +# ----- 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 :) +for direction in ["x", "y", "z"]: + cpacs_inout.add_input( + var_name=direction, + var_type=float, + default_value=None, + unit="1", + descr=f"Fuselage scaling on {direction} axis", + xpath=FUSELAGES_XPATH + f"/fuselage/transformation/scaling/{direction}", + gui=include_gui, + gui_name=f"{direction.capitalize()} scaling", + gui_group="Fuselage scaling", + ) + +cpacs_inout.add_input( + var_name="test", + var_type=str, + default_value="This is a test", + unit=None, + descr="This is a test of description", + xpath=CEASIOMPY_XPATH + "/test/myTest", + gui=include_gui, + gui_name="My test", + gui_group="Group Test", +) + +cpacs_inout.add_input( + var_name="other_var", + var_type=list, + default_value=[2, 33, 444], + unit="[unit]", + xpath=CEASIOMPY_XPATH + "/test/myList", + gui=include_gui, + gui_name="Choice", + gui_group="My Selection", +) + +# ----- Output ----- + +cpacs_inout.add_output( + var_name="output", + default_value=None, + unit="1", + descr="Description of the output", + xpath=CEASIOMPY_XPATH + "/test/myOutput", +) diff --git a/ceasiompy/EdgeRun/func/edgeconfig.py b/ceasiompy/EdgeRun/func/edgeconfig.py index 28b0d5275..2e3421c63 100644 --- a/ceasiompy/EdgeRun/func/edgeconfig.py +++ b/ceasiompy/EdgeRun/func/edgeconfig.py @@ -26,33 +26,34 @@ from shutil import copyfile from ambiance import Atmosphere -#from ceasiompy.SU2Run.func.su2actuatordiskfile import ( + +# from ceasiompy.SU2Run.func.su2actuatordiskfile import ( # get_advanced_ratio, # get_radial_stations, # save_plots, # thrust_calculator, # write_actuator_disk_data, # write_header, -#) +# ) from ceasiompy.EdgeRun.func.edgeutils import get_edge_ainp_template from ceasiompy.utils.ceasiomlogger import get_logger from ceasiompy.utils.commonnames import ( -AINP_CFD_NAME, + AINP_CFD_NAME, ) from ceasiompy.utils.commonxpath import ( GMSH_SYMMETRY_XPATH, PROP_XPATH, RANGE_XPATH, EdgeMESH_XPATH, - Edge_AEROMAP_UID_XPATH, + Edge_AEROMAP_UID_XPATH, Edge_CFL_NB_XPATH, Edge_MAX_ITER_XPATH, Edge_MG_LEVEL_XPATH, Edge_NB_CPU_XPATH, Edge_FIXED_CL_XPATH, - ) -#from ceasiompy.utils.configfiles import ConfigFile + +# from ceasiompy.utils.configfiles import ConfigFile from ceasiompy.utils.create_ainpfile import CreateAinp from cpacspy.cpacsfunctions import ( create_branch, @@ -61,7 +62,8 @@ get_value_or_default, ) from cpacspy.cpacspy import CPACS -#import cpacs + +# import cpacs log = get_logger() @@ -79,14 +81,14 @@ def generate_edge_cfd_ainp(cpacs_path, cpacs_out_path, wkdir): - #output_path = Path(case_dir_path, AINP_CFD_NAME) + # output_path = Path(case_dir_path, AINP_CFD_NAME) """Function to create Edge input (*.ainp) file. Function 'generate_edge_cfd_ainp' reads data in the CPACS file and generate configuration files for one or multiple flight conditions (alt,mach,aoa,aos) Source: - * M-Edge ainp template: + * M-Edge ainp template: Args: cpacs_path (Path): Path to CPACS file @@ -100,7 +102,7 @@ def generate_edge_cfd_ainp(cpacs_path, cpacs_out_path, wkdir): edge_mesh = Path(get_value(cpacs.tixi, EdgeMESH_XPATH)) if not edge_mesh.is_file(): raise FileNotFoundError(f"M-Edge mesh file {edge_mesh} not found") - + # Get the fixedCL value from CPACS fixed_cl = get_value_or_default(cpacs.tixi, Edge_FIXED_CL_XPATH, "NO") if fixed_cl == "NO": @@ -109,7 +111,7 @@ def generate_edge_cfd_ainp(cpacs_path, cpacs_out_path, wkdir): if aeromap_list: aeromap_default = aeromap_list[0] - log.info(f'The aeromap is {aeromap_default}') + log.info(f"The aeromap is {aeromap_default}") aeromap_uid = get_value_or_default(cpacs.tixi, Edge_AEROMAP_UID_XPATH, aeromap_default) @@ -134,7 +136,9 @@ def generate_edge_cfd_ainp(cpacs_path, cpacs_out_path, wkdir): aoa_list = [0.0] aos_list = [0.0] - aeromap_uid = get_value_or_default(cpacs.tixi, Edge_AEROMAP_UID_XPATH, "DefaultAeromap") + aeromap_uid = get_value_or_default( + cpacs.tixi, Edge_AEROMAP_UID_XPATH, "DefaultAeromap" + ) log.info(f"{aeromap_uid} has been created") else: # if fixed_cl == 'YES': @@ -154,7 +158,7 @@ def generate_edge_cfd_ainp(cpacs_path, cpacs_out_path, wkdir): aoa_list = [0.0] aos_list = [0.0] - #cfg = ConfigFile(get_su2_config_template()) + # cfg = ConfigFile(get_su2_config_template()) # Check if symmetry plane is defined (Default: False) sym_factor = 1.0 @@ -163,7 +167,7 @@ def generate_edge_cfd_ainp(cpacs_path, cpacs_out_path, wkdir): sym_factor = 2.0 # General parameters -# cfg["RESTART_SOL"] = "NO" + # cfg["RESTART_SOL"] = "NO" CREF = cpacs.aircraft.ref_length SREF = cpacs.aircraft.ref_area / sym_factor BREF = SREF / CREF @@ -174,13 +178,12 @@ def generate_edge_cfd_ainp(cpacs_path, cpacs_out_path, wkdir): ITMAX = int(get_value_or_default(cpacs.tixi, Edge_MAX_ITER_XPATH, 200)) CFL = get_value_or_default(cpacs.tixi, Edge_CFL_NB_XPATH, 1.5) NGRID = int(get_value_or_default(cpacs.tixi, Edge_MG_LEVEL_XPATH, 3)) - NPART = int(get_value_or_default(cpacs.tixi,Edge_NB_CPU_XPATH,32)) + NPART = int(get_value_or_default(cpacs.tixi, Edge_NB_CPU_XPATH, 32)) INSEUL = 0 - # Parameters which will vary for the different cases (alt,mach,aoa,aos) for case_nb in range(len(alt_list)): - #cfg["MESH_FILENAME"] = str(su2_mesh) + # cfg["MESH_FILENAME"] = str(su2_mesh) alt = alt_list[case_nb] mach = mach_list[case_nb] @@ -192,23 +195,23 @@ def generate_edge_cfd_ainp(cpacs_path, cpacs_out_path, wkdir): PFREE = Atm.pressure[0] TFREE = Atm.temperature[0] speedofsound = Atm.speed_of_sound[0] - airspeed = mach*speedofsound - + airspeed = mach * speedofsound + aoa_rad = math.radians(aoa) aos_rad = math.radians(aos) - + UFREE = airspeed * math.cos(aos) * math.cos(aoa) WFREE = airspeed * math.cos(aos) * math.sin(aoa) VFREE = airspeed * math.sin(aos) * (-1) - + IDCDP1 = math.cos(aos) * math.cos(aoa) - IDCDP2 = math.sin(aos) + IDCDP2 = math.sin(aos) IDCDP3 = math.cos(aos) * math.sin(aoa) - + IDCLP1 = math.sin(aoa) * (-1) IDCLP2 = 0 IDCLP3 = math.cos(aoa) - + IDCCP1 = math.cos(aoa) * math.sin(aos) * (-1) IDCCP2 = math.cos(aos) * (-1) IDCCP3 = math.sin(aoa) * math.sin(aos) * (-1) @@ -221,7 +224,7 @@ def generate_edge_cfd_ainp(cpacs_path, cpacs_out_path, wkdir): IDCRP1 = IDCDP1 IDCRP2 = IDCDP2 IDCRP3 = IDCDP3 - + IDCLP = f"{IDCLP1} {IDCLP2} {IDCLP3}" IDCDP = f"{IDCDP1} {IDCDP2} {IDCDP3}" IDCMP = f"{IDCMP1} {IDCMP2} {IDCMP3}" @@ -238,20 +241,41 @@ def generate_edge_cfd_ainp(cpacs_path, cpacs_out_path, wkdir): if not case_dir_path.exists(): case_dir_path.mkdir() output_path = Path(case_dir_path, AINP_CFD_NAME) - #template_path = get_edge_ainp_template() + # template_path = get_edge_ainp_template() create_ainp_instance = CreateAinp() - #create_ainp_instance = CreateAinp(get_edge_ainp_template()) - - create_ainp_instance.create_ainp(UFREE, VFREE, WFREE, TFREE, PFREE, SREF, CREF, BREF, IXMP, IDCLP, IDCDP, IDCCP, IDCMP, IDCNP, IDCRP, NPART, ITMAX, INSEUL, NGRID, CFL, output_path) + # create_ainp_instance = CreateAinp(get_edge_ainp_template()) + + create_ainp_instance.create_ainp( + UFREE, + VFREE, + WFREE, + TFREE, + PFREE, + SREF, + CREF, + BREF, + IXMP, + IDCLP, + IDCDP, + IDCCP, + IDCMP, + IDCNP, + IDCRP, + NPART, + ITMAX, + INSEUL, + NGRID, + CFL, + output_path, + ) - #cfg.write_file(config_output_path, overwrite=True) + # cfg.write_file(config_output_path, overwrite=True) cpacs.save_cpacs(cpacs_out_path, overwrite=True) - # ================================================================================================= # MAIN # ================================================================================================= if __name__ == "__main__": - log.info("Nothing to execute!") \ No newline at end of file + log.info("Nothing to execute!") diff --git a/ceasiompy/EdgeRun/moduletemplate.py b/ceasiompy/EdgeRun/moduletemplate.py new file mode 100644 index 000000000..fe0a536d9 --- /dev/null +++ b/ceasiompy/EdgeRun/moduletemplate.py @@ -0,0 +1,207 @@ +""" +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/EdgeRun/tests/ToolInput/simpletest_cpacs.xml b/ceasiompy/EdgeRun/tests/ToolInput/simpletest_cpacs.xml new file mode 100644 index 000000000..b407294db --- /dev/null +++ b/ceasiompy/EdgeRun/tests/ToolInput/simpletest_cpacs.xml @@ -0,0 +1,576 @@ + + +
+ Cpacs2Test + Simple Wing for unit testing + Martin Siggel + 2012-10-09T15:12:47 + 0.2 + 3.0 + + + Converted to cpacs 3.0 using cpacs2to3 - does not include structure update + cpacs2to3 + 2018-01-15T09:22:57 + 0.2 + 3.0 + + + Add this update + Aidan + 2018-10-03T09:00:01 + 0.3 + 3.0 + + +
+ + + + Cpacs2Test + + 1 + 1 + + 0 + 0 + 0 + + + + + name + description + + + 1.0 + 0.5 + 0.5 + + + 0.0 + 0.0 + 0.0 + + + 0.0 + 0.0 + 0.0 + + + +
+ D150_Fuselage_1Section1 + + + 1.0 + 1.0 + 1.0 + + + 0.0 + 0.0 + 0.0 + + + 0 + 0 + 0 + + + + + D150_Fuselage_1Section1 + fuselageCircleProfileuID + + + 1.0 + 1.0 + 1.0 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + +
+
+ D150_Fuselage_1Section2 + + + 1.0 + 1.0 + 1.0 + + + 0.0 + 0.0 + 0.0 + + + 0.5 + 0 + 0 + + + + + D150_Fuselage_1Section2 + fuselageCircleProfileuID + + + 1 + 1 + 1 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + +
+
+ D150_Fuselage_1Section3 + + + 1.0 + 1.0 + 1.0 + + + 0.0 + 0.0 + 0.0 + + + 0 + 0 + 0 + + + + + D150_Fuselage_1Section3 + fuselageCircleProfileuID + + + 1 + 1 + 1 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + +
+
+ D150_Fuselage_1Section4 + + + 1.0 + 1.0 + 1.0 + + + 0.0 + 0.0 + 0.0 + + + 0 + 0 + 0 + + + + + D150_Fuselage_1Section4 + fuselageCircleProfileuID + + + 1 + 1 + 1 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + +
+
+ + + D150_Fuselage_1Positioning1 + -0.5 + 90 + 0 + D150_Fuselage_1Section1ID + + + D150_Fuselage_1Positioning3 + 2 + 90 + 0 + D150_Fuselage_1Section1ID + D150_Fuselage_1Section2ID + + + D150_Fuselage_1Positioning3 + 2 + 90 + 0 + D150_Fuselage_1Section2ID + D150_Fuselage_1Section3ID + + + D150_Fuselage_1Positioning4 + 2 + 90 + 0 + D150_Fuselage_1Section3ID + D150_Fuselage_1Section4ID + + + + + D150_Fuselage_1Segment1 + D150_Fuselage_1Section1IDElement1 + D150_Fuselage_1Section2IDElement1 + + + D150_Fuselage_1Segment2 + D150_Fuselage_1Section2IDElement1 + D150_Fuselage_1Section3IDElement1 + + + D150_Fuselage_1Segment3 + D150_Fuselage_1Section3IDElement1 + D150_Fuselage_1Section4IDElement1 + + +
+
+ + + Wing + SimpleFuselage + This wing has been generated to test CATIA2CPACS. + + + 1 + 1 + 1 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + +
+ Cpacs2Test - Wing Section 1 + Cpacs2Test - Wing Section 1 + + + 1 + 1 + 1 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + + Cpacs2Test - Wing Section 1 Main Element + Cpacs2Test - Wing Section 1 Main Element + NACA0012 + + + 1 + 1 + 1 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + +
+
+ Cpacs2Test - Wing Section 2 + Cpacs2Test - Wing Section 2 + + + 1 + 1 + 1 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + + Cpacs2Test - Wing Section 2 Main Element + Cpacs2Test - Wing Section 2 Main Element + NACA0012 + + + 1 + 1 + 1 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + +
+
+ Cpacs2Test - Wing Section 3 + Cpacs2Test - Wing Section 3 + + + 1 + 1 + 1 + + + 0 + 0 + 0 + + + 0 + 0 + 0 + + + + + Cpacs2Test - Wing Section 3 Main Element + Cpacs2Test - Wing Section 3 Main Element + NACA0012 + + + 0.5 + 0.5 + 0.5 + + + 0 + 0 + 0 + + + 0.5 + 0 + 0 + + + + +
+
+ + + Cpacs2Test - Wing Section 1 Positioning + Cpacs2Test - Wing Section 1 Positioning + 0 + 0 + 0 + Cpacs2Test_Wing_Sec1 + + + Cpacs2Test - Wing Section 2 Positioning + Cpacs2Test - Wing Section 2 Positioning + 1 + 0 + 0 + Cpacs2Test_Wing_Sec1 + Cpacs2Test_Wing_Sec2 + + + Cpacs2Test - Wing Section 3 Positioning + Cpacs2Test - Wing Section 3 Positioning + 1 + 0 + 0 + Cpacs2Test_Wing_Sec2 + Cpacs2Test_Wing_Sec3 + + + + + Fuselage Segment from Cpacs2Test - Wing Section 1 Main Element to Cpacs2Test - Wing Section 2 Main Element + Fuselage Segment from Cpacs2Test - Wing Section 1 Main Element to Cpacs2Test - Wing Section 2 Main Element + Cpacs2Test_Wing_Sec1_El1 + Cpacs2Test_Wing_Sec2_El1 + + + Fuselage Segment from Cpacs2Test - Wing Section 2 Main Element to Cpacs2Test - Wing Section 3 Main Element + Fuselage Segment from Cpacs2Test - Wing Section 2 Main Element to Cpacs2Test - Wing Section 3 Main Element + Cpacs2Test_Wing_Sec2_El1 + Cpacs2Test_Wing_Sec3_El1 + + + + + Wing_CS1 + Cpacs2Test_Wing_Sec1_El1 + Cpacs2Test_Wing_Sec3_El1 + + + + + MySkinMat + 0.0 + + + + + + + MyCellMat + 0.0 + + + + 0.8 + 0.8 + + + 1.0 + 1.0 + + + 0.0 + 0.0 + + + 0.5 + 0.5 + + + + + + + + MySkinMat + + + + + + +
+
+
+
+ + + + NACA0.00.00.12 + NACA 4 Series Profile + + 1.0;0.9875;0.975;0.9625;0.95;0.9375;0.925;0.9125;0.9;0.8875;0.875;0.8625;0.85;0.8375;0.825;0.8125;0.8;0.7875;0.775;0.7625;0.75;0.7375;0.725;0.7125;0.7;0.6875;0.675;0.6625;0.65;0.6375;0.625;0.6125;0.6;0.5875;0.575;0.5625;0.55;0.5375;0.525;0.5125;0.5;0.4875;0.475;0.4625;0.45;0.4375;0.425;0.4125;0.4;0.3875;0.375;0.3625;0.35;0.3375;0.325;0.3125;0.3;0.2875;0.275;0.2625;0.25;0.2375;0.225;0.2125;0.2;0.1875;0.175;0.1625;0.15;0.1375;0.125;0.1125;0.1;0.0875;0.075;0.0625;0.05;0.0375;0.025;0.0125;0.0;0.0125;0.025;0.0375;0.05;0.0625;0.075;0.0875;0.1;0.1125;0.125;0.1375;0.15;0.1625;0.175;0.1875;0.2;0.2125;0.225;0.2375;0.25;0.2625;0.275;0.2875;0.3;0.3125;0.325;0.3375;0.35;0.3625;0.375;0.3875;0.4;0.4125;0.425;0.4375;0.45;0.4625;0.475;0.4875;0.5;0.5125;0.525;0.5375;0.55;0.5625;0.575;0.5875;0.6;0.6125;0.625;0.6375;0.65;0.6625;0.675;0.6875;0.7;0.7125;0.725;0.7375;0.75;0.7625;0.775;0.7875;0.8;0.8125;0.825;0.8375;0.85;0.8625;0.875;0.8875;0.9;0.9125;0.925;0.9375;0.95;0.9625;0.975;0.9875;1.0 + 0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0;0.0 + -0.00126;-0.0030004180415;-0.00471438572941;-0.00640256842113;-0.00806559133343;-0.00970403933653;-0.0113184567357;-0.0129093470398;-0.0144771727147;-0.0160223549226;-0.0175452732434;-0.0190462653789;-0.0205256268372;-0.0219836105968;-0.0234204267471;-0.024836242105;-0.0262311798047;-0.0276053188583;-0.0289586936852;-0.0302912936071;-0.0316030623052;-0.0328938972373;-0.0341636490097;-0.0354121207001;-0.0366390671268;-0.0378441940595;-0.0390271573644;-0.0401875620783;-0.0413249614032;-0.042438855614;-0.043528690869;-0.0445938579126;-0.0456336906587;-0.04664746464;-0.0476343953088;-0.0485936361694;-0.0495242767241;-0.0504253402064;-0.0512957810767;-0.0521344822472;-0.0529402520006;-0.0537118205596;-0.0544478362583;-0.0551468612564;-0.0558073667285;-0.0564277274483;-0.0570062156697;-0.0575409941929;-0.0580301084765;-0.0584714776309;-0.0588628840933;-0.059201961739;-0.0594861821311;-0.0597128385384;-0.059879027262;-0.0599816256958;-0.060017266394;-0.059982306219;-0.05987278938;-0.0596844028137;-0.059412421875;-0.059051643633;-0.0585963041308;-0.0580399746271;-0.0573754299024;-0.0565944788455;-0.0556877432118;-0.054644363746;-0.0534516022043;-0.0520942903127;-0.0505540468987;-0.0488081315259;-0.0468277042382;-0.0445750655553;-0.0419990347204;-0.0390266537476;-0.0355468568262;-0.0313738751622;-0.0261471986426;-0.0189390266528;0.0;0.0189390266528;0.0261471986426;0.0313738751622;0.0355468568262;0.0390266537476;0.0419990347204;0.0445750655553;0.0468277042382;0.0488081315259;0.0505540468987;0.0520942903127;0.0534516022043;0.054644363746;0.0556877432118;0.0565944788455;0.0573754299024;0.0580399746271;0.0585963041308;0.059051643633;0.059412421875;0.0596844028137;0.05987278938;0.059982306219;0.060017266394;0.0599816256958;0.059879027262;0.0597128385384;0.0594861821311;0.059201961739;0.0588628840933;0.0584714776309;0.0580301084765;0.0575409941929;0.0570062156697;0.0564277274483;0.0558073667285;0.0551468612564;0.0544478362583;0.0537118205596;0.0529402520006;0.0521344822472;0.0512957810767;0.0504253402064;0.0495242767241;0.0485936361694;0.0476343953088;0.04664746464;0.0456336906587;0.0445938579126;0.043528690869;0.042438855614;0.0413249614032;0.0401875620783;0.0390271573644;0.0378441940595;0.0366390671268;0.0354121207001;0.0341636490097;0.0328938972373;0.0316030623052;0.0302912936071;0.0289586936852;0.0276053188583;0.0262311798047;0.024836242105;0.0234204267471;0.0219836105968;0.0205256268372;0.0190462653789;0.0175452732434;0.0160223549226;0.0144771727147;0.0129093470398;0.0113184567357;0.00970403933653;0.00806559133343;0.00640256842113;0.00471438572941;0.0030004180415;0.00126 + + + + + + Circle + Profile build up from set of Points on Circle where may Dimensions are 1..-1 + + 0.0;0.0;0.0;0.0;0.0 + 0.0;1.0;0.0;-1.0;0.0 + 1.0;0.0;-1.0;0.0;1.0 + + + + +
+ +
diff --git a/ceasiompy/EdgeRun/tests/ToolOutput/.keep b/ceasiompy/EdgeRun/tests/ToolOutput/.keep new file mode 100644 index 000000000..8d1c8b69c --- /dev/null +++ b/ceasiompy/EdgeRun/tests/ToolOutput/.keep @@ -0,0 +1 @@ + diff --git a/ceasiompy/EdgeRun/tests/tests_edgeconfig/test_edgerun.py b/ceasiompy/EdgeRun/tests/test_edgerun.py similarity index 81% rename from ceasiompy/EdgeRun/tests/tests_edgeconfig/test_edgerun.py rename to ceasiompy/EdgeRun/tests/test_edgerun.py index 44ce5c506..7901f68d5 100644 --- a/ceasiompy/EdgeRun/tests/tests_edgeconfig/test_edgerun.py +++ b/ceasiompy/EdgeRun/tests/test_edgerun.py @@ -23,14 +23,15 @@ from pathlib import Path # Add the ceasiompy module to the PYTHONPATH -ceasiompy_path = Path('/home/mengmeng/Documents/CEASIOMpy23/CEASIOMpy/ceasiompy') +ceasiompy_path = Path("/home/mengmeng/Documents/CEASIOMpy23/CEASIOMpy/ceasiompy") sys.path.append(str(ceasiompy_path)) # Now you can import and use the ceasiompy module -#import ceasiompy +# import ceasiompy from ceasiompy.EdgeRun.func.edgeconfig import generate_edge_cfd_ainp import os -#from ceasiompy.utils.create_ainpfile import CreateAinp + +# from ceasiompy.utils.create_ainpfile import CreateAinp MODULE_DIR = Path(__file__).parent @@ -38,14 +39,17 @@ # CLASSES # ================================================================================================= + class TestEdgeConfig(unittest.TestCase): """Test class for 'ceasiompy/EdgeRun/func/edgerun.py'""" def test_generate_edge_cfd_ainp(self): """Test function for 'ceasiompy.EdgeRun.func.edgeconfig.py'.""" - cpacs_path = Path('/home/mengmeng/Documents/CEASIOMpy23/CEASIOMpy/WKDIR/labARstraight_toolInput.xml') - cpacs_out_path = MODULE_DIR / 'ToolOutput' - wkdir = MODULE_DIR / 'ToolOutput' + cpacs_path = Path( + "/home/mengmeng/Documents/CEASIOMpy23/CEASIOMpy/WKDIR/labARstraight_toolInput.xml" + ) + cpacs_out_path = MODULE_DIR / "ToolOutput" + wkdir = MODULE_DIR / "ToolOutput" if not os.path.exists(wkdir): os.makedirs(wkdir) @@ -58,7 +62,6 @@ def test_generate_edge_cfd_ainp(self): # ================================================================================================= if __name__ == "__main__": - print("Test configfile.py") print("To run test use the following command:") print(">> pytest -v") diff --git "a/src/streamlit/pages/02_\342\232\231\357\270\217_Settings.py" "b/src/streamlit/pages/02_\342\232\231\357\270\217_Settings.py" index e9f74ed04..225482556 100644 --- "a/src/streamlit/pages/02_\342\232\231\357\270\217_Settings.py" +++ "b/src/streamlit/pages/02_\342\232\231\357\270\217_Settings.py" @@ -217,7 +217,6 @@ def section_edit_aeromap(): def mesh_file_upload(): st.markdown("#### Upload mesh file") - # Verifica se รจ stato caricato un file mesh uploaded_mesh = st.file_uploader( "Select a mesh file", key="00_mesh_upload", @@ -225,37 +224,28 @@ def mesh_file_upload(): ) if uploaded_mesh: - # Crea la cartella "mesh" se non esiste mesh_dir = os.path.join(st.session_state.workflow.working_dir, "mesh") os.makedirs(mesh_dir, exist_ok=True) - # Crea un nuovo percorso per il file .su2 nella cartella "mesh" mesh_new_path = os.path.join(mesh_dir, uploaded_mesh.name) print(f"mesh path: {mesh_new_path}") try: - # Scrivi il file nel percorso specificato with open(mesh_new_path, "wb") as f: f.write(uploaded_mesh.getbuffer()) - # Apri il file CPACS cpacs_path = st.session_state.workflow.cpacs_in print(f"cpacs_path: {cpacs_path}") tixi = open_tixi(cpacs_path) - # Definisci la variabile mesh_xpath in base alla tua struttura CPACS mesh_xpath = "/cpacs/toolspecific/CEASIOMpy/filesPath/su2Mesh" - # Verifica se il percorso esiste if not tixi.checkElement(mesh_xpath): - # Se il percorso non esiste, crealo create_branch(tixi, mesh_xpath) if st.button("Add this mesh"): - # Aggiorna il percorso del file SU2 mesh nel documento CPACS tixi.updateTextElement(mesh_xpath, str(mesh_new_path)) - # Salva il file CPACS save_cpacs_file() return mesh_new_path @@ -361,7 +351,6 @@ def add_module_tab(): ) elif name == "pathtype": - # Chiama la funzione mesh_file_upload() e ottieni il percorso del file mesh mesh_path = mesh_file_upload() with st.columns([1, 2])[0]: