|
| 1 | +""" |
| 2 | +Created on 01/12/2025 |
| 3 | +
|
| 4 | +Illustrative example 5.1 from Paz, M. and Leigh, W., Structural Dynamics: Theory |
| 5 | +and Computation, 5th ed., Springer, 2001 |
| 6 | +""" |
| 7 | + |
| 8 | +from numpy import array, dot, pi |
| 9 | +from context import pystran |
| 10 | +from pystran import model |
| 11 | +from pystran import section |
| 12 | +from pystran import rotation |
| 13 | +from pystran import plots |
| 14 | + |
| 15 | + |
| 16 | +def rotx(angleindegrees): |
| 17 | + return rotation.rotmat3(array([+1, 0, 0]) * angleindegrees / 180.0 * pi) |
| 18 | + |
| 19 | + |
| 20 | +L = 200.0 |
| 21 | +E = 29500.0 |
| 22 | +G = E / (2 * (1 + 0.3)) |
| 23 | + |
| 24 | +m = model.create(3) |
| 25 | + |
| 26 | +model.add_joint(m, 1, [0.0, 0.0, 0.0]) |
| 27 | +model.add_joint(m, 2, [-L, 0.0, 0.0]) |
| 28 | +model.add_joint(m, 3, [0.0, -L, 0.0]) |
| 29 | +model.add_joint(m, 4, [0.0, 0.0, +L]) |
| 30 | +model.add_joint(m, 5, [0.0, 0.0, -L]) |
| 31 | + |
| 32 | +model.add_support(m["joints"][2], model.CLAMPED) |
| 33 | +model.add_support(m["joints"][3], model.CLAMPED) |
| 34 | +model.add_support(m["joints"][4], model.CLAMPED) |
| 35 | + |
| 36 | +# Member 1, 2: W18x130 |
| 37 | +A, Ix, Iy, Iz, J = section.i_beam(19.3, 11.2, 1.2, 0.67) |
| 38 | +xz_vector = dot(rotx(-30), array([0, 0, 1])) |
| 39 | +sect_1 = section.beam_3d_section( |
| 40 | + "sect_1", E=E, G=G, A=A, Ix=Ix, Iy=Iy, Iz=Iz, J=J, xz_vector=xz_vector |
| 41 | +) |
| 42 | +# Member 1, 3: W18x130 |
| 43 | +A, Ix, Iy, Iz, J = section.i_beam(19.3, 11.2, 1.2, 0.67) |
| 44 | +xz_vector = array([1, 0, 0]) |
| 45 | +sect_2 = section.beam_3d_section( |
| 46 | + "sect_2", E=E, G=G, A=A, Ix=Ix, Iy=Iy, Iz=Iz, J=J, xz_vector=xz_vector |
| 47 | +) |
| 48 | +# Member 1, 4: W14x82 |
| 49 | +A, Ix, Iy, Iz, J = section.i_beam(14.3, 10.1, 0.855, 0.51) |
| 50 | +xz_vector = array([1, 0, 0]) |
| 51 | +sect_3 = section.beam_3d_section( |
| 52 | + "sect_3", E=E, G=G, A=A, Ix=Ix, Iy=Iy, Iz=Iz, J=J, xz_vector=xz_vector |
| 53 | +) |
| 54 | +# Member 1, 5: W14x82 |
| 55 | +A, Ix, Iy, Iz, J = section.i_beam(14.3, 10.1, 0.855, 0.51) |
| 56 | +xz_vector = array([1, 0, 0]) |
| 57 | +sect_4 = section.beam_3d_section( |
| 58 | + "sect_4", E=E, G=G, A=A, Ix=Ix, Iy=Iy, Iz=Iz, J=J, xz_vector=xz_vector |
| 59 | +) |
| 60 | + |
| 61 | +model.add_beam_member(m, 1, [1, 2], sect_1) |
| 62 | +model.add_beam_member(m, 2, [1, 3], sect_2) |
| 63 | +model.add_beam_member(m, 3, [1, 4], sect_3) |
| 64 | +model.add_beam_member(m, 4, [1, 5], sect_4) |
| 65 | + |
| 66 | + |
| 67 | +model.add_load(m["joints"][1], model.U3, -5e3 - 7.5e3) |
| 68 | + |
| 69 | +model.number_dofs(m) |
| 70 | + |
| 71 | +print("Number of free degrees of freedom = ", m["nfreedof"]) |
| 72 | +print("Number of all degrees of freedom = ", m["ntotaldof"]) |
| 73 | + |
| 74 | +# print([j["dof"] for j in m["joints"].values()]) |
| 75 | + |
| 76 | +model.solve(m) |
| 77 | + |
| 78 | +# print([j["displacements"] for j in m["joints"].values()]) |
| 79 | + |
| 80 | +# print(m['K'][0:m['nfreedof'], 0:m['nfreedof']]) |
| 81 | + |
| 82 | +# print(m["U"][0 : m["nfreedof"]])# out |
| 83 | + |
| 84 | + |
| 85 | +# if ( |
| 86 | +# norm(b["displacements"] - [0.0, 0.0, -0.02238452, 0.00419677, 0.00593197, 0.0]) |
| 87 | +# > 1.0e-5 |
| 88 | +# ): |
| 89 | +# raise ValueError("Displacement calculation error") |
| 90 | + |
| 91 | +# print("Displacement calculation OK") |
| 92 | + |
| 93 | +# print('Reference: ', [-0.02238452, 0.00419677, 0.00593197]) |
| 94 | + |
| 95 | +plots.plot_setup(m) |
| 96 | +plots.plot_members(m) |
| 97 | +plots.plot_beam_orientation(m, 40) |
| 98 | +plots.show(m) |
| 99 | + |
| 100 | +plots.plot_setup(m) |
| 101 | +plots.plot_members(m) |
| 102 | +plots.plot_deformations(m, 10.0) |
| 103 | +# ax = plots.plot_shear_forces(m, scale=0.50e-3) |
| 104 | +# ax.set_title('Shear forces') |
| 105 | +plots.show(m) |
0 commit comments