片持ちはりの例では、節点に直接荷重を与えました。今回は、長方形の右辺に圧力を与えて圧縮し、支持反力が圧力の合力とつり合うことを確かめます。
圧力の単位はN/mm²、反力の単位はNです。この二つを比較するために、圧力が作用する面の面積を使います。
1. モデル・拘束条件・圧力の向き
長さ 、高さ 、厚さ の長方形を、1個の4節点四角形要素で表します。微小ひずみ・等方線形弾性・平面応力を仮定し、ヤング率は 、ポアソン比は とします。
xは右向き、yは上向きを正とします。左側の節点10・40はx方向の変位を0とし、さらに節点10のy方向変位を0とします。
for node in (10, 40):
model.add_boundary_condition(node, "ux")
model.add_boundary_condition(10, "uy")
節点10のy変位を拘束するのは、モデル全体の上下方向の移動を止めるためです。節点40のy変位は拘束せず、圧縮に伴って高さ方向へ膨らめるようにします。
右辺には、一様な圧力 を与えます。正の圧力は内向きなので、この右辺では表面力のx成分が になります。圧力を与えていない上辺・下辺は自由表面です。
外力の仮想仕事と同じく、圧力の方向と作用面積は初期形状から求めて固定します。図に表示する変形後の向きや面積で、荷重を更新する解析ではありません。
2. 圧力を与える辺の指定と解析の実行
要素番号と局所辺番号を指定する
この例の節点座標と接続情報は、次のとおりです。
mesh = Mesh(
[[0, 0], [10, 0], [10, 2], [0, 2]],
[[10, 20, 30, 40]],
node_labels=[10, 20, 30, 40],
element_labels=[100],
)
要素100の局所節点1・2・3・4は、接続情報の順に節点10・20・30・40を指します。局所辺は1→2、2→3、3→4、4→1の順に番号1〜4を付けます。図の右辺は局所節点2→3、つまり節点20→30なので、辺番号は2です。
model.add_pressure(element=100, edge=2, value=10.0)
element は要素ラベル、edge はその要素の局所辺番号、value は最終段階の圧力です。節点荷重を一つずつ指定する代わりに、モジュールが辺上の圧力から等価節点荷重を計算します。
例題を実行する
提供モジュールを導入した環境で、次のコードを全文コピーし、教材の linear-fem フォルダー直下に uniform_pressure.py としてUTF-8で保存してください。
uniform_pressure.py:圧力による圧縮解析と結果出力
# Copyright (c) 2026 Numerical Atlas
# SPDX-License-Identifier: MIT
"""初期形状の右辺に一定圧力を与える一要素圧縮(mm・N系)。"""
import argparse
from pathlib import Path
import numpy as np
from fem import FEMModel, LinearElastic, LinearElasticStaticAnalysis, Mesh, OutputRequest, Quad4
from fem.io import write_paraview, write_web_data, write_curve_csv
from fem.postprocess import Curve, sum_histories
def plot_results(results, *, directory, scale=5000, overwrite=False):
"""保存済みの最終状態を描く。変形倍率は表示だけに使う。"""
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
from fem.matplotlib import plot_deformed, plot_contour, write_figure
for name in ("deformed", "stress"):
fig, ax = plt.subplots(figsize=(8, 3.2), layout="constrained")
try:
if name == "deformed":
plot_deformed(results.latest_frame, scale=scale, ax=ax)
else:
plot_contour(results.latest_frame, "S", component="xx", scale=scale,
method="gauss", undeformed=True, clim=(-10, 0), ax=ax)
write_figure(fig, path=Path(directory) / f"{name}.png", overwrite=overwrite)
finally:
plt.close(fig)
def build_model():
mesh = Mesh([[0, 0], [10, 0], [10, 2], [0, 2]], [[10, 20, 30, 40]],
node_labels=[10, 20, 30, 40], element_labels=[100])
model = FEMModel(mesh, units={"length": "mm", "force": "N"})
model.assign_elements([100], element_type=Quad4, material=LinearElastic(200000, .3),
kinematics="plane_stress", thickness=1)
for node in (10, 40):
model.add_boundary_condition(node, "ux")
model.add_boundary_condition(10, "uy")
# 辺2は局所節点2→3、ここでは外部節点20→30。正の圧力は内向き。
model.add_pressure(element=100, edge=2, value=10.0)
return model
def build_outputs():
return (OutputRequest().field_nodes(variables=["U", "RF", "CF", "TF"])
.field_elements(variables=["S", "E", "SENER"])
.history_nodes(labels=[20], variables=["U"])
.history_nodes(labels=[10, 40], variables=["RF"])
.history_global(variables=["ALLSE", "ALLWK", "ETOTAL"]))
def main(*, directory="output/uniform-pressure", overwrite=False, scale=5000, plots=True):
directory = Path(directory)
results = LinearElasticStaticAnalysis(time_increment=.25).solve(
build_model(), outputs=build_outputs(), field_directory=directory / "fields")
displacement = results.node(20).history("U", component="ux")
reaction = sum_histories([results.node(n).history("RF", component="fx") for n in (10, 40)],
name="Left support reaction")
# sigma=-p, ux=-p*L/E, RF=p*h*thickness, energy=p²*volume/(2E).
np.testing.assert_allclose(displacement.values, -.0005*results.times, atol=1e-15)
np.testing.assert_allclose(reaction.values, 20*results.times, atol=1e-10)
np.testing.assert_allclose(results.latest_frame.fields["S"].values,
np.tile([-10, 0, 0], (4, 1)), atol=1e-10)
np.testing.assert_allclose(results.history("ALLWK").values, .005*results.times**2, atol=1e-14)
np.testing.assert_allclose(results.history("ETOTAL").values, 0, atol=1e-14)
write_paraview(results, directory=directory / "paraview", overwrite=overwrite)
write_web_data(results, directory=directory / "web", overwrite=overwrite)
write_curve_csv(Curve(x=displacement, y=reaction), path=directory / "reaction-displacement.csv",
overwrite=overwrite)
if plots:
plot_results(results, directory=directory, scale=scale, overwrite=overwrite)
print(f"U.ux at node 20 = {displacement.values[-1]:.6g} mm")
print(f"Left support RF.fx sum = {reaction.values[-1]:.6g} N")
print(f"ALLWK = {results.history('ALLWK').values[-1]:.6g} N mm")
print(f"Results: {directory.resolve()}")
return results
if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--output", default="output/uniform-pressure")
parser.add_argument("--overwrite", action="store_true")
parser.add_argument("--scale", type=float, default=5000, help="Deformation display scale")
parser.add_argument("--no-plots", action="store_true", help="Export data without Matplotlib figures")
args = parser.parse_args()
main(directory=args.output, overwrite=args.overwrite, scale=args.scale, plots=not args.no_plots).venv/Scripts/python.exe uniform_pressure.py --output output/pressure-first
解析、Matplotlibの画像出力、解析解との数値比較を一度に実行します。再実行時に結果を残す場合は保存先を変え、既存の出力を置き換える場合は --overwrite を付けてください。
| 出力 | 内容 |
|---|---|
deformed.png | 変形前後の形状 |
stress.png | x方向応力のコンター図 |
reaction-displacement.csv | 節点20のx変位と左側の支持反力合計 |
fields/・paraview/・web/ | 保存フィールド、ParaView用データ、Web用JSON |
主な出力値は次のとおりです。
U.ux at node 20 = -0.0005 mm
Left support RF.fx sum = 20 N
例題は圧力を最終値の25%ずつ増やし、4段階で静的なつり合いを解きます。time_increment=0.25 の時刻は載荷の進行を表し、慣性や振動を計算する時間ではありません。
3. 変形・応力を可視化する
横に縮み、縦に膨らむ変形
最終状態は results.latest_frame から取り出します。変位は小さいので、表示では5000倍に拡大します。
fig, ax = plot_deformed(results.latest_frame, scale=5000)

節点20の実際のx変位は−0.0005 mmです。図上の移動は5000倍の−2.5 mmになります。表示倍率を変えても、計算した変位や応力の値は変わりません。
応力を読む
fig, ax = plot_contour(
results.latest_frame, "S", component="xx",
scale=5000, method="gauss", undeformed=True, clim=(-10, 0),
)

method="gauss" は要素を4区画に分け、対応する積分点の値で塗ります。この問題では一様な応力状態になるため、どの区画も同じ色です。
ブラウザで載荷段階を切り替える
次の図も、例題で求解した4状態を使っています。載荷段階を切り替え、圧力、応力、変位、反力が一緒に変わることを確認してください。変形倍率を0にすると元の形状に戻りますが、数値は変わりません。
- 圧力
- 10.0 N/mm²
- σxx(積分点1)
- -10.0 N/mm²
- 節点20のux
- -0.0005000 mm
- 節点30のuy
- 0.0000300 mm
- 圧力の合力Fx
- -20.0 N
- 支持反力合計Rx
- +20.0 N
4. 支持反力と解析解を確認する
圧力×面積と支持反力
右辺に対応する面の面積は、高さと厚さの積です。
圧力による合力のx成分は、左向きを負として、
となります。ここでは厚さ も面積に含めます。高さだけを掛けると単位がN/mmとなり、力にはなりません。
一様な圧力を受ける直線の辺なので、等価節点荷重は節点20・30へ半分ずつ、各−10 Nになります。左側の支持反力は RF から取得し、節点10・40のx成分を足します。
reaction = sum_histories([
results.node(n).history("RF", component="fx") for n in (10, 40)
], name="Left support reaction")
CF は節点へ直接与えた集中荷重であり、圧力の等価節点荷重を含みません。 この例では CF は0です。圧力の合力を CF の合計から読まず、入力した圧力と面積から求めて、RF と比較します。
| 載荷段階 | 圧力 [N/mm²] | 圧力の合力Fx [N] | 支持反力合計Rx [N] |
|---|---|---|---|
| 1 / 4 | 2.5 | −5 | +5 |
| 2 / 4 | 5.0 | −10 | +10 |
| 3 / 4 | 7.5 | −15 | +15 |
| 4 / 4 | 10.0 | −20 | +20 |
最終段階では となり、x方向につり合います。
一様圧縮の解析解と照合する
この拘束条件では、右辺の圧力に対して一様な一軸圧縮状態が成り立ちます。平面応力の構成則から、
です。左側のx変位と下側のy変位が0になる変位場は、
と書けます。この変位場は指定した拘束を満たし、上辺・下辺の表面力も0になります。最終圧力を代入すると、次の値を得ます。
| 確認する量 | 解析解 | FEMの結果 |
|---|---|---|
| 節点20のux [mm] | −0.0005 | −0.0005 |
| 節点30のuy [mm] | +0.00003 | +0.00003 |
| εxx | −0.00005 | −0.00005 |
| εyy | +0.000015 | +0.000015 |
| σxx [N/mm²] | −10 | −10 |
| 左側の支持反力合計 [N] | +20 | +20 |
ひずみ・応力は4積分点すべてでこの値になります。座標に対して一次の変位場をこの要素で表せるため、1要素でも丸め誤差の範囲で解析解と一致します。
例えば、要素100の積分点1におけるx方向応力は次のように確認できます。
sxx = results.latest_frame.element(100).value(
"S", component="xx", integration_point=1)
節点40のy変位を自由にした拘束条件が、一様な高さ方向の膨らみを許していることも、変位の解析解と図から読み取れます。