Cyclic Loading foreach

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

Moderators: silvia, selimgunay, Moderators

Post Reply
deihimmehdi
Posts: 8
Joined: Tue Jul 24, 2012 8:50 pm

Cyclic Loading foreach

Post by deihimmehdi »

Dear vesna
would you please help me . where did i go wrong?i think this command is wrong ( foreach ) how can i modify this programing command?
plz

I am so confused
Looking forward to your guidance
Thanks so much
i just got a month to start working.

proc GeneratePeaks { Dmaxp Dmaxn {DincrStatic 0.001} {CycleType "Full"} {Fact $LBuilding} } {; # generate incremental disps for Dmaxp

file mkdir data;
set outFileID [open data/tmpDsteps.tcl w]
set Disp 0.
set DincrStatic 0.001;
puts $outFileID "set iDstep { ";
puts $outFileID $Disp;
puts $outFileID $Disp; # open vector definition and some 0
set Dmaxp [expr $Dmaxp*$Fact]; # scale value?
set dx $DincrStatic ;
set NstepsPeak [expr int(abs($Dmaxp)/$DincrStatic)]
for {set i 1} {$i <= $NstepsPeak} {incr i 1} {; # zero to one
set Disp [expr $Disp + $dx]
puts $outFileID $Disp; # write to file
}
if {$CycleType !="Push"} {
for {set i 1} {$i <= $NstepsPeak} {incr i 1} {; # one to zero
set Disp [expr $Disp - $dx]
puts $outFileID $Disp; # write to file
}
set Dmaxn [expr $Dmaxn*$Fact]
set NstepsPeak [expr ($Dmaxn/$DincrStatic)]
if {$CycleType !="HalfCycle"} {
for {set i 1} {$i <= $NstepsPeak} {incr i 1} {; # zero to minus one
set Disp [expr $Disp - $dx]
puts $outFileID $Disp; # write to file
}
for {set i 1} {$i <= $NstepsPeak} {incr i 1} {; # minus one to zero
set Disp [expr $Disp + $dx]
puts $outFileID $Disp; # write to file
}
}
}
puts $outFileID " }"; # close vector definition
close $outFileID
source data/tmpDsteps.tcl; # source tcl file to define entire vector?return?
return $iDstep
};
source GeneratePeaks.tcl; # procedure to generate displacement increments for cyclic peaks

# characteristics of cyclic analysis
set iDmaxp "0.005 0.01 0.025 0.05 0.1" ; # vector of positive displacement-cycle peaks, in terms of storey drift ratio
set iDmaxn "0.004 0.06 0.02 0.04 0.09"; # vector of negative displacement-cycle peaks, in terms of storey drift ratio
set iNcycles " 8 6 3 5 2 " ; # specify the number of cycles at each peak
set LBuilding .1 ;
set Fact $LBuilding ; # scale drift ratio by storey height for displacement cycles
set Dincr [expr 0.001*$LBuilding ]; # displacement increment for pushover. you want this to be very small, but not too small to slow analysis
set CycleType Full; # you can do Full / Push / Half cycles with the proc



# # # ---------------------------- perform Static Cyclic Displacements Analysis ----------------------------- # # #



set fmt1 "%s Cyclic analysis: CtrlNode %.3i, dof %.1i, Disp=%.4f %s"; # format for screen/file output of DONE/PROBLEM analysis
foreach Dmaxp $iDmaxp {
foreach Dmaxn $iDmaxn {
foreach Ncycles $iNcycles {
set iDstep [GeneratePeaks $Dmaxp $Dmaxn $Dincr $CycleType $Fact]; # this proc is defined above
for {set i 1} {$i <= $Ncycles} {incr i 1} { ; #execute the NCycles
set zeroD 0
set D0 0.0
foreach Dstep $iDstep {
set D1 $Dstep
set Dincr [expr $D1 - $D0]
integrator DisplacementControl $IDctrlNode $IDctrlDOF $Dincr
analysis Static
# ----------------------------------------------first analyze command------------------------
set ok [analyze 1]
# ----------------------------------------------if convergence failure-------------------------
if {$ok != 0} {
# if analysis fails, we try some other stuff
# performance is slower inside this loop global maxNumIterStatic; # max no. of iterations performed before "failure to converge" is ret'd
if {$ok != 0} {
puts "Trying Newton with Initial Tangent .."
test NormDispIncr $Tol 200
algorithm Newton -initial
set ok [analyze 1]
test $testTypeStatic $TolStatic $maxNumIterStatic 0
algorithm $algorithmTypeStatic
}
if {$ok != 0} {
puts "Trying Broyden .."
algorithm Broyden 8
set ok [analyze 1 ]
algorithm $algorithmTypeStatic
}
if {$ok != 0} {
puts "Trying NewtonWithLineSearch .."
algorithm NewtonLineSearch 0.8
set ok [analyze 1]
algorithm $algorithmTypeStatic
}
if {$ok != 0} {
set putout [format $fmt1 "PROBLEM" $IDctrlNode $IDctrlDOF [nodeDisp $IDctrlNode $IDctrlDOF] $LunitTXT]
puts $putout
return -1
}; # end if
}; # end if
# -----------------------------------------------------------------------------------------------------
set D0 $D1; # move to next step
}; # end Dstep
}; # end i
}; #end Ncycles
}; #end of iDmaxncycle
}; # end of iDmaxpCycle
# -----------------------------------------------------------------------------------------------------
if {$ok != 0 } {
puts [format $fmt1 "PROBLEM" $IDctrlNode $IDctrlDOF [nodeDisp $IDctrlNode $IDctrlDOF] $LunitTXT]
} else {
puts [format $fmt1 "DONE" $IDctrlNode $IDctrlDOF [nodeDisp $IDctrlNode $IDctrlDOF] $LunitTXT]
}
vesna
Posts: 3033
Joined: Tue May 23, 2006 11:23 am
Location: UC Berkeley

Re: Cyclic Loading foreach

Post by vesna »

Here is an example of the cyclic analysis that you may consider using:

pattern Plain 201 Linear {
load 2 1 0 0 0 0 0
}
constraints Transformation;
numberer Plain;
system BandGeneral;
test NormDispIncr $tol 10 ;
algorithm Newton;

set currentDisp 0.0

foreach Dincr {0.5 -1.0 0.5} {
integrator DisplacementControl $controlnode $loaddirection $Dincr
analysis Static
set nSteps 160
if { $Dincr > 0 } {
set Dmax [expr $Dincr*$nSteps]
set ok 0
while {$ok == 0 && $currentDisp < $Dmax} {
set ok [analyze 1]
if {$ok != 0} {
puts "Trying Newton with Initial Tangent .."
test NormDispIncr 1.0e-6 2000 0
algorithm Newton -initial
set ok [analyze 1]
test NormDispIncr 1.0e-6 6 2
algorithm Newton
}
if {$ok != 0} {
puts "Trying Broyden .."
algorithm Broyden 8
set ok [analyze 1 ]
algorithm Newton
}
if {$ok != 0} {
puts "Trying NewtonWithLineSearch .."
algorithm NewtonLineSearch 0.8
set ok [analyze 1]
algorithm Newton
}
set currentDisp [nodeDisp $controlnode $loaddirection]
}
} elseif { $Dincr < 0 } {
set Dmax [expr $Dincr*$nSteps/2]
set ok 0
while {$ok == 0 && $currentDisp > $Dmax} {
set ok [analyze 1]
if {$ok != 0} {
puts "Trying Newton with Initial Tangent .."
test NormDispIncr 1.0e-6 2000 0
algorithm Newton -initial
set ok [analyze 1]
test NormDispIncr 1.0e-6 6 2
algorithm Newton
}
if {$ok != 0} {
puts "Trying Broyden .."
algorithm Broyden 8
set ok [analyze 1 ]
algorithm Newton
}
if {$ok != 0} {
puts "Trying NewtonWithLineSearch .."
algorithm NewtonLineSearch 0.8
set ok [analyze 1]
algorithm Newton
}
set currentDisp [nodeDisp $controlnode $loaddirection]
}
}
}
deihimmehdi
Posts: 8
Joined: Tue Jul 24, 2012 8:50 pm

Re: Cyclic Loading foreach

Post by deihimmehdi »

dear vesna
thank you so much for answering
bmj
Posts: 6
Joined: Sun Oct 11, 2015 2:18 pm

Re: Cyclic Loading foreach

Post by bmj »

Hi guys,

I'm analyzing an infilled frame of one bay. However, I received this error " unexpected "," outside function argument list in expression "0.001,0.0015,0.003,0.006,0.0..... " when I do the pushover analysis. I hope you can help me!! this are my scripts.

source RCFrame.InelasticElement.tcl;

# we need to set up parameters that are particular to the model.
set IDctrlNode 3; # node where displacement is read for displacement control
set IDctrlDOF 1; # degree of freedom of displacement read for displacement contro
# characteristics of cyclic analysis
set iDmax "0.001,0.0015,0.003,0.006,0.013,0.019,0.025,0.03"; # vector of displacement-cycle peaks, in terms of storey drift ratio
set Dincr [expr 0.001*$LCol]; # displacement increment for pushover. you want this to be very small, but not too small to slow down the analysis
set Fact $LCol; # scale drift ratio by storey height for displacement cycles
set CycleType Full; # you can do Full / Push / Half cycles with the proc
set Ncycles 1; # specify the number of cycles at each peak

# create load pattern for lateral pushover load
set Hload [expr 160*$kN/2]; # define the lateral load as a proportion of the weight so that the pseudo time equals the lateral-load coefficient when using linear load pattern
set iPushNode "3 4"; # define nodes where lateral load is applied in static lateral analysis
pattern Plain 200 Linear {; # define load pattern -- generalized
foreach PushNode $iPushNode {
load $PushNode $Hload 0.0 0.0 0.0 0.0 0.0
}
}

# ----------- set up analysis parameters
source LibAnalysisStaticParameters.tcl; # constraintsHandler,DOFnumberer,system-ofequations,convergenceTest,solutionAlgorithm,integrator

# --------------------------------- perform Static Cyclic Displacements Analysis
source LibGeneratePeaks.tcl
set fmt1 "%s Cyclic analysis: CtrlNode %.3i, dof %.1i, Disp=%.4f %s"; # format for screen/file output of DONE/PROBLEM analysis
foreach Dmax $iDmax {
set iDstep [GeneratePeaks $Dmax $Dincr $CycleType $Fact]; # this proc is defined above
for {set i 1} {$i <= $Ncycles} {incr i 1} {
set zeroD 0
set D0 0.0
foreach Dstep $iDstep {
set D1 $Dstep
set Dincr [expr $D1 - $D0]
integrator DisplacementControl $IDctrlNode $IDctrlDOF $Dincr
analysis Static
# ----------------------------------------------first analyze command------------------------
set ok [analyze 1]
# ----------------------------------------------if convergence failure-------------------------
if {$ok != 0} {
# if analysis fails, we try some other stuff
# performance is slower inside this loop global maxNumIterStatic; # max no. of iterations performed before "failure to converge" is ret'd
if {$ok != 0} {
puts "Trying Newton with Initial Tangent .."
test NormDispIncr $Tol 2000 0
algorithm Newton -initial
set ok [analyze 1]
test $testTypeStatic $TolStatic $maxNumIterStatic 0
algorithm $algorithmTypeStatic
}
if {$ok != 0} {
puts "Trying Broyden .."
algorithm Broyden 8
set ok [analyze 1 ]
algorithm $algorithmTypeStatic
}
if {$ok != 0} {
puts "Trying NewtonWithLineSearch .."
algorithm NewtonLineSearch 0.8
set ok [analyze 1]
algorithm $algorithmTypeStatic
}
if {$ok != 0} {
set putout [format $fmt1 "PROBLEM" $IDctrlNode $IDctrlDOF [nodeDisp $IDctrlNode $IDctrlDOF] $LunitTXT]
puts $putout
return -1
}; # end if
}; # end if
# -----------------------------------------------------------------------------------------------------
set D0 $D1; # move to next step
}; # end Dstep
}; # end i
}; # end of iDmaxCycl
# -----------------------------------------------------------------------------------------------------
if {$ok != 0 } {
puts [format $fmt1 "PROBLEM" $IDctrlNode $IDctrlDOF [nodeDisp $IDctrlNode $IDctrlDOF] $LunitTXT]
} else {
puts [format $fmt1 "DONE" $IDctrlNode $IDctrlDOF [nodeDisp $IDctrlNode $IDctrlDOF] $LunitTXT]
}
fmk
Site Admin
Posts: 5884
Joined: Fri Jun 11, 2004 2:33 pm
Location: UC Berkeley
Contact:

Re: Cyclic Loading foreach

Post by fmk »

you have defined as a string (set iDmax "0.001,0.0015,0.003,0.006,0.013,0.019,0.025,0.03"; ), you want a list
set iDmax {0.001 0.0015 0.003 0.006 0.013 0.019 0.025 0.03};
Post Reply