Skip to content

Residuary resistance surface: LVR and BTR axes look swapped in HydroMod.__load_data #70

Closed

Description

@pclusius

Version: commit 141ea66 (main).

What I see

src/python_vpp/dat/ORCi_Drag_Surfaces.csv has the title RRmult(lvr_i,btr_j). In each Fn block the first column (the row labels) runs 3 … 9 and the header row (the column labels) runs 2.5 … 9. So rows are indexed by lvr_i and columns by btr_j, if the title is read literally.

HydroMod.__load_data does the opposite:

btr = surf[0, 2:, 0]      # first column  -> 3 … 9   (row labels)
lvr = surf[0, 1, 1:]      # header row    -> 2.5 … 9 (column labels)
...
self._interp_Rr = RegularGridInterpolator((fn, btr, lvr), data, ...)

The comment just above says y is btr := [2.5,9], z is lvr := [3,9]. That matches the ranges of the file's columns and rows respectively, so the comment and the code disagree with each other as well.

The table values agree with the file title. At Fn = 0.4 and column label 5.1 the multiplier changes strongly along the rows (labels 3, 4, …, 9: 14.5, 25.2, 27.6, 24.2, 18.0, 14.0, 10.9). Along the columns at row label 6 it changes only a little (labels 3 … 9: 25.2, 24.7, 24.2, 24.2, 24.4, 25.2, 25.9). Residuary resistance per unit displacement depends mainly on slenderness (LVR), so the row axis is LVR.

Effect

_get_Rr then evaluates _interp_Rr((fn, self.btr, self.lvr)), i.e. with the two ratios exchanged relative to the file's layout. The effect depends on the boat. When LVR and BTR are close (e.g. 5.14 / 4.42) it is small (3 %). For a slender boat it is larger (my numbers, Fn 0.4, h._interp_Rr as coded vs. with lvr/btr exchanged: LVR 7.0, BTR 3.5: 21.0 vs 18.6, i.e. +13 %; Fn 0.3, LVR 8.0, BTR 4.0: 3.3 vs 2.2, i.e. +50 %).

Reproduce

import numpy as np
s = np.genfromtxt("src/python_vpp/dat/ORCi_Drag_Surfaces.csv", delimiter=",", skip_header=1).reshape((24, 43, 42))
fns = [s[i, 0, 3] for i in range(24)]
k = int(np.argmin([abs(f - 0.4) for f in fns]))
rows, cols = s[k, 2:, 0], s[k, 1, 1:]            # 3..9 and 2.5..9
print(s[k, 2:, 17][::8])                            # down the rows
print(s[k, 2 + 19, 1:][::8])                        # along the columns

Suggested fix

Swap the two assignments (lvr = surf[0, 2:, 0], btr = surf[0, 1, 1:]) and the order in RegularGridInterpolator, and in _get_Rr pass (fn, self.lvr, self.btr). I have been working around this in-process by exchanging the two arguments in _interp_Rr, not by editing the package.

Caveat: this is based on the file title and the shape of the data. I have not seen the original ORC source table. If the ORC table is really organised the other way and the title is wrong, the title and the comment still need correcting.

Activity

  1. marinlauber commented on Nov 13, 2026

    @marinlauber
    Owner

    @pclusius that is a great pick!
    I think you are correct, thanks a lot for tracking this down.
    I've just opened a PR #71 that fixes it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions