Skip to content

Add forced touchdown mode to prevent floating-point precision issues - #41

Merged
pillowbeast merged 3 commits into
mainfrom
bugfix-brentq
Feb 3, 2026
Merged

Add forced touchdown mode to prevent floating-point precision issues#41
pillowbeast merged 3 commits into
mainfrom
bugfix-brentq

Conversation

@pillowbeast

@pillowbeast pillowbeast commented Feb 2, 2026

Copy link
Copy Markdown
Collaborator

Explicit Touchdown Mode Control

This PR addresses floating-point precision errors in touchdown mode boundary calculations by introducing a manual override system. It also bumps the project version to v3.1.3 across all configuration and metadata files.

🛠️ Key Changes
Manual Touchdown Control (Bug Fix)
New Configuration: Added forced_touchdown_mode to the Config class, allowing users to explicitly define the touchdown state.

Logic Override: Updated the SlabTouchdown class to prioritize the forced_mode parameter over automatic calculation, preventing inconsistent behavior caused by numerical drift.

API Propagation: Modified SystemModel to include a set_forced_touchdown_mode method, ensuring consistency in the steady-state evaluator during parameter shifts.

Summary by CodeRabbit

Release Notes - v3.1.3

  • New Features

    • Added configuration option to force a specific touchdown mode instead of automatic calculation
  • Documentation

    • Updated installation guides to reference the latest release version
  • Chores

    • Bumped version to 3.1.3

- Introduce forced touchdown mode in the system model to mitigate floating-point precision issues.
- Update criteria evaluator and slab touchdown classes to support forced mode.
- Modify configuration to allow specification of forced touchdown mode, improving stability in calculations.
Copilot AI review requested due to automatic review settings February 2, 2026 21:36
@coderabbitai

coderabbitai Bot commented Feb 2, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Bumps package version to 3.1.3 and adds a configurable override for slab touchdown selection: a new TouchdownMode type, a Config.forced_touchdown_mode field, plumbing to pass that into SlabTouchdown, a SystemModel API to set it, and usage in the steady-state evaluator to lock the mode.

Changes

Cohort / File(s) Summary
Version bump
CITATION.cff, pyproject.toml, src/weac/__init__.py, demo/demo.ipynb
Update version from 3.1.2 → 3.1.3 in metadata, packaging, package version, and demo text.
Touchdown mode type & export
src/weac/components/scenario_config.py, src/weac/components/__init__.py
Add TouchdownMode alias (Literal of three mode strings) and export it via weac.components package surface.
Config field
src/weac/components/config.py
Add `forced_touchdown_mode: TouchdownMode
SlabTouchdown core
src/weac/core/slab_touchdown.py
Add forced_mode parameter to SlabTouchdown.init, store as _forced_mode, and make _calc_touchdown_mode use forced mode when present (otherwise keep threshold logic).
SystemModel integration
src/weac/core/system_model.py
Import TouchdownMode, pass config.forced_touchdown_mode into SlabTouchdown instantiation, add `SystemModel.set_forced_touchdown_mode(mode: TouchdownMode
Evaluator usage
src/weac/analysis/criteria_evaluator.py
After scenario update in evaluate_SteadyState, call system_copy.set_forced_touchdown_mode(mode) to lock the touchdown mode before recomputation.

Sequence Diagram(s)

sequenceDiagram
    participant CriteriaEval as CriteriaEvaluator
    participant SystemModel as SystemModel
    participant Config as Config
    participant SlabTouchdown as SlabTouchdown

    CriteriaEval->>SystemModel: update scenario parameters
    CriteriaEval->>SystemModel: set_forced_touchdown_mode(mode)
    SystemModel->>Config: set forced_touchdown_mode = mode
    SystemModel->>SystemModel: invalidate slab_touchdown & constants caches
    SystemModel->>SlabTouchdown: instantiate with forced_mode=mode
    SlabTouchdown->>SlabTouchdown: _calc_touchdown_mode()
    alt forced_mode is set
        SlabTouchdown->>SlabTouchdown: use forced_mode (skip thresholds)
    else
        SlabTouchdown->>SlabTouchdown: compute mode via thresholds
    end
    SlabTouchdown-->>SystemModel: return touchdown mode
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Packaging/hotfix #29 — touches package metadata/versioning (pyproject.toml, CITATION.cff, src/weac/init.py); likely related to the version bump.
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: adding a forced touchdown mode feature to prevent floating-point precision issues, which aligns with the core objective of the pull request.
Docstring Coverage ✅ Passed Docstring coverage is 87.50% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix-brentq

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes floating-point precision issues in touchdown mode calculation by introducing a forced touchdown mode feature. The changes allow the touchdown mode to be explicitly set rather than recalculated from l_AB/l_BC thresholds when scenario parameters change, preventing boundary condition inconsistencies.

Changes:

  • Added forced_touchdown_mode parameter to configuration and touchdown calculation
  • Implemented set_forced_touchdown_mode() method in SystemModel to control touchdown behavior
  • Updated version from 3.1.2 to 3.1.3 across project files

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/weac/core/system_model.py Added forced_touchdown_mode parameter handling and new setter method
src/weac/core/slab_touchdown.py Modified touchdown mode calculation to use forced mode when provided
src/weac/components/config.py Added TouchdownMode type and forced_touchdown_mode configuration field
src/weac/analysis/criteria_evaluator.py Applied forced touchdown mode in steady state evaluation
src/weac/init.py Updated package version to 3.1.3
pyproject.toml Updated project version to 3.1.3
demo/demo.ipynb Updated version reference in documentation
CITATION.cff Updated citation version to 3.1.3

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/weac/components/config.py

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@CITATION.cff`:
- Around line 11-12: CITATION.cff has a version bump to "3.1.3" but the
"date-released" field still reads "2021-12-30"; update the "date-released" value
to the actual release date for version 3.1.3 (or explicitly document in the PR
that you intentionally leave it unchanged per project convention). Edit the
"date-released" field in CITATION.cff to the correct ISO date string matching
the 3.1.3 release or add a brief comment in the PR description if no change is
desired.

In `@src/weac/components/config.py`:
- Around line 17-18: The TouchdownMode Literal alias is duplicated; remove the
local definition in config.py and import TouchdownMode from the canonical source
in weac.core.slab_touchdown so there is a single authoritative type. Update any
local references in config.py to use the imported TouchdownMode symbol, and
ensure the slab_touchdown module exports that alias (or create/export it there)
so imports succeed and type-checking remains consistent across the codebase.

In `@src/weac/core/slab_touchdown.py`:
- Around line 127-144: The forced_mode handling in the assign-stage must
validate that self._forced_mode is consistent with the current thresholds
(self.scenario.cut_length, self.l_AB, self.l_BC) to avoid invalid downstream
calculations; add a guard in the block that checks if self._forced_mode is one
of the allowed values ("A_free_hanging", "B_point_contact", "C_in_contact") and
that it matches the interval implied by cut_length (use a small tolerance, e.g.,
1e-6), and if it does not either raise a clear ValueError explaining the
mismatch or fall back to auto-selection (recompute touchdown_mode from
thresholds) before proceeding with touchdown_mode assignment and logging.

Comment thread CITATION.cff
Comment thread src/weac/components/config.py Outdated
Comment thread src/weac/core/slab_touchdown.py
@pillowbeast pillowbeast changed the title Bugfix-brentq Add forced touchdown mode to prevent floating-point precision issues Feb 2, 2026
@pillowbeast
pillowbeast merged commit 8e45268 into main Feb 3, 2026
4 of 7 checks passed
@pillowbeast
pillowbeast deleted the bugfix-brentq branch February 3, 2026 09:01
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