Compression-only membrane panel — CompressionOnlyMembraneElement demo
Part 6 of the unilateral-elements series. The 2D counterpart of the
1D strut demo (02_compression_prop.py): instead of a truss, a
plain-concrete shear panel is modelled with a single four-node
CompressionOnlyMembraneElement: a membrane that carries no force
in tension.
Geometry
Section titled “Geometry”A square panel of side L on the global xy plane, pinned along
its bottom edge (y = 0) and loaded through a prescribed in-plane
horizontal displacement of the top edge (y = L):
top edge → prescribed ±Δ along x ─────── │ │ │ ░░ │ panel │ ░░ │ (one element) │ │ ─────── bottom edge pinned (y = 0)Three cases are solved: (a) shear +Δ : top edge pushed in the +x direction → panel develops a diagonal compressive strut from the bottom-right to the top-left corner. (b) shear −Δ : top edge pushed in the −x direction → the compressive strut flips to the other diagonal (bottom-left → top-right). Reaction force at the loaded edge equals (a) in magnitude. (c) pure tension : top edge pulled in +y → every principal stress in the panel is tensile → the panel carries no force in tension → the top edge slacks away with ~zero reaction.
Units: mm / N / MPa.

The model before it is solved: its parts, supports (red) and loads (blue).
![The result: the deformed shape coloured by displacement (magnitude [mm])](/examples/core-concepts/unilateral-elements/06-compression-only-membrane-results.webp)
The deformed shape, coloured by displacement (magnitude [mm]), in xfea’s 3D viewer.
Open in 3D turn it, cut it, pick any field: in xfea's viewer, in your browser
The script
Section titled “The script”examples/scripts/02_core_concepts/unilateral_elements/06_compression_only_membrane.py. Run it from the repository with uv run python examples/scripts/02_core_concepts/unilateral_elements/06_compression_only_membrane.py, or, with xfea-examples installed, xfea-examples run 02_core_concepts/unilateral_elements/06_compression_only_membrane.py.
from __future__ import annotations
from pathlib import Path
from xfea.model import ( CompressionOnlyMembraneElement, CompressionOnlyMembraneSection, ElasticIsotropic, Model, Node, Part,)from xfea.problem import Problem, StaticStepfrom xfea.results import DisplacementFieldResults, ReactionFieldResults
from xfea_examples import out_dir
# Geometry / material / loadL = 1_000.0 # [mm] panel side lengthT = 200.0 # [mm] panel thicknessE_C = 30_000.0 # [MPa] concrete Young's modulusNU = 0.2 # [-] Poisson ratioDELTA = 1.0 # [mm] prescribed edge displacement magnitude
concrete = ElasticIsotropic(E=E_C, v=NU, density=2.4e-9, name="concrete")
def build_panel(name: str) -> tuple[Model, tuple[Node, ...], tuple[Node, ...]]: """Square membrane panel, pinned along the bottom edge (y = 0).
Returns the model plus the (bottom, top) node tuples so individual load cases can prescribe an imposed displacement on the top edge. """ model = Model(name=name) part = model.add_part(Part(name="panel")) # corners in counter-clockwise order. n00 = part.add_node(Node(xyz=[0.0, 0.0, 0.0])) n10 = part.add_node(Node(xyz=[L, 0.0, 0.0])) n11 = part.add_node(Node(xyz=[L, L, 0.0])) n01 = part.add_node(Node(xyz=[0.0, L, 0.0]))
section = CompressionOnlyMembraneSection(t=T, material=concrete) part.add_element( CompressionOnlyMembraneElement( nodes=[n00, n10, n11, n01], section=section ) )
# Pin the bottom edge in all three translations; leaves the top # edge free until a displacement field is attached by the caller. model.add_pin_bc(nodes=[n00, n10]) # Restrain out-of-plane motion on the full panel so the membrane # sits flat in the xy plane — membranes have no bending stiffness # and need this lateral restraint to stay well-posed. model.add_rollerZ_bc(nodes=[n01, n11]) return model, (n00, n10), (n01, n11)
def solve_case(tag: str, *, dx: float = 0.0, dy: float = 0.0) -> dict: """Run one load case with a prescribed top-edge displacement.""" model, _, top = build_panel(f"panel_{tag}")
problem = model.add_problem(Problem(name=f"{model.name}_run")) step = problem.add_step( StaticStep( name=tag, nlgeom=True, initial_inc_size=0.25, max_inc_size=1.0, min_inc_size=1e-3, max_increments=30, ) ) kwargs = {} if dx: kwargs["x"] = dx if dy: kwargs["y"] = dy step.add_uniform_displacement_field(nodes=list(top), **kwargs)
disp = DisplacementFieldResults() reac = ReactionFieldResults() step.add_field_outputs([disp, reac])
out = Path(out_dir(model.name)) try: problem.analyse_and_extract(path=out, verbose=False) except Exception as exc: return {"ok": False, "error": f"{type(exc).__name__}: {exc}"}
STEP_END = 1.0 # Sum reaction components on the loaded (top) edge. rx = ry = 0.0 for n in top: r = reac.get_result_at(n, time=STEP_END) rx += float(getattr(r, "x", 0.0) or 0.0) ry += float(getattr(r, "y", 0.0) or 0.0) # Tip displacement we actually achieved (sanity check on the BC). dxt = float(getattr(disp.get_result_at(top[0], time=STEP_END), "x", 0.0) or 0.0) dyt = float(getattr(disp.get_result_at(top[0], time=STEP_END), "y", 0.0) or 0.0) return { "ok": True, "Rx_top": rx, "Ry_top": ry, "dx_top": dxt, "dy_top": dyt, }
def _print_result(label: str, res: dict): print(f"--- {label} ---") if not res["ok"]: print(f" solver failure: {res['error']}") return print(f" top δx (FEA) : {res['dx_top']:+.4f} mm") print(f" top δy (FEA) : {res['dy_top']:+.4f} mm") print(f" ΣRx top edge : {res['Rx_top']:+.1f} N") print(f" ΣRy top edge : {res['Ry_top']:+.1f} N") print()
if __name__ == "__main__": # Reference elastic shear stiffness of the panel in its *active* # (compressive) regime: for a square plane-stress panel of side L # and thickness t, a uniform top-edge x-displacement Δ with the # bottom edge pinned imposes an average shear strain γ = Δ / L and # an average in-plane shear stress τ = G · γ, G = E / (2(1+ν)). # The total horizontal reaction on the top edge is # Rx ≈ τ · (L · t) = G · t · Δ. G = E_C / (2.0 * (1.0 + NU)) Rx_ref = G * T * DELTA print("Compression-only membrane panel — imposed edge displacement.") print(f" geometry : square L = {L:.0f} mm, t = {T:.0f} mm on the xy plane") print(f" material : E = {E_C:.0f} MPa, ν = {NU}, no tension") print(f" load : top edge prescribed δ = ±{DELTA:.1f} mm") print() print("Reference (linear-elastic, small-strain shear on the active branch):") print(f" G = E/(2(1+ν)) = {G:.1f} MPa") print(f" Rx ≈ G·t·Δ = {Rx_ref:+.1f} N per unit imposed Δ") print()
res_plus = solve_case("shear_plus", dx=+DELTA) _print_result("Shear +Δ (compressive strut along the top-left diagonal)", res_plus)
res_minus = solve_case("shear_minus", dx=-DELTA) _print_result("Shear −Δ (compressive strut along the other diagonal)", res_minus)
res_tension = solve_case("tension", dy=+DELTA) _print_result("Pure tension (top edge pulled in +y → every principal stress tensile)", res_tension)
# Symmetry check: the two shear cases mobilise opposite diagonals # but the same material law, so |Rx_+| ≈ |Rx_−|. if res_plus["ok"] and res_minus["ok"]: sym_err = abs(abs(res_plus["Rx_top"]) - abs(res_minus["Rx_top"])) print(f"Symmetry check: ||Rx(+)| − |Rx(−)|| = {sym_err:.3f} N " f"(should be ≈ 0)") if res_plus["ok"]: ratio = res_plus["Rx_top"] / Rx_ref if Rx_ref else float("nan") print(f"Active-branch stiffness: Rx(+) / (G·t·Δ) = {ratio:+.3f} " f"(should be ≈ 1)") if res_tension["ok"]: slack = abs(res_tension["Ry_top"]) < 1e-2 * Rx_ref marker = "✓ slack" if slack else "✗ not slack" print(f"Tension case: |ΣRy_top| = {abs(res_tension['Ry_top']):.3f} N [{marker}]")
print() print( "Interpretation:\n" " The ±shear cases activate a compressive diagonal strut inside\n" " the panel and recover the linear plane-stress shear stiffness\n" " (|Rx| ≈ G·t·Δ) regardless of sign. The tension case attempts\n" " to stretch every fibre of the panel — all principal stresses\n" " go tensile, the panel has zero stiffness in tension, the\n" " top edge slacks away with essentially zero reaction. That is\n" " the 2D counterpart of the slack branch exercised in the 1D\n" " strut demo (02_compression_prop.py).\n" )© 2026 Francesco Ranaudo · Text and pictures CC BY 4.0 · Code Elastic License 2.0 · how to reuse them