・(2025-03-16)作業中
・長文です。
・タイトルを変更予定です。
・超初心者の方(私) は、「符号の決め方」は,おすすめ?必須です。
私は、2,3,2',3'のどっちつかず(deepl翻訳済み)で実行しています。
ChatGPT先生は2,3でした。
https://qiita.com/mrrclb48z/items/09b7cc73f0a22bf651b8
・作図はアメリカ式です。
・図に文字も表示できるとうれしい。
・答え1つ出すのに、大変な事をしています。
・sympyのBeamの.remove_load を使いました。
remove_load(value, start, order, end=None)
https://docs.sympy.org/latest/modules/physics/continuum_mechanics/beam.html#sympy.physics.continuum_mechanics.beam.Beam.remove_load
Qiita_建築士
https://qiita.com/mrrclb48z/items/893cb0967e4ddb2945f7
オリジナル
・Youtube 建築士試験マニア/はまちゃん 様 (0:00〜11:15)
二級建築士【406】最大曲げモーメント(構造)
https://youtu.be/y5GM9ztHQs0
>長さに反力は反比例する。
>せん断が0がモーメントがmax
sympyで(オリジナル 様の方法を参考に)
ver0.1
# ver0.1
from sympy import *
var('x')
x=solve(Eq(288-18*x,0),x)[0]
print("#", x )
print("#",24-x )
print("#",24*(6+6)/18)
print("#",24*( 6)/18)
print("#",16*4-16*8 )
# 16
# 8
# 16.0
# 8.0
# -64
sympyで(いつもの方法で省略)
ver0.2
・同じ「発展例題4.24」
sympyで(釣り合いで)
ver0.3
・いつもの方法がいいです。
・普通は?ΣX=とか、ΣY=とか、ΣM=で十分です。solveを使わなくてもです。
# ver0.3
from sympy import *
var('x,q,L,a,RA,RB,MAC,MCB') # aは区間ACの長さ
MAC=solve( Eq(MAC+q*(L-a)*((a-x)+Rational(1,2)*(L-a))-RB*(L-x),0),MAC)[0] #;print(MAC)
MCB=solve( Eq(MCB+q*(L-x)*( Rational(1,2)*(L-x))-RB*(L-x),0),MCB)[0] #;print(MCB)
sol=solve([Eq(RA+RB-q*(L-a),0),Eq(MAC.subs({x:0}),0)],[RA,RB]) #;print(sol)
MAC=MAC.subs(sol) #;print(MAC)
MCB=MCB.subs(sol) #;print(MCB)
# RA =sol[RA].factor() #;print(RA)
# RB =sol[RB].factor() #;print(RB)
rep ={L:18,a:6,q:2}
MCB =MCB.subs(rep) #;print("#",MCB)
xMCB=solve(Eq(diff(MCB,x),0),x)[0] #;print("#",xMCB)
yMCB=MCB.subs({x:xMCB}) ;print("#",yMCB)
# 64
MAC =MAC.subs(rep)
plot((diff(MAC,x),(x,0,6)),(diff(MCB,x),(x,6,18)))
plot( (MAC ,(x,0,6)), (MCB ,(x,6,18)))
・SFD(matplotlib)
・BMD(matplotlib)
ver0.4
・matplotlibの線種がいま一歩。対応予定。
# ver0.4
from sympy import *
def find_max_piecewise_symbolic(piecewise_func):
"""Piecewise関数の最大値を記号的に求める関数 (x 固定)
Args:
piecewise_func (sympy.Piecewise): 最大値を求めたいPiecewise関数
Returns:
list: 各条件における最大値のリスト
"""
# x = sympy.Symbol('x')
max_vals = []
for expr, cond in piecewise_func.args:
max_val = solve(diff(expr, x), x)
max_vals.append((max_val, cond))
return max_vals
def find_max_piecewise_conditional(piecewise_func):
"""Piecewise関数の最大値を条件分岐で求める関数 (x 固定)
Args:
piecewise_func (sympy.Piecewise): 最大値を求めたいPiecewise関数
Returns:
sympy.Expr: Piecewise関数の最大値
"""
# x = sympy.Symbol('x')
max_vals = find_max_piecewise_symbolic(piecewise_func)
if not max_vals:
return None
max_val = None
for vals, cond in max_vals:
if vals:
val = vals[0]
if cond.subs(x, val):
if max_val is None or piecewise_func.subs(x, val) > max_val:
max_val = piecewise_func.subs(x, val)
return max_val
var('x,q,L,a,RA,RB,MAC,MCB') # aは区間ACの長さ
MAC=solve( Eq(MAC+q*(L-a)*((a-x)+Rational(1,2)*(L-a))-RB*(L-x),0),MAC)[0] #;print(MAC)
MCB=solve( Eq(MCB+q*(L-x)*( Rational(1,2)*(L-x))-RB*(L-x),0),MCB)[0] #;print(MCB)
sol=solve([Eq(RA+RB-q*(L-a),0),Eq(MAC.subs({x:0}),0)],[RA,RB]) #;print(sol)
MAC=MAC.subs(sol) #;print(MAC)
MCB=MCB.subs(sol) #;print(MCB)
# RA =sol[RA].factor() #;print(RA)
# RB =sol[RB].factor() #;print(RB)
rep ={L:18,a:6,q:2}
# M_pie=Piecewise((MAC.subs(rep),x<6) ,(0,True)) #;だめでした。
M_pie =Piecewise((MAC.subs(rep),x<6),(MCB.subs(rep),x<=18),(0,True)) #;print("#",M_pie)
print("#",find_max_piecewise_conditional(M_pie))
# 64
plot((M_pie,(x,0,18)))
sympyのBeamで(新)
ver0.5
・.remove_load を使いました。
from sympy import *
from sympy.physics.continuum_mechanics.beam import Beam
from sympy import symbols, Piecewise
E , I = symbols('E , I ')
R1, R2 = symbols('R1, R2')
x = symbols('x')
L,a,w=18,6,2
b = Beam(L, E, I)
b.apply_load ( w,a, 0,L)
# # ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
b.apply_load (R1,0,-1 )
b.apply_load (R2,L,-1 )
# # ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
b.solve_for_reaction_loads(R1, R2)
print("#",b.max_bmoment()[1])
b.plot_shear_force()
b.plot_bending_moment()
# # ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
b.remove_load (R1,0,-1 )
b.remove_load (R2,L,-1 )
# # ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
b.apply_support( 0,'pin' )
b.apply_support( L,'roller')
p = b.draw()
p.show()
# 64
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
sympyのBeamで(旧)
ver0.5
・それでも、解決していません。
?①以下の順番がおかしい。
?②絵がおかしい。↓2つ表示される。
?③エラーメッセージ
# ver0.5
from sympy import *
from sympy.physics.continuum_mechanics.beam import Beam
from sympy import symbols, Piecewise
E , I = symbols('E , I ')
R1, R2 = symbols('R1, R2')
x = symbols('x')
b = Beam(18, E, I)
b.apply_load (R1, 0,-1 )
b.apply_load ( 2, 6, 0,18 )
b.apply_load (R2,18,-1 )
b.bc_deflection = [(0, 0),(18, 0)]
b.solve_for_reaction_loads(R1, R2)
print("#",b.reaction_loads[R1],b.reaction_loads[R2])
print("#",b.bending_moment())
print("#",b.bending_moment().rewrite(Piecewise)) # このprint行は不要です。見てみたかった。
print("#",b.max_bmoment())
b.plot_shear_force()
b.plot_bending_moment()
#
b.apply_support( 0 ,'pin' )
b.apply_support(18 ,'roller')
p = b.draw()
p.show()
# -8 -16
# 8*SingularityFunction(x, 0, 1) - SingularityFunction(x, 6, 2) + 16*SingularityFunction(x, 18, 1) + SingularityFunction(x, 18, 2)
# 8*Piecewise((x, x >= 0), (0, True)) + 16*Piecewise((x - 18, x >= 18), (0, True)) + Piecewise(((x - 18)**2, x >= 18), (0, True)) - Piecewise(((x - 6)**2, x >= 6), (0, True))
# (10, 64)
#
# /home/xxx/.local/lib/python3.11/site-packages/sympy/physics/continuum_mechanics/beam.py:2382: UserWarning: Please, note that this schematic view might not be in agreement with the sign convention used by the Beam class for load-related computations,
# because it was not possible to determine the sign (hence, the direction) of the following loads:
# * Point load R2 located at 18
# * Point load R1 located at 0
# warnings.warn(warning_head + warning_body)
・SymPy Live Shell で、作図はできません。 エラーImportError...がでます。
・以下の作図は、PC(例.私のchromebook)で実行しました。
# 令和5年二級建築士試験学科Ⅲ(建築構造)〔No. 3〕
# ver0.5
from sympy import *
from sympy.physics.continuum_mechanics.beam import Beam
from sympy import symbols, Piecewise
E , I = symbols('E, I')
R1, R2 = symbols('R1, R2')
x = symbols('x')
b = Beam(18, E, I)
b.apply_load( R1, 0,-1)
b.apply_load( 2, 6, 0,18)
b.apply_load( R2,18,-1)
b.bc_deflection = [(0, 0), (18, 0)]
b.solve_for_reaction_loads(R1, R2)
# print("#",b.reaction_loads[R1])
# print("#",b.reaction_loads[R2])
# print("#",b.boundary_conditions)
# print("#",b.applied_loads)
print("#",b.bending_moment())
# print("#",b.load .rewrite(Piecewise))
# print("#",b.shear_force() .rewrite(Piecewise))
# print("#",b,b.slope() .rewrite(Piecewise))
print("#",b.bending_moment().rewrite(Piecewise))
# print("#",b.deflection() .rewrite(Piecewise))
#
myInterval=Interval(0,18)
myMaxM =maximum(b.bending_moment() ,x,myInterval)
myMaxMr=maximum(b.bending_moment().rewrite(Piecewise),x,myInterval)
print("#",myMaxM )
print("#",myMaxMr)
# print("#",solve(Eq(b.bending_moment(),myMaxM),x))
print("#",solveset(Eq(b.bending_moment(),myMaxM),x,myInterval).args[0])
#
p = b.draw()
p.show()
# b.plot_shear_force()
b.plot_bending_moment()
# ---------------------------------------------------------------------
# 8*SingularityFunction(x, 0, 1) - SingularityFunction(x, 6, 2) + 16*SingularityFunction(x, 18, 1) + SingularityFunction(x, 18, 2)
# 8*Piecewise((x, x > 0), (0, True)) + 16*Piecewise((x - 18, x > 18), (0, True)) + Piecewise(((x - 18)**2, x > 18), (0, True)) - Piecewise(((x - 6)**2, x > 6), (0, True))
# 64
# 64
# 10
いつもの? sympyの実行環境と 参考のおすすめです。
いつもと違うおすすめです。
sympyのdoc
公式ホームページ
試験問題〔No.3〕と正答肢
https://www.jaeic.or.jp/shiken/2k/2k-mondai.files/2k-2023-1st-gakka3_4-r.pdf#page=3
https://www.jaeic.or.jp/shiken/2k/2k-mondai.files/2k-2023-1st-gokakukijun-r.pdf
「学科の試験」< 一級建築士を志す者に対して、...
https://www.jaeic.or.jp/smph/shiken/1k/1k-mondai.html
「学科の試験」< 二級建築士を志す者に対して、...
https://www.jaeic.or.jp/smph/shiken/2k/2k-mondai.html