本ポストはこちらの続きです。

Rで有限要素法:片持ち梁-自由端に集中モーメント:たわみ量
const typesetMath = (el) => { if (window.MathJax) { // MathJax Typeset window.MathJax.typeset(); } else if (window.katex...
片持ち梁-中間点に集中荷重
片持ち梁のたわみ:FEM(オイラー・ベルヌーイ梁要素) vs 厳密解
# ============================================================
# 片持ち梁のたわみ(中間点に集中荷重):FEM vs 厳密解
# ============================================================
#
# 厳密解(xは自由端Aから測った距離。荷重点を境に2つの式に分かれる):
# w1(x) = (Pl^3/6EI){-β^3+3β^2-3β^2(x/l)} [0 <= x <= a]
# w2(x) = (Pl^3/6EI)(1-x/l)^2(3β-1+x/l) [a <= x <= l]
# w_max = (Pl^3/6EI)(-β^3+3β^2) [x = 0, 自由端]
#
# s : FEM座標(固定端起点、s=0で固定端、s=lで自由端)
# x : 厳密解の座標(自由端起点、x = l - s)
# 荷重点のFEM座標は s_load = l - a = b
#
# 集中荷重が節点と一致しない場合の等価節点荷重:
# f_e = P * [N1(xi0), N2(xi0), N3(xi0), N4(xi0)]
# (xi0は、荷重が含まれる要素内でのローカル座標)
# 今回はメッシュを、荷重点にちょうど節点が来るように選んでいるため、
# 実質的に「自由端に集中荷重がかかる場合」と同じ「節点にそのまま荷重を与える」扱いになる。
library(ggplot2)
# ------------------------------------------------------------
# 1. 梁の諸元と荷重の設定
# ------------------------------------------------------------
l <- 2.0
a <- 0.8 # 自由端Aから荷重点までの距離
b <- l - a # 荷重点から固定端Bまでの距離
beta <- b / l
P <- 1000 # 荷重点にかかる集中荷重 [N]
E <- 210e9
I <- 4.1667e-6
EI <- E * I
s_load <- l - a # 荷重点のFEM座標(固定端起点)
# ------------------------------------------------------------
# 2. 形状関数と要素剛性行列
# ------------------------------------------------------------
shape_N <- function(xi, Le) {
N1 <- 1 - 3 * xi^2 + 2 * xi^3
N2 <- Le * (xi - 2 * xi^2 + xi^3)
N3 <- 3 * xi^2 - 2 * xi^3
N4 <- Le * (-xi^2 + xi^3)
c(N1, N2, N3, N4)
}
beam_element_k <- function(Le) {
(EI / Le^3) * matrix(c(
12, 6 * Le, -12, 6 * Le,
6 * Le, 4 * Le^2, -6 * Le, 2 * Le^2,
-12, -6 * Le, 12, -6 * Le,
6 * Le, 2 * Le^2, -6 * Le, 4 * Le^2
), nrow = 4, byrow = TRUE)
}
# ------------------------------------------------------------
# 3. メッシュ生成(荷重点s_loadにちょうど節点が来るように要素数を選ぶ)
# ------------------------------------------------------------
n_elem <- 10L # Le = 2.0/10 = 0.2、s_load = 1.2 はその6倍 → 節点上に載る
Le <- l / n_elem
n_node <- n_elem + 1L
n_dof <- 2L * n_node
K <- matrix(0, n_dof, n_dof)
F <- numeric(n_dof)
K_e <- beam_element_k(Le)
for (e in seq_len(n_elem)) {
dofs <- c(2 * e - 1, 2 * e, 2 * e + 1, 2 * e + 2)
K[dofs, dofs] <- K[dofs, dofs] + K_e
}
# ------------------------------------------------------------
# 4. 集中荷重の載荷(荷重点を含む要素を探し、形状関数で等価節点荷重に変換)
# ------------------------------------------------------------
e_idx <- min(floor(s_load / Le) + 1L, n_elem) # 荷重点を含む要素番号(1始まり)
s0 <- (e_idx - 1) * Le # その要素の始点(固定端起点)
xi0 <- (s_load - s0) / Le # 要素内のローカル座標(0〜1)
f_e <- shape_N(xi0, Le) * P
dofs <- c(2 * e_idx - 1, 2 * e_idx, 2 * e_idx + 1, 2 * e_idx + 2)
F[dofs] <- F[dofs] + f_e
# ------------------------------------------------------------
# 5. 境界条件(固定端: w=0, θ=0)
# ------------------------------------------------------------
fixed_dofs <- c(1, 2)
free_dofs <- setdiff(seq_len(n_dof), fixed_dofs)
u <- numeric(n_dof)
u[free_dofs] <- solve(K[free_dofs, free_dofs], F[free_dofs])
w_fem <- u[seq(1, n_dof, by = 2)]
th_fem <- u[seq(2, n_dof, by = 2)]
s_nodes <- seq(0, l, length.out = n_node)
x_nodes <- l - s_nodes
# ------------------------------------------------------------
# 6. 厳密解との比較(荷重点を境に2つの式を使い分ける)
# ------------------------------------------------------------
w_exact_fn <- function(x) {
ifelse(x <= a,
(P * l^3) / (6 * EI) * (-beta^3 + 3 * beta^2 - 3 * beta^2 * (x / l)),
(P * l^3) / (6 * EI) * (1 - x / l)^2 * (3 * beta - 1 + x / l)
)
}
comparison <- data.frame(
自由端起点_x_m = round(x_nodes, 3),
FEM近似解_mm = round(w_fem * 1000, 8),
厳密解_mm = round(w_exact_fn(x_nodes) * 1000, 8),
差_mm = w_fem * 1000 - w_exact_fn(x_nodes) * 1000
)
print(comparison)
cat("\n自由端でのたわみ量:\n")
cat(" FEM近似解:", w_fem[n_node] * 1000, "mm\n")
cat(" 厳密解 :", (P * l^3) / (6 * EI) * (-beta^3 + 3 * beta^2) * 1000, "mm\n")
# ------------------------------------------------------------
# 7. 可視化
# ------------------------------------------------------------
hermite_w <- function(xi, Le, w1, th1, w2, th2) {
N1 <- 1 - 3 * xi^2 + 2 * xi^3
N2 <- Le * (xi - 2 * xi^2 + xi^3)
N3 <- 3 * xi^2 - 2 * xi^3
N4 <- Le * (-xi^2 + xi^3)
N1 * w1 + N2 * th1 + N3 * w2 + N4 * th2
}
fem_curve <- do.call(rbind, lapply(seq_len(n_elem), function(e) {
xi_seq <- seq(0, 1, length.out = 20)
w1v <- w_fem[e]
th1v <- th_fem[e]
w2v <- w_fem[e + 1]
th2v <- th_fem[e + 1]
s_local <- s_nodes[e] + xi_seq * Le
data.frame(x = l - s_local, w_mm = hermite_w(xi_seq, Le, w1v, th1v, w2v, th2v) * 1000)
}))
x_fine <- seq(0, l, length.out = 300)
exact_curve <- data.frame(x = x_fine, w_mm = w_exact_fn(x_fine) * 1000)
p <- ggplot() +
geom_line(data = exact_curve, aes(x = x, y = w_mm, color = "厳密解"), linewidth = 1.2) +
geom_line(
data = fem_curve, aes(x = x, y = w_mm, color = "FEM(要素内補間)"),
linetype = "dashed", linewidth = 0.8
) +
geom_point(
data = data.frame(x = x_nodes, w_mm = w_fem * 1000),
aes(x = x, y = w_mm, color = "FEM(節点)"), size = 2
) +
geom_vline(xintercept = a, linetype = "dotted", color = "gray50") +
annotate("text",
x = a, y = max(exact_curve$w_mm) * 0.95, label = "荷重点",
hjust = -0.1, size = 3.5, color = "gray40"
) +
scale_color_manual(values = c(
"厳密解" = "gray40", "FEM(要素内補間)" = "steelblue",
"FEM(節点)" = "firebrick"
), name = "") +
labs(
title = "中間点に集中荷重を受ける片持ち梁:FEM vs 厳密解",
subtitle = paste0("要素数 = ", n_elem, "(荷重点にちょうど節点があるため完全一致)"),
x = "自由端からの距離 x [m]", y = "たわみ量 w [mm]"
) +
theme_minimal(base_size = 12)
print(p) 自由端起点_x_m FEM近似解_mm 厳密解_mm 差_mm
1 2.0 0.00000000 0.00000000 0.000000e+00
2 1.8 0.02590455 0.02590455 -5.672546e-15
3 1.6 0.09752303 0.09752303 -2.157996e-14
4 1.4 0.20571264 0.20571264 -4.604650e-14
5 1.2 0.34133060 0.34133060 -7.732703e-14
6 1.0 0.49523413 0.49523413 -1.139089e-13
7 0.8 0.65828045 0.65828045 -1.553202e-13
8 0.6 0.82285056 0.82285056 -1.968425e-13
9 0.4 0.98742067 0.98742067 -2.357003e-13
10 0.2 1.15199078 1.15199078 -2.735590e-13
11 0.0 1.31656090 1.31656090 -3.119727e-13
自由端でのたわみ量:
FEM近似解: 1.316561 mm
厳密解 : 1.316561 mm厳密解の公式
- 出典 : 「構造力学公式集 昭和61年版」(土木学会)
反力・せん断力
\[\begin{eqnarray}R_B &=& P\\M_B &=& -Pb\\Q_1 &=& 0\\Q_2 &=& -P\end{eqnarray}\]
曲げモーメント
\[\begin{eqnarray}
M_1 &=& 0\\
M_2 &=& -P(x-a)\\
M_{\max} &=& -Pb, \quad [x = l]
\end{eqnarray}\]
たわみ
\[\begin{eqnarray}
w_1 &=& \frac{Pl^3}{6EI}\left\{-\beta^3+3\beta^2-3\beta^2\left(\frac{x}{l}\right)\right\}\\
w_2 &=& \frac{Pl^3}{6EI}\left(1-\frac{x}{l}\right)^2\left(3\beta-1+\frac{x}{l}\right)\\
w_{\max} &=& \frac{Pl^3}{6EI}(-\beta^3+3\beta^2), \quad [x = 0]
\end{eqnarray}\]
たわみ角
\[\begin{eqnarray}
\theta_1 &=& \frac{Pb^2}{2EI}\\
\theta_2 &=& -\frac{Pl^2}{2EI}\left(1-\frac{x}{l}\right)\left(1-\frac{x}{l}-2\beta\right)\\
\theta_A &=& \frac{Pb^2}{2EI}
\end{eqnarray}\]
以上です。


