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?

ひずみエネルギとそれを使った材料力学 基本例題8.18 P276 「材料力学演習(20221021)」をsympyでやってみたい。

Last updated at Posted at 2024-11-14

パイソニスタの方へ
・教えて下さい。
 変数Eはsymbol,var宣言しても、自然対数の底(ネイピア数)ですか。

Gemini先生へ
sympyで、変数Eはsymbol,var宣言しても、自然対数の底(ネイピア数)ですか。
>???...、計算の際にその性質が考慮されます。..

   基本例題8.18 解説1,2 P276  (2024-11-14)
   基本例題8.18 解説3(途中) P277 (2024-11-14)

オリジナル

基本例題8.18 P276 (pdf)「材料力学演習(20221021)一括(ver.3.3)」を勉強したい。#sympy
        ???タブレット等で、pdfを開く事ができないかも。??? 

sympyで

・ ver0.1 p276 基本例題8.18
・変数Eを変数myEすべきでした。ver0.2で

# ver0.1 p276 基本例題8.18
from sympy import *
var('E,G,Iz,Ip' )
var('P,a,b,c'   )
var('x,x1,x2,x3')
UDC  ="1/(2*E*Iz)*Integral((P*x1)**2        ,(x1,0,c))"                                           ;print("#",UDC)
UCB  ="1/(2*E*Iz)*Integral((P*x2)**2        ,(x2,0,b)) + 1/(2*G*Ip)*Integral((P*c)**2,(x2,0,b))"  ;print("#",UCB)
UAB  ="1/(2*E*Iz)*Integral((P*(c-a)+P*x3)**2,(x3,0,a)) + 1/(2*G*Ip)*Integral((P*b)**2,(x3,0,a))"  ;print("#",UAB)
UDC,UCB,UAB=map(sympify,[UDC,UCB,UAB])
print()
Uz   =UDC+UCB.as_ordered_terms()[1]+UAB.as_ordered_terms()[1]                                    #;print("#",Uz)
Up   =    UCB.as_ordered_terms()[0]+UAB.as_ordered_terms()[0]                                    #;print("#",Up)
dUz  =diff(Uz.doit(),P)                                                                           ;print("#",dUz)
dUp  =diff(Up.doit(),P)                                                                           ;print("#",dUp)
print()
print("#",dUz.as_ordered_terms()[1])
print("#",dUz.as_ordered_terms()[0])
print("#",simplify(dUz.as_ordered_terms()[2]),"   ←←← あと一歩 (a-c)**3+C**3") 
print("#",dUp.as_ordered_terms()[1])
print("#",dUp.as_ordered_terms()[0])
# 1/(2*E*Iz)*Integral((P*x1)**2        ,(x1,0,c))
# 1/(2*E*Iz)*Integral((P*x2)**2        ,(x2,0,b)) + 1/(2*G*Ip)*Integral((P*c)**2,(x2,0,b))
# 1/(2*E*Iz)*Integral((P*(c-a)+P*x3)**2,(x3,0,a)) + 1/(2*G*Ip)*Integral((P*b)**2,(x3,0,a))

# P*c**3*exp(-1)/(3*Iz) + P*a*b**2/(G*Ip) + P*b*c**2/(G*Ip)
# P*b**3*exp(-1)/(3*Iz) + (2*P*a**3/3 + a**2*(-2*P*a + 2*P*c) + a*(2*P*a**2 - 4*P*a*c + 2*P*c**2))*exp(-1)/(2*Iz)

# P*a*b**2/(G*Ip)
# P*c**3*exp(-1)/(3*Iz)
# P*b*c**2/(G*Ip)    ←←← あと一歩 (a-c)**3+C**3
# (2*P*a**3/3 + a**2*(-2*P*a + 2*P*c) + a*(2*P*a**2 - 4*P*a*c + 2*P*c**2))*exp(-1)/(2*Iz)
# P*b**3*exp(-1)/(3*Iz)

・ ver0.2 p276 基本例題8.18
・変数Eを変数myEにしました。

# ver0.2 p276 基本例題8.18
from sympy import *
var('myE,G,Iz,Ip' )
var('P,a,b,c'   )
var('x,x1,x2,x3')
UDC  ="1/(2*myE*Iz)*Integral((P*x1)**2        ,(x1,0,c))"                                           ;print("#",UDC)
UCB  ="1/(2*myE*Iz)*Integral((P*x2)**2        ,(x2,0,b)) + 1/(2*G*Ip)*Integral((P*c)**2,(x2,0,b))"  ;print("#",UCB)
UAB  ="1/(2*myE*Iz)*Integral((P*(c-a)+P*x3)**2,(x3,0,a)) + 1/(2*G*Ip)*Integral((P*b)**2,(x3,0,a))"  ;print("#",UAB)
UDC,UCB,UAB=map(sympify,[UDC,UCB,UAB])
print()
Uz   =UDC+UCB.as_ordered_terms()[1]+UAB.as_ordered_terms()[1]                                      #;print("#",Uz)
Up   =    UCB.as_ordered_terms()[0]+UAB.as_ordered_terms()[0]                                      #;print("#",Up)
dUz  =diff(Uz.doit(),P)                                                                             ;print("#",dUz)
dUp  =diff(Up.doit(),P)                                                                             ;print("#",dUp)
print()
print("#",dUz.as_ordered_terms()[1])
print("#",dUz.as_ordered_terms()[0])
print("#",simplify(dUz.as_ordered_terms()[2]),"   ←←← あと一歩 (a-c)**3+C**3") 
print("#",dUp.as_ordered_terms()[1])
print("#",dUp.as_ordered_terms()[0])
# 1/(2*myE*Iz)*Integral((P*x1)**2        ,(x1,0,c))
# 1/(2*myE*Iz)*Integral((P*x2)**2        ,(x2,0,b)) + 1/(2*G*Ip)*Integral((P*c)**2,(x2,0,b))
# 1/(2*myE*Iz)*Integral((P*(c-a)+P*x3)**2,(x3,0,a)) + 1/(2*G*Ip)*Integral((P*b)**2,(x3,0,a))

# P*c**3/(3*Iz*myE) + P*a*b**2/(G*Ip) + P*b*c**2/(G*Ip)
# P*b**3/(3*Iz*myE) + (2*P*a**3/3 + a**2*(-2*P*a + 2*P*c) + a*(2*P*a**2 - 4*P*a*c + 2*P*c**2))/(2*Iz*myE)

# P*a*b**2/(G*Ip)
# P*c**3/(3*Iz*myE)
# P*b*c**2/(G*Ip)    ←←← あと一歩 (a-c)**3+C**3
# (2*P*a**3/3 + a**2*(-2*P*a + 2*P*c) + a*(2*P*a**2 - 4*P*a*c + 2*P*c**2))/(2*Iz*myE)
# P*b**3/(3*Iz*myE)

いつもの? sympyの実行環境と 参考のおすすめです。

(テンプレート)

いつもと違うおすすめです。

as_ordered_terms(order=None, data=False)

参考文献

>一部に等分布荷重を受ける単純支持はり
>JSME p89
 
>単純支持ばり 7)
>構造力学公式集 p136

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?