Beams
Two complete programs to copy and change. Both use a shear-rigid section (k: 1e32), so their numbers are exactly the Euler–Bernoulli formulas. Run them with node cantilever.ts (Node 22.18 or later), in a folder set up as in Install.
A cantilever
4 m long, fixed at A, 18 kN down at the free end:
import { DofID, LinearStaticSolver } from '@edubeam/fem'
const solver = new LinearStaticSolver()
const { domain } = solver
domain.createMaterial(1, { e: 210e9, g: 81e9 })
domain.createCrossSection(1, { a: 28.5e-4, iy: 1943e-8, k: 1e32 })
domain.createNode('A', [0, 0, 0], [DofID.Dx, DofID.Dz, DofID.Ry]) // fixed
const tip = domain.createNode('B', [4, 0, 0]) // free
const beam = domain.createBeam2D(1, ['A', 'B'], 1, 1)
const lc = solver.loadCases[0]
lc.createNodalLoad('B', { [DofID.Dz]: 18e3 }) // 18 kN down at the tip
solver.solve()
console.log(beam.computeBendingMomentAt(lc, 0)) // N·m at the root
console.log(tip.getUnknowns(lc, [DofID.Dz])) // m, the tip deflection
-72000
0.09411072715241528
kNm, hogging, and the tip deflection is mm, with MNm². The same cantilever is one of the EduBeam app's examples.
A continuous beam
Two 5 m spans on three supports, 10 kN/m on both. The reactions, the moment over the middle support and the largest span moment:
import { DofID, LinearStaticSolver } from '@edubeam/fem'
const solver = new LinearStaticSolver()
const { domain } = solver
domain.createMaterial(1, { e: 210e9, g: 81e9 })
domain.createCrossSection(1, { a: 28.5e-4, iy: 1943e-8, k: 1e32 })
domain.createNode('A', [0, 0, 0], [DofID.Dx, DofID.Dz])
domain.createNode('B', [5, 0, 0], [DofID.Dz])
domain.createNode('C', [10, 0, 0], [DofID.Dz])
const span1 = domain.createBeam2D(1, ['A', 'B'], 1, 1)
domain.createBeam2D(2, ['B', 'C'], 1, 1)
const lc = solver.loadCases[0]
for (const span of [1, 2]) {
lc.createBeamElementUniformEdgeLoad(span, [0, 10e3], true)
}
solver.solve()
// getReactions gives a mathjs Matrix or an array: make it an array
const list = (v: unknown): number[] =>
Array.isArray(v) ? v : (v as { toArray(): number[] }).toArray()
for (const label of ['A', 'B', 'C']) {
const { dofs, values } = domain.getNode(label).getReactions(lc)
const rz = list(values)[dofs.indexOf(DofID.Dz)]
console.log(`R${label} = ${(-rz / 1e3).toFixed(2)} kN up`)
}
const mB = span1.computeBendingMomentAt(lc, 5)
console.log(`MB = ${(mB / 1e3).toFixed(2)} kNm`)
// The largest sagging moment in span 1, from 501 points along it
const { x, M } = span1.computeBendingMoment(lc, 500)
const i = M.indexOf(Math.max(...M))
console.log(`max M = ${(M[i] / 1e3).toFixed(2)} kNm at x = ${x[i]} m`)
RA = 18.75 kN up
RB = 62.50 kN up
RC = 18.75 kN up
MB = -31.25 kNm
max M = 17.58 kNm at x = 1.87 m
The textbook values for two equal spans: , , , and the largest span moment kNm, at m. The sampling finds it at the grid point 1.87 m, within 0.0002 kNm of the true value.
The figure uses the app's example section rather than the IPE 200. With one section throughout, the internal forces of a continuous beam do not depend on its stiffness, so the diagrams carry the same numbers; only the deflection differs.
Change it
- Unequal spans or loads: change the coordinates of C or the load list. A load on one span only gives the familiar pattern loading.
- Three spans: add a node D and a member
['C', 'D']. - A fixed end: give A
[DofID.Dx, DofID.Dz, DofID.Ry]. - Real shear deformation:
k: 5 / 6for a rectangle, or the shear coefficient of your section. - A figure of it: hand the solver to @edubeam/plot.
The continuous beam tutorial builds a beam like this in the EduBeam app, and the verification page has more textbook cases with their formulas.