27
27
28
28
from ceasiompy .PyAVL .pyavl import main as run_avl
29
29
from ceasiompy .utils .ceasiompyutils import call_main
30
+ from ceasiompy .PyAVL .func .utils import create_case_dir
30
31
from ceasiompy .PyAVL .func .plot import convert_ps_to_pdf
31
32
from ceasiompy .utils .ceasiompyutils import get_aeromap_conditions
32
33
from cpacspy .cpacsfunctions import (
43
44
plot_deformed_wing
44
45
)
45
46
from ceasiompy .AeroFrame_new .func .config import (
46
- read_AVL_fe_file ,
47
+ read_avl_fe_file ,
47
48
create_framat_model ,
48
49
get_material_properties ,
49
50
get_section_properties ,
71
72
72
73
73
74
# TODO: Reduce complexity
74
- def aeroelastic_loop (cpacs_path , CASE_PATH , q , xyz , fxyz ):
75
+ def aeroelastic_loop (
76
+ cpacs ,
77
+ results_dir ,
78
+ case_dir_path ,
79
+ q , xyz , fxyz
80
+ ):
75
81
"""Function to execute the aeroelastic-loop.
76
82
77
83
Function 'aeroelastic_loop' executes the aeroelastic-loop,
@@ -90,12 +96,10 @@ def aeroelastic_loop(cpacs_path, CASE_PATH, q, xyz, fxyz):
90
96
res (list): residual of the mid-chord wing tip deflection.
91
97
"""
92
98
93
- cpacs = CPACS (cpacs_path )
94
-
95
- AVL_ITER1_PATH = Path (CASE_PATH , "Iteration_1" , "AVL" )
99
+ AVL_ITER1_PATH = Path (case_dir_path , "Iteration_1" , "AVL" )
96
100
97
101
# Get the path to the undeformed/initial AVL geometry
98
- for path in AVL_ITER1_PATH .glob ('*.avl' ):
102
+ for path in results_dir .glob ('*.avl' ):
99
103
AVL_UNDEFORMED_PATH = path
100
104
AVL_UNDEFORMED_COMMAND = Path (AVL_ITER1_PATH , "avl_commands.txt" )
101
105
@@ -111,10 +115,10 @@ def aeroelastic_loop(cpacs_path, CASE_PATH, q, xyz, fxyz):
111
115
wg_center_z_list ,
112
116
wg_chord_list ,
113
117
wg_scaling
114
- ) = compute_cross_section (cpacs_path )
118
+ ) = compute_cross_section (cpacs )
115
119
116
120
# Get the properties of the wing material and the number of beam nodes to use
117
- young_modulus , shear_modulus , material_density = get_material_properties (cpacs_path )
121
+ young_modulus , shear_modulus , material_density = get_material_properties (cpacs )
118
122
N_beam = get_value_or_default (cpacs .tixi , FRAMAT_MESH_XPATH + "/NumberNodes" , 8 )
119
123
120
124
# Define the coordinates of the wing root and tip
@@ -155,7 +159,7 @@ def aeroelastic_loop(cpacs_path, CASE_PATH, q, xyz, fxyz):
155
159
Zle_array [- 1 ]])
156
160
157
161
# Get cross-section properties from CPACS file (if constants)
158
- area_const , Ix_const , Iy_const = get_section_properties (cpacs_path )
162
+ area_const , Ix_const , Iy_const = get_section_properties (cpacs )
159
163
160
164
if area_const > 0 :
161
165
area_list = area_const * np .ones (len (wg_center_y_list ))
@@ -189,10 +193,10 @@ def aeroelastic_loop(cpacs_path, CASE_PATH, q, xyz, fxyz):
189
193
log .info ("" )
190
194
log .info (f"----- FramAT: Deformation { n_iter } -----" )
191
195
192
- Path (CASE_PATH , f"Iteration_{ n_iter + 1 } " , "AVL" ).mkdir (parents = True , exist_ok = True )
193
- Path (CASE_PATH , f"Iteration_{ n_iter } " , "FramAT" ).mkdir (parents = True , exist_ok = True )
194
- AVL_ITER_PATH = Path (CASE_PATH , f"Iteration_{ n_iter + 1 } " , "AVL" )
195
- FRAMAT_ITER_PATH = Path (CASE_PATH , f"Iteration_{ n_iter } " , "FramAT" )
196
+ Path (case_dir_path , f"Iteration_{ n_iter + 1 } " , "AVL" ).mkdir (parents = True , exist_ok = True )
197
+ Path (case_dir_path , f"Iteration_{ n_iter } " , "FramAT" ).mkdir (parents = True , exist_ok = True )
198
+ AVL_ITER_PATH = Path (case_dir_path , f"Iteration_{ n_iter + 1 } " , "AVL" )
199
+ FRAMAT_ITER_PATH = Path (case_dir_path , f"Iteration_{ n_iter } " , "FramAT" )
196
200
AVL_DEFORMED_PATH = Path (AVL_ITER_PATH , "deformed.avl" )
197
201
AVL_DEFORMED_COMMAND = Path (AVL_ITER_PATH , "avl_commands.txt" )
198
202
@@ -217,7 +221,7 @@ def aeroelastic_loop(cpacs_path, CASE_PATH, q, xyz, fxyz):
217
221
Iy_profile ,
218
222
chord_profile ,
219
223
twist_profile ,
220
- CASE_PATH ,
224
+ case_dir_path ,
221
225
AVL_UNDEFORMED_PATH ,
222
226
wg_scaling )
223
227
@@ -283,7 +287,7 @@ def aeroelastic_loop(cpacs_path, CASE_PATH, q, xyz, fxyz):
283
287
284
288
# Read the new forces file to extract the loads
285
289
FE_PATH = Path (AVL_ITER_PATH , "fe.txt" )
286
- _ , _ , _ , xyz_list , p_xyz_list , _ = read_AVL_fe_file (FE_PATH , plot = False )
290
+ _ , _ , _ , xyz_list , p_xyz_list , _ = read_avl_fe_file (FE_PATH , plot = False )
287
291
288
292
xyz = xyz_list [0 ]
289
293
fxyz = np .array (p_xyz_list [0 ]) * q
@@ -368,7 +372,7 @@ def main(cpacs: CPACS, results_dir: Path) -> None:
368
372
369
373
# First AVL run
370
374
# You need to first load the default values of AVL
371
- # Then you add back the ones that you wanted to specify...
375
+ # Then you add back the ones that you wanted to specify.
372
376
run_avl (cpacs , results_dir )
373
377
374
378
for i_case , _ in enumerate (alt_list ):
@@ -380,38 +384,47 @@ def main(cpacs: CPACS, results_dir: Path) -> None:
380
384
Atm = Atmosphere (alt )
381
385
fluid_density = Atm .density [0 ]
382
386
fluid_velocity = Atm .speed_of_sound [0 ] * mach
383
- q = 0.5 * fluid_density * fluid_velocity ** 2
384
-
385
- case_dir_name = (
386
- f"Case{ str (i_case ).zfill (2 )} _alt{ alt } _mach{ round (mach , 2 )} "
387
- f"_aoa{ round (aoa , 1 )} _aos{ round (aos , 1 )} "
387
+ rho = 0.5 * fluid_density * fluid_velocity ** 2
388
+
389
+ case_dir_path = create_case_dir (
390
+ results_dir ,
391
+ i_case ,
392
+ alt ,
393
+ mach = mach ,
394
+ aoa = aoa ,
395
+ aos = aos ,
396
+ q = 0.0 ,
397
+ p = 0.0 ,
398
+ r = 0.0 ,
388
399
)
400
+ Path (case_dir_path , "Iteration_1" , "AVL" ).mkdir (parents = True , exist_ok = True )
389
401
390
- CASE_PATH = Path (results_dir , case_dir_name )
391
- Path (CASE_PATH , "Iteration_1" , "AVL" ).mkdir (parents = True , exist_ok = True )
392
- AVL_ITER_PATH = Path (CASE_PATH , "Iteration_1" , "AVL" )
402
+ avl_iter_path = Path (case_dir_path , "Iteration_1" , "AVL" )
393
403
394
- for file_path in CASE_PATH .iterdir ():
404
+ for file_path in case_dir_path .iterdir ():
395
405
if file_path .is_file ():
396
- shutil .move (str (file_path ), str (AVL_ITER_PATH / file_path .name ))
406
+ shutil .move (str (file_path ), str (avl_iter_path / file_path .name ))
397
407
398
- FE_PATH = Path (AVL_ITER_PATH , "fe.txt" )
399
- _ , _ , _ , xyz_list , p_xyz_list , _ = read_AVL_fe_file ( FE_PATH , plot = False )
408
+ fe_path = Path (avl_iter_path , "fe.txt" )
409
+ _ , _ , _ , xyz_list , p_xyz_list , _ = read_avl_fe_file ( fe_path , plot = False )
400
410
401
- f_xyz_array = np .array (p_xyz_list ) * q
411
+ f_xyz_array = np .array (p_xyz_list ) * rho
402
412
403
413
# Start the aeroelastic loop
404
- tip_deflection , residuals = aeroelastic_loop (cpacs_path ,
405
- CASE_PATH ,
406
- q ,
407
- xyz_list [0 ],
408
- f_xyz_array [0 ])
414
+ tip_deflection , residuals = aeroelastic_loop (
415
+ cpacs ,
416
+ results_dir ,
417
+ case_dir_path ,
418
+ rho ,
419
+ xyz_list [0 ],
420
+ f_xyz_array [0 ],
421
+ )
409
422
410
423
# Write results in CPACS out
411
424
create_branch (tixi , FRAMAT_RESULTS_XPATH + "/TipDeflection" )
412
425
tixi .updateDoubleElement (FRAMAT_RESULTS_XPATH + "/TipDeflection" , tip_deflection [- 1 ], "%g" )
413
426
414
- plot_convergence (tip_deflection , residuals , wkdir = CASE_PATH )
427
+ plot_convergence (tip_deflection , residuals , wkdir = case_dir_path )
415
428
416
429
417
430
# =================================================================================================
0 commit comments