Add forced touchdown mode to prevent floating-point precision issues - #41
Conversation
- 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.
📝 WalkthroughWalkthroughBumps 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
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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_modeparameter 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.
There was a problem hiding this comment.
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.
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
Documentation
Chores