48 lines
1.7 KiB
Python
48 lines
1.7 KiB
Python
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from femsurrogate.fea.io import read_beam_example, read_expected_displacements
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def test_read_beam_example_parses_cantilever_fixture():
|
|
model = read_beam_example(ROOT / "BeamExamples" / "CantileverBeam.txt")
|
|
|
|
assert model.metadata["Area"] == pytest.approx(1.0)
|
|
assert model.metadata["Izz"] == pytest.approx(0.0833333)
|
|
assert model.metadata["ElasticModulus"] == pytest.approx(2.05e11)
|
|
assert model.metadata["Poisson'sRatio"] == pytest.approx(0.3)
|
|
|
|
assert len(model.nodes) == 6
|
|
assert model.nodes[1].x == pytest.approx(0.0)
|
|
assert model.nodes[6].x == pytest.approx(5.0)
|
|
assert model.nodes[6].y == pytest.approx(0.0)
|
|
|
|
assert len(model.beams) == 5
|
|
assert model.beams[0].id == 1
|
|
assert model.beams[0].node_i == 1
|
|
assert model.beams[0].node_j == 2
|
|
assert model.beams[-1].node_i == 5
|
|
assert model.beams[-1].node_j == 6
|
|
|
|
assert model.fixed_nodes == (1,)
|
|
assert model.nodal_loads[6].fx == pytest.approx(0.0)
|
|
assert model.nodal_loads[6].fy == pytest.approx(-100000.0)
|
|
assert model.nodal_loads[6].mz == pytest.approx(0.0)
|
|
|
|
|
|
def test_read_expected_displacements_parses_reference_values():
|
|
displacements = read_expected_displacements(
|
|
ROOT / "BeamExamples" / "CantileverBeam_Displacements.txt"
|
|
)
|
|
|
|
assert len(displacements) == 6
|
|
assert displacements[1].ux == pytest.approx(0.0)
|
|
assert displacements[1].uy == pytest.approx(0.0)
|
|
assert displacements[1].rz == pytest.approx(0.0)
|
|
assert displacements[6].ux == pytest.approx(0.0)
|
|
assert displacements[6].uy == pytest.approx(-0.000244)
|
|
assert displacements[6].rz == pytest.approx(0.000073)
|