Giter VIP home page Giter VIP logo

Comments (2)

Clauperezma avatar Clauperezma commented on June 23, 2024 1

Here is an example:

from ansys.mapdl.core import launch_mapdl
mapdl= launch_mapdl(additional_switches='-smp')
import numpy as np
ma_Lx=0.03
ma_Ly=0.05
ma_nelx=4
ma_nely=2
xmin=1e-3
p=3
nel_ma=ma_nelx*ma_nely
DH1=[[2.19963816e+11,  6.51264991e+10, -5.36441803e-07],
       [ 6.51264991e+10,  2.19963816e+11,  5.36441803e-07],
       [ 2.38418579e-07, -3.57627869e-07,  7.62813778e+10]]
 
elem_list = np.arange(1, nel_ma + 1)
S=np.linalg.inv(DH1)
Ex=1/S[0,0]
Ey=1/S[1,1]
vh=-S[1,0]/S[0,0]
Gh=1/S[2,2]
G2=Ex/(2*(1+vh))

mapdl.clear()
mapdl.prep7()  
mapdl.mp("EX",1, Ex)
mapdl.mp("EY",1, Ey)
mapdl.mp("EZ",1, Ex)
mapdl.mp("PRXY",1,vh)
  #mapdl2.mp("PRYZ",1,vh)
  #mapdl2.mp("PRXZ",1,vh)
mapdl.mp("GXY",1,Gh)
mapdl.mp("GYZ",1,Gh)
mapdl.mp("GXZ",1,Gh)
  
mapdl.mp("EX",2,xmin**p)
mapdl.mp("PRXY",2,vh)

mapdl.et(1,"PLANE42",kop2=1)

mapdl.blc4(0,0,ma_Lx,ma_Ly)
mapdl.mat(1)
mapdl.allsel()
mapdl.lsel("S", "LOC", "X",0) 
mapdl.lsel("A", "LOC", "X",ma_Lx) 
mapdl.lesize("ALL","","",ma_nely)
mapdl.allsel()
mapdl.lsel("S", "LOC", "Y",0) 
mapdl.lsel("A", "LOC", "Y",ma_Ly) 
mapdl.lesize("ALL","","",ma_nelx)
mapdl.allsel()
mapdl.amesh("ALL")

F = -100  # downward 100 newton force
mapdl.nsel("S", "LOC", "X",0)  # select nodes at x=0
mapdl.d("ALL", "ALL",0)  # set all dof of selected nodes to 0
mapdl.allsel()  # select all nodes
mapdl.nsel("S", "LOC", "X", ma_Lx)  # select nodes at x=len_x
#mapdl.nsel("R", "LOC", "Y", Ly)  # select subset of nodes in the y region
mapdl.nsel("R", "LOC", "Y", 0.5*ma_Ly)  # select subset of nodes in the y region
mapdl.f("ALL","FY", F)  # apply force
mapdl.allsel()  # reselect all entities
  
nel_ma=int(mapdl.get("ELEM_sum","ELEMENT",0,"COUNT"))
nnods_ma=int(mapdl.get("NODE_sum","NODE",0,"COUNT"))
  #print("nel=",nel_ma)
  #print("nnods=",nnods_ma) 

coor_ma = np.copy(mapdl.mesh.nodes[:, [0, 1]])  # coordinates matrix
elem_prop_ma = np.array(mapdl.mesh.elem)
inci_ma= np.copy(elem_prop_ma[:, -4::])  
 
mapdl.run("/SOLU")
mapdl.antype("STATIC")
mapdl.solve()        
 
mapdl.run("/POST1 ")  # Post-processor module   

  # Cálculo del desplazamiento
 
mapdl.format(20)

U_ma= np.zeros(2*nnods_ma)
mapdl.dim('U_nodal',"ARRAY",nnods_ma,2)
mapdl.starvget('U_nodal(1,1)',"NODE",1,"U","X")
mapdl.starvget('U_nodal(1,2)',"NODE",1,"U","Y")
U1=mapdl.parameters["U_nodal"]
  
for k in range(1,nnods_ma+1):
  U_ma[(2*k)-2]=U1[k-1,0]  
  U_ma[(2*k)-1]=U1[k-1,1]

From this code I compared the results in the variable U_ma. With the results reported in Ansys: Here is the comparison:

ejemplo_github

There are significant digits that are lost when I want to collect an Ansys variable to use in Python. Which in this case is displacement. I would like to know how I can increase that number of significant digits, so as not to lose precision, because I must use that offset value for subsequent calculations.

from pymapdl.

germa89 avatar germa89 commented on June 23, 2024

Hi @Clauperezma

Can you share a minimum working example? So I can check changes against it?

from pymapdl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.