Skip to content

Commit

Permalink
Merge pull request #33 from marinlauber/28-kite-crash
Browse files Browse the repository at this point in the history
Fixed bug in code for plotting single sail set performance
  • Loading branch information
marinlauber authored Feb 19, 2024
2 parents b2a46f8 + 8984d53 commit c2f291c
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ venv
dev.py
/.pytest_cache
/__pycache__/
.pytest_cache
2 changes: 1 addition & 1 deletion src/UtilsMod.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def _get_vmg(dat, twa_range):
if dat.shape[1] == 1: # if only one sails, it has both VMGs
up = np.argmax(dat[:, 0, 0] * np.cos(twa_range / 180 * np.pi))
dn = np.argmax(-dat[:, 0, 0] * np.cos(twa_range / 180 * np.pi))
return np.array([up, dn]), 0, 0
return np.array([up, dn]), np.array([0, 0])
else:
up = np.zeros(dat.shape[1])
dn = np.zeros(dat.shape[1])
Expand Down
7 changes: 0 additions & 7 deletions tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import io
import json
import os
import tempfile
import zipfile

import numpy as np
import pytest
from PIL import Image

from src.api import app


def test_ping_route():
client = app.test_client()
response = client.get("/ping")
Expand Down
28 changes: 28 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from src.SailMod import Jib, Kite, Main
from src.YachtMod import Keel, Rudder, Yacht

def return_YD41_particulars():

YD41 = Yacht(
Name="YD41",
Lwl=11.90,
Vol=6.05,
Bwl=3.18,
Tc=0.4,
WSA=28.20,
Tmax=2.30,
Amax=1.051,
Mass=6500,
Ff=1.5,
Fa=1.5,
Boa=4.2,
Loa=12.5,
App=[Keel(Cu=1.00, Cl=0.78, Span=1.90), Rudder(Cu=0.48, Cl=0.22, Span=1.15)],
Sails=[
Main("MN1", P=16.60, E=5.60, Roach=0.1, BAD=1.0),
Jib("J1", I=16.20, J=5.10, LPG=5.40, HBI=1.8),
Kite("A2", area=150.0, vce=9.55),
Kite("A5", area=75.0, vce=2.75),
],
)
return YD41
26 changes: 26 additions & 0 deletions tests/test_vpp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

import numpy as np

from tests.test_utils import return_YD41_particulars
from src.VPPMod import VPP
from src.SailMod import Jib, Main

def test_single_sail_set():
YD41 = return_YD41_particulars()

YD41_no_kite = YD41
YD41_no_kite.sails = [
Main("MN1", P=16.60, E=5.60, Roach=0.1, BAD=1.0),
Jib("J1", I=16.20, J=5.10, LPG=5.40, HBI=1.8)
]

vpp = VPP(Yacht=YD41)

vpp.set_analysis(
tws_range=np.arange(4.0, 6.0, 1.0), twa_range=np.linspace(30.0, 180.0, 3)
)

vpp.run(verbose=False)
vpp.write("results")
vpp.polar(3, False)
vpp.SailChart(False)

0 comments on commit c2f291c

Please sign in to comment.