Hydrodynamics
Drag and lift coefficients
Hull
Float
Centreboard
Rudder
File format
File for hydrodynamics coefficients must have the following format.
file_format.txt
# NUMBER_OF_CURRENT_ANGLE
181
# CURRENT_ANGLES
0 1 2 3 ... 177 178 179 180
# NUMBER_OF_CURRENT_SPEED
7
# CURRENT_SPEED
speed_0 speed_1 speed_2 speed_3 speed_4 speed_5 speed_6
# SERIE_0, speed_0
cd_0,cl_0
...,...
cd_180,cl_180
...
# SERIE_i, speed_i
...
# SERIE_7, speed_7
cd_0,cl_0
...,...
cd_180,cl_180
Warning
Make sure to respect the spacing betwen lines! Else, the file will be read incorrectly!
Note
Spaces between parameters are tabulation character : ‘\t’
This file can be generated using the python script 1
Rotation coefficients
These coefficients are resulting from the forces created on the boat part when the boat rotates along it vertical axis. See theory section
Hull
Float
Centreboard
Rudder
File format
Appendices
Python script 1
def write_file(datas, speeds, angles, out_name, out_path = './'):
"""
## Description
Write the output file to be treated by the C# code in Unity.
### Args:
datas (list): format : [{cd: [], cl: []}, {cd: [], cl: []}, ...]
speeds (list): Ascending sorted list of current speeds
angles (list): Ascending sorted list of current angles
out_name (str): Output file name
out_path (str): Output file path with '/' at the end
"""
# Open a file to write in
with open(out_path + out_name + ".txt", "w") as f:
# Write parameters
f.write("# NUMBER_OF_CURRENT_ANGLE\n")
f.write(f"{len(angles)}\n\n")
f.write("# CURRENT_ANGLES\n")
for a in angles:
f.write(f"{a:.2f}\t")
f.write("\n\n")
f.write("# NUMBER_OF_CURRENT_SPEED\n")
f.write(f"{len(speeds)}\n\n")
f.write("# CURRENT_SPEEDS\n")
for s in speeds:
f.write(f"{s:.5f}\t")
f.write("\n")
# Write coefficients
for i in range(len(speeds)):
f.write(f"\n# SERIE_{i}, SPEED_{speeds[i]:.5f}\n")
for j in range(len(angles)):
f.write(f"{datas[i]['cd'][j]},{datas[i]['cl'][j]}\n")
print("File written with success")