BEAM_REACTION
Calculates a specific reaction component (horizontal force, vertical force, or bending moment) at a support location for a given beam configuration. This function is ideal for extracting specific results from a beam analysis directly into an Excel cell.
The function builds a numerical model of the beam internally, calculates all reactions, and returns the requested component at the specified coordinate.
Excel Usage
=BEAM_REACTION(span, supports, loads, query_x, beam_react_dir)
span(float, required): Total length of the beam (m).supports(list[list], required): 2D array of support definitions [[x, rx, ry, rm]].loads(list[list], required): 2D array of load definitions [[type, val1, val2, x1, x2]].query_x(float, required): The x-coordinate of the support to query (m).beam_react_dir(str, required): The reaction component to return (‘x’, ‘y’, or ‘m’).
Returns (float): The reaction force (N) or moment (N.m) at the specified position and direction.
Example 1: Left reaction of simple beam
Inputs:
| span | supports | loads | query_x | beam_react_dir | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| 6 | 0 | 0 | 1 | 0 | point | -600 | 0 | 2 | 0 | 0 | y |
| 6 | 0 | 1 | 0 |
Excel formula:
=BEAM_REACTION(6, {0,0,1,0;6,0,1,0}, {"point",-600,0,2,0}, 0, "y")
Expected output:
400
Example 2: Right reaction of simple beam
Inputs:
| span | supports | loads | query_x | beam_react_dir | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| 6 | 0 | 0 | 1 | 0 | point | -600 | 0 | 2 | 0 | 6 | y |
| 6 | 0 | 1 | 0 |
Excel formula:
=BEAM_REACTION(6, {0,0,1,0;6,0,1,0}, {"point",-600,0,2,0}, 6, "y")
Expected output:
200
Example 3: Fixed end moment of cantilever
Inputs:
| span | supports | loads | query_x | beam_react_dir | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| 4 | 0 | 1 | 1 | 1 | point | -100 | 0 | 4 | 0 | 0 | m |
Excel formula:
=BEAM_REACTION(4, {0,1,1,1}, {"point",-100,0,4,0}, 0, "m")
Expected output:
400
Example 4: Interior support reaction (propped cantilever)
Inputs:
| span | supports | loads | query_x | beam_react_dir | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| 10 | 0 | 1 | 1 | 1 | udl | -10 | 0 | 0 | 10 | 10 | y |
| 10 | 0 | 1 | 0 |
Excel formula:
=BEAM_REACTION(10, {0,1,1,1;10,0,1,0}, {"udl",-10,0,0,10}, 10, "y")
Expected output:
37.5
Python Code
Show Code
from indeterminatebeam import Beam, Support
from indeterminatebeam.loading import PointLoadV, PointLoadH, PointTorque, UDLV, TrapezoidalLoadV
def beam_reaction(span, supports, loads, query_x, beam_react_dir):
"""
Calculate the reaction force or moment at a specific support position.
See: https://indeterminatebeam.readthedocs.io/en/main/docstrings.html#indeterminatebeam.Beam.get_reaction
This example function is provided as-is without any representation of accuracy.
Args:
span (float): Total length of the beam (m).
supports (list[list]): 2D array of support definitions [[x, rx, ry, rm]].
loads (list[list]): 2D array of load definitions [[type, val1, val2, x1, x2]].
query_x (float): The x-coordinate of the support to query (m).
beam_react_dir (str): The reaction component to return ('x', 'y', or 'm'). Valid options: Horizontal Force (x), Vertical Force (y), Bending Moment (m).
Returns:
float: The reaction force (N) or moment (N.m) at the specified position and direction.
"""
try:
def to2d(value):
return [[value]] if not isinstance(value, list) else value
supports = to2d(supports)
loads = to2d(loads)
if not isinstance(supports, list) or not all(isinstance(row, list) for row in supports):
return "Error: Invalid input - supports must be a 2D list"
if not isinstance(loads, list) or not all(isinstance(row, list) for row in loads):
return "Error: Invalid input - loads must be a 2D list"
direction = str(beam_react_dir).lower()
if direction not in {"x", "y", "m"}:
return "Error: beam_react_dir must be one of 'x', 'y', or 'm'"
beam = Beam(span=span)
support_positions = []
support_rows = []
has_x_restraint = False
for row in supports:
if len(row) < 4:
continue
try:
x_pos = float(row[0])
rx_raw = float(row[1])
ry_raw = float(row[2])
rm_raw = float(row[3])
except (TypeError, ValueError):
continue
kx = rx_raw if rx_raw > 1 else None
ky = ry_raw if ry_raw > 1 else None
rx_fixed = int(bool(rx_raw)) if kx is None else 0
ry_fixed = int(bool(ry_raw)) if ky is None else 0
rm_fixed = int(bool(rm_raw))
if rx_fixed == 1 or (kx is not None and kx > 0):
has_x_restraint = True
support_rows.append({
"x": x_pos,
"fixed": (rx_fixed, ry_fixed, rm_fixed),
"kx": kx,
"ky": ky,
})
support_positions.append(x_pos)
if not support_rows:
return "Error: At least one valid support is required"
if not has_x_restraint:
support_rows[0]["fixed"] = (1, support_rows[0]["fixed"][1], support_rows[0]["fixed"][2])
support_rows[0]["kx"] = None
for support in support_rows:
beam.add_supports(Support(support["x"], fixed=support["fixed"], kx=support["kx"], ky=support["ky"]))
for row in loads:
if len(row) < 2:
continue
l_type = str(row[0]).lower()
try:
val1 = float(row[1])
val2 = float(row[2]) if len(row) > 2 else 0.0
x1 = float(row[3]) if len(row) > 3 else 0.0
x2 = float(row[4]) if len(row) > 4 else 0.0
except (TypeError, ValueError):
continue
if l_type == "point":
beam.add_loads(PointLoadV(val1, x1))
elif l_type == "moment":
beam.add_loads(PointTorque(val1, x1))
elif l_type == "udl":
beam.add_loads(UDLV(val1, (x1, x2)))
elif l_type == "trap":
beam.add_loads(TrapezoidalLoadV((val1, val2), (x1, x2)))
elif l_type == "point_h":
beam.add_loads(PointLoadH(val1, x1))
beam.analyse()
reaction = beam.get_reaction(query_x, direction)
if reaction is not None:
return float(reaction)
for x_pos in support_positions:
if abs(x_pos - query_x) < 1e-6:
reaction = beam.get_reaction(x_pos, direction)
if reaction is not None:
return float(reaction)
return f"Error: No support found at x={query_x}"
except Exception as e:
return f"Error: {str(e)}"Online Calculator
Total length of the beam (m).
2D array of support definitions [[x, rx, ry, rm]].
2D array of load definitions [[type, val1, val2, x1, x2]].
The x-coordinate of the support to query (m).
The reaction component to return ('x', 'y', or 'm').