def test_speed_multiplier_sideforce_by_element_fossati(): r"""Different speed multipliers.""" force = sideforce_by_element_fossati(boatspeed=4., heel_angle=20., leeway_angle=5., rudder_angle=5., coe=(0.5, 0., -0.1), projected_area=0.03, span=0.2, aspect_ratio_multiplier=2., use_cos_heel_angle=True, rudder_angle_influence=0.5, speed_multiplier=1.0) # force = spbef.force(boatspeed=4., # heel_angle=20., leeway_angle=5., rudder_angle=5.) force_if_mult = sideforce_by_element_fossati(boatspeed=4., heel_angle=20., leeway_angle=5., rudder_angle=5., coe=(0.5, 0., -0.1), projected_area=0.03, span=0.2, aspect_ratio_multiplier=2., use_cos_heel_angle=True, rudder_angle_influence=0.5, speed_multiplier=1.2) assert force_if_mult.fx / 1.2**2 - 1e-6 <= force.fx <= force_if_mult.fx / 1.2**2 + 1e-6 assert force_if_mult.fy / 1.2**2 - 1e-6 <= force.fy <= force_if_mult.fy / 1.2**2 + 1e-6
def test_coe_position_sideforce_by_element_fossati(): r"""Centre of effort position tests.""" force = sideforce_by_element_fossati(boatspeed=4., heel_angle=20., leeway_angle=5., rudder_angle=5., coe=(0.5, 0., -0.1), projected_area=0.03, span=0.2, aspect_ratio_multiplier=2., use_cos_heel_angle=True, rudder_angle_influence=0.5, rho_water=1025.) assert force.px == 0.5 assert force.py < 0. assert force.pz > -0.2167 force = sideforce_by_element_fossati(boatspeed=4., heel_angle=-20., leeway_angle=5., rudder_angle=5., coe=(0.5, 0., -0.1), projected_area=0.03, span=0.2, aspect_ratio_multiplier=2., use_cos_heel_angle=True, rudder_angle_influence=0.5, rho_water=1025.) assert force.px == 0.5 assert force.py > 0. assert force.pz > -0.2167
def test_rudder_angle_sideforce_by_element_fossati(): r"""Opposite rudder angles.""" force = sideforce_by_element_fossati(boatspeed=4., heel_angle=0., leeway_angle=0., rudder_angle=5., coe=(0.5, 0., -0.1), projected_area=0.03, span=0.2, aspect_ratio_multiplier=2., use_cos_heel_angle=True, rudder_angle_influence=0.5, rho_water=1025.) force_negative_rudder = \ sideforce_by_element_fossati(boatspeed=4., heel_angle=0., leeway_angle=0., rudder_angle=-5., coe=(0.5, 0., -0.1), projected_area=0.03, span=0.2, aspect_ratio_multiplier=2., use_cos_heel_angle=True, rudder_angle_influence=0.5, rho_water=1025.) assert force.fx == force_negative_rudder.fx assert force.fy == -force_negative_rudder.fy
def test_heel_angle_sideforce_sideforce_by_element_fossati(): r"""Symmetric situations, mirrored by XZ plane.""" force = sideforce_by_element_fossati(boatspeed=4., heel_angle=20., leeway_angle=4., rudder_angle=3., coe=(0.5, 0., -0.1), projected_area=0.03, span=0.2, aspect_ratio_multiplier=2., use_cos_heel_angle=True, rudder_angle_influence=0.5, rho_water=1025.) force_heeled_to_windward_negative_leeway = \ sideforce_by_element_fossati(boatspeed=4., heel_angle=-20., leeway_angle=-4., rudder_angle=-3., coe=(0.5, 0., -0.1), projected_area=0.03, span=0.2, aspect_ratio_multiplier=2., use_cos_heel_angle=True, rudder_angle_influence=0.5, rho_water=1025.) assert force.fy == -force_heeled_to_windward_negative_leeway.fy
def test_heel_angle_resistance_sideforce_by_element_fossati(): r"""x component of force with opposite heel angles should be equal.""" force = sideforce_by_element_fossati(boatspeed=4., heel_angle=20., leeway_angle=4., rudder_angle=3., coe=(0.5, 0., -0.1), projected_area=0.03, span=0.2, aspect_ratio_multiplier=2., use_cos_heel_angle=True, rudder_angle_influence=0.5, rho_water=1025.) force_heeled_to_windward_negative_leeway = \ sideforce_by_element_fossati(boatspeed=4., heel_angle=-20., leeway_angle=-4., rudder_angle=-3., coe=(0.5, 0., -0.1), projected_area=0.03, span=0.2, aspect_ratio_multiplier=2., use_cos_heel_angle=True, rudder_angle_influence=0.5, rho_water=1025.) assert force.fx == force_heeled_to_windward_negative_leeway.fx
def test_negative_projected_area_sideforce_by_element_fossati(): r"""Negative projected area.""" with pytest.raises(ValueError): sideforce_by_element_fossati(boatspeed=4., heel_angle=0., leeway_angle=4., rudder_angle=0., coe=(0.5, 0., -0.1), projected_area=-0.03, span=0.2, aspect_ratio_multiplier=2., use_cos_heel_angle=True, rudder_angle_influence=0.5, rho_water=1025.)
def test_sign_and_symmetry_sideforce_by_element_fossati(): r"""Test signs and symmetry.""" force = sideforce_by_element_fossati(boatspeed=4., heel_angle=0., leeway_angle=4., rudder_angle=0., coe=(0.5, 0., -0.1), projected_area=0.03, span=0.2, aspect_ratio_multiplier=2., use_cos_heel_angle=True, rudder_angle_influence=0.5, rho_water=1025.) force_backwards = sideforce_by_element_fossati(boatspeed=-4., heel_angle=0., leeway_angle=4., rudder_angle=0., coe=(0.5, 0., -0.1), projected_area=0.03, span=0.2, aspect_ratio_multiplier=2., use_cos_heel_angle=True, rudder_angle_influence=0.5, rho_water=1025.) force_nose_down = sideforce_by_element_fossati(boatspeed=4., heel_angle=0., leeway_angle=-4., rudder_angle=0., coe=(0.5, 0., -0.1), projected_area=0.03, span=0.2, aspect_ratio_multiplier=2., use_cos_heel_angle=True, rudder_angle_influence=0.5, rho_water=1025.) assert force.fx == -force_backwards.fx assert force.fy == -force_nose_down.fy assert force.fx < 0
def test_zero_boatspeed_sideforce_by_element_fossati(): r"""Zero boatspeed.""" f = sideforce_by_element_fossati(boatspeed=0., heel_angle=0., leeway_angle=4., rudder_angle=0., coe=(0.5, 0., -0.1), projected_area=0.03, span=0.2, aspect_ratio_multiplier=2., use_cos_heel_angle=True, rudder_angle_influence=0.5, rho_water=1025.) assert f.fx == 0. assert f.fy == 0. assert f.fz == 0.
#!/usr/bin/env python # coding: utf-8 r"""Tests for the sideforce.py module.""" import pytest from ydeos_hydrodynamics.sideforce import sideforce_by_element_fossati, \ sideforce_production_keuning_verwerft from ydeos_forces.forces import Force, SystemOfForces spbef = sideforce_by_element_fossati(boatspeed=4., heel_angle=0., leeway_angle=4., rudder_angle=0., coe=(0.5, 0., -0.1), projected_area=0.03, span=0.2, aspect_ratio_multiplier=2., use_cos_heel_angle=True, rudder_angle_influence=0.5, rho_water=1025.) def test_known_value_sideforce_by_element_fossati(): r"""No know data.""" assert True def test_zero_boatspeed_sideforce_by_element_fossati(): r"""Zero boatspeed.""" f = sideforce_by_element_fossati(boatspeed=0., heel_angle=0.,