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?

More than 1 year has passed since last update.

静力学と材料力学 基本例題1.06 P3「材料力学演習(20221021)」をsympyでやってみた。

Last updated at Posted at 2023-05-29

2通りで

オリジナル

基本例題1.06 P3
http://zairikiweb.starfree.jp/zai_enshuh/zai_enshuh_ver.3.3.pdf#page=9

「材料力学演習(20221021)一括(ver.3.3)」を勉強したい。>sympy
https://qiita.com/mrrclb48z/items/c3274daf5f7a99cfe027#%E4%BD%9C%E6%A5%AD%E4%B8%AD%E7%A7%81%E3%81%AE%E8%A7%A3%E7%AD%94sympy

sympyで(pdfの手順で実行)

from sympy import *
PA, PB, PC=symbols('PA  PB  PC',real=True)
NAB,NBC   =symbols('NAB NBC   ',real=True)
#
myAF=Eq(-PA +NAB   ,0)
myBF=Eq(-NAB-PB+NBC,0)
myCF=Eq(-NBC+PC    ,0)
myABCF=Eq( myAF.lhs+myBF.lhs+myCF.lhs,myAF.rhs+myBF.rhs+myCF.rhs)
print("#",myABCF)
PA_ans=solve(myABCF,PA)[0]
print("#",PA_ans)
NAB_ans=solve(myAF,NAB)[0].subs({PA:PA_ans})
NBC_ans=solve(myCF,NBC)[0].subs({PA:PA_ans})
print("#",NAB_ans,NBC_ans)
mySubs={PB:7,PC:10}
print("#",NAB_ans.subs(mySubs),NBC_ans.subs(mySubs))
# Eq(-PA - PB + PC, 0)
# -PB + PC
# -PB + PC PC
# 3 10

sympyで(solveを1回で実行)

from sympy import *
PA, PB, PC=symbols('PA  PB  PC',real=True)
NAB,NBC   =symbols('NAB NBC   ',real=True)
myAF=Eq(-PA+NAB    ,0)
myBF=Eq(-NAB-PB+NBC,0)
myCF=Eq(-NBC+PC    ,0)
ans=solve([myAF,myBF,myCF],[PA,NAB,NBC])
print("#",ans)
mySubs={PB:7,PC:10}
print("#",ans[NAB].subs(mySubs))
print("#",ans[NBC].subs(mySubs))
# {PA: -PB + PC, NAB: -PB + PC, NBC: PC}
# 3
# 10

①私の環境は,pycharmです。
②よく聞くのは、Jupyterです。
③web上で、上記のソースを「SymPy Live shell」に、コピー貼り付けでもできました。
黒背景の右上に、マウスを移動すると、コピーマークが発生します。
??? タブレット環境で、コピー貼り付けが実行できませんでした。???

Mathematicaで

勉強中

作図

勉強中

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?