Tcl/Tk Programming Problem
Moderators: silvia, selimgunay, Moderators
Tcl/Tk Programming Problem
Hi there,
I have several 3D models in my M.Sc. thesis, and I want all of them to show a rather identical strength (base shear) during pushover analyses (Actually I want the base shear to be in a specific range). I have written a script for my purpose that checks the base shear in first step (I have written a script named BaseShearCalculator.tcl that calculates base shear), and in the next step, if the base shear is less than the minimum boundary of intended range, it makes beams and columns (as well as rebars) bigger to increase the strength, and if the base shear is more than the maximum boundary of intended range, it makes beams and columns (as well as rebars) smaller to reduce the strength. However, when I run this script, the analysis doesn't converge! I personally think the reason is that I cannot clear the results of previous analyses, although i use wipeAnalysis command in my script. Here is the code:
# ----------------------------------------------------------- #
# ---------------- Base Shear Modifier -------------- #
# ------------------------------------------------------- #
set IterationNum 0
set MaxIteration 100
while {($BaseShear>24000 || $BaseShear<22000) && $IterationNum<$MaxIteration} {
wipeAnalysis
if {$BaseShear<22000} {
set HColumn1 [expr 1.005*$HColumn1];
set BColumn1 [expr 1.005*$BColumn1];
set HColumn3 [expr 1.005*$HColumn3];
set BColumn3 [expr 1.005*$BColumn3];
set HColumn5 [expr 1.005*$HColumn5];
set BColumn5 [expr 1.005*$BColumn5];
set HBeam1 [expr 1.005*$HBeam1];
set BBeam1 [expr 1.005*$BBeam1];
set HBeam3 [expr 1.005*$HBeam3];
set BBeam3 [expr 1.005*$BBeam3];
set HBeam5 [expr 1.005*$HBeam5];
set BBeam5 [expr 1.005*$BBeam5];
set barAreaTopColumn1 [expr 1.005*$barAreaTopColumn1];
set barAreaBotColumn1 [expr 1.005*$barAreaBotColumn1];
set barAreaIntColumn1 [expr 1.005*$barAreaIntColumn1];
.... (it continues)
} else {
set HColumn1 [expr 0.995*$HColumn1];
set BColumn1 [expr 0.995*$BColumn1];
set HColumn3 [expr 0.995*$HColumn3];
set BColumn3 [expr 0.995*$BColumn3];
set HColumn5 [expr 0.995*$HColumn5];
set BColumn5 [expr 0.995*$BColumn5];
set HBeam1 [expr 0.995*$HBeam1];
set BBeam1 [expr 0.995*$BBeam1];
set HBeam3 [expr 0.995*$HBeam3];
set BBeam3 [expr 0.995*$BBeam3];
set HBeam5 [expr 0.995*$HBeam5];
set BBeam5 [expr 0.995*$BBeam5];
set barAreaTopColumn1 [expr 0.995*$barAreaTopColumn1];
set barAreaBotColumn1 [expr 0.995*$barAreaBotColumn1];
set barAreaIntColumn1 [expr 0.995*$barAreaIntColumn1];
.... (it continues)
}
source GravityREanalysis.tcl
source PushoverREanalysis.tcl
source BaseShearCalculator.tcl
incr $IterationNum 1
}
It should be noted that GravityREanalysis.tcl and PushoverREanalysis.tcl are the same as common scripts that everybody uses. The only difference is that I implement $IterationNum for load pattern tags in order to avoid repeated tag numbers. However, after I get analysis divergence warning, I encounter another error which says "load pattern tag "0" already exists in your model and cannot be created again". this is while I use tags 1000 and 2000 for my first gravity and pushover analysis, and there should not be any problem regarding pattern tags (I really don't know why it happens!). Here are the codes:
# ----------------------------------------------------------- #
# ---------------- Gravity Reanalysis --------------- #
# ------------------------------------------------------- #
set GravityTag $IterationNum
pattern Plain $GravityTag Linear {
eleLoad -ele $B1 -type -beamUniform 0.0 -3600.0 0.0
.... (it continues)
}
constraints Lagrange;
numberer RCM;
system UmfPack;
test EnergyIncr 1.E-6 6;
algorithm Newton;
integrator LoadControl 0.1;
analysis Static;
analyze 10;
loadConst -time 0.0
# ----------------------------------------------------------- #
# ---------------- Pushover Reanalysis -------------- #
# ------------------------------------------------------- #
set PushTag [expr $IterationNum+100]
pattern Plain $PushTag Linear {
load 6 1.000 0.0 0.0 0.0 0.0 0.0
.... (it continues)
}
constraints Lagrange;
numberer RCM;
system UmfPack;
test EnergyIncr 1.E-8 6;
algorithm Newton;
integrator DisplacementControl 66 1 0.01;
analysis Static;
analyze 100;
I can never thank you enough for your taking time out of your busy schedule to write me back and help me about my problem.
I have several 3D models in my M.Sc. thesis, and I want all of them to show a rather identical strength (base shear) during pushover analyses (Actually I want the base shear to be in a specific range). I have written a script for my purpose that checks the base shear in first step (I have written a script named BaseShearCalculator.tcl that calculates base shear), and in the next step, if the base shear is less than the minimum boundary of intended range, it makes beams and columns (as well as rebars) bigger to increase the strength, and if the base shear is more than the maximum boundary of intended range, it makes beams and columns (as well as rebars) smaller to reduce the strength. However, when I run this script, the analysis doesn't converge! I personally think the reason is that I cannot clear the results of previous analyses, although i use wipeAnalysis command in my script. Here is the code:
# ----------------------------------------------------------- #
# ---------------- Base Shear Modifier -------------- #
# ------------------------------------------------------- #
set IterationNum 0
set MaxIteration 100
while {($BaseShear>24000 || $BaseShear<22000) && $IterationNum<$MaxIteration} {
wipeAnalysis
if {$BaseShear<22000} {
set HColumn1 [expr 1.005*$HColumn1];
set BColumn1 [expr 1.005*$BColumn1];
set HColumn3 [expr 1.005*$HColumn3];
set BColumn3 [expr 1.005*$BColumn3];
set HColumn5 [expr 1.005*$HColumn5];
set BColumn5 [expr 1.005*$BColumn5];
set HBeam1 [expr 1.005*$HBeam1];
set BBeam1 [expr 1.005*$BBeam1];
set HBeam3 [expr 1.005*$HBeam3];
set BBeam3 [expr 1.005*$BBeam3];
set HBeam5 [expr 1.005*$HBeam5];
set BBeam5 [expr 1.005*$BBeam5];
set barAreaTopColumn1 [expr 1.005*$barAreaTopColumn1];
set barAreaBotColumn1 [expr 1.005*$barAreaBotColumn1];
set barAreaIntColumn1 [expr 1.005*$barAreaIntColumn1];
.... (it continues)
} else {
set HColumn1 [expr 0.995*$HColumn1];
set BColumn1 [expr 0.995*$BColumn1];
set HColumn3 [expr 0.995*$HColumn3];
set BColumn3 [expr 0.995*$BColumn3];
set HColumn5 [expr 0.995*$HColumn5];
set BColumn5 [expr 0.995*$BColumn5];
set HBeam1 [expr 0.995*$HBeam1];
set BBeam1 [expr 0.995*$BBeam1];
set HBeam3 [expr 0.995*$HBeam3];
set BBeam3 [expr 0.995*$BBeam3];
set HBeam5 [expr 0.995*$HBeam5];
set BBeam5 [expr 0.995*$BBeam5];
set barAreaTopColumn1 [expr 0.995*$barAreaTopColumn1];
set barAreaBotColumn1 [expr 0.995*$barAreaBotColumn1];
set barAreaIntColumn1 [expr 0.995*$barAreaIntColumn1];
.... (it continues)
}
source GravityREanalysis.tcl
source PushoverREanalysis.tcl
source BaseShearCalculator.tcl
incr $IterationNum 1
}
It should be noted that GravityREanalysis.tcl and PushoverREanalysis.tcl are the same as common scripts that everybody uses. The only difference is that I implement $IterationNum for load pattern tags in order to avoid repeated tag numbers. However, after I get analysis divergence warning, I encounter another error which says "load pattern tag "0" already exists in your model and cannot be created again". this is while I use tags 1000 and 2000 for my first gravity and pushover analysis, and there should not be any problem regarding pattern tags (I really don't know why it happens!). Here are the codes:
# ----------------------------------------------------------- #
# ---------------- Gravity Reanalysis --------------- #
# ------------------------------------------------------- #
set GravityTag $IterationNum
pattern Plain $GravityTag Linear {
eleLoad -ele $B1 -type -beamUniform 0.0 -3600.0 0.0
.... (it continues)
}
constraints Lagrange;
numberer RCM;
system UmfPack;
test EnergyIncr 1.E-6 6;
algorithm Newton;
integrator LoadControl 0.1;
analysis Static;
analyze 10;
loadConst -time 0.0
# ----------------------------------------------------------- #
# ---------------- Pushover Reanalysis -------------- #
# ------------------------------------------------------- #
set PushTag [expr $IterationNum+100]
pattern Plain $PushTag Linear {
load 6 1.000 0.0 0.0 0.0 0.0 0.0
.... (it continues)
}
constraints Lagrange;
numberer RCM;
system UmfPack;
test EnergyIncr 1.E-8 6;
algorithm Newton;
integrator DisplacementControl 66 1 0.01;
analysis Static;
analyze 100;
I can never thank you enough for your taking time out of your busy schedule to write me back and help me about my problem.
Ph.D. Student Researcher
Colorado State University
Civil & Environmental Engineering
Fort Collins, CO 80523, USA
amerikmr@engr.colostate.edu
Colorado State University
Civil & Environmental Engineering
Fort Collins, CO 80523, USA
amerikmr@engr.colostate.edu
Re: Tcl/Tk Programming Problem
you probably want a wipe and not a wipeAnalysis .. the wipe is when you want to start over again in that it removes all noes, elements, materials, analysis objects and recorders . the wipeAnalysis just removes the analysis, leaves the domain (nodes and elements) in the state they are in.
Re: Tcl/Tk Programming Problem
Dear Dr. McKenna,
Thanks a lot for your reply. I rewrote my program and implemented wipe command instead of wipeAnalysis. Now my script is working. I appreciate your generous help. Anyway, as I understood, wipeAnalysis command doesn't make the model get rid of loads that have been assigned to it during the previous analysis. It means that the secondary pushover analyses are actually operating on a model that is under the effects of previous pushover analyses (i.e. deflections, stresses, ...). Such a situation apparently results in an analysis divergence. Isn't there any command in OpenSees that transfers the model to the state that it was before the analysis?
Thanks a lot for your reply. I rewrote my program and implemented wipe command instead of wipeAnalysis. Now my script is working. I appreciate your generous help. Anyway, as I understood, wipeAnalysis command doesn't make the model get rid of loads that have been assigned to it during the previous analysis. It means that the secondary pushover analyses are actually operating on a model that is under the effects of previous pushover analyses (i.e. deflections, stresses, ...). Such a situation apparently results in an analysis divergence. Isn't there any command in OpenSees that transfers the model to the state that it was before the analysis?
Ph.D. Student Researcher
Colorado State University
Civil & Environmental Engineering
Fort Collins, CO 80523, USA
amerikmr@engr.colostate.edu
Colorado State University
Civil & Environmental Engineering
Fort Collins, CO 80523, USA
amerikmr@engr.colostate.edu
Re: Tcl/Tk Programming Problem
there is the database command, and the subsequent save and restore. it does noy work for every element and material though.
Re: Tcl/Tk Programming Problem
Hi again!
I encountered a new problem in my programing. I want to multiply the dimension of beams and columns by a scale factor, in order to make them bigger and raise the strength (base shear) of the model. However, what I have in mind really doesn't work in a while loop (it should be noted that I want the scale factors to be 1.000, 1.005, 1.010, 1.015, 1.020, ... i.e. want to add 0.005 to the previous scale factor in the while loop, but "incr" command only accepts integers, so it forces me to write a script like this, although it doesn't work again!)
set IterationNum 1005.0 (intentionally I put ".0" here, although it doesn't help at all!)
set ScaleFactor [expr $IterationNum/1000] (or simply: set ScaleFactor $IterationNum/1000)
incr IterationNum 5 (here I cannot use ".0" since the number used here should be an integer! and I think this is the main cause of problem)
I would be grateful if you could provide any idea, since I am not really good in Tcl/Tk!
Thanks a lot.
I encountered a new problem in my programing. I want to multiply the dimension of beams and columns by a scale factor, in order to make them bigger and raise the strength (base shear) of the model. However, what I have in mind really doesn't work in a while loop (it should be noted that I want the scale factors to be 1.000, 1.005, 1.010, 1.015, 1.020, ... i.e. want to add 0.005 to the previous scale factor in the while loop, but "incr" command only accepts integers, so it forces me to write a script like this, although it doesn't work again!)
set IterationNum 1005.0 (intentionally I put ".0" here, although it doesn't help at all!)
set ScaleFactor [expr $IterationNum/1000] (or simply: set ScaleFactor $IterationNum/1000)
incr IterationNum 5 (here I cannot use ".0" since the number used here should be an integer! and I think this is the main cause of problem)
I would be grateful if you could provide any idea, since I am not really good in Tcl/Tk!
Thanks a lot.
Ph.D. Student Researcher
Colorado State University
Civil & Environmental Engineering
Fort Collins, CO 80523, USA
amerikmr@engr.colostate.edu
Colorado State University
Civil & Environmental Engineering
Fort Collins, CO 80523, USA
amerikmr@engr.colostate.edu
Re: Tcl/Tk Programming Problem
i suggest you try google or one of the other search engines in future before asking tcl related questions (or even opensees questions!) .. anyway look at the int function that can be used inside an expr.
http://wiki.tcl.tk/583
http://wiki.tcl.tk/583
Re: Tcl/Tk Programming Problem
I'll try to carefully consider your valuable suggestion. Again, thank you so much for your permanent support and patience.
Ph.D. Student Researcher
Colorado State University
Civil & Environmental Engineering
Fort Collins, CO 80523, USA
amerikmr@engr.colostate.edu
Colorado State University
Civil & Environmental Engineering
Fort Collins, CO 80523, USA
amerikmr@engr.colostate.edu
Re: Tcl/Tk Programming Problem
Hi,
I have created a loop in OpenSees that incorporates OpenFresco commands. But the wipe command cannot destroy the OpenFresco objects, and accordingly, in the second loop I get an error stating that expControl component could not be added since it already exist. I also couldn't find the Cpp code for wipe command to figure out how it works. I tried the Reset command, but it didn't work as well.
There is a "delete" command for itcl, but it doesn't work for tcl.
I have created a loop in OpenSees that incorporates OpenFresco commands. But the wipe command cannot destroy the OpenFresco objects, and accordingly, in the second loop I get an error stating that expControl component could not be added since it already exist. I also couldn't find the Cpp code for wipe command to figure out how it works. I tried the Reset command, but it didn't work as well.
There is a "delete" command for itcl, but it doesn't work for tcl.
Re: Tcl/Tk Programming Problem
i will forward to Andreas.
Re: Tcl/Tk Programming Problem
Dr. Schellenberg has added a new command “wipeExp” to the new version of OpenFresco for cleaning up OpenFresco objects. It should be used before the wipe command like this:
wipeExp
wipe
I used it in my code, and it worked perfectly.
wipeExp
wipe
I used it in my code, and it worked perfectly.