Skip to content

Bugfix slab criterion + Weac Layer Presets + Regression Test Steady State#45

Merged
pillowbeast merged 12 commits intomainfrom
bugfix-slab-criterion
Feb 25, 2026
Merged

Bugfix slab criterion + Weac Layer Presets + Regression Test Steady State#45
pillowbeast merged 12 commits intomainfrom
bugfix-slab-criterion

Conversation

@pillowbeast
Copy link
Collaborator

@pillowbeast pillowbeast commented Feb 25, 2026

  • BugFix: Slab Criterion calculation
  • Addition: Weak Layer Presets
  • Tests: Regression Tests Steady State
  • BugFix: Generalized Backend + Touchdown also not possible in mutation

Config validation and safety:

  • The Config class now includes field and model validators to enforce that touchdown=True is only allowed when backend='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:

  • Added a new presets.py module with named presets for WeakLayer (e.g., VERY_WEAK_LAYER, WEAK_LAYER, etc.), and a helper function weak_layer_from_preset. The __init__.py was updated to expose these presets and maintain import order. (src/weac/components/presets.py [1] src/weac/components/__init__.py [2]

Test enhancements:

  • Comprehensive tests for the new config validation logic were added to ensure that invalid combinations raise errors and valid transitions succeed. (tests/components/test_configs.py tests/components/test_configs.pyR33-R106)
  • All force decomposition tests were updated to explicitly include the theta parameter, improving clarity and robustness. (tests/utils/test_misc.py [1] [2] [3] [4] [5]

Analysis and criteria evaluation fixes:

Dependency and housekeeping:

  • Raises the minimum required version of ipykernel in both interactive and dev dependencies to improve compatibility. (pyproject.toml [1] [2]
  • Removed /demo/ from .cursorignore to ensure it is tracked. (.cursorignore .cursorignoreL4)

…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
- setup logging in jupyter notebook
- rm .env.example from .gitignore
Copilot AI review requested due to automatic review settings February 25, 2026 13:25
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 25, 2026

Warning

Rate limit exceeded

@pillowbeast has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 14 minutes and 30 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between 6bbc9d2 and fef434e.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (15)
  • .cursorignore
  • .gitignore
  • CITATION.cff
  • demo/demo.ipynb
  • demo/generalized_backend_documentation.ipynb
  • pyproject.toml
  • src/weac/__init__.py
  • src/weac/analysis/analyzer.py
  • src/weac/analysis/criteria_evaluator.py
  • src/weac/components/__init__.py
  • src/weac/components/config.py
  • src/weac/components/presets.py
  • tests/analysis/test_criteria_evaluator.py
  • tests/components/test_configs.py
  • tests/utils/test_misc.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix-slab-criterion

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.

Copy link
Contributor

Copilot AI left a comment

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 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 WeakLayer presets + helper factory for preset instantiation/overrides.
  • Enforce touchdown=True only for backend="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 interactive extra: the dev extra now requires ipykernel>=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.

Comment on lines 36 to 41
interactive = [
"jupyter",
"ipython>=8.37.0",
"ipykernel>=6.30.1",
"ipykernel>=7.1.0",
"jupyter_client>=8.6.3",
"jupyter_core>=5.8.1",
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +779 to +807
# 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,
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
# 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,

Copilot uses AI. Check for mistakes.
Comment on lines +317 to +321
segments = [
Segment(length=self.segments_length, has_foundation=True, m=0),
Segment(length=self.segments_length, has_foundation=True, m=0),
]
system = SystemModel(
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@pillowbeast pillowbeast merged commit ad9e55a into main Feb 25, 2026
4 checks passed
@pillowbeast pillowbeast deleted the bugfix-slab-criterion branch February 25, 2026 13:35
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