Sail with camber#

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.

# 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./8, 1./4, 1./2, 3./4, 7./8, 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='my_file_name')

solver = Solver(n_spanwise=15,
                n_chordwise=4,
                interpolation_type='spline')

conditions = Conditions(leeway_deg=5.,    
                        heel_deg=10.,    
                        SOG_yacht=4.63,  
                        tws_ref= 4.63,     
                        alpha_true_wind_deg= 50., 
                        reference_water_level_for_wind_profile=-0.,
                        wind_exp_coeff=0.1428,
                        wind_reference_measurment_height=10.,
                        rho=1.225,
                        wind_profile='exponential',
                        roughness=0.05)


rig = Rig(main_sail_luff=12.4,
          jib_luff=10.0,
          foretriangle_height=11.50,
          foretriangle_base=3.90,
          sheer_above_waterline=1.2,
          boom_above_sheer=1.3,
          rake_deg=92.,
          mast_LOA=0.15,
          sails_def='jib_and_main')

main = MainSail(centerline_twist_deg=None,
                girths=np.array([0.00, 1./8, 1./4, 1./2, 3./4, 7./8, 1.00]),
                chords=np.array([4.00, 3.82, 3.64, 3.20, 2.64, 2.32, 2.00]),
                camber=5*np.array([0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01]),
                camber_distance_from_luff=np.array([0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5]))

jib = JibSail(centerline_twist_deg=None,
             girths=np.array([0.00, 1./4, 1./2, 3./4, 1.00]),
             chords=np.array([3.80, 2.98, 2.15, 1.33, 0.5]),
             camber=0*np.array([0.01, 0.01, 0.01, 0.01, 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.0]))
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('sailing_fig')
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): (240, 4, 3)
Quantity Value
0 F_jib_total_COG.x -194.910017
1 F_jib_total_COG.y 446.957244
2 F_jib_total_COG.z -32.279372
3 F_main_sail_total_COG.x -390.594481
4 F_main_sail_total_COG.y 1113.411846
5 F_main_sail_total_COG.z -213.001146
6 F_sails_total_COG.x -585.504498
7 F_sails_total_COG.y 1560.369090
8 F_sails_total_COG.z -245.280518
9 F_sails_total_COW.x -719.271604
10 F_sails_total_COW.y 1503.401335
11 F_sails_total_COW.z -245.280518
12 M_jib_total_COG.x -2352.912026
13 M_jib_total_COG.y -1155.077251
14 M_jib_total_COG.z -681.331651
15 M_keel_total_COG.x -1579.094015
16 M_keel_total_COG.y -580.321551
17 M_keel_total_COG.z 77.669591
18 M_keel_total_COW.x (heel) -1522.506729
19 M_keel_total_COW.y (pitch) -715.740364
20 M_keel_total_COW.z (yaw - JG sign) -77.669591
21 M_keel_total_COW.z (yaw) 77.669591
22 M_main_sail_total_COG.x -9718.978453
23 M_main_sail_total_COG.y -3203.265665
24 M_main_sail_total_COG.z 2436.064550
25 M_sails_total_COG.x -12071.890479
26 M_sails_total_COG.y -4358.342915
27 M_sails_total_COG.z 1754.732899
28 M_sails_total_COW.x (heel) -11646.098677
29 M_sails_total_COW.y (pitch) -5393.892686
30 M_sails_total_COW.z (yaw - JG sign) -1754.732899
31 M_sails_total_COW.z (yaw) 1754.732899
32 M_total_COG.x -13650.984493
33 M_total_COG.y -4938.664467
34 M_total_COG.z 1832.402491
35 M_total_COW.x (heel) -13168.605406
36 M_total_COW.y (pitch) -6109.633050
37 M_total_COW.z (yaw - JG sign) -1832.402491
38 M_total_COW.z (yaw) 1832.402491

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.