CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   ANSYS (https://www.cfd-online.com/Forums/ansys/)
-   -   DO Loop in APDL (https://www.cfd-online.com/Forums/ansys/188115-do-loop-apdl.html)

keulehans May 23, 2017 12:48

DO Loop in APDL
 
Hey Guys,

I have to do a parametric study in ANSYS, where I have to investigate the influence of the dimensions of a rectangular plate with tensile forces. Therefore I have a couple of hundred working models (as .inp files) of the plate with each of them having slightly different dimensions.
The input files are called:
ANSYS_MODEL_1
ANSYS_MODEL_2
ANSYS_MODEL_3
.... and so on.
My problem now is, that I am not able to write a working Batch Code in APDL, so that ANSYS calculates all models consecutively.
I tried the following code:

*DO,i,1,521,1
valchr(i)
/input,ANSYS_MODEL_i,inp
/solu
outpr,basic,all
irlf,-1
/output,mass_output,txt
psolve,elform
psolve,elprep
/output
finish

ANALYSIS_MODE = 'LINEAR_STATIC'
/solu
allsel,all
/TITLE,ANALYSIS_MODE
ANTYPE,STATIC
PSTRES,ON
SOLVE
fini

/post1
...
...

/EOF

*ENDDO

/EXIT,ALL

With this code however,Ansys always searches for an input file, which is called "ANSYS_MODEL_i" instead of putting the right number of the DO Loop for the i.
Doea anybody know how to do it properly?
And am I using the DO Loop right?

Thanks a lot in advance, I really am desperate by now:( :D

Cheers

S.Tushar May 24, 2017 02:04

You are parsing the file name as a character string. I don't think 'i' will iterate with passes of the *DO loop.
when you write /input, filename_i, APDL searches for a file with name filename_i in the current directory.
There are many ways to achieve the parametric iterations that you are aiming at, maybe use the LINE or LABEL parameter of /input to read input lines from same input file.

cheers

keulehans May 27, 2017 07:18

Hi,

Thanks for your reply first of all. I asked my supervisor about changing the input files, but I am not allowed to do so.
He made it clear, that my task is, to write a batch code, which consecutively calculates all the models and saves each results file, so he can look at those later.
My current code looks like this:

*DO,i,1,521,1
/input,'ANSYS_MODEL_' chrval(i),inp
/solu
outpr,basic,all
irlf,-1
/output,mass_output,txt
psolve,elform
psolve,elprep
/output
finish

ANALYSIS_MODE = 'LINEAR_STATIC'
/solu
allsel,all
/TITLE,ANALYSIS_MODE
ANTYPE,STATIC
PSTRES,ON
SOLVE
fini

/post1
*DIM,DP_DISPL_ARRAY,ARRAY,5,1
ALLSEL,ALL
Nn = 202876
*GET,Xcord,NODE,Nn,LOC,X
*GET,Ycord,NODE,Nn,LOC,Y
*GET,Zcord,NODE,Nn,LOC,Z
*GET,U_X,NODE,Nn,U,X
*GET,U_Y,NODE,Nn,U,Y
DP_DISPL_ARRAY(1,1)=Xcord
DP_DISPL_ARRAY(2,1)=Ycord
DP_DISPL_ARRAY(3,1)=Zcord
DP_DISPL_ARRAY(4,1)=U_X
DP_DISPL_ARRAY(5,1)=U_Y
! write array to file
RST_DP_U_OUTPUT_ARRAY='DP_DISPL_ARRAY'
RST_DP_U_FILE_NAME=STRCAT('RST_U_DP_',CHRVAL(1))
RST_DP_U_FILE_EXTENSION='dat'
writecsv,RST_DP_U_FILE_NAME,RST_DP_U_FILE_EXTENSIO N,RST_DP_U_OUTPUT_ARRAY
allsel,all
/EOF

*ENDDO

/EXIT,ALL

This however gives me the error. Invalid /INPUT file or too many levels.

Can you help me with this?
Thanks in advance!

Cheers


All times are GMT -4. The time now is 07:28.