API reference

What @edubeam/fem 0.3 exports, grouped by what you use it for. Units are SI throughout: m, N, N·m, N/m, Pa, K and rad. Labels (LabelType) are string | number, stored as strings. Methods not listed here are internal: they are public in TypeScript only because the solver's own classes call them.

Exports

ExportKindSection
LinearStaticSolverclassAnalyses
Solverabstract classAnalyses
DomainclassDomain
NodeclassNode
Beam2D, ElementclassesElements
Material, CrossSectionclassesMaterials and sections
LoadCaseclassLoads
NodalLoad, BeamConcentratedLoad, BeamElementUniformEdgeLoad, BeamElementTrapezoidalEdgeLoad, BeamTemperatureLoad, PrescribedDisplacement, Load, BeamElementLoadclassesLoads
DofIDenumDofID
LabelType, EnumDictionary, MaterialParameters, CrossSectionParameterstypes

Analyses

LinearStaticSolver

TypeScript
const solver = new LinearStaticSolver()
MemberTypeDescription
domainDomainThe model
loadCasesLoadCase[]Starts with one case, 'DefaultLC'. Push more with new LoadCase(label, solver.domain): Load cases.
solve()voidNumbers the equations if needed, assembles and solves every load case. May throw on a mechanism, but does not always. Silent from 0.3.1; 0.3.0 logged its time.
codeNumberGeneratedbooleanSet it to false after adding or removing nodes or members, or changing supports: why
neq, pneqnumberNumbers of free and of supported DOFs, after a solve
kmathjs MatrixThe assembled global stiffness matrix, after a solve
getNodeDofIDs(label)number[]The DOFs a node has, after a solve

EigenValueDynamicSolver exists in the source but is not exported.

Domain

solver.domain holds the model in four Maps keyed by the label as a string: nodes, elements, materials, crossSections. There are no remove methods: domain.nodes.delete(label) and domain.elements.delete(label) remove a node or a member, followed by renumbering.

MethodReturnsDescription
createNode(label, coords?, bcs?)Nodecoords [x, y, z] in m (default [0, 0, 0]), bcs the supported DofIDs (default none)
createBeam2D(label, nodes, mat, cs, hinges?)Beam2Dnodes [first, second], hinges [atFirst, atSecond] (default [false, false])
createMaterial(label, params?)MaterialSee Materials and sections
createCrossSection(label, params?)CrossSectionSee Materials and sections
getNode(label), getElement(label), getMaterial(label), getCS(label)the objectThrows a RangeError for an unknown label. getElement is typed Element: write as Beam2D to read results.

Creating an object with a label already in use replaces the old one.

Node

MemberTypeDescription
labelstring
coordsnumber[][x, y, z], m. Change it to move the node.
bcsSet<DofID>Supported DOFs. Replace it to change the support.
lcsnumber[][] | undefinedThe node's turned axes, if any
updateLcs({ locx, locy }?)voidTurns the node's axes: locx its x axis in global components, locy [0, 1, 0]. No argument resets them.
hasLcs()booleanWhether the axes are turned
getUnknowns(lc, dofs)Matrix, or a number for one DOFDisplacements (m) and rotations (rad), in the node's axes
getReactions(lc, global?){ dofs, values }Reactions at the supported DOFs, in the order of bcs: N, N·m. values is a mathjs Matrix for several, a one-element array for one, [] for a free node. With global true on a turned node: all three DOFs in global axes, dofs [0, 2, 4], values an array with 0 where nothing is held. Reading them.

Elements

Beam2D

A two-node Timoshenko beam in the x–z plane, three DOFs per node (Dx, Dz, Ry). x is in metres from the first node; n is a number of segments, giving n + 1 points.

MemberReturnsDescription
label, nodes, mat, csstring, string[], string, string
hinges[boolean, boolean]Moment releases at the first and second node
computeNormalForceAt(lc, x)numberN, tension positive
computeShearForceAt(lc, x)numberV, positive where M grows along local x
computeBendingMomentAt(lc, x)numberM, positive with tension on the local +z side
computeNormalForce(lc, n){ x, N }N at n + 1 points
computeShearForce(lc, n){ x, V }V at n + 1 points
computeBendingMoment(lc, n){ x, M }M at n + 1 points
computeLocalDefl(lc, n){ u, w }Displacements along and across the member, local axes, m
computeGlobalDefl(lc, n){ u, w }The same in global x and z
computeEndForces(lc)Matrix[X12, Z12, M12, X21, Z21, M21], the forces the nodes put on the member, local axes
computeEndDisplacement(lc)MatrixEnd displacements in local axes, hinge rotations included
computeGeo(){ l, dx, dz }Length and projections, m
computeT()Matrix6 × 6 transformation, global to local
computeLocalStiffnessMtrx(){ answer }answer: 6 × 6 local stiffness, hinges condensed
computeStiffness()Matrix6 × 6 global stiffness
computeShearFactor()number
getMaterial(), getCS()Material, CrossSection

At a point load, the …At methods return the value just past it. Element is the abstract base class of Beam2D; it is the type domain.elements and getElement use.

Materials and sections

MaterialParametersUnitDefaultUsed for
ePa1stiffness
gPa1shear stiffness
alpha1/K1temperature loads
dkg/m³1nothing in statics
CrossSectionParametersUnitDefaultUsed for
am²none, requiredaxial and shear stiffness
iym⁴none, requiredbending stiffness
k–none, requiredshear stiffness ; 1e32 for none
hmnonetemperature gradients (NaN without it)
iz, dyz, jm⁴nonenot used by Beam2D

A missing material parameter is 1, not a typical value; a missing a, iy or k makes every result NaN. Neither throws. Both classes have a change(params) method that sets the parameters given, and keep them as properties of the same names.

Loads

LoadCase

MethodReturnsValues
createNodalLoad(node, values, lcs?)NodalLoad{ [DofID.Dx]: N, [DofID.Dz]: N, [DofID.Ry]: N·m }; lcs (default false) true: in the node's turned axes
createBeamElementUniformEdgeLoad(el, [fx, fz], lcs)BeamElementUniformEdgeLoadN/m over the whole member
createBeamElementTrapezoidalEdgeLoad(el, [fx1, fz1], [fx2, fz2], lcs)BeamElementTrapezoidalEdgeLoadN/m at the first and second node, linear between
createBeamConcentratedLoad(el, [fx, fz, my, a], lcs)BeamConcentratedLoadN, N, N·m, at a m from the first node
createBeamTemperatureLoad(el, [dTc, dTb, dTt])BeamTemperatureLoadK: centroid, bottom fibre, top fibre
createPrescribedDisplacement(node, values)PrescribedDisplacement{ [DofID.Dz]: m, … } on supported DOFs, in the node's axes; ignored on free DOFs

For member loads, lcs true means local axes (x along the member, z across it), false global axes. Line loads are per metre of the member's length. Loads has examples.

MemberTypeDescription
labelstring
nodalLoadListNodalLoad[]
elementLoadListBeamElementLoad[]Member and temperature loads
prescribedBCPrescribedDisplacement[]
solvedbooleantrue after a successful solve
getElementLoadsOnElement(el)BeamElementLoad[]The loads on one member

The load objects keep their values in public properties, which you can change before solving again: values (and lcs) on NodalLoad, BeamElementUniformEdgeLoad, BeamConcentratedLoad and BeamTemperatureLoad; startValues and endValues on BeamElementTrapezoidalEdgeLoad; prescribedValues on PrescribedDisplacement. Each has a target, the label it acts on.

DofID

NameValueUsed by Beam2D
Dx0yes
Dy1no
Dz2yes
Rx3no
Ry4yes
Rz5no

Results

Results are read from a Beam2D (internal forces, deflections, end forces) and from a Node (displacements, reactions), always for a given LoadCase, after solve(): see the two tables above, and Reading results for examples and the signs. In short:

To getCall
Reactions, N and N·mnode.getReactions(lc)
Displacements, m, and rotations, radnode.getUnknowns(lc, [DofID.Dx, DofID.Dz, DofID.Ry])
N, V or M at a point, N and N·mbeam.computeNormalForceAt(lc, x), computeShearForceAt, computeBendingMomentAt
N, V or M along a memberbeam.computeNormalForce(lc, n), computeShearForce, computeBendingMoment
Deflected shape, mbeam.computeLocalDefl(lc, n), computeGlobalDefl
End forces, N and N·mbeam.computeEndForces(lc)
A figure of it allStructurePlot or structureSvg from @edubeam/plot