INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

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.

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

(OP)
Solved.

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

Zhou,
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

Zhou,

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

! Initialize
*dim, Wvar_vec, array, 30
*dim, Lvar1_vec, array, 30

! Create array of loop index
ct=0
*do, Wvar, 1, 5, 2
	*do, Lvar1, 1, 10, 1
		ct = ct+1
		Wvar_vec(ct) = Wvar
		Lvar1_vec(ct) = Lvar1
	*enddo
*enddo

! Single loop for restart analysis
*do, ct, 1, 30	
	! prior loop variables extracted
	Wvar = Wvar_vec(ct) 	
	Lvar1 = Lvar1_vec(ct)	
	
	... [ restart analysis code goes here ] ...
	
*enddo 


Best regards,
Sze Kwan (Jason) Cheah

RE: Restart analysis with nested do loop causing error

(OP)
Jason and Pavel,

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close