Lateral Torsional Buckling using PYANSYS

In this post, I'll use pyansys to solve the I-section LTB problem . You can find the python library pyansys on the following link;

https://github.com/akaszynski/pyansys 

Though the fact pyansys classes are quite intuitive for APDL and python users, documentation on the following link may also help;

https://pyansys.readthedocs.io/

After importing pyansys to any python terminal, you can start an ANSYS server using pyansys.ANSYS() class and free to run any APDL command using pyansys.ANSYS().run("some APDL string"). Also full list of available commands, that you can directly use python double or integer variables as APDL inputs, is available here.

It is also worth to noting that you can use pyansys.convert("apdl input file","python script") class to convert an APDL input to a python script that you can manipulate analysis and results easily in python environment.

Here we go, I'll call os too, just to point ANSYS server a run path in my directory.

import pyansys
import os

path = os.getcwd()


preallocation of elastic and inelastic buckling strength for changing beam length;

elasticStrength = []
inelasticStrength = []

LEN = [2,4,6,8,10]
H = 120e-3
B = 58e-3
TF = 7.7E-3
TW = 5.1E-3


Node coordinates as python arrays;
X = [TW/2, B/2, B/2, -B/2, -B/2, -TW/2, -TW/2, -B/2, -B/2, B/2, B/2, TW/2]
Y = [H/2-TF, H/2-TF, H/2, H/2, H/2-TF, H/2-TF, -(H/2-TF), -(H/2-TF), -H/2, -H/2, -(H/2-TF), -(H/2-TF)]

Other auxillary variables required to define our problem; 


IX = TW*(H-2*TF)*(H-2*TF)*(H-2*TF)/12 + 2*(TF*TF*TF*B/12+B*TF*(H/2-TF/2)*(H/2-TF/2))
WX = 2*IX/H
MX = 1
SIGX = MX/WX
SLOPE = 2*SIGX/H


Starting an analysis loop over changing beam length;
for loop in range(0,len(LEN)):
    ansys = pyansys.ANSYS(loglevel="INFO", interactive_plotting=True,run_location=path, override = True)
    ansys.Run("/FILNAME,file,0")
    ansys.Run("/NERR,,,,,0")

    ansys.Prep7()

    ansys.Et(1, 185)
    ansys.Mptemp(1, 0)
    ansys.Mpdata("EX", 1, "", 200E+09)
    ansys.Mpdata("PRXY", 1, "", 0.3)
    ansys.Mpdata("DENS", 1, "", 7850)
    ansys.Tb("BISO", 1, 1, 2, "")
    ansys.Tbtemp(0)
    ansys.Tbdata("", 235E+06, 200E+07, "", "", "", "")

    for i in range(1, 13):
        ansys.K(i,X[i-1], Y[i-1])

    ansys.A(1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
    ansys.Vext(1, " ", " ", " ", " ", LEN[loop], " ", " ", " ")

    ansys.Esize(1E-02, 0)
    ansys.Vsweep("ALL")

    ansys.Dl(21, " ", "UX", 0)
    ansys.Dl(21, " ", "UY", 0)
    ansys.Dl(21, " ", "UZ", 0)

    ansys.Dl(9, " ", "UX", 0)
    ansys.Dl(9, " ", "UY", 0)

    ansys.Sfgrad("PRES", 0, "Y", H/2, SLOPE)
    ansys.Sfa(2, " ", "PRES", SIGX)
    ansys.Sfa(1, " ", "PRES", SIGX)

# LINEAR STATIC ANALYSIS

    ansys.Run("/SOL")
    ansys.Solve(1)
    ansys.Finish()

# BUCKLING ANALYSIS

    ansys.Run("/SOL")
    ansys.Antype(1)
    ansys.Bucopt("LANB", 1, 1E-06, 1E+06, "RANGE")
    ansys.Solve()
    ansys.Finish()

# POST-PROCESSING

    ansys.Run("/POST1")
    ansys.Run("/EDGE,1,0,45")
    ansys.Run("/GLINE,1,-1")
    ansys.Set("LAST11")

    result = ansys.result
    elasticStrength.append(result.GetTimeValues())

# INELASTIC BUCKLING

    ansys.Prep7()
    ansys.Upgeom(1, "", "", "file", "rst")
    ansys.Cdwrite("db", "file", "cdb")

    SIGX_2 = elasticStrength[loop]/WX
    SLOPE_2 = 2*SIGX_2[0]/H

    ansys.Sfgrad("PRES", 0, "Y", H/2, SLOPE_2)
    ansys.Sfadele(1, 1, "PRES")
    ansys.Sfadele(2, 1, "PRES")

    ansys.Sfa(2, "", "PRES", SIGX_2[0])
    ansys.Sfa(1, "", "PRES", SIGX_2[0])

    ansys.Run("/SOLU")
    ansys.Antype(0)
    ansys.Nlgeom(1)
    ansys.Nsubst(50, 100, 25)
    ansys.Outres("ERASE")
    ansys.Outres("ALL", "ALL")
    ansys.Autots(1)
    ansys.Lnsrch(1)
    ansys.Neqit(50)
    ansys.Pstres(1)
    ansys.Time(1)

    ansys.Solve()
    ansys.Finish()

    result_nl = ansys.result
    steps = result_nl.GetTimeValues()
    inelasticStrength.append(steps[-2]*elasticStrength[loop])
    print(inelasticStrength[loop])

Comments

Popular posts from this blog

Elastic Beam Problem without using ANSYS GUI

Modal Frequencies and Shapes of Bogazici "Bosporus" Suspension Bridge