femlabpy.matlab#

Packaged legacy benchmark decks and MATLAB-style convenience wrappers.

Workflow role#

This module preserves the original classroom problem names and data layouts so existing FemLab examples remain easy to recognize. Some functions simply return the benchmark data, while others keep the old wrapper behavior for users who want the Python port to feel close to the source MATLAB material.

What lives here#

  • benchmark data loaders such as bar01, square, hole, and canti,

  • compatibility wrappers such as nlbar, plastps, and plastpe,

  • small translation helpers that normalize the old tables into typed Python dictionaries.

Functions#

bar01()

Return the packaged input deck corresponding to bar01.m.

bar02()

Return the packaged input deck corresponding to bar02.m.

bar03()

Return the packaged input deck corresponding to bar03.m.

canti()

Return the original canti.m cantilever benchmark input deck.

elastic(T, X, G, C, P, *[, etype, dof, ...])

Solve a linear 2D elasticity problem following the original elastic.m workflow.

flow()

Return the original flow.m potential-flow benchmark data.

flowq4([T1, X, G, C, P, dof, plot])

Solve a Q4 potential problem following the original flowq4.m driver.

flowt3([T2, X, G, C, P, dof, plot])

Solve a T3 potential problem following the original flowt3.m driver.

hole(*[, plane_strain])

Return the packaged input deck corresponding to hole.m.

nlbar(T, X, G, C, P, *, no_loadsteps, i_max, ...)

Solve a nonlinear truss problem through the legacy nlbar.m driver logic.

plastpe(T, X, G, C, P, *, no_loadsteps, ...)

Solve a plane-strain elastoplastic Q4 problem following plastpe.m.

plastps(T, X, G, C, P, *, no_loadsteps, ...)

Solve a plane-stress elastoplastic Q4 problem following plastps.m.

square(*[, plane_strain])

Return the packaged input deck corresponding to square.m.

Function Reference#

femlabpy.matlab.bar01() dict[str, ndarray | int][source]#

Return the packaged input deck corresponding to bar01.m.

The returned dictionary contains the original truss geometry, material table, constraints, loads, and nonlinear load-stepping controls exported from the classroom MATLAB benchmark.

femlabpy.matlab.bar02() dict[str, ndarray | int][source]#

Return the packaged input deck corresponding to bar02.m.

This is the spatial three-dimensional nonlinear truss benchmark used by the legacy nlbar.m teaching script.

femlabpy.matlab.bar03() dict[str, ndarray | int][source]#

Return the packaged input deck corresponding to bar03.m.

Notes

bar03.m is a historically difficult 12-bar benchmark. It is exposed for compatibility and regression work even though the legacy load-stepping method can exceed its restart guard on this case.

femlabpy.matlab.canti() dict[str, ndarray | int][source]#

Return the original canti.m cantilever benchmark input deck.

Returns:
dict

Result dictionary containing u, q, S, E, R, the normalized data dictionary, and an optional figures list.

femlabpy.matlab.elastic(T, X, G, C, P, *, etype: str | None = None, dof: int | None = None, plot: bool = False, scale: float = 5.0) dict[str, Any][source]#

Solve a linear 2D elasticity problem following the original elastic.m workflow.

Parameters:
T, X, G, C, P:

Legacy FemLab topology, coordinates, material data, prescribed displacements, and nodal loads.

etype:

Element family used by the topology table. Supported values are "q4" and "t3". When omitted, the wrapper infers the type from the number of nodes per element.

dof:

Degrees of freedom per node. Defaults to X.shape[1].

plot:

When True, return Matplotlib figures for the geometry and the first stress component.

scale:

Displacement magnification factor used only for the deformed plot.

Returns:
dict

Linear elastic solution, recovered stresses and strains, reactions, normalized input data, and optional Matplotlib figures.

femlabpy.matlab.flow() dict[str, ndarray | int][source]#

Return the original flow.m potential-flow benchmark data.

The returned dictionary contains both the Q4 topology T1 and the T3 topology T2 used by the legacy flowq4.m and flowt3.m drivers.

femlabpy.matlab.flowq4(T1=None, X=None, G=None, C=None, P=None, *, dof: int = 1, plot: bool = False) dict[str, Any][source]#

Solve a Q4 potential problem following the original flowq4.m driver.

Parameters:
T1, X, G, C, P:

Legacy FemLab topology, coordinates, material data, prescribed potentials, and optional nodal loads. When omitted, the packaged flow.m benchmark data is used.

dof:

Degrees of freedom per node. The legacy flow examples use dof=1.

plot:

When True, return a single four-panel Matplotlib figure matching the original classroom driver.

femlabpy.matlab.flowt3(T2=None, X=None, G=None, C=None, P=None, *, dof: int = 1, plot: bool = False) dict[str, Any][source]#

Solve a T3 potential problem following the original flowt3.m driver.

Parameters:
T2, X, G, C, P:

Legacy FemLab topology, coordinates, material data, prescribed potentials, and optional nodal loads. When omitted, the packaged flow.m benchmark data is used.

dof:

Degrees of freedom per node. The legacy flow examples use dof=1.

plot:

When True, return a single four-panel Matplotlib figure matching the original classroom driver.

femlabpy.matlab.hole(*, plane_strain: bool = False) dict[str, ndarray | int][source]#

Return the packaged input deck corresponding to hole.m.

Parameters:
plane_strain:

When False the plane-stress deck used by plastps.m is returned. When True the plane-strain deck used by plastpe.m is returned.

Returns:
dict

Legacy FemLab matrices together with the nonlinear stepping controls expected by plastps() and plastpe().

femlabpy.matlab.nlbar(T, X, G, C, P, *, no_loadsteps: int, i_max: int, i_d: int, plotdof: int, tol: float = 1e-08, plot: bool = False, plotaxis=None, elaxis=None) dict[str, Any][source]#

Solve a nonlinear truss problem through the legacy nlbar.m driver logic.

Parameters:
T, X, G, C, P:

Legacy FemLab topology, coordinates, material data, displacement constraints, and nodal loads.

no_loadsteps, i_max, i_d, plotdof:

Legacy load-stepping controls used by the orthogonal residual method. plotdof is interpreted as the original 1-based degree-of-freedom index.

tol:

Convergence tolerance used by femlabpy.solve_nlbar().

plot:

When True, return a load-displacement figure and a deformed-geometry figure.

plotaxis, elaxis:

Optional MATLAB-style axis vectors kept for API compatibility.

femlabpy.matlab.plastpe(T, X, G, C, P, *, no_loadsteps: int, i_max: int, i_d: int, plotdof: int, tol: float = 1e-08, mattype: int = 1, plot: bool = False, strainaxis=None, elaxis=None) dict[str, Any][source]#

Solve a plane-strain elastoplastic Q4 problem following plastpe.m.

Parameters:
T, X, G, C, P:

Legacy FemLab topology, coordinates, material data, displacement constraints, and nodal loads.

no_loadsteps, i_max, i_d, plotdof:

Orthogonal-residual load-stepping controls. plotdof is interpreted in the original 1-based numbering.

tol:

Convergence tolerance passed to femlabpy.solve_plastic().

mattype:

1 for von Mises and 2 for Drucker-Prager, matching FemLab.

plot:

When True, return a load-displacement figure and an equivalent plastic-strain contour plot in the deformed geometry.

strainaxis, elaxis:

Optional MATLAB-style axis vectors kept for API compatibility.

femlabpy.matlab.plastps(T, X, G, C, P, *, no_loadsteps: int, i_max: int, i_d: int, plotdof: int, tol: float = 1e-08, mattype: int = 1, plot: bool = False, strainaxis=None, elaxis=None) dict[str, Any][source]#

Solve a plane-stress elastoplastic Q4 problem following plastps.m.

Parameters:
T, X, G, C, P:

Legacy FemLab topology, coordinates, material data, displacement constraints, and nodal loads.

no_loadsteps, i_max, i_d, plotdof:

Orthogonal-residual load-stepping controls. plotdof is interpreted in the original 1-based numbering.

tol:

Convergence tolerance passed to femlabpy.solve_plastic().

mattype:

1 for von Mises and 2 for Drucker-Prager, matching FemLab.

plot:

When True, return a load-displacement figure and an equivalent plastic-strain contour plot in the deformed geometry.

strainaxis, elaxis:

Optional MATLAB-style axis vectors kept for API compatibility.

femlabpy.matlab.square(*, plane_strain: bool = False) dict[str, ndarray | int][source]#

Return the packaged input deck corresponding to square.m.

Parameters:
plane_strain:

When False the plane-stress deck used by plastps.m is returned. When True the plane-strain deck used by plastpe.m is returned.

Returns:
dict

Legacy FemLab matrices together with the nonlinear stepping controls expected by plastps() and plastpe().