LoginSignup
0
0

Mohr's stress circle 組み合わせ応力 問題3 P147「材料力学演習(20221021)」をsympyと作図FreeCAD でやってみた。

Last updated at Posted at 2023-11-22

・モールの応力円は2次元ですが、3次元FreeCADのマクロで、XY平面上に作図しました。

オリジナル

問題3 P147
http://zairikiweb.starfree.jp/zai_enshuh/zai_enshuh_ver.3.3.pdf#page=153

<「材料力学演習(20221021)一括(ver.3.3)」を勉強したい。
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で

ver0.2 です。ユーザー定義関数にしました。

# ver0.2
from sympy import *
var('θn',real=True)
def myσxσyτxy(σx,σy,τxy):
     ci=Circle(Point(Rational(1,2)*(σx+σy),0),sqrt( (Rational(1,2)*(σx-σy))**2+τxy**2) )
     (σ1,σ2,τmax)=(ci.center.x+ci.radius,ci.center.x-ci.radius,ci.radius)
     θn_ans=solve(Eq(tan(2*θn),(2*τxy)/(σx-σy)),θn)[0]*180/pi
     return σ1,σ2,τmax,θn_ans
(σx,σy,τxy)=(-12,-15,-7.5)
σ1,σ2,τmax,θn=myσxσyτxy(σx,σy,τxy)
print("# 1)",round(σ1,2),round(σ2,2))
print("# 2)",round(τmax,2))
print("# 3)",round(θn,1))
# 1) -5.85 -21.15
# 2) 7.65
# 3) -39.3

ver0.1 です。

# ver0.1
from sympy import *
var('θn',real=True)
(σx,σy,τxy)=(-12,-15,-7.5)
ci=Circle(Point(Rational(1,2)*(σx+σy),0),sqrt( (Rational(1,2)*(σx-σy))**2+τxy**2) )
(σ1,σ2,τmax)=(ci.center.x+ci.radius,ci.center.x-ci.radius,ci.radius)
θn=solve(Eq(tan(2*θn),(2*τxy)/(σx-σy)),θn)[0]*180/pi
print("# 1)",round(σ1,2),round(σ2,2))
print("# 2)",round(τmax,2) )
print("# 3)",round(θn,1))
# 1) -5.85 -21.15
# 2) 7.65
# 3) -39.3

作図sympy moduleで

・文字表示のサンプルを探しています。

作図FreeCADで

・モールの応力円は2次元ですが、3次元FreeCADのマクロで、XY平面上に作図しました。
・isometric方向?です。Originは、表示です。

0png.png

・上空から?です。
・σは、表示できませんでした。
・文字の移動の勉強中。

1png.png

import FreeCAD
import Part
import DraftTools
import Draft
import Mesh
############################################################################
# 計算
from sympy import *

var('θn',real=True)
def myσxσyτxy(σx,σy,τxy):
     ci=Circle(Point(Rational(1,2)*(σx+σy),0),sqrt( (Rational(1,2)*(σx-σy))**2+τxy**2) )
     (σ1,σ2,τmax)=(ci.center.x+ci.radius,ci.center.x-ci.radius,ci.radius)
     θn_ans=solve(Eq(tan(2*θn),(2*τxy)/(σx-σy)),θn)[0]*180/pi
     return σ1,σ2,τmax,θn_ans
(σx,σy,τxy)=(-12,-15,-7.5)
σ1,σ2,τmax,θn=myσxσyτxy(σx,σy,τxy)
print("# 1)",round(σ1,2),round(σ2,2))
print("# 2)",round(τmax,2))
print("# 3)",round(θn,1))
############################################################################
# 作図用
A      =Point(σx,-τxy)
B      =Point(σy, τxy)
ro_σ1  =round(float(σ1)  ,2)
ro_σ2  =round(float(σ2)  ,2)
ro_τmax=round(float(τmax),2)
O =Point(0.0    ,0.0)
Od=Point((ro_σ1+ro_σ2)/2 ,0.0)
S1=Point(ro_σ1,0.0)
S2=Point(ro_σ2,0.0)
T1=Point((ro_σ1+ro_σ2)/2,-ro_τmax)
T2=Point((ro_σ1+ro_σ2)/2, ro_τmax)
ci=Circle( Point( (ro_σ1+ro_σ2)/2 ,0.0) , ro_τmax)
############################################################################
# 3D作図 z=0 XY平面に作図しました。
############################################################################
############################################################################
# 円の作図 FrecCADのdocより
# https://wiki.freecad.org/Macro_Circle
def Freecad3D_circle(x=0.0,y=0.0,z=0.0,radius=0.0,diameter=0.0,circumference=0.0,area=0.0,startangle=0.0,endangle=0.0,arc=0.0,anglecenter=0.0,cord=0.0,arrow=0.0,center=0,placemObject=""):
    from math import sqrt, pi
    if placemObject == "":
        pl = FreeCAD.Placement()
        pl.Rotation = FreeCADGui.ActiveDocument.ActiveView.getCameraOrientation()   
        pl.Base = FreeCAD.Vector(x,y,z)
    else:
        pl = FreeCAD.Placement()
        pl = placemObject                                  # placement imposted
    if diameter != 0:                                      # with diameter
        radius = diameter / 2.0
    elif circumference != 0:                               # with circumference
        radius = (circumference / pi) / 2.0
    elif area != 0:                                        # with area
        radius =  sqrt((area / pi))
    elif (cord != 0) and (arrow != 0):                     # with cord and arrow
        radius = ((arrow**2) + (cord**2) / 4.0) / (arrow*2) 
    elif (arc != 0) and (anglecenter != 0):                # with arc and anglecenter central in degrees
        radius = ((360/anglecenter)*arc) / pi/2.0
        if endangle != 0:
            startangle  = endangle - anglecenter
        endangle   = anglecenter + startangle
        startangle  = endangle - anglecenter
    if radius != 0:
        try:
            Draft.makeCircle(radius,placement=pl,face=False,startangle=startangle,endangle=endangle,support=None)
            if center != 0:
                x=pl.Base.x
                y=pl.Base.y
                z=pl.Base.z
                Draft.makePoint(x,y,z)
        except Exception:
            App.Console.PrintError("Unexpected keyword argument" + "\n")
        App.ActiveDocument.recompute()
    else:
        App.Console.PrintMessage("Unexpected keyword argument" + "\n")
        App.Console.PrintMessage("circle(x,y,z,radius,diameter,circumference,area,startangle,endangle,[arc,anglecenter],[cord,arrow],center,placemObject)" + "\n")
        App.Console.PrintMessage("circle(radius=10.0,placemObject=App.Placement(App.Vector(11,20,30), App.Rotation(30,40,0), App.Vector(0,0,0)))" + "\n")
    return
def myCircle_2D(myCi):
    x=float(myCi.center.x)
    y=float(myCi.center.y)
    r=float(myCi.radius  )
    Freecad3D_circle(
           x=float(x),y=float(y),z=0.0,
           radius=float(abs(r)),
           center=1,
           placemObject=App.Placement(App.Vector(float(x),float(y),0),
           App.Rotation(0,0,0),App.Vector(0,0,0)))
    return
############################################################################
def myfloat(y):
    if y == 0.0:
       y=0.0
    else:
       y=float(y)
    return y
def myXYZ2Txt_2D_xRy(A):
    return '(' + str(float(A.x)) + ',' + str(myfloat(-A.y)) +  ')'
def myTxtXYZ_2D_xRy(A,myWedgei):
    P5x=float(A.x)
    P5y=float(A.y)
    P5z=0.0
    p5 = FreeCAD.Vector(P5x, P5y, P5z)
    myText = Draft.makeText(myWedgei, p5)
    myText.Label = myWedgei
    # FreeCADGui.ActiveDocument.ActiveObject.FontSize = '1.0 mm'
    FreeCADGui.ActiveDocument.ActiveObject.FontSize = '0.8 mm'
    return
def myTxtXYZ_S_2D_xRy(*xy_tx):
    for i in range(1,int(len(xy_tx)/2)+1):
        myTxtXYZ_2D_xRy(xy_tx[2*i-2],xy_tx[2*i-1]+myXYZ2Txt_2D_xRy(xy_tx[2*i-2]) )
    return
def myLine_2D(A,B):
    Ax,Ay,Az=float(A.x),float(A.y),0.0
    Bx,By,Bz=float(B.x),float(B.y),0.0
    pl = FreeCAD.Placement()
    pl.Rotation.Q = (0.4247081540122249, 0.17592004639554645, 0.33985110062924484, 0.8204732460821097)
    pl.Base = FreeCAD.Vector(-3.9166066876399563, -2.1670824762243774, 1.7495260956243028)
    points = [FreeCAD.Vector(Ax,Ay,Az), FreeCAD.Vector(Bx,By,Bz)]
    line = Draft.make_wire(points, placement=pl, closed=False, face=True, support=None)
    Draft.autogroup(line)
    return
def myLine_S_2D(*args):
    for i in range(1,len(args)):
        myLine_2D(args[i-1],args[i])
    return
def myLine_C_2D(*args):
    for i in range(1,len(args)):
        myLine_2D(args[i-1],args[i])
    myLine_2D(args[i],args[0])
    return
#######################################################################################
myCircle_2D      ( ci    )
myLine_S_2D      ( A ,B  ) 
myTxtXYZ_S_2D_xRy( O,"O",Od,"O'",A,"A",B,"B" )
myTxtXYZ_S_2D_xRy( T1,"taumax",T2,"taumin"   )
myTxtXYZ_S_2D_xRy( S1,"sigma1"  ,S2,"sigma2" )
#######################################################################################
doc = App.activeDocument()
App.ActiveDocument.addObject("App::Origin", "Origin")
App.ActiveDocument.getObject('Origin').Visibility = True
App.ActiveDocument.recompute()
Gui.activeDocument().activeView().viewAxonometric()
Gui.SendMsgToActiveView("ViewFit")

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

(テンプレート)

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

参考文献

>一部に等分布荷重を受ける単純支持はり
>JSME p89
 
>片持ちばり 1)
>構造力学公式集 表5.1 片持ちばりの公式 p128

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