Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Outputing results from ansys into separate file!

Status
Not open for further replies.

spudweiser

Mechanical
Oct 3, 2005
8
Hi,

I have modelled a 3D Magnet in ANSYS and i want to output the results for the flux intensity for a single area of the magnet. Not just that i want to put these values into a 30*30 array so that i can inport it into matlab!! Is it possible to do this with the ansys software? i have seen some reference to the use of *vwrite and *mwrite but i am unsure how they would be best used in this situation or how to get the exact information i need using *vget.

hopefully somebody can help me!

 
Replies continue below

Recommended for you

You must define a component of the desired nodes on the area, like this:

Code:
asel,s,area,,"areanumber" ! select the area
nsla,s,1 ! select nodes on area
CM,outnodes,NODES ! define nodes component for output

Define a 30x30 matrix for the results:

Code:
*array,resultsmatrix,array,30,30

Define a 30 (?) rows vector for the nodes numbers:

Code:
*array,nodesvect,array,30,1
*get,nmin,node,,num,min ! nmin=smallest selected element number 
*do,row,1,30
nodesvect(row,1)=nmin
nmin=ndnext(nmin) ! next selected element number
*enddo

then solve:

Code:
/solu  
solve ! or magsolve?

then enter postprocessor:

Code:
/post1
set, ! read in the results

and do a loop trough the outputnodes to fill the array whith
results:

Code:
*do,row,1,30
*do,column,1,30
*get,resultsmatrix(row,column),node,nodevect(row),... ! hier apropiate keywords
*enddo
*enddo


Hope it helps!

Regards,
Alex

PS: *vget would not work, since this command gets results for consecutively numbered nodes or for node numbers with constant increment.

PPS: why do you need a 30x30 matrix for your results??
 
hey alex,

Thats a great help and il throw it into ansys now and see how i get on!

I need the 30*30 matrix as i have recorded data of the flux density from a real magnet and am trying to model it in ansys and see how accurate it is! Then using matlab i can compile the error across each surface

well thanks a million

Shane

 
For writing the results matrix to a file, you can use:

Code:
*mwrite,resultsmatrix(1),emagresults,dat
(30F10.6)

Regards,
Alex

 
hey Alex,

I cant seem to get the solution that you gave me out! I tried manipulating what you gave me so that i got the x and z coordinate at every node along with the flux density as follows:

asel,s,area,,10
nsla,s,1
cm,outnodes,node

*get,nmin,node,,num,min !defining minimum node number on area
*get,nmax,node,,count !counted all nodes on area

*dim,results,array,3,nmax !dimensioned results array

*do,column,1,nmax,1 !interating column for all nodes on area

*get,results(1,column),node,nmin,B,Y
*get,results(2,column),node,nmin,loc,X
*get,results(3,column),node,nmin,loc,Z
nmin=ndnext(nmin)

*enddo

*mwrite,results,c:\Result\magresults,dat



!When i do the above i get the following errors, for the B values it says that requested data not stored for node and then says that *get command is ignored. When i remove the do loop and just use the 3 *get commands it gives me an ouput for each. When i remove the *get for B, i find that the loop only iterates once and does not go through the cycle from 1 to nmax!!

Along with that the results matrix does not write to the file, Do you have any idea what is wrong with the above code? i have tried everything at this stage, i believe that the do loop iteration is the main issue.

Well thanks in advance,

Shane
 
Hi Shane,

I think, there is just a small problem:

- Check if you selected the wright area

- Check if nmax has the wright value (*status,nmax)

- Before you solve, you must tell ansys to compute the results for your output nodes (OUTRES,ALL,ALL)

- Normaly you define more rows than columns in ANSYS, so I would define the results matrix as *dim,results,array,nmax,3 not
*dim,results,array,3,nmax

- You must use this format for outputing results:
*mwrite,results,'c:\Result\magresults',dat
(3F10.6) ! Note this formating code (see FORTRAN)


So your code should look like this:

Code:
/prep7
asel,s,area,,10
nsla,s,1
cm,outnodes,node
/solu
outres,all,all ! compute results for all entities
allsel ! select all entities
solve
/post1
nsel,s,node,,outnodes ! [b]select the output nodes![/b]
set,last ! read it the last results set (for example)
*get,nmin,node,,num,min !defining minimum node number on area
*get,ncount,node,,count !counted all nodes on area

*dim,results,array,nmax,3 !dimensioned results array

*do,row,1,ncount  !interating column for all nodes on area
*get,results(row,1),node,nmin,B,Y
*get,results(row,2),node,nmin,loc,X
*get,results(row,3),node,nmin,loc,Z
nmin=ndnext(nmin)
*enddo

*mwrite,results,'c:\Result\magresults',dat
(3F10.6)
 
hey Alex,

The above code worked out great but i just have one further question! For some reason Ansys has given back a value of 0 for flux density in the Y direction for alot but not all of the nodes when it exports them into that separate file! Is there a reason for this? I believe that i have defined the magnet appropriately and also when you do a nodal solution it appears that there is a value of flux density at every point on Area 10 which is an air layer a few mm's above the surface of the magnet.

Thanks for all your help by the way, it is much appreciated

Shane

I have posted the code below,just place it in a text or dat file and import it into ansys if you wish to run it:

/prep7
et,1,117
!*
EMUNIT,MKS
!*
MPTEMP,,,,,,,,
MPTEMP,1,0
MPDATA,MURX,1,,300
MPTEMP,,,,,,,,
MPTEMP,1,0
MPDATA,MGXX,1,,0
MPDATA,MGYY,1,,994712.5007
MPDATA,MGZZ,1,,0
MPDE,MURX,1
MPTEMP,,,,,,,,
MPTEMP,1,0
MPDATA,MURX,1,,300
*CSET,1,2, 1,2,
MPCOPY, ,1,2
TBCOPY,ALL,1,2
!*
MPDE,MGXX,2
MPDE,MGYY,2
MPDE,MGZZ,2
MPTEMP,,,,,,,,
MPTEMP,1,0
MPDE,MURX,2
MPDATA,MURX,2,,1
/VIEW,1,1,1,1
/ANG,1
/REP,FAST
BLOCK,0,+0.049657,0,0.01699,0,+0.049657,
allsel
*get,xmx,kp,,mxloc,x
*get,xmn,kp,,mnloc,x
*get,ymx,kp,,mxloc,y
*get,ymn,kp,,mnloc,y
*get,zmx,kp,,mxloc,z
*get,zmn,kp,,mnloc,z
block,xmn-0.0014986,xmx+0.0014986,ymn-0.0014986,ymx+0.0014986,zmn-0.0014986,zmx+0.0014986
allsel
*get,xmx,kp,,mxloc,x
*get,xmn,kp,,mnloc,x
*get,ymx,kp,,mxloc,y
*get,ymn,kp,,mnloc,y
*get,zmx,kp,,mxloc,z
*get,zmn,kp,,mnloc,z
block,xmn-0.1,xmx+0.1,-3*ymx,3*ymx,zmn-ymx,zmx+ymx
vovlap,all
/REPLOT,RESIZE
!*
*CSET,1,2, 2,3,
MPCOPY, ,2,3
TBCOPY,ALL,2,3
!*
LPLOT
CM,_Y,VOLU
VSEL, , , , 1
CM,_Y1,VOLU
CMSEL,S,_Y
!*
CMSEL,S,_Y1
VATT, 1, , 1, 0
CMSEL,S,_Y
CMDELE,_Y
CMDELE,_Y1
!*
CM,_Y,VOLU
VSEL, , , , 4
CM,_Y1,VOLU
CMSEL,S,_Y
!*
CMSEL,S,_Y1
VATT, 2, , 1, 0
CMSEL,S,_Y
CMDELE,_Y
CMDELE,_Y1
!*
CM,_Y,VOLU
VSEL, , , , 5
CM,_Y1,VOLU
CMSEL,S,_Y
!*
CMSEL,S,_Y1
VATT, 3, , 1, 0
CMSEL,S,_Y
CMDELE,_Y
CMDELE,_Y1
!*
/UI,MESH,OFF
/DIST,1,0.924021086472,1
/REP,FAST
/DIST,1,0.924021086472,1
/REP,FAST
/DIST,1,0.924021086472,1
/REP,FAST
/DIST,1,0.924021086472,1
/REP,FAST
/DIST,1,0.924021086472,1
/REP,FAST
/DIST,1,0.924021086472,1
/REP,FAST
/DIST,1,0.924021086472,1
/REP,FAST
/USER, 1
/VIEW, 1, 0.203979337162 , 0.960828475521 , 0.187619483633
/ANG, 1, 2.32539772697
/REPLO
/DIST,1,0.924021086472,1
/REP,FAST
/DIST,1,0.924021086472,1
/REP,FAST
/DIST,1,0.924021086472,1
/REP,FAST
/DIST,1,0.924021086472,1
/REP,FAST
/VIEW, 1, 0.644786474421E-01, 0.977050326931 , 0.203015178416
/ANG, 1, -26.4146248625
/REPLO
/VIEW, 1, 0.298484510976 , 0.208504836719 , 0.931360687259
/ANG, 1, -11.1346283405
/REPLO
FLST,5,12,4,ORDE,2
FITEM,5,13
FITEM,5,-24
CM,_Y,LINE
LSEL, , , ,P51X
CM,_Y1,LINE
CMSEL,,_Y
!*
LESIZE,_Y1,0.00175514, , , , , , ,1
!*
FLST,5,12,4,ORDE,2
FITEM,5,1
FITEM,5,-12
CM,_Y,LINE
LSEL, , , ,P51X
CM,_Y1,LINE
CMSEL,,_Y
!*
LESIZE,_Y1,0.0015, , , , , , ,1
!*
/DIST,1,1.08222638492,1
/REP,FAST
/DIST,1,1.08222638492,1
/REP,FAST
/DIST,1,1.08222638492,1
/REP,FAST
/DIST,1,1.08222638492,1
/REP,FAST
/DIST,1,1.08222638492,1
/REP,FAST
/DIST,1,1.08222638492,1
/REP,FAST
/DIST,1,1.08222638492,1
/REP,FAST
/DIST,1,1.08222638492,1
/REP,FAST
/DIST,1,1.08222638492,1
/REP,FAST
/DIST,1,1.08222638492,1
/REP,FAST
FLST,5,12,4,ORDE,2
FITEM,5,25
FITEM,5,-36
CM,_Y,LINE
LSEL, , , ,P51X
CM,_Y1,LINE
CMSEL,,_Y
!*
LESIZE,_Y1,0.01, , , , , , ,1
!*
MSHAPE,1,3D
MSHKEY,0
!*
FLST,5,3,6,ORDE,3
FITEM,5,1
FITEM,5,4
FITEM,5,-5
CM,_Y,VOLU
VSEL, , , ,P51X
CM,_Y1,VOLU
CHKMSH,'VOLU'
CMSEL,S,_Y
!*
VMESH,_Y1
!*
CMDELE,_Y
CMDELE,_Y1
CMDELE,_Y2
!*
LPLOT
/DIST,1,0.924021086472,1
/REP,FAST
/DIST,1,0.924021086472,1
/REP,FAST
/DIST,1,0.924021086472,1
/REP,FAST
/DIST,1,0.924021086472,1
/REP,FAST
/DIST,1,0.924021086472,1
/REP,FAST
/DIST,1,0.924021086472,1
/REP,FAST
/DIST,1,0.924021086472,1
/REP,FAST
/DIST,1,0.924021086472,1
/REP,FAST
/DIST,1,0.924021086472,1
/REP,FAST
/DIST,1,0.924021086472,1
/REP,FAST
/VIEW, 1, 0.355617124484 , 0.923795276594E-01, 0.930055097101
/ANG, 1, -10.5575101749
/REPLO
/PNUM,KP,0
/PNUM,LINE,0
/PNUM,AREA,1
/PNUM,VOLU,0
/PNUM,NODE,0
/PNUM,TABN,0
/PNUM,SVAL,0
/NUMBER,0
!*
/PNUM,ELEM,0
/REPLOT
!*
/PNUM,KP,0
/PNUM,LINE,0
/PNUM,AREA,1
/PNUM,VOLU,0
/PNUM,NODE,0
/PNUM,TABN,0
/PNUM,SVAL,0
/NUMBER,0
!*
/PNUM,ELEM,0
/REPLOT
!*
/UI,MESH,OFF
/DIST,1,1.08222638492,1
/REP,FAST
/DIST,1,1.08222638492,1
/REP,FAST
/DIST,1,1.08222638492,1
/REP,FAST
/DIST,1,1.08222638492,1
/REP,FAST
/DIST,1,1.08222638492,1
/REP,FAST
/DIST,1,1.08222638492,1
/REP,FAST
/DIST,1,1.08222638492,1
/REP,FAST
/DIST,1,1.08222638492,1
/REP,FAST
/DIST,1,1.08222638492,1
/REP,FAST
/DIST,1,1.08222638492,1
/REP,FAST
/DIST,1,1.08222638492,1
/REP,FAST
/DIST,1,1.08222638492,1
/REP,FAST
/DIST,1,1.08222638492,1
/REP,FAST
/VIEW,1,1,1,1
/ANG,1
/REP,FAST
APLOT
LPLOT
ALLSEL,ALL
APLOT
asel,all
asel,all
APLOT
FLST,2,1,5,ORDE,1
FITEM,2,17
DA,P51X,AZ,0,0
FLST,2,1,5,ORDE,1
FITEM,2,18
DA,P51X,AZ,0,0
FLST,2,1,5,ORDE,1
FITEM,2,14
DA,P51X,AZ,0,0
FLST,2,1,5,ORDE,1
FITEM,2,13
DA,P51X,AZ,0,0
FLST,2,1,5,ORDE,1
FITEM,2,16
DA,P51X,AZ,0,0
/VIEW, 1, 0.168960754392 , -0.714252330648 , 0.679187655688
/ANG, 1, 6.10913720025
/REPLO
FLST,2,1,5,ORDE,1
FITEM,2,15
DA,P51X,AZ,0,0
/VIEW,1,1,1,1
/ANG,1
/REP,FAST
asel,s,area,,10
nsla,s,1
cm,outnodes,node
/sol
outres,all,all
allsel
magsolv
/post1
nsel,s,node,,outnodes
set,last
*get,nmin,node,,num,min
*get,ncount,node,,count

*dim,results,array,ncount,3

*do,row,1,ncount
*get,results(row,1),node,nmin,B,Y
*get,results(row,2),node,nmin,loc,X
*get,results(row,3),node,nmin,loc,Z
nmin=ndnext(nmin)
*enddo

*mwrite,results,'c:\Result\emagresults2',dat
(3F10.6)
 
Hi Shane,

my gues is, that the fortran format code at the end of your code is not properly set. F10.6 means that the flux value has 10 numbers and 6 decimal places. This is not allways working, so you must adapt this fortran format to your needs.

You could also check if the results matrix has all the places different from 0:

Code:
*status,results(1)

Regards
Alex
 
hey Alex,

I tried what you said and it didnt seem to make any difference! but when i eliminate the 0's in excel and input the results into matlab they seem to work out pretty well! maybe it outputs excess nodes or something,

Well thanks for all your help, youve been a lifesaver!

Cheers

Shane
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor