|
| 1 | +import sys |
| 2 | +import pytest |
| 3 | +import veux |
| 4 | +import numpy as np |
| 5 | +from xara.units import us, si |
| 6 | +from xsection.library import from_aisc, aisc_data |
| 7 | + |
| 8 | + |
| 9 | +def _check_data(shape, data): |
| 10 | + assert shape.A == pytest.approx(data["A"], abs=0.5) |
| 11 | + assert shape.Iy == pytest.approx(data["Ix"], rel=1e-2) |
| 12 | + assert shape.Iz == pytest.approx(data["Iy"], rel=1e-2) |
| 13 | + assert shape.Iyz == pytest.approx(0.0, abs=1e-8) |
| 14 | + |
| 15 | + |
| 16 | +def test_units_(): |
| 17 | + shape_us = from_aisc("W14x48", units=us).elastic |
| 18 | + shape_si = from_aisc("W14x48", units=si).elastic |
| 19 | + |
| 20 | + L = getattr(us, si.Length) |
| 21 | + |
| 22 | + assert shape_us.A == pytest.approx(shape_si.A*L**2, rel=1e-8) |
| 23 | + assert shape_us.Iy == pytest.approx(shape_si.Iy*L**4, rel=1e-8) |
| 24 | + assert shape_us.Iz == pytest.approx(shape_si.Iz*L**4, rel=1e-8) |
| 25 | + |
| 26 | + |
| 27 | +def test_data_w(): |
| 28 | + data = aisc_data("W14x48") |
| 29 | + shape = from_aisc("W14x48", mesh_scale=1/5).elastic |
| 30 | + _check_data(shape, data) |
| 31 | + |
| 32 | + |
| 33 | +def test_data_wt(): |
| 34 | + data = aisc_data("WT22X145") |
| 35 | + shape = from_aisc("WT22X145", mesh_scale=1/5) |
| 36 | + shape = shape.translate(-shape.centroid).elastic |
| 37 | + _check_data(shape, data) |
| 38 | + |
| 39 | + |
| 40 | +# def test_data_c(): |
| 41 | +# data = aisc_data("C15x50") |
| 42 | +# shape = from_aisc("C15x50", mesh_scale=1/10, mesher="gmsh") |
| 43 | +# shape = shape.translate(-shape.centroid).elastic |
| 44 | +# assert shape.A == pytest.approx(data["A"], rel=0.35) |
| 45 | +# assert shape.Iy == pytest.approx(data["Ix"], rel=0.25) |
| 46 | +# assert shape.Iz == pytest.approx(data["Iy"], rel=0.25) |
| 47 | +# assert shape.Iyz == pytest.approx(0.0, abs=1e-8) |
| 48 | + |
| 49 | + |
| 50 | +if __name__ == "__main__": |
| 51 | + from xsection.analysis.interaction import limit_surface, plot_limit_surface |
| 52 | + c = "centroid" |
| 53 | + |
| 54 | + shape = from_aisc(sys.argv[1], mesh_scale=1/20) |
| 55 | + d = shape.d |
| 56 | + |
| 57 | + if False: |
| 58 | + pass |
| 59 | + elif c == "shear-center": |
| 60 | + shape = shape.translate(-shape._analysis.shear_center()) |
| 61 | + |
| 62 | + elif c == "centroid": |
| 63 | + print(f"{shape.centroid = }") |
| 64 | + shape = shape.translate(-shape.centroid) |
| 65 | + |
| 66 | + else: |
| 67 | + shape = shape.translate(c) |
| 68 | + |
| 69 | + print(shape.summary(shear=True)) |
| 70 | + |
| 71 | + print("tan(alpha): ", np.tan(shape._principal_rotation())) |
| 72 | + |
| 73 | +# _test_opensees(shape, |
| 74 | +# section=os.environ.get("Section", "fiber"), |
| 75 | +# center =os.environ.get("Center", None) |
| 76 | +# ) |
| 77 | + |
| 78 | + # 1) create basic section |
| 79 | +# basic = shape.linearize() |
| 80 | + |
| 81 | +# field = shape._analysis.warping() |
| 82 | + field = shape._analysis.fiber_shear()[1] |
| 83 | + |
| 84 | + # 3) view warping modes |
| 85 | + artist = veux.create_artist(shape.model, ndf=1, ndm=2) |
| 86 | + |
| 87 | + field = {node: (shape.depth/8)*value/max(field) for node, value in enumerate(field)} |
| 88 | + |
| 89 | + artist.draw_surfaces(field = field, |
| 90 | + #state=field |
| 91 | + ) |
| 92 | + artist.draw_outlines() |
| 93 | + R = artist._plot_rotation |
| 94 | + |
| 95 | + artist.canvas.plot_vectors([[0,0,0] for i in range(3)], d/5*R.T, extrude=True) |
| 96 | + artist.canvas.plot_vectors([R@[*shape._analysis.shear_center(), 0] for i in range(3)], d/5*R.T, extrude=True) |
| 97 | + artist.draw_outlines() |
| 98 | + veux.serve(artist) |
0 commit comments