Bugfix slab criterion + Weac Layer Presets + Regression Test Steady State#45
Bugfix slab criterion + Weac Layer Presets + Regression Test Steady State#45pillowbeast merged 12 commits intomainfrom
Conversation
…alized mode - Bug Fix: generalized backend was invokable with slab touchdown - Refactored force decomposition tests in `test_misc.py` to include rotation angle (theta) and use x/y/z notation
…n not level of failure
…lized, leading to unexpected behaviour
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (15)
✨ 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 parts of the SteadyState / slab tensile criterion evaluation, adds reusable WeakLayer presets, and hardens runtime configuration validation around backend/touchdown compatibility, along with expanded regression testing.
Changes:
- Add
WeakLayerpresets + helper factory for preset instantiation/overrides. - Enforce
touchdown=Trueonly forbackend="classic"via Pydantic validators (incl. assignment validation) and add tests. - Adjust maximal stress evaluation resolution (
dz=1) and correct slab tensile criterion computation; add extensive SteadyState regression tests.
Reviewed changes
Copilot reviewed 12 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/weac/components/config.py |
Adds assignment-time + model-level validation to prevent incompatible backend/touchdown combinations. |
src/weac/components/presets.py |
Introduces named WeakLayer presets and weak_layer_from_preset helper. |
src/weac/components/__init__.py |
Exposes presets and factory via package exports. |
src/weac/analysis/criteria_evaluator.py |
Increases stress mesh resolution and fixes slab tensile criterion logic. |
src/weac/analysis/analyzer.py |
Fixes generalized backend ERR calls by using positional args matching the generalized API signature. |
tests/components/test_configs.py |
Adds tests for constructor + assignment validation of config constraints. |
tests/utils/test_misc.py |
Updates decomposition tests to explicitly pass theta and use (fx, fy, fz) outputs. |
tests/analysis/test_criteria_evaluator.py |
Adds many SteadyState structure/behavior/regression tests, including numeric baselines. |
pyproject.toml |
Updates optional dependency constraints for ipykernel. |
uv.lock |
Lockfile updated to match new ipykernel constraints. |
.gitignore |
Un-ignores .env.example so it can be committed. |
.cursorignore |
Stops ignoring /demo/ so it can be tracked by Cursor tooling. |
Comments suppressed due to low confidence (1)
pyproject.toml:66
- Same concern as the
interactiveextra: the dev extra now requiresipykernel>=7.1.0, which appears inconsistent with the stated goal of improving compatibility and may refer to a nonexistent version. Please verify and adjust the constraint accordingly.
# Jupyter stack for interactive development
"jupyter",
"ipython>=8.37.0",
"ipykernel>=7.1.0",
"jupyter_client>=8.6.3",
"jupyter_core>=5.8.1",
"matplotlib-inline>=0.1.7",
"nest-asyncio>=1.6.0",
"pyzmq>=27.0.1",
"tornado>=6.5.2",
"traitlets>=5.14.3",
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| interactive = [ | ||
| "jupyter", | ||
| "ipython>=8.37.0", | ||
| "ipykernel>=6.30.1", | ||
| "ipykernel>=7.1.0", | ||
| "jupyter_client>=8.6.3", | ||
| "jupyter_core>=5.8.1", |
There was a problem hiding this comment.
The PR description says the minimum ipykernel version was lowered for compatibility, but this change raises it (from 6.30.1 to 7.1.0). Either update the description or adjust the requirement to reflect the intended compatibility range.
| # Allow small tolerances for numerical precision | ||
| np.testing.assert_allclose( | ||
| result.touchdown_distance, | ||
| expected_touchdown_distance, | ||
| rtol=1e-4, | ||
| err_msg="Touchdown distance changed unexpectedly", | ||
| ) | ||
| np.testing.assert_allclose( | ||
| result.energy_release_rate, | ||
| expected_err, | ||
| rtol=1e-4, | ||
| err_msg="Energy release rate changed unexpectedly", | ||
| ) | ||
| np.testing.assert_allclose( | ||
| result.maximal_stress_result.max_principal_stress_norm, | ||
| expected_max_principal_stress_norm, | ||
| rtol=1e-4, | ||
| err_msg="Max principal stress norm changed unexpectedly", | ||
| ) | ||
| np.testing.assert_allclose( | ||
| result.maximal_stress_result.max_Sxx_norm, | ||
| expected_max_Sxx_norm, | ||
| rtol=1e-4, | ||
| err_msg="Max Sxx norm changed unexpectedly", | ||
| ) | ||
| np.testing.assert_allclose( | ||
| result.maximal_stress_result.slab_tensile_criterion, | ||
| expected_slab_tensile_criterion, | ||
| rtol=1e-4, |
There was a problem hiding this comment.
These regression assertions hard-code very specific floating-point outputs with a tight rtol=1e-4. This is likely to be flaky across platforms/BLAS/Python/Numpy versions; consider relaxing tolerances (and/or using atol) or asserting on more stable invariants (sign, bounds, ordering) to avoid brittle CI failures.
| # Allow small tolerances for numerical precision | |
| np.testing.assert_allclose( | |
| result.touchdown_distance, | |
| expected_touchdown_distance, | |
| rtol=1e-4, | |
| err_msg="Touchdown distance changed unexpectedly", | |
| ) | |
| np.testing.assert_allclose( | |
| result.energy_release_rate, | |
| expected_err, | |
| rtol=1e-4, | |
| err_msg="Energy release rate changed unexpectedly", | |
| ) | |
| np.testing.assert_allclose( | |
| result.maximal_stress_result.max_principal_stress_norm, | |
| expected_max_principal_stress_norm, | |
| rtol=1e-4, | |
| err_msg="Max principal stress norm changed unexpectedly", | |
| ) | |
| np.testing.assert_allclose( | |
| result.maximal_stress_result.max_Sxx_norm, | |
| expected_max_Sxx_norm, | |
| rtol=1e-4, | |
| err_msg="Max Sxx norm changed unexpectedly", | |
| ) | |
| np.testing.assert_allclose( | |
| result.maximal_stress_result.slab_tensile_criterion, | |
| expected_slab_tensile_criterion, | |
| rtol=1e-4, | |
| # Allow small tolerances for numerical precision (relaxed to avoid platform-specific flakiness) | |
| np.testing.assert_allclose( | |
| result.touchdown_distance, | |
| expected_touchdown_distance, | |
| rtol=1e-3, | |
| atol=1e-6, | |
| err_msg="Touchdown distance changed unexpectedly", | |
| ) | |
| np.testing.assert_allclose( | |
| result.energy_release_rate, | |
| expected_err, | |
| rtol=1e-3, | |
| atol=1e-6, | |
| err_msg="Energy release rate changed unexpectedly", | |
| ) | |
| np.testing.assert_allclose( | |
| result.maximal_stress_result.max_principal_stress_norm, | |
| expected_max_principal_stress_norm, | |
| rtol=1e-3, | |
| atol=1e-6, | |
| err_msg="Max principal stress norm changed unexpectedly", | |
| ) | |
| np.testing.assert_allclose( | |
| result.maximal_stress_result.max_Sxx_norm, | |
| expected_max_Sxx_norm, | |
| rtol=1e-3, | |
| atol=1e-6, | |
| err_msg="Max Sxx norm changed unexpectedly", | |
| ) | |
| np.testing.assert_allclose( | |
| result.maximal_stress_result.slab_tensile_criterion, | |
| expected_slab_tensile_criterion, | |
| rtol=1e-3, | |
| atol=1e-6, |
| segments = [ | ||
| Segment(length=self.segments_length, has_foundation=True, m=0), | ||
| Segment(length=self.segments_length, has_foundation=True, m=0), | ||
| ] | ||
| system = SystemModel( |
There was a problem hiding this comment.
This added block introduces many nearly-identical SteadyState test setups (segments/system construction repeated across tests). Consider factoring out a small helper (or parametrizing) to reduce duplication and keep the suite maintainable; it will also make it easier to adjust shared inputs if the solver API changes.
Config validation and safety:
Configclass now includes field and model validators to enforce thattouchdown=Trueis only allowed whenbackend='classic'. This validation is triggered both during object creation and on assignment, preventing invalid configurations from being set. (src/weac/components/config.py[1] [2] [3]Presets and code organization:
presets.pymodule with named presets forWeakLayer(e.g.,VERY_WEAK_LAYER,WEAK_LAYER, etc.), and a helper functionweak_layer_from_preset. The__init__.pywas updated to expose these presets and maintain import order. (src/weac/components/presets.py[1]src/weac/components/__init__.py[2]Test enhancements:
tests/components/test_configs.pytests/components/test_configs.pyR33-R106)thetaparameter, improving clarity and robustness. (tests/utils/test_misc.py[1] [2] [3] [4] [5]Analysis and criteria evaluation fixes:
_calculate_maximal_stressesto use a finerdz=1(instead ofdz=5) for better resolution, and fixed the slab failure criterion. (src/weac/analysis/criteria_evaluator.pysrc/weac/analysis/criteria_evaluator.pyL1269-R1280)differential_ERRfor consistency. (src/weac/analysis/analyzer.pysrc/weac/analysis/analyzer.pyL748-R749)Dependency and housekeeping:
ipykernelin both interactive and dev dependencies to improve compatibility. (pyproject.toml[1] [2]/demo/from.cursorignoreto ensure it is tracked. (.cursorignore.cursorignoreL4)