Skip to content

Commit

Permalink
update D150 (flake+codacy)
Browse files Browse the repository at this point in the history
  • Loading branch information
Romain-Gauthier committed Oct 23, 2024
1 parent 47715c9 commit 454d804
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 34 deletions.
20 changes: 12 additions & 8 deletions ceasiompy/AeroFrame_new/aeroframe_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def aeroelastic_loop(cpacs_path, CASE_PATH, q, xyz, fxyz):
# xyz_tip = np.array([wg_center_x_list[-1] + wing_origin[0] + wg_chord_list[-1] / 2,
# wg_center_y_list[-1] + wing_origin[1],
# wg_center_z_list[-1] + wing_origin[2]])

Xle_list = []
Yle_list = []
Zle_list = []
Expand All @@ -163,12 +163,11 @@ def aeroelastic_loop(cpacs_path, CASE_PATH, q, xyz, fxyz):
Xle_array = np.array(Xle_list)
Yle_array = np.array(Yle_list)
Zle_array = np.array(Zle_list)

xyz_tip = np.array([Xle_array[-1] + wg_chord_list[-1] / 2,
Yle_array[-1],
Zle_array[-1]])


# Get cross-section properties from CPACS file (if constants)
area_const, Ix_const, Iy_const = get_section_properties(cpacs_path)

Expand Down Expand Up @@ -273,7 +272,9 @@ def aeroelastic_loop(cpacs_path, CASE_PATH, q, xyz, fxyz):

log.info(f"Iteration {n_iter} done!")
log.info(
f"Wing tip deflection: {deflection:.3e} m ({percentage:.2%} of the semi-span length).")
f"Wing tip deflection: {deflection:.3e} m "
f"({percentage:.2%} of the semi-span length)."
)
log.info(f"Residual: {res[-1]:.3e}")

# Run AVL with the new deformed geometry
Expand Down Expand Up @@ -321,8 +322,9 @@ def compute_structural_work(row):
log.info(f"Total aerodynamic work: {total_aero_work:.3e} J.")
log.info(f"Total structural work: {total_structural_work:.3e} J.")
log.info(
f"Work variation: {((total_aero_work-total_structural_work)/total_aero_work):.2%}.")

f"Work variation: "
f"{((total_aero_work - total_structural_work) / total_aero_work):.2%}."
)
log.info("")
log.info("----- Final results -----")
if res[-1] <= tol:
Expand All @@ -339,8 +341,10 @@ def compute_structural_work(row):
log.info(f"Total aerodynamic work: {total_aero_work:.3e} J.")
log.info(f"Total structural work: {total_structural_work:.3e} J.")
log.info(
f"Work variation: {((total_aero_work-total_structural_work)/total_aero_work):.2%}.")

"Work variation: "
f"{((total_aero_work - total_structural_work) / total_aero_work):.2%}."
)

return delta_tip, res


Expand Down
45 changes: 26 additions & 19 deletions ceasiompy/AeroFrame_new/func/aeroframe_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,15 +340,14 @@ def create_framat_model(young_modulus, shear_modulus, material_density,
beam.add('point_load', {'at': node_uid, 'load': load})

# ===== BOUNDARY CONDITIONS =====
#idx_to_fix = centerline_df["y"].idxmin()
#bc.add('fix', {'node': "wing1_node" + str(idx_to_fix + 1), 'fix': ['all']})
# idx_to_fix = centerline_df["y"].idxmin()
# bc.add('fix', {'node': "wing1_node" + str(idx_to_fix + 1), 'fix': ['all']})

# /!\ FOR D150 ONLY
idx_to_fix = centerline_df[centerline_df["y"] < 1.8].index
for idx in idx_to_fix:
bc.add('fix', {'node': "wing1_node" + str(idx + 1), 'fix': ['all']})


# ===== POST-PROCESSING =====
pp = model.set_feature('post_proc')
pp.set('plot_settings', {'show': False,
Expand Down Expand Up @@ -841,10 +840,18 @@ def compute_cross_section(cpacs_path):
wg_chord_list.append(wg_sec_chord)

log.info(f"Section number: {i_sec}")
log.info(f"Area of the sections: [{', '.join([f'{area:.2e}' for area in area_list])}] m^2.")
log.info(f"Ix of the sections: [{', '.join([f'{Ix:.2e}' for Ix in Ix_list])}] m^4.")
log.info(f"Iy of the sections: [{', '.join([f'{Iy:.2e}' for Iy in Iy_list])}] m^4.")

log.info(
"Area of the sections: "
f"[{', '.join([f'{area:.2e}' for area in area_list])}] m^2."
)
log.info(
"Ix of the sections: "
f"[{', '.join([f'{Ix:.2e}' for Ix in Ix_list])}] m^4."
)
log.info(
"Iy of the sections: "
f"[{', '.join([f'{Iy:.2e}' for Iy in Iy_list])}] m^4."
)

return (
wg_origin, wg_twist_list, area_list, Ix_list, Iy_list,
Expand All @@ -866,8 +873,8 @@ def write_deformed_geometry(UNDEFORMED_PATH, DEFORMED_PATH, centerline_df, defor

deformed_df.sort_values(by="y_leading", inplace=True)
deformed_df.reset_index(drop=True, inplace=True)
twist_profile = interpolate.interp1d(
centerline_df["y_new"], centerline_df["AoA_new"], fill_value="extrapolate")
# twist_profile = interpolate.interp1d(
# centerline_df["y_new"], centerline_df["AoA_new"], fill_value="extrapolate")

with open(UNDEFORMED_PATH, "r") as file_undeformed:
with open(DEFORMED_PATH, "w") as file_deformed:
Expand All @@ -888,16 +895,16 @@ def write_deformed_geometry(UNDEFORMED_PATH, DEFORMED_PATH, centerline_df, defor
y_new = deformed_df.iloc[i_node]["y_leading"]
z_new = deformed_df.iloc[i_node]["z_leading"]
chord = deformed_df.iloc[i_node]["chord"]
AoA = 2#twist_profile(y_new)
if y_new > 1.856 and root_sec_added == False:
AoA = 2 # twist_profile(y_new)

if y_new > 1.856 and root_sec_added is False:
file_deformed.writelines(
["SECTION\n",
"#Xle Yle Zle Chord Ainc\n",
f"{12.746} {1.856} {-1.136} {6.076} {2}\n\n",
"#---------------\n"])
["SECTION\n",
"#Xle Yle Zle Chord Ainc\n",
f"{12.746} {1.856} {-1.136} {6.076} {2}\n\n",
"#---------------\n"])
root_sec_added = True

file_deformed.writelines(
["SECTION\n",
"#Xle Yle Zle Chord Ainc\n",
Expand All @@ -908,7 +915,7 @@ def write_deformed_geometry(UNDEFORMED_PATH, DEFORMED_PATH, centerline_df, defor
y_new = deformed_df.iloc[-1]["y_leading"]
z_new = deformed_df.iloc[-1]["z_leading"]
chord = deformed_df.iloc[-1]["chord"]
AoA = 2#centerline_df.iloc[-1]["AoA_new"]
AoA = 2 # centerline_df.iloc[-1]["AoA_new"]
file_deformed.writelines(
["SECTION\n",
"#Xle Yle Zle Chord Ainc\n",
Expand Down
7 changes: 3 additions & 4 deletions ceasiompy/AeroFrame_new/func/aeroframe_debbug.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
Developed by CFS ENGINEERING, 1015 Lausanne, Switzerland
Script to plot the FEM mesh and VLM panels used in the aeroelastic computations,
and plot the shape of the deformed wing. It helps to see if the geometry was
accurately captured and if the meshes are fine.
Script to plot the FEM mesh and VLM panels used in the aeroelastic computations,
and plot the shape of the deformed wing. It helps to see if the geometry was
accurately captured and if the meshes are fine.
Python version: >=3.8
Expand Down Expand Up @@ -78,7 +78,6 @@ def plot_deformed_wing(centerline_df, undeformed_df, wkdir):
centerline_df (pandas dataframe): dataframe containing the nodes of the deformed wing.
undeformed_df (pandas dataframe): dataframe containing the nodes of the initial wing.
wkdir (Path): path to the directory to save the plot.
"""
fig, axs = plt.subplots()
axs.plot(centerline_df['y_new'],
Expand Down
2 changes: 1 addition & 1 deletion ceasiompy/AeroFrame_new/func/aeroframe_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Developed by CFS ENGINEERING, 1015 Lausanne, Switzerland
Script to compute the wing deformation, plot the displacements and rotations,
Script to compute the wing deformation, plot the displacements and rotations,
and plot the convergence.
Python version: >=3.8
Expand Down
4 changes: 2 additions & 2 deletions ceasiompy/AeroFrame_new/func/aeroframe_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def second_moments_of_area(x, y):
x_centr, y_centr = compute_centroid(x, y)
x = [xi - x_centr for xi in x]
y = [yi - y_centr for yi in y]

n = len(x)
for i in range(n):
j = (i + 1) % n
Expand Down Expand Up @@ -115,5 +115,5 @@ def rotate_3D_points(x, y, z, angle_x, angle_y, angle_z):
# =================================================================================================

if __name__ == "__main__":

log.info("Nothing to execute!")

0 comments on commit 454d804

Please sign in to comment.