Skip to content

Commit

Permalink
first part of the vector in sumo
Browse files Browse the repository at this point in the history
  • Loading branch information
GBenedett committed Dec 4, 2023
1 parent 542f968 commit f28ff7f
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions ceasiompy/CPACS2SUMO/cpacs2sumo.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,16 +626,16 @@ def convert_cpacs_to_sumo(cpacs_path, cpacs_out_path):
# then TE(1 0), but not reverse way.

# to avoid double zero, not accepted by SUMO
for i, item in enumerate(prof_vect_x):
# if not (prof_vect_x[i] == prof_vect_x[i-1] or \
# round(prof_vect_z[i],4) == round(prof_vect_z[i-1],4)):
if round(prof_vect_z[i], 4) != round(prof_vect_z[i - 1], 4):
prof_str += (
str(round(prof_vect_x[i], 4))
+ " "
+ str(round(prof_vect_z[i], 4))
+ " "
)
prof_str += (
str(round(prof_vect_x[0], 4)) + " " + str(round(prof_vect_z[0], 4)) + " "
)

for i in range(1, len(prof_vect_x)):
dx_squared = (prof_vect_x[i] - prof_vect_x[i - 1]) ** 2
dz_squared = (prof_vect_z[i] - prof_vect_z[i - 1]) ** 2

if dx_squared + dz_squared > 1e-8:
prof_str += f"{round(prof_vect_x[i], 4)} {round(prof_vect_z[i], 4)} "

sumo.addTextElementAtIndex(wg_sk_xpath, "WingSection", prof_str, wing_sec_index)
wg_sec_xpath = wg_sk_xpath + "/WingSection[" + str(wing_sec_index) + "]"
Expand Down Expand Up @@ -883,16 +883,15 @@ def convert_cpacs_to_sumo(cpacs_path, cpacs_out_path):
# then TE(1 0), but not reverse way.

# to avoid double zero, not accepted by SUMO
for i, item in enumerate(prof_vect_x):
# if not (prof_vect_x[i] == prof_vect_x[i-1] or \
# round(prof_vect_z[i],4) == round(prof_vect_z[i-1],4)):
if round(prof_vect_z[i], 4) != round(prof_vect_z[i - 1], 4):
prof_str += (
str(round(prof_vect_x[i], 4))
+ " "
+ str(round(prof_vect_z[i], 4))
+ " "
)
prof_str += (
str(round(prof_vect_x[0], 4)) + " " + str(round(prof_vect_z[0], 4)) + " "
)
for i in range(1, len(prof_vect_x)):
dx_squared = (prof_vect_x[i] - prof_vect_x[i - 1]) ** 2
dz_squared = (prof_vect_z[i] - prof_vect_z[i - 1]) ** 2

if dx_squared + dz_squared > 1e-6:
prof_str += f"{round(prof_vect_x[i], 4)} {round(prof_vect_z[i], 4)} "

sumo.addTextElementAtIndex(wg_sk_xpath, "WingSection", prof_str, wing_sec_index)
wg_sec_xpath = wg_sk_xpath + "/WingSection[" + str(wing_sec_index) + "]"
Expand Down

0 comments on commit f28ff7f

Please sign in to comment.