Some checks failed
CI / lint (pull_request) Has been cancelled
CI / type (pull_request) Has been cancelled
CI / test-headless (macos-latest, 3.10) (pull_request) Has been cancelled
CI / test-headless (macos-latest, 3.11) (pull_request) Has been cancelled
CI / test-headless (macos-latest, 3.12) (pull_request) Has been cancelled
CI / test-headless (ubuntu-latest, 3.10) (pull_request) Has been cancelled
CI / test-headless (ubuntu-latest, 3.11) (pull_request) Has been cancelled
CI / test-headless (ubuntu-latest, 3.12) (pull_request) Has been cancelled
CI / test-headless (windows-latest, 3.10) (pull_request) Has been cancelled
CI / test-headless (windows-latest, 3.11) (pull_request) Has been cancelled
CI / test-headless (windows-latest, 3.12) (pull_request) Has been cancelled
CI / test-gui (pull_request) Has been cancelled
CI / test-integration (macos-latest) (pull_request) Has been cancelled
CI / test-integration (ubuntu-latest) (pull_request) Has been cancelled
CI / test-integration (windows-latest) (pull_request) Has been cancelled
Auto-fixes (UP037, UP038, F401, I001, SIM105, RUF100) plus hand-fixes: drop the now-unused `Union` imports, annotate mutable class attributes with ClassVar, raise ValidationError instead of blind Exception in the zero-length test, delete two dead locals, and bind the per-iteration grid-builder closures to their loop variables (B023).
53 lines
1.5 KiB
Python
53 lines
1.5 KiB
Python
"""Integration test for the 2D elastic cantilever earthquake example."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import tempfile
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
pytest.importorskip("openseespy")
|
|
|
|
from otko.services import load_project, save_project
|
|
from otko.services.opensees_runner import OpenSeesRunner
|
|
|
|
pytestmark = pytest.mark.slow
|
|
|
|
|
|
def test_ex1a_canti2d_eq_runs_and_oscillates(tmp_path) -> None: # type: ignore[no-untyped-def]
|
|
from examples.ex1a_canti2d_eq import (
|
|
ANALYSIS_DT,
|
|
COLUMN_HEIGHT,
|
|
build_ex1a_canti2d_eq,
|
|
)
|
|
|
|
proj = build_ex1a_canti2d_eq()
|
|
proj.validate_references()
|
|
|
|
path = tmp_path / "ex1a.osmodel"
|
|
save_project(proj, path)
|
|
reloaded = load_project(path)
|
|
reloaded.validate_references()
|
|
|
|
results_dir = Path(tempfile.mkdtemp(prefix="ex1a_eq_"))
|
|
result = OpenSeesRunner(reloaded).run(reloaded.analyses[1], results_dir=results_dir)
|
|
|
|
t = result.time()
|
|
top = result.node_disp_history(2)
|
|
ux = top[:, 0]
|
|
uy = top[:, 1]
|
|
|
|
assert len(t) == reloaded.analyses[1].n_steps
|
|
assert result.dt == pytest.approx(ANALYSIS_DT)
|
|
assert t[-1] == pytest.approx(ANALYSIS_DT * reloaded.analyses[1].n_steps, abs=ANALYSIS_DT)
|
|
|
|
# Dynamic response should oscillate in both directions under the base motion.
|
|
assert ux.max() > 0.01
|
|
assert ux.min() < -0.01
|
|
|
|
# The elastic column should stay in a physically reasonable range.
|
|
assert max(abs(ux)) < 0.10 * COLUMN_HEIGHT
|
|
|
|
# Gravity remains locked but the input is horizontal, so Uy should stay small.
|
|
assert max(abs(uy)) < 1.0
|