Restart analysis with nested do loop causing error
Restart analysis with nested do loop causing error
(OP)
Dear all,
I encountered a problem in debugging an element birth-death problem. I’m new to this community as well as APDL language, so I hope your extensive experience would help me.
Problem statement:
I was trying to construct a cuboid model, apply initial temperature and convection boundary condition first, kill all elements, and activate the elements one by one to simulate an additive manufacturing process. The activation procedure involves activate along the length, width, and height, so I programmed it as a triple nested do loop. However, ANSYS gives me an error of “an error has occurred in reading the CDWRITE file on surface loads (CONV). This may be the result of editing the CDWRITE file.”
Debug approaches:
Remove width and height loop: program runs without error and result looks reasonable
Remove convection BC: program runs without error
Substitute convection to heat flux: similar error occurred
Run inside loop twice with outside loop counter manually changed: program runs without error and result looks reasonable. This is what confuse me at most, is there any special issue I need pay attention to when using nested loop? I know a maximum of 20 nested loops is allowed, but I don't think I exceed that limit.
APDL codes I used:
I removed the death-birth feature but the problem presists. Right now it is nothing but a transient heat transfer problem with multiple restrat in the middle.
Much appreciated if you could help me.
X.Zhou
I encountered a problem in debugging an element birth-death problem. I’m new to this community as well as APDL language, so I hope your extensive experience would help me.
Problem statement:
I was trying to construct a cuboid model, apply initial temperature and convection boundary condition first, kill all elements, and activate the elements one by one to simulate an additive manufacturing process. The activation procedure involves activate along the length, width, and height, so I programmed it as a triple nested do loop. However, ANSYS gives me an error of “an error has occurred in reading the CDWRITE file on surface loads (CONV). This may be the result of editing the CDWRITE file.”
Debug approaches:
Remove width and height loop: program runs without error and result looks reasonable
Remove convection BC: program runs without error
Substitute convection to heat flux: similar error occurred
Run inside loop twice with outside loop counter manually changed: program runs without error and result looks reasonable. This is what confuse me at most, is there any special issue I need pay attention to when using nested loop? I know a maximum of 20 nested loops is allowed, but I don't think I exceed that limit.
APDL codes I used:
I removed the death-birth feature but the problem presists. Right now it is nothing but a transient heat transfer problem with multiple restrat in the middle.
CODE --> APDL
!***************TEMPERATURE CALCULATION*****************
FINISH
/CLEAR,START
/TITLE, Transient Analysis of FDM
/UNITS,SI
*SET,L2,2E-3
*SET,W2,2E-3
*SET,H2,0.3E-3
!Regulate the size of one single element
L1=10*L2
W1=6*W2
H1=5*H2
Tnumber=L1/L2*W1/W2*H1/H2 !dimension ratio
/PREP7
ET,1,SOLID70
MP,DENS,1,1150
MP,KXX,1,3E-2
MP,C,1,1470 ! a bunch of properties
! MODELING
BLC4,0,0,L1,W1,H1 ! Create rectangle
LSEL,S,LENGTH,,L1,,,0
LESIZE,ALL,L2,,,,0,,,0
LSEL,A,LENGTH,,W1,,,0
LESIZE,ALL,W2,,,,0,,,0
LSEL,A,LENGTH,,H1,,,0
LESIZE,ALL,H2,,,,0,,,0
VMESH,ALL
FINISH
/SOLU
ANTYPE,TRANSIENT,NEW
TRNOPT,FULL
LUMPM,OFF
NROPT,FULL,,ON
TINTP,,,,1.0
LSCLEAR,ALL !remove all loads
IC,ALL,TEMP,270
SFA,ALL,1,CONV,72,25 !Apply convection BC
/REPLOT,FAST
OUTRES,ALL,ALL
OUTPR,NSOL,LAST
Itvar=0.1
tvar=Itvar
TIME,Itvar
KBC,1 !STEP
AUTOTS,ON
DELTIM,Itvar/4,Itvar/4,Itvar/2,0
TIMINT,ON
*DO,Wvar,1,5,2 !W do loop, Wvar is not used inside of the loop
*DO,Lvar1,1,10,1 !l do +loop, Lvar1 is not used inside of the loop
SOLVE
tvar=tvar+Itvar
save
FINISH
PARSAV,ALL !ALL - Write scalar and array parameters.
/SOL
ANTYPE,,RESTART
PARRES
TIME,tvar
*ENDDO
*ENDDO
!*ENDDO
SOLVE
!****************program COMPLETE**************! Much appreciated if you could help me.
X.Zhou





RE: Restart analysis with nested do loop causing error
5.8.1.1.1. Multiframe Restart Limitations
Nested *DO loops are not supported for restarts.
I will try to find a new way.
RE: Restart analysis with nested do loop causing error
how about writing your loop as a set of commands to a file and then execute that file? So first your loop would create the set of commands that behave like your loop and write them to file and then you would execute that file.
*DO,Wvar,1,5,2 !W do loop, Wvar is not used inside of the loop
*DO,Lvar1,1,10,1 !l do +loop, Lvar1 is not used inside of the loop
write('solverestart,%tvar%')
*ENDDO
*ENDDO
then would get you file that looks like:
solverestart,1
solverestart,2
solverestart,3
Then you can replace the loop in your main code with execution of that file.
By solverestart I mean macro solverestat.mac that contains the content of your loop (can have input parameters)
Regards,
Pavel
RE: Restart analysis with nested do loop causing error
If nested *DO loops are not allowed, would a single *DO loop work? If so, a possibility is to create an array of the loop index and call from it.
CODE --> APDL
Best regards,
Sze Kwan (Jason) Cheah
RE: Restart analysis with nested do loop causing error
I greatly appreciate your help. I just spend 2 hrs to modify my code to run Jason's method and it works. I believe Pavel's way would also work but it just need some additional storage spaces if I have thousands of elements to loop. I hope this post would help others who have a similar issue.
Xunfei Zhou