Skip to content

Fix NameError in Subsystem.getYawStiffness (undefined 'l')#68

Merged
shousner merged 1 commit into
NatLabRockies:devfrom
gaoflow:fix/subsystem-yawstiffness-undefined-l
Jun 4, 2026
Merged

Fix NameError in Subsystem.getYawStiffness (undefined 'l')#68
shousner merged 1 commit into
NatLabRockies:devfrom
gaoflow:fix/subsystem-yawstiffness-undefined-l

Conversation

@gaoflow

@gaoflow gaoflow commented Jun 1, 2026

Copy link
Copy Markdown

Calling Subsystem.getYawStiffness() always raises NameError: name 'l' is not defined.

The bug

def getYawStiffness(self):
    tau0 = -self.fB[0]  # horizontal tension component [N]
    yaw_stiff = (tau0/l)*self.rad_fair**2 + tau0*self.rad_fair  # [N-m]   # <- l undefined
    return yaw_stiff

l is never assigned in the method (no local, no attribute, no global), so every call fails. git blame points to commit 2f330c8 "Subsystem updates for span consistency" — the rename of the line length to span missed this one site, leaving the stale l.

The fix

Use self.span (the horizontal end-to-end distance, set in __init__), which is the length the formula intends:

yaw_stiff = (tau0/self.span)*self.rad_fair**2 + tau0*self.rad_fair  # [N-m]

Dimensionally consistent: [N]/[m]·[m²] + [N]·[m] = [N·m].

Reproduction (before this PR)

import numpy as np
import moorpy as mp

ss = mp.Subsystem(depth=100, span=200, rad_fair=10, z_fair=-10)
ss.fB = np.array([-1.0e5, 0.0, 5.0e4])   # horizontal fairlead force
ss.getYawStiffness()        # -> NameError: name 'l' is not defined

Verification

  • New regression test tests/test_subsystem.py::test_getYawStiffness_runs asserts the call returns the documented value (tau0/span)*rad_fair**2 + tau0*rad_fair. It fails on dev (NameError) and passes with this fix.
  • Full test suite: 29 passed.

getYawStiffness computed (tau0/l)*rad_fair**2 + tau0*rad_fair, but 'l'
was never defined in the method, so every call raised
'NameError: name "l" is not defined'. The variable is a leftover from
the rename of the line length to 'span' (commit 2f330c8, "Subsystem
updates for span consistency") which missed this one site.

Use self.span (the horizontal end-to-end distance) as intended, and add
a regression test exercising the formula.
@shousner shousner merged commit 0f9ab41 into NatLabRockies:dev Jun 4, 2026
31 checks passed
@shousner

shousner commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Note to self that Subsystem.getYawStiffness() is not used anywhere within MoorPy or FAD-Toolset (but LineDesign does have its own getYawStiffness method, which is not exactly the same)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants