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?

simple beam,uniformly distributed load はりの応力とSFD,BMD 発展例題4.24 p102「材料力学演習」をsympyでやってみたい。

Last updated at Posted at 2023-12-19

パイソニスタの方へ
・??? 何かいい方法がありませんか。変な質問で申し訳ありません。
・私のver0.2の「symbol」の使い方を教えて下さい。(2023/12/22追加)
 以下で問い合わせ中。

・私のver0.3の「doble integral」の使い方を教えて下さい。(2023/12/24追加)
 あと2息です。

オリジナル

発展例題4.24 p102<「材料力学演習(20221021)一括(ver.3.3)」を勉強したい。
          ???タブレット等で、pdfを開く事ができないかも。??? 

latexで(勉強中)

(2023/12/26追加)
基本事項3の4関係式 P94より

\begin{array}{ll}
\dfrac{dQ}{dx}=q\\
\dfrac{dM}{dx}=Q\\
\end{array}

(2023/12/22追加)
・左端を揃えたいです。
・左端のスペースを削除したいです。

F = \left\{
\begin{array}{ll}
R_A & (0 \leq x \leq a)\\
R_A-q(x-a) & (a \leq x \leq l)
\end{array}
\right.

       Fを積分
       Mを微分

M = \left\{
\begin{array}{ll}
R_Ax & (0 \leq x \leq a)\\
R_Ax-1/2q(x-a)^2 & (a \leq x \leq l)
\end{array}
\right.

sympyで

ver0.3 重複積分法で

・「double integral」の使い方を教えて下さい。(2023/12/24追加)

# ver0.3 (2023/12/22追加)
# 発展例題4.24 p102

from sympy import *
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

var('l,q,a',real=True)
var('x'    ,real=True)
var('u,v'  ,real=True)
# var('RA'     ,real=True)
RA = Symbol('RA')
def myDic (myStrKey,myValue):
    return {sympify(myStrKey):myValue}
#
u0x = (u,0,x)
MAC = integrate(RA ,u0x)                    .simplify()               ;print("# MAC =",MAC)                      
FAC = diff(MAC,x)                           .simplify()               ;print("# FAC =",FAC)                      
# 
uav = (u,a,v)
vax = (v,a,x)
MCB = (MAC-integrate(integrate(q,uav),vax)) .simplify()               ;print("# MCB =",MCB)                      
FCB = diff(MCB,x)                           .simplify()               ;print("# FCB =",FCB)                      
RA  = solve(MCB.subs({x:l}),RA) [0]                                   ;print("# RA  =",RA );print()                     
# 
rep = {l:1.0,a:0.4,q:1670}
rep|= myDic("RA" ,RA.subs(rep).simplify() )                           ;print("# rep =",rep)
# 
print("# RA  =",Decimal(str(RA .subs(rep))).quantize(Decimal('0'), ROUND_HALF_UP))
print("# FAC =",Decimal(str(FAC.subs(rep))).quantize(Decimal('0'), ROUND_HALF_UP))
print("# FCB =",            FCB.subs(rep)  .simplify()                           )
print("# MAC =",            MAC.subs(rep)  .simplify()                           )
print("# MCB =",            MCB.subs(rep)  .simplify()                           )
# MAC = RA*x
# FAC = RA
# MCB = RA*x - a**2*q/2 + a*q*x - q*x**2/2
# FCB = RA + a*q - q*x
# RA  = q*(a**2 + l*(-2*a + l))/(2*l)

# rep = {l: 1.0, a: 0.4, q: 1670, RA: 300.600000000000}
# RA  = 301
# FAC = 301
# FCB = 968.6 - 1670*x
# MAC = 300.6*x
# MCB = -835*x**2 + 968.6*x - 133.6

ver0.2 うごきません。

・repに全部の値を、辞書へ。辞書から要素を取り出したい。
・変数RAを,varだと、RAでした。symbolで対応しました。

# ver0.2 (2023/12/22追加)
# 発展例題4.24 p102

from sympy import *

var('l,q,a'   ,real=True)
var('MAC,x'   ,real=True)
var('MCB'     ,real=True)
var('FAC,FCB' ,real=True)
var('RB'      ,real=True)
var('F0x'     ,real=True)
# var('RA'      ,real=True)
RA = Symbol('RA')

def myDic (myStrKey,myValue):
    return {sympify(myStrKey):myValue}
MAC = RA*x                                                           ;print("# MAC=",MAC)                                                              
MCB = solve(-RA*x-Rational(1,2)*q*(x - a)**2+MCB,MCB)[0]             ;print("# MCB=",MCB)
FAC = diff(MAC,x)                                                    ;print("# FAC=",FAC)
FCB = diff(MCB,x).simplify()                                         ;print("# FCB=",FCB)   
RA  = solve(MCB.subs({x:l}),RA)[0]                                   ;print("# RA =",RA )
RB  = q*(l - a)-RA                                                   ;print("# RB =",RB )
print()
rep={l:1.0,a:0.4,q:1.67*1000}                                     #  ;print("# ",rep )
rep |= myDic("RA" ,RA .subs(rep))                                 #  ;print("# ",rep )
rep |= myDic("FAC",FAC.subs(rep))                                 #  ;print("# ",rep )
rep |= myDic("RB" ,RB .subs(rep))                                 #  ;print("# ",rep )
rep |= myDic("FCB",FCB.subs(rep))                                 #  ;print("# ",rep )
rep |= myDic("MAC",MAC.subs(rep))                                 #  ;print("# ",rep )
rep |= myDic("MCB",MCB.subs(rep))                                    ;print("# ",rep,type(rep) )
print("# RA =",rep[RA]  )
# print("# RB =",rep[RB] )
# print("# FAC=",rep[FAC])
# print("# FCB=",rep[FCB])
# print("# MAC=",rep[MAC])
# print("# MCB=",rep[MCB])

# MAC= RA*x
# MCB= RA*x + q*(a - x)**2/2
# FAC= RA
# FCB= RA - q*(a - x)
# RA = -q*(a - l)**2/(2*l)
# RB = q*(-a + l) + q*(a - l)**2/(2*l)

#  {l: 1.0, a: 0.4, q: 1670.0, RA: -300.600000000000, FAC: -300.600000000000, RB: 1302.60000000000, FCB: 1670.0*x - 968.6, MAC: -300.6*x, MCB: -300.6*x + 835.0*(0.4 - x)**2} <class 'dict'>

File "/home/xxx/xxx.py", line 32, in
print("# RA =",rep[RA] )
KeyError: -q*(a - l)**2/(2*l)

ver0.1

# ver0.1 (2023/12/19作成)
# 発展例題4.24 p102
from sympy import *

var('l,q,a'   ,real=True)
var('MAC,RA,x',real=True)
var('MCB'     ,real=True)
var('FAC,FCB' ,real=True)
var('RB'      ,real=True)
var('F0x'     ,real=True)
def myEq_RepLR(eq):
     return {eq.lhs:eq.rhs}
eqMAC=Eq(MAC,RA*x)                                                ;print("#",eqMAC)
eqMCB=Eq(-RA*x+Rational(1,2)*q*(x-a)**2+MCB,0)                    ;print("#",eqMCB)
eqMCB=Eq(MCB,solve([eqMAC,eqMCB],MCB)[MCB])                       ;print("#",eqMCB)
eqFAC=Eq(FAC,diff(eqMAC.rhs,x))                                   ;print("#",eqFAC)
eqFCB=Eq(FCB,diff(eqMCB.rhs,x))                                   ;print("#",eqFCB)
eqRA =Eq(RA,solve(Eq(eqMCB.rhs.subs({x:l}),0),RA)[0].factor() )   ;print("#",eqRA ) 
print()
rep={l:1.0,a:0.4,q:1.67*1000}                                     ;print("#",rep )
eqRA =Eq(RA,eqRA.rhs.subs(rep))                                   ;print("#",eqRA)
eqRB =Eq(RB,solve(Eq(RB,q*(l-a)-RA),RB)[0])                       ;print("#",eqRB) 
eqRB =eqRB.subs(rep).subs(myEq_RepLR(eqRA))                       ;print("#",eqRB) 
eqFAC=eqFAC.subs(myEq_RepLR(eqRA))                                ;print("#",eqFAC)
eqFCB=eqFCB.subs(rep).subs(myEq_RepLR(eqRA))                      ;print("#",eqFCB)
eqMAC=eqMAC.subs(myEq_RepLR(eqRA))                                ;print("#",eqMAC)
eqMCB=eqMCB.subs(rep).subs(myEq_RepLR(eqRA))                      ;print("#",eqMCB)
print()
eqF0x=Eq(F0x,solve(Eq(eqFCB.rhs,0),x)[0])                         ;print("#",eqF0x)
# Eq(MAC, RA*x)
# Eq(MCB - RA*x + q*(-a + x)**2/2, 0)
# Eq(MCB, RA*x - a**2*q/2 + a*q*x - q*x**2/2)
# Eq(FAC, RA)
# Eq(FCB, RA + a*q - q*x)
# Eq(RA, q*(a - l)**2/(2*l))

# {l: 1.0, a: 0.4, q: 1670.0}
# Eq(RA, 300.6)
# Eq(RB, -RA - a*q + l*q)
# Eq(RB, 701.4)
# Eq(FAC, 300.6)
# Eq(FCB, 968.6 - 1670.0*x)
# Eq(MAC, 300.6*x)
# Eq(MCB, -835.0*x**2 + 968.6*x - 133.6)

# Eq(F0x, 0.58)

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

(テンプレート)

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

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

0
0
3

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?