0023
{#0023}
import anon
# anon.conf.config.update('jax_disable_jit', True)
"jax_enable_x64", True)
anon.conf.config.update(import anabel.backend as anp
import anabel as em
from jax.test_util import check_grads
import elle.sections
import elle.beam2d
= elle.beam2d.transform_no2(elle.beam2d.geom_no1)
geom_template = elle.beam2d.resp_no1 beam_template
An Assembler
is an object with an .assemble()
and optionally a .compose()
method
# Create a model Assembler
= em.SkeletalModel(ndm=2,ndf=3)
model
# Define problem parameters
= model.param("ColumnArea")
ColumnArea = model.param("ColumnMOI")
ColumnMOI = model.param("GirderArea")
GirderArea = model.param("GirderMOI")
GirderMOI = model.param("P1")
P1
# Define model components
= {"A": ColumnArea, "E": 3600.0, "I": ColumnMOI}
column_section = {"A": GirderArea, "E": 3600.0, "I": GirderMOI}
girder_section = beam_template(**girder_section)
basic_girder = beam_template(**column_section)
basic_column
= geom_template(basic_girder)
girder = geom_template(basic_column) column
WARNING:absl:No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)
# Set up nodes
= 12
ft = 30.*ft, 13.*ft
B, H "1", 0., 0.)
model.node("2", 0., H )
model.node("3", B/2, H )
model.node("4", B , H )
model.node("5", B , 0.)
model.node(
"a", "1", "2", **column_section, elem=column)
model.beam("b", "2", "3", **girder_section, elem=girder)
model.beam("c", "3", "4", **girder_section, elem=girder)
model.beam("d", "4", "5", **column_section, elem=column)
model.beam(
"1", [1,1,1])
model.boun("5", [1,1,1])
model.boun(
"2", P1, dof="x")
model.load("2", -2.0, dof="y")
model.load("4", -2.0, dof="y")
model.load(
; em.plot_skeletal(model)
= model.compose() f
= f(30**2.,684.0,1e3)
U U
DeviceArray([[ 1.52848857],
[ 0.00583992],
[-0.01110097],
[ 1.49259297],
[-0.02807216],
[ 0.0053456 ],
[ 1.45669737],
[-0.00603251],
[-0.01047929]], dtype=float64)
for i,u in enumerate(anp.array([[ 1.52848857],
0.00583992],
[ -0.01110097],
[1.49259297],
[ -0.02807216],
[0.0053456 ],
[ 1.45669737],
[ -0.00603251],
[-0.01047929]])):
[assert abs(U[i] - u) < 1e-7
= em.plot_displ(model, f(30**2.,684.0,1e3),scale=2e1)
fig, ax "off")
ax.axis("/home/claudio/prnt/ms-thesis/doc/img/frame.svg") fig.savefig(
= anon.diff.jacfwd(f, None, (0,1), squeeze=False) df
30**2.,684.0,1e3) df(
(DeviceArray([[-1.62639751e-06],
[-6.48010720e-06],
[ 2.08512502e-08],
[-1.62639751e-06],
[ 1.06995885e-07],
[ 4.44669006e-08],
[-1.62639751e-06],
[ 6.69409896e-06],
[ 2.08512502e-08]], dtype=float64),
DeviceArray([[-5.15397694e-05],
[-1.28712372e-20],
[ 4.46315830e-07],
[-3.53933002e-18],
[ 4.01684247e-05],
[-1.34782635e-20],
[ 5.15397694e-05],
[ 1.48398390e-20],
[-4.46315830e-07]], dtype=float64))
30**2.,684.0,1e3), order=1) check_grads(f, (
WARNING:absl:No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)