Example: Frame and barsΒΆ

This example is from the CALFEM MATLAB manual (exs7.m)

Purpose:

Set up a frame, consisting of both beams and bars, and illustrate the calculations by use of graphics functions.

Description:

A frame consists of horizontal and vertical beams, and is stabilized with diagonal bars

frame and bars

As usual, import necessary modules.

[1]:
import numpy as np
import calfem.core as cfc

The frame with its coordinates and loading is shown in the left figure, and the finite element model in the right. The matrices of the global system i.e. the stiffness matrix K, the load vector f, the coordinate matrix Coord, and the corresponding degrees of freedom matrix Dof are defined by

[2]:
K = np.zeros([18,18])
f = np.zeros([18,1])
f[12,0] = 1.0

coord = np.array([
    [0.0, 0.0],
    [1.0, 0.0],
    [0.0, 1.0],
    [1.0, 1.0],
    [0.0, 2.0],
    [1.0, 2.0]
])

dof1 = np.array([
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9],
    [10, 11, 12],
    [13, 14, 15],
    [16, 17, 18]
])

dof2 = np.array([
    [1, 2],
    [4, 5],
    [7, 8],
    [10, 11],
    [13, 14],
    [16, 17]
])

The material properties, the topology, and the element coordinates for the beams and bars respectively, are defined by

[3]:
ep1 = [1.0, 1.0, 1.0]

edof1 = np.array([
    [1, 2, 3, 7, 8, 9],
    [7, 8, 9, 13, 14, 15],
    [4, 5, 6, 10, 11, 12],
    [10, 11, 12, 16, 17, 18],
    [7, 8, 9, 10, 11, 12],
    [13, 14, 15, 16, 17, 18]
])

ex1, ey1 = cfc.coordxtr(edof1, coord, dof1);

ep2 = [1.0, 1.0]

edof2 = np.array([
    [1, 2, 10, 11],
    [7, 8, 16, 17],
    [7, 8, 4, 5],
    [13, 14, 10, 11]
])

ex2, ey2 = cfc.coordxtr(edof2, coord, dof2);

Create and assemble element matrices

[4]:
for elx, ely, eltopo in zip(ex1, ey1, edof1):
    Ke = cfc.beam2e(elx, ely, ep1)
    cfc.assem(eltopo, K, Ke)
[5]:
for elx, ely, eltopo in zip(ex2, ey2, edof2):
    Ke = cfc.bar2e(elx, ely, ep2)
    cfc.assem(eltopo,K,Ke)

Solve equation system

[6]:
bc_prescr = np.array([1, 2, 3, 4, 5, 6])
a, r = cfc.solveq(K, f, bc_prescr)
[7]:
print(a)
[[ 0.        ]
 [ 0.        ]
 [ 0.        ]
 [ 0.        ]
 [ 0.        ]
 [ 0.        ]
 [ 0.37905924]
 [ 0.30451926]
 [-0.65956297]
 [ 0.3041448 ]
 [-0.28495132]
 [-0.54570174]
 [ 1.19791809]
 [ 0.44655174]
 [-0.85908643]
 [ 0.96969909]
 [-0.34780417]
 [-0.74373562]]