How to keep the "for" loop running?

Forum for OpenSees users to post questions, comments, etc. on the use of the OpenSees interpreter, OpenSees.exe

Moderators: silvia, selimgunay, Moderators

Post Reply
ismailqeshta
Posts: 115
Joined: Mon Feb 20, 2017 1:19 am
Location: RMIT University, Melbourne, Australia

How to keep the "for" loop running?

Post by ismailqeshta » Thu Oct 12, 2017 10:32 pm

Hi,

I am performing a series of pushover analyses for different values of fy using "for" loop. The problem is that when the structure fails before reaching the maximum specified displacement, the "for" loop stops, and it does not go to the next pushover analysis.

Is there any command that I should insert or remove in order to keep it going?

Thank you.

giovannimilan
Posts: 71
Joined: Wed Apr 05, 2017 12:49 am
Location: ARUP, amsterdam

Re: How to keep the "for" loop running?

Post by giovannimilan » Fri Oct 13, 2017 12:11 am

I did something like...

Mind the removers at the bottom!

---------------------------- Example --------------------------

for { set k 1 } { $k <= 10 } { incr k } {

# do stuff -------------------------

# perform the dynamic analysis and display whether analysis was successful
set ok [analyze $NumSteps $dt_analysis]; # ok = 0 if analysis was completed
if {$ok == 0} {
#puts "Dynamic analysis complete \n";
} else {
puts "Dynamic analysis did not converge \n";
set error_flag ="true";
}


wipeAnalysis;
remove loadPattern $patternID
reset;
remove recorders
}; #closing the fy loop

ismailqeshta
Posts: 115
Joined: Mon Feb 20, 2017 1:19 am
Location: RMIT University, Melbourne, Australia

Re: How to keep the "for" loop running?

Post by ismailqeshta » Fri Oct 13, 2017 12:34 am

Many thanks giovannimilan.

Actually, my code for the pushover analysis involves a number of attempts to achieve convergence. It is shown below for your kind reference. I tried to use break, but it did not work.




#Converge Quick & Easy (PUSHOVER Analysis)
set Dmax 100; #Target Displacment
set Dincr 0.3048; #initial disp. increment
set Tol 1.0e-6; #initial tolerance criteria used to check for convergence
set IDctrlNode 216; # Set Monitor Node Tag, i.e Roof node Tag is 20)
set IDctrlDOF 3; # degree of freedom (1) of disp read for disp control
set Dstep 0.0;
set fmt1 "%s Pushover analysis: CtrlNode %.1i, dof %.1i, Disp=%.4f"; # format for screen/file output of DONE/PROBLEM analysis

system BandGeneral
numberer RCM
constraints Transformation
# test EnergyIncr $Tol 400
test NormDispIncr 1.0e-6 100
algorithm Newton
integrator DisplacementControl $IDctrlNode $IDctrlDOF $Dincr; #displacement control algorithm seking increment of $dincr at node $MNode at 1st dof.
analysis Static

for {set i 1} {$Dstep <= 1.0} {incr i 1} {
set ok [analyze 1]

set controlDisp [nodeDisp $IDctrlNode $IDctrlDOF ]
set Dstep [expr $controlDisp/$Dmax]

if {$ok != 0} {
# if analysis fails, we try some other stuff, performance is slower inside this loop
set ok 0
while {$Dstep <= 1.0 && $ok == 0} {
set controlDisp [nodeDisp $IDctrlNode $IDctrlDOF ]
set Dstep [expr $controlDisp/$Dmax]
set ok [analyze 1]; # this will return zero if no convergence problems were encountered
if {$ok != 0} {; # reduce step size if still fails to converge
set Nk 10; # reduce step size
set DincrReduced [expr $Dincr/$Nk];
integrator DisplacementControl $IDctrlNode $IDctrlDOF $DincrReduced
for {set ik 1} {$ik <=$Nk} {incr ik 1} {
set ok [analyze 1]; # this will return zero if no convergence problems were encountered
#------------------------------------------------------------
if {$ok != 0} {
test NormDispIncr 1.0e-6 1000 1
algorithm Newton -initial
set ok [analyze 1]
test NormDispIncr 1.0e-6 100
algorithm Newton
}
#--------------------------------------------------------------------

if {$ok != 0} {; # stop if still fails to converge
puts [format $fmt1 "PROBLEM" $IDctrlNode $IDctrlDOF [expr $controlDisp] %]
return -1
}; # end if
}; # end for
integrator DisplacementControl $IDctrlNode $IDctrlDOF $Dincr; # bring back to original increment
}; # end if
}; # end while loop
}; # end if ok !0
## -----------------------------------------------------------------------------------------------------

if {$ok != 0 } {
puts [format $fmt1 "PROBLEM" $IDctrlNode $IDctrlDOF [expr $controlDisp]]
} else {
puts [format $fmt1 "DONE" $IDctrlNode $IDctrlDOF [expr $controlDisp]]
}
wipe
}
Last edited by ismailqeshta on Fri Oct 13, 2017 10:28 pm, edited 1 time in total.

giovannimilan
Posts: 71
Joined: Wed Apr 05, 2017 12:49 am
Location: ARUP, amsterdam

Re: How to keep the "for" loop running?

Post by giovannimilan » Fri Oct 13, 2017 1:57 am

I dont think it matters if you have more than one attempt.. the work flow is the same, at the end of the day you flag only once at the end of the analysis if it is converged, with any attempt.

Please try to introduce the wipeanalysis and/or reset, right before closing the loop, in such a way that at the end of each analysis, the analysis starts from scratch.

I think u need to refresh the material model as well, check if there is a way to wipe the material (or maybe it is within reset)

At that time I did some trial and error stuff to check which commands were necessary (wipe, remover, reset, etc) untill the program was running properly.

I also had some non-converged analysis inbeteween but the program still went to the next analysis.

ismailqeshta
Posts: 115
Joined: Mon Feb 20, 2017 1:19 am
Location: RMIT University, Melbourne, Australia

Re: How to keep the "for" loop running?

Post by ismailqeshta » Fri Oct 13, 2017 5:22 am

Many thanks giovannimilan.

I could sort the problem out and now it is running. It was actually the location of break command. It should be out of the "if" loop for the pushover attempts. As you mentioned, it does not matter how many attempts I have. I also had to remove the return -1 from the code to let it stop the analysis and close the loop for each run.

I will take your comments into consideration for my other models in case the break command did not work. Thanks again for your suggestions.

Post Reply