diff --git a/Figure.png b/Figure.png index cc71e54..6ca8dae 100644 Binary files a/Figure.png and b/Figure.png differ diff --git a/Polars.pdf b/Polars.pdf new file mode 100644 index 0000000..092e4b1 Binary files /dev/null and b/Polars.pdf differ diff --git a/Polars.png b/Polars.png deleted file mode 100644 index cc71e54..0000000 Binary files a/Polars.png and /dev/null differ diff --git a/README.md b/README.md index d9c66a3..592b128 100644 --- a/README.md +++ b/README.md @@ -6,17 +6,38 @@ Please see the demo hosted at [https://yacht-vpp.streamlit.app/](https://yacht-v ## Using the code -To use the code, first clone or download this repository then install the required dependencies (see below). +The project is managed with [uv](https://docs.astral.sh/uv/). Install it once (see the [uv docs](https://docs.astral.sh/uv/getting-started/installation/) for other methods): + +```bash +curl -LsSf https://astral.sh/uv/install.sh | sh +``` + +Then clone the repository and install the dependencies into a local `.venv`: + +```bash +git clone https://github.com/marinlauber/Python-VPP.git +cd Python-VPP +uv sync +``` The main files that are used are `runVPP.py` and `righting_moment.json`. These have to be filled with the data of your boat. By default they are using the YD-41 (from Principle of Yacht Design). -The VPP is run with. +The VPP is run from the root of the repository with ```bash -$ python runVPP.py +uv run python runVPP.py ``` -Once the code has run, it should generate the following figure (or a similar one) +At each TWS/TWA the boat speed is maximised over boat speed, heel, leeway, sail flattening and reefing, subject to force and moment equilibrium (SLSQP). `VPP.set_analysis` takes an optional maximum heel angle (`phi_max`, default 35 degrees); the sails are only flattened (down to flat = 0.53) and reefed as much as is fastest within it, following the ORC VPP 2026 depowering scheme. Kites are further limited to their own `max_heel` (default 21.5 degrees, the ORC limit under spinnaker). Points where a sail set cannot be carried within its heel limit are left at 0 and not plotted. The apparent wind follows the ORC heeled wind triangle: TWS is taken at 10 m and scaled to the sail plan's centre of effort with a log wind profile (z0 = 0.005 m), and its cross-track component is reduced by cos(heel). Appendage drag follows the ORC strip friction, form factor and lift-dependent drag, and the induced drag the ORC rudder ramp (zero lift upright), heel multiplier and free-surface/funsteady span corrections. Appendage lift uses the geometric aspect ratio span²/area, doubled for the reflection in the hull, in a lifting-line lift-curve slope (Jones slender-wing slope for short keels). `VPP.run` accepts `method="sequential"` (default) or `"parallel"` (same results, spread over all CPU cores). + +To run the Streamlit demo locally: + +```bash +uv sync --extra demo --extra api +uv run streamlit run demos/Home.py +``` + +The run writes the results to `results.json` and saves the polars (`Polars.pdf`) and the sail chart (`SailChart.pdf`) as PDF, so the curves stay sharp when zoomed. For the YD-41 the polars look like this (`Figure.png` is a PNG copy of `Polars.pdf` for this page)

YD-41 VPP results @@ -32,6 +53,7 @@ Here is a list of the key variables used in the VPP. * Cu : Root Chord / Upper Chord (m) * Cl : Tip Chord / Lower Chord (m) * Span : Span (m) + * Tc_ratio : thickness/chord ratio for the ORC form factor (keel 0.20, rudder 0.10 by default) 1. Yacht : * Lwl : Length waterline (m) * Vol : Displ. volume of canoebody (m^3) @@ -49,7 +71,8 @@ Here is a list of the key variables used in the VPP. * Sails : List of Sails 1. Sails: Standard measurements, except Roach is defined as 1-A/(0.5PE) - Kite only takes area and vce estimate (this is very rough) + HBI (jib) is the height of the base of I above the waterline; sail centres of effort (kite vce) are measured from it + Kite only takes area and vce estimate (this is very rough), min_reef (default 0.85) for depowering and max_heel (default 21.5 degrees) 1. VPP.set_analysis() * TWA range : range of TWA to use * TWS range : range of TWS, must be between [2, 35] @@ -64,16 +87,18 @@ Follow the steps below to contribute to this project. ### Install dependencies -Install the project using [uv](https://docs.astral.sh/uv/): +Install the project with the development tools (pytest, ruff, mypy) and the API dependencies: ```bash -uv sync --extra dev +uv sync --extra dev --extra api ``` -If using `pip`: +Note that `uv sync` removes extras that are not listed, so pass every extra you need (or use `uv sync --all-extras`). + +If using `pip` instead: ```bash -pip install -e ".[dev]" +pip install -e ".[dev,api]" ``` ### Run tests @@ -83,13 +108,13 @@ Tests are implemented using [pytest](https://docs.pytest.org/en/8.0.x/). You can run tests with ```bash -pytest -vv +uv run pytest -vv ``` -You can run a benchmark against the YD-41 results from WinVPP by running the `benchmark.py` script. +You can run a benchmark against the YD-41 results from WinVPP by running the `benchmark.py` script (`-g` saves the polars as one `Figure_