Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

ANSYS APDL

Status
Not open for further replies.

NaikD

Mechanical
Nov 23, 2002
48
Hi All,

I am new to ansys apdl and am not familiar with the coding. I know I am not doing this right.
Can someone help me with this code. I am trying to write x, y and z displacements to arrays dx, dy and dz
I appreciate your help!
Thank you,
Dipak

/post1
*cfopen,D:\documents\crank3.txt !Open output text file in a directory
*vwrite
CRANK,dx,dy,dz,ncount

! Selects a subset of components and assemblies (a new set, whose name is crank)
!set,3,1
cmsel,s,crank
nsle,s ! Select a set
*GET,nmax,NODE,0,num,max ! get highest node number in selected body
*GET,nmin,NODE,0,num,min ! get lowest node number in selected body
ncount=nmax-nmin+1
*DIM,dx,ARRAY,nmax
*DIM,dy,ARRAY,nmax
*DIM,dz,ARRAY,nmax

!Loop for all nodes (nmin to nmax with increment of 1000) in selected set
*do,i,nmin,nmax,1000

set,3,1
dx(i)=ux(i)
dy(i)=uy(i)
dz(i)=uz(i)

*vwrite
CRANK1,dx,dy,dz,ncount
*vwrite,dx(i),dy(i),dz(i),ncount
%15.5e,%15.5e,%15.5e,%8.0f

!*enddo
 
Replies continue below

Recommended for you

Dont use loops for something like this. They are slow, boring, unsophisticated, and people will think you are an amateur. Use vector commands instead. Also, what you are doing will only work if the selected nodes are continuously numbered. Try something more like this:

nsele=ndinqr(0,13)
*dim,ddata,,nsele,4

ncount=ndinqr(0,14)
*dim,ndata,,ncount,10

cmsel,s,crank
nsle,s
*vget,ndata(1,10),node,0,nsel

*vfill,ndata(1,1),ramp,1,1
*vget,ndata(1,2),node,1,u,x
*vget,ndata(1,3),node,1,u,y
*vget,ndata(1,4),node,1,u,z

*do,j,1,3
*vmask,ndata(1,10)
*vfun,ddata(1,j),compress,ndata(1,j)
*enddo

*cfopen....
*write,ddata(1,1),ddata(1,2),ddata(1,3),ddata(1,4)
%15.5e......



Rick Fischer
Principal Engineer
Argonne National Laboratory
 
Rick,

That was quick.

I struggled for few days to get info on ANSYS APDL which is scarce (except for the help in mechanical) more particularly on sample examples/tutorials. Coding and syntax is little different than FORTRAN....I think.

I will implement your suggestions in my bigger program where I use displacements and velocities for further computations.

Today I learned few things from you.
I really appreciate your timely help.

With Best Regards,

- Dipak
 
APDL is considered archaic by the new guard at Ansys Inc. Power users embrace it because it is immensely powerful. Good sources for APDL tips and macros are the websites of the various Ansys distributors, and Sheldon's Ansys.net.

Rick Fischer
Principal Engineer
Argonne National Laboratory
 
Hi,

I wrote the following code based on the previous posts.

node_count = ndinqr(0,14)

*dim,node_id,array,node_count,2

*vget,node_id(1,1),node,1,nlist

cmsel,s,face1

*vget,node_id(1,2),node,0,nsel

*cfopen,nodes.txt

*vmask,node_id(1,2)

*vwrite,node_id(1,1)

%15.5e

*cfclose

face1 is a face named selection. This code writes a text file containing the selected nodes on a column. I would like to modify it
so that the node ids are written in this format:

1,2,3,...

Any tips?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor