# Beams - structural beams#

This notebook shows how to use Beam elements model cantilever beams, how to get the results and how those results compare to theory.

A “Beam” in DAVE consists of a number of discrete segments and has a different formulation than the beams typically found in FEM packages.

```
from DAVE import *
s = Scene();
```

```
DAVEcore version = 2.0 from c:\python\miniconda3\envs\book\Lib\site-packages\DAVEcore.cp311-win_amd64.pyd
! Blender not found - Blender can be installed from the microsoft windows store. if you have blender already and want to be able to use blender then please either:
- configure windows to open .blend files with blender automatically
- add the folder containing blender-launcher.exe to the PATH variable.
```

Beams are elastic nodes that can be created between axis systems.

```
left = s.new_frame("left")
right = s.new_frame("right", position = (5,0,0)) # position is not needed, it will be solved
beam = s.new_beam("beam", nodeA=left, nodeB = right,
EA = 1000,
EIy = 1e5, EIz = 1e5, GIp = 1e3,
L=10,
mass = 0,
n_segments=20)
right.set_free()
s.solve_statics();
```

```
from DAVE.jupyter import *;
```

```
show(s, camera_pos=(5,-10,4), lookat = (5,0,2), width=1000, height = 200)
```

A Beam node is rigidly fixed to the axis systems at its ends. It is fixed in the positive X-direction, so it departs from node A along the X-axis and arrives at ndoe B from the negative X-direction.

At the momement we have a massless beam with its left side fixed (`Frame`

“left” is fixed) and its right size free (the right end of the beam is fixed to `Frame`

“right”, but “right” is not connected to anything and is free to move).

This is one of those cases that frequently occur in textbooks and for which we can easily check the results.

First place a point on the right side so that we can apply a force:

```
s.new_point("point", parent = right)
force = s.new_force("force", parent = "point")
```

## Cantilever beam with a force#

```
force.force = (0,0,-100)
```

```
s.solve_statics()
```

```
True
```

```
show(s, camera_pos=(5,-10,0), lookat = (5,0,0), width=1000, height = 300)
```

Theory tells us that the deflection and rotation of the right end should be:

\(\delta = -PL^3 / 3EI\)

and

\(\Theta = PL^2 / 2EI\)

Get the values from the model:

```
L = beam.L
EI = beam.EIy
P = -force.force[2]
```

And calculate their values

The deflection is the vertical displacement of the axis system on the right side of the beam:

```
right.z
```

```
-0.33604653085525665
```

```
-P*L**3 / (3*EI)
```

```
-0.3333333333333333
```

Theta is the slope. The slope can be calculated from the rotation of the axis system, but it is also available as “tilt”, which is a percentage.

```
right.tilt_y / 100
```

```
0.05014161613346104
```

```
P*L**2 / (2*EI)
```

```
0.05
```

It is also possible to obtain the forces in the beam.

The moments are available at the nodes.

```
import matplotlib.pyplot as plt
```

```
plt.plot(beam.X_nodes, beam.bending[:,1])
plt.xlabel('Distance along the beam [m]')
plt.ylabel('Moment about y-axis [kN*m]');
```

## Cantilever with moment#

We can do the same with a moment

```
force.force = (0,0,0)
force.moment = (0,1000,0)
```

```
s.solve_statics()
```

```
True
```

```
show(s, camera_pos=(5,-10,3), lookat = (5,0,-1), width=1000, height = 300)
```

Theory tells us that the deflection and rotation of the right end should be:

\(\delta = ML^2 / 2EI\)

and

\(\Theta = ML / EI\)

Get the values from the model:

```
M = force.moment[1] # moment about Y-axis
```

```
M*L**2 / (2*EI)
```

```
0.5
```

```
-right.z
```

```
0.49958399262792197
```

```
M*L / EI
```

```
0.1
```

```
right.tilt_y / 100
```

```
0.09983341665268047
```

## Tension and torsion#

Beam can also take tension and torsion.

```
force.force = (100,0,0)
force.moment = (100,0,0)
```

```
s.solve_statics()
```

```
True
```

```
show(s, camera_pos=(5,-10,3), lookat = (5,0,-1), width=1000, height = 300)
```

Tension and torsion forces in the beam are available not at the nodes but at the centers for the beam segments.

```
plt.plot(beam.X_midpoints, beam.torsion);
```

```
plt.plot(beam.X_midpoints, beam.tension);
```

**Now this looks horrible!**

Fortunately this is just the way matplotlib displays data which is almost constant.

Looking at the data directly it appears to be comfortingly constant:

```
beam.torsion
```

```
[99.99999998240641,
99.99999998240617,
99.99999998242056,
99.99999998244243,
99.99999998245247,
99.99999998258812,
99.99999998257329,
99.99999998293968,
99.99999998298821,
99.99999998346509,
99.99999998372786,
99.9999999849416,
99.9999999850111,
99.99999998720205,
99.99999998864935,
99.99999998999292,
99.99999999134315,
99.99999999435587,
99.99999999690863,
99.99999999871956]
```

```
import matplotlib
matplotlib.rcParams['axes.formatter.useoffset'] = False
```

```
plt.plot(beam.X_midpoints, beam.torsion);
plt.ylim((99.9, 100.1));
```

```
plt.plot(beam.X_midpoints, beam.tension);
plt.ylim((99.9, 100.1));
```

## Distributed load#

Modelling a distributed load is not possible in this way. Loads can only be added at points.

To model a distributed load we would have to manually discretise the model and add discrete loads at each node.

But these is a shortcut that we can take: The beams can have a mass. We can use the mass to model a distributed load as gravity.

```
s.delete('force')
```

```
q = 10 # kN/m
```

```
beam.mass = beam.L * q / 9.81
```

```
s.solve_statics()
```

```
True
```

```
show(s, camera_pos=(5,-10,0), lookat = (5,0,0), width=1000, height = 300)
```

Theory tells us that the deflection and rotation of the right end should be:

\(\delta = qL^4 / 8EI\)

and

\(\Theta = qL^3 / 6EI\)

```
-q*L**4 / (8*EI)
```

```
-0.125
```

```
right.z
```

```
-0.12539340699150792
```

```
q*L**3 / (6*EI)
```

```
0.016666666666666666
```

```
right.tilt_y / 100
```

```
0.01668937486490294
```

## Large deflections#

All the tests done so far were performed on small deflections. That is for a good reason. The Euler/Bernouilli beam theory is only applicable to small displacements. This is because in this theory the moment is derived from the deflection:

\(d^2/dx^2(EI d^2w / dx^2) = q\)

so the moment in the beam is proprtional to the change in slope. This is only valid for small changes.

The implementation in DAVE **is valid for large deflections**, it is just that the analytical formula used above are not.

## Number of segments#

Beams use a discrete model (see theory https://davedocs.online/beams.html).

When a higher number of segments is used:

The model become more accurate

The solver becomes slower

(The numerical errors build up)

So the number of nodes should be selected with some caution. In general 20 seems to be a good number for beams although in some cases (for example pure tension or torsion) a single segment is just as good.

It is easy to use the “plot_effect” function in scene to check the effect of the number of segments.

Here we calculate the effect of the number of segments on the vertical position of the second end of the beam:

```
s.plot_effect(evaluate="s['point'].gz",
change_property="n_segments",
change_node="beam",
start=1,
to=25.0,
steps=25);
```

```
setting 1.0 results in -0.2504353954495112
setting 2.0 results in -0.15639089336147097
setting 3.0 results in -0.13899104345031135
setting 4.0 results in -0.132904038677239
setting 5.0 results in -0.13008723297556585
setting 6.0 results in -0.12855725685173824
setting 7.0 results in -0.1276347990048547
setting 8.0 results in -0.12703611080260704
setting 9.0 results in -0.1266256627342448
setting 10.0 results in -0.12633207552408007
setting 11.0 results in -0.1261148602975286
```

```
setting 12.0 results in -0.12594965051398313
setting 13.0 results in -0.12582107945580862
setting 14.0 results in -0.1257190628826079
setting 15.0 results in -0.1256367615202469
setting 16.0 results in -0.12556940416109647
```

```
setting 17.0 results in -0.12551358025909992
setting 18.0 results in -0.12546679927827983
setting 19.0 results in -0.12542720748937944
```

```
setting 20.0 results in -0.1253934068819362
```

```
setting 21.0 results in -0.12536431820665916
```

```
setting 22.0 results in -0.12533910517723687
```

```
setting 23.0 results in -0.12531710883253022
```

```
setting 24.0 results in -0.12529780433919482
```

```
setting 25.0 results in -0.12528076896359913
```

– end –