RC44 yacht#

Example#

In the cell below insert your initial parameters. If some of them are not required for your model, simply pass 0 value (for numbers). Some parameters are necessary only for specific cases like roughness (used by package when logarithmic profile is set) and they are omitted during computation.

ATTENTION: Make sure that the length of your arrays match, like: girths and chords

More information can be found in code comments below.

https://www.sail-world.com/news/249078/44Cup-Cascais-Day-3

# varaibles.py for jupyter
import os
import numpy as np
import time
from pySailingVLM.runner.container import Output, Rig, Conditions, Solver, MainSail, JibSail, Csys, Keel

mgirths =  np.array([0.00, 1./4, 1./2, 3./4, 1.00])
jgirths = np.array([0.00, 1./4, 1./2, 3./4, 1.00])

out = Output(case_name='my_case_name',
             case_dir=os.path.abspath(''),
             name=os.path.join("results_example_jib_and_mainsail_vlm", time.strftime("%Y-%m-%d_%Hh%Mm%Ss")),
            file_name='results_RC44_GENOA_VLM')

solver = Solver(n_spanwise=25,
                n_chordwise=17,
                interpolation_type='spline')


conditions = Conditions(leeway_deg=0.,    
                        heel_deg=13.,    
                        SOG_yacht=3.4460,  
                        tws_ref= 3.0860,     
                        alpha_true_wind_deg= 45., 
                        reference_water_level_for_wind_profile=-1.23,
                        wind_exp_coeff=0.1,
                        wind_reference_measurment_height=22.,
                        rho=1.184,
                        wind_profile='exponential',
                        roughness=0.05)
   
rig = Rig(main_sail_luff=17.52,
          jib_luff=17.40,
          foretriangle_height=16.98,
          foretriangle_base=5.13,
          sheer_above_waterline=1.23,
          boom_above_sheer=1.41,
          rake_deg=95.,
          mast_LOA=0.24,
          sails_def='jib_and_main')

main = MainSail(centerline_twist_deg=17. * mgirths + 0,
                girths=mgirths,
                chords=np.array([5.37, 4.98, 4.45, 3.72, 2.49]),
                camber= 1*np.array([0.028, 0.083, 0.095, 0.087, 0.013]),
                camber_distance_from_luff= np.array([0.5, 0.5, 0.5, 0.5, 0.5]))
                
jib = JibSail(centerline_twist_deg=24. * jgirths + 8.6,
             girths=jgirths,
             chords=np.array([7.32, 5.39, 3.55, 1.76, 0.09]),
             camber=1*np.array([0.055, 0.1, 0.13, 0.131, 0.01]),
             camber_distance_from_luff=np.array([0.5, 0.5, 0.5, 0.5, 0.5]))

csys = Csys(reference_level_for_moments=np.array([0, 0, 0]))
keel = Keel(center_of_lateral_resistance_upright=np.array([0, 0, -1.25]))  
Run cell below twice: Run cell below twice before running other cells. Output below is expected to always appear at first time importing pySailingVLM:

/home/user/miniconda3/envs/mgr_test/lib/python3.10/site-packages/numba/core/lowering.py:107: NumbaDebugInfoWarning: Could not find source for function: . Debug line information may be inaccurate.warnings.warn(NumbaDebugInfoWarning(msg))
import shutil
from pySailingVLM.rotations.csys_transformations import CSYS_transformations
from pySailingVLM.yacht_geometry.hull_geometry import HullGeometry
from pySailingVLM.results.save_utils import save_results_to_file
from pySailingVLM.solver.panels_plotter import display_panels_xyz_and_winds
from pySailingVLM.results.inviscid_flow import InviscidFlowResults
from pySailingVLM.solver.vlm import Vlm
from pySailingVLM.runner.sail import Wind, Sail
from pySailingVLM.solver.panels_plotter import plot_cp
csys_transformations = CSYS_transformations(
    conditions.heel_deg, conditions.leeway_deg,
    v_from_original_xyz_2_reference_csys_xyz=csys.reference_level_for_moments)

w = Wind(conditions)
s = Sail(solver, rig, main, jib, csys_transformations)
sail_set = s.sail_set
hull = HullGeometry(rig.sheer_above_waterline, rig.foretriangle_base, csys_transformations, keel.center_of_lateral_resistance_upright)
myvlm = Vlm(sail_set.panels, solver.n_chordwise, solver.n_spanwise, conditions.rho, w.profile, sail_set.trailing_edge_info, sail_set.leading_edge_info)

inviscid_flow_results = InviscidFlowResults(sail_set, csys_transformations, myvlm)
inviscid_flow_results.estimate_heeling_moment_from_keel(hull.center_of_lateral_resistance)

Cell below displays computations and saves integrals to output file.

Tip: For proper rendering of matplotlib figures in jupyter notebooks insert %matplotlib widget before calling plot functions.
%matplotlib widget
print("Preparing visualization.")   
display_panels_xyz_and_winds(myvlm, inviscid_flow_results, myvlm.inlet_conditions, hull, show_plot=True) # add show_apparent_induced_wind=True for apparent + induced wind 
df_components, df_integrals, df_inlet_IC = save_results_to_file(myvlm, csys_transformations, inviscid_flow_results, s.sail_set, out.name, out.file_name)
import matplotlib. pyplot as plt
plt.savefig('rc44_fig', dpi=300)
Preparing visualization.

Lets see our integrals :)

print(f"-------------------------------------------------------------")
print(f"Notice:\n"
  f"\tThe forces [N] and moments [Nm] are without profile drag.\n"
  f"\tThe the _COG_ CSYS is aligned in the direction of the yacht movement (course over ground).\n"
  f"\tThe the _COW_ CSYS is aligned along the centerline of the yacht (course over water).\n"
  f"\tNumber of panels (sail s.sail_set with mirror): {s.sail_set.panels.shape}")

df_integrals
-------------------------------------------------------------
Notice:
	The forces [N] and moments [Nm] are without profile drag.
	The the _COG_ CSYS is aligned in the direction of the yacht movement (course over ground).
	The the _COW_ CSYS is aligned along the centerline of the yacht (course over water).
	Number of panels (sail s.sail_set with mirror): (1700, 4, 3)
Quantity Value
0 F_jib_total_COG.x -470.556668
1 F_jib_total_COG.y 1418.480440
2 F_jib_total_COG.z -159.681747
3 F_main_sail_total_COG.x -207.920071
4 F_main_sail_total_COG.y 1301.364733
5 F_main_sail_total_COG.z -320.100472
6 F_sails_total_COG.x -678.476739
7 F_sails_total_COG.y 2719.845174
8 F_sails_total_COG.z -479.782219
9 F_sails_total_COW.x -678.476739
10 F_sails_total_COW.y 2719.845174
11 F_sails_total_COW.z -479.782219
12 M_jib_total_COG.x -11113.392565
13 M_jib_total_COG.y -4166.427025
14 M_jib_total_COG.z 250.638726
15 M_keel_total_COG.x -3447.579043
16 M_keel_total_COG.y -826.359281
17 M_keel_total_COG.z 190.780072
18 M_keel_total_COW.x (heel) -3447.579043
19 M_keel_total_COW.y (pitch) -826.359281
20 M_keel_total_COW.z (yaw - JG sign) -190.780072
21 M_keel_total_COW.z (yaw) 190.780072
22 M_main_sail_total_COG.x -15351.724572
23 M_main_sail_total_COG.y -1938.226420
24 M_main_sail_total_COG.z 4976.656385
25 M_sails_total_COG.x -26465.117137
26 M_sails_total_COG.y -6104.653445
27 M_sails_total_COG.z 5227.295110
28 M_sails_total_COW.x (heel) -26465.117137
29 M_sails_total_COW.y (pitch) -6104.653445
30 M_sails_total_COW.z (yaw - JG sign) -5227.295110
31 M_sails_total_COW.z (yaw) 5227.295110
32 M_total_COG.x -29912.696180
33 M_total_COG.y -6931.012726
34 M_total_COG.z 5418.075182
35 M_total_COW.x (heel) -29912.696180
36 M_total_COW.y (pitch) -6931.012726
37 M_total_COW.z (yaw - JG sign) -5418.075182
38 M_total_COW.z (yaw) 5418.075182

Compute aerodynamic parameters:

Make model plot in 2D colored by pressure coefficients:

from pySailingVLM.solver.panels_plotter import plot_cp
plot_cp(sail_set.zero_mesh, myvlm.p_coeffs, out.name)
Loading BokehJS ...

Calculate section coefficient per each sail, plot results and save to file.

from pySailingVLM.solver.panels_plotter import plot_cp, plot_section_coeff
from pySailingVLM.solver.coefs import get_data_for_coeff_plot
mean_cp, cl_data, cd_data = get_data_for_coeff_plot(myvlm, solver)

plot_section_coeff(cd_data, mean_cp,  out.name,  'lift', ['blue', 'green'])
plot_section_coeff(cl_data, mean_cp, out.name,  'drag',  ['teal', 'purple'])

Thats all. Experiment and play with this code on your own.