0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

わかりませんでした。P1P2片持ち梁の複数荷重(3/4) 「はりのたわみの エネルギー法のsympyのコードを 微分方程式の直接解法のsympyのコードへ 変換して下さい。」AI先生へ

Last updated at Posted at 2024-12-14

・いくらなんでもと思いましたが、チャレンジ? しました。
・私の聞き方が悪いかも。

下記のはりのたわみの エネルギー法のsympyのコードを 微分方程式の直接解法のsympyのコードへ 変換して下さい。
# ver0.4
from sympy import *
EI,P1,P2,a,b,x =symbols('EI,P1,P2,a,b,x')
M01_str="-(P1*(a-x)+P2*(a+b-x))"                               #;print("#",M01_str)
M12_str=          "-P2*(a+b-x) "                               #;print("#",M12_str)
U      = "1/(2*EI)*integrate((" + M01_str+")**2,(x,0,a)) +" \
        +"1/(2*EI)*integrate((" + M12_str+")**2,(x,a,a+b))"    #;print("#,U)
δ1=collect((diff(sympify(U),P1).expand()),[P1,P2])              ;print("#",δ1)
δ2=collect((diff(sympify(U),P2).expand()),[P1,P2])              ;print("#",δ2)
# P2*(a**3/(3*EI) + a**2*b/(2*EI)) + P1*a**3/(3*EI)
# P1*(a**3/(3*EI) + a**2*b/(2*EI)) + P2*(a**3/(3*EI) + a**2*b/EI + a*b**2/EI + b**3/(3*EI))

Gemini先生より

回答抜粋

from sympy import *

# 変数定義
EI, P1, P2, a, b, x = symbols('EI,P1,P2,a,b,x')

# 変位式
δ1 = P2*(a**3/(3*EI) + a**2*b/(2*EI)) + P1*a**3/(3*EI)
δ2 = P1*(a**3/(3*EI) + a**2*b/(2*EI)) + P2*(a**3/(3*EI) + a**2*b/EI + a*b**2/EI + b**3/(3*EI))

# 曲率を求める (例: δ1について)
kappa1 = diff(δ1, x, x)
M1 = EI * kappa1

# 微分方程式を立てる (例: δ1について)
diff_eq1 = Eq(EI * diff(y(x), x, 2), M1)

# 境界条件の設定 (例: 両端単純支持)
BCs = [y(0), y(a)]

# 微分方程式を解く
sol = dsolve(diff_eq1, y(x), ics=BCs)

# 解を表示
print(sol)

(vscodeで)
NameError: name 'y' is not defined
・以下、私は、修正をあきらめました。(2024-12-14)
・修正の聞き方も、思いつきませんでした。アドバイスをいただけると幸いです。
・先生に、修正の聞き方のアドバイスの アドバイスを聞く???

ChatGPT先生より

copilot先生より

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?