program loop in opensees
Moderators: silvia, selimgunay, Moderators
program loop in opensees
Hi,
There is a big question in my code, i need calculate my code 100 times because it has a variable which has 100 value.
For example,
set Es 10000;
Es is a variable and Es ={10000 12000 14000 .........40000,50000} it is 100 value.
I want write a loop in opensees to calculate my code (source opensees.tcl) 100 times,and each times have each record (results).
What can i do ?
thanks !
There is a big question in my code, i need calculate my code 100 times because it has a variable which has 100 value.
For example,
set Es 10000;
Es is a variable and Es ={10000 12000 14000 .........40000,50000} it is 100 value.
I want write a loop in opensees to calculate my code (source opensees.tcl) 100 times,and each times have each record (results).
What can i do ?
thanks !
Re: program loop in opensees
You can do it this way:
set j 0
foreach Es { 10000 12000 14000 .........40000 50000 } {
puts "Es: $Es"
model basic -ndm 2 -ndf 3
wipe
.....
incr j 1
set dataDir [format "Es%i" $j ]
file mkdir $dataDir; # create data directory
.....
recorder Node -file [format "$dataDir/DispEs%i.out" $j ] -time -node 3 -dof 1 disp; #records displacement
......
}
set j 0
foreach Es { 10000 12000 14000 .........40000 50000 } {
puts "Es: $Es"
model basic -ndm 2 -ndf 3
wipe
.....
incr j 1
set dataDir [format "Es%i" $j ]
file mkdir $dataDir; # create data directory
.....
recorder Node -file [format "$dataDir/DispEs%i.out" $j ] -time -node 3 -dof 1 disp; #records displacement
......
}
Re: program loop in opensees
Hi,vesna,
Thank you very much!
And in this question,if I have a file *.txt or*.out ,which consider Es value: 10000 12000 14000 .........40000 50000 ,how can i do call *.txt or *.out
in opensees? That is ,if i can call this file ,i can not input the numerical value of Es in opensees .
PLS tell me how can use it ?
Appreciation!
Thank you very much!
And in this question,if I have a file *.txt or*.out ,which consider Es value: 10000 12000 14000 .........40000 50000 ,how can i do call *.txt or *.out
in opensees? That is ,if i can call this file ,i can not input the numerical value of Es in opensees .
PLS tell me how can use it ?
Appreciation!
Re: program loop in opensees
PS:
[format "Es%i" $j ]
Can i use other chars instead of % which its have the same function ?
[format "Es%i" $j ]
Can i use other chars instead of % which its have the same function ?
Re: program loop in opensees
Hi,vesna,
other question!
set T1 [expr 2.0*$pi/$w1]; # 1st mod
set T2 [expr 2.0*$pi/$w2]; # 2nd mod
set T3 [expr 2.0*$pi/$w3]; # 3nd mod
puts "T1 = $T1 s"; # display the
puts "T2 = $T2 s"; # display the
puts "T3 = $T3 s"
# write the output file cosisting of periods
HOW TO Write THIS PERIODS ?
set period [format "Periods%i.txt" $k]
#set period "TRussData_beam_push_3D/Periods.txt"
set Periods [open $period "w"]
foreach t1 {$T1} t2 {$T2} t3 {$T3} {
puts $Periods " $t1 $t2 $t3 "
}
close $Periods
other question!
set T1 [expr 2.0*$pi/$w1]; # 1st mod
set T2 [expr 2.0*$pi/$w2]; # 2nd mod
set T3 [expr 2.0*$pi/$w3]; # 3nd mod
puts "T1 = $T1 s"; # display the
puts "T2 = $T2 s"; # display the
puts "T3 = $T3 s"
# write the output file cosisting of periods
HOW TO Write THIS PERIODS ?
set period [format "Periods%i.txt" $k]
#set period "TRussData_beam_push_3D/Periods.txt"
set Periods [open $period "w"]
foreach t1 {$T1} t2 {$T2} t3 {$T3} {
puts $Periods " $t1 $t2 $t3 "
}
close $Periods
Re: program loop in opensees
this is a basic tcl question on the use of foreach .. google tcl foreach .. e.g. http://www.astro.princeton.edu/~rhl/Tcl ... ach.n.html
Re: program loop in opensees
hi friends,
i have a same type problem in my code,i have a six random variables which have 100 values in matrix form
for example;
var-1 var-2 var-3 var-4 vAR-5 var-6
={40.2285 0.3088 16.1031 12.9999 5.1254 1.6663
40.8183 0.4883 15.6421 5.6726 2.6696 2.1183
37.7136 0.3961 11.8791 6.7538 4.0445 0.5526
40.3427 0.3681 18.1188 7.8508 4.8990 1.4542
39.3762 0.4104 17.0790 2.3890 0.7384 2.1817
..............................................} six variables have 100 values...
i want to write a loop in opensees for calculating this in my code, and each times have each record (results)
please help
thanks in advance
i have a same type problem in my code,i have a six random variables which have 100 values in matrix form
for example;
var-1 var-2 var-3 var-4 vAR-5 var-6
={40.2285 0.3088 16.1031 12.9999 5.1254 1.6663
40.8183 0.4883 15.6421 5.6726 2.6696 2.1183
37.7136 0.3961 11.8791 6.7538 4.0445 0.5526
40.3427 0.3681 18.1188 7.8508 4.8990 1.4542
39.3762 0.4104 17.0790 2.3890 0.7384 2.1817
..............................................} six variables have 100 values...
i want to write a loop in opensees for calculating this in my code, and each times have each record (results)
please help
thanks in advance
Sumit Jindal
IIT Kanpur (India)
IIT Kanpur (India)
Re: program loop in opensees
Here is an example about saving the periods into a file:
http://opensees.berkeley.edu/wiki/index ... e_analysis
http://opensees.berkeley.edu/wiki/index ... e_analysis
Re: program loop in opensees
Hi,vesna,
Thank you very much!
Thank you very much!
Re: program loop in opensees
To read Es from file, at the beginning of your file write this:
set fileR [open Es.txt "r"]
set EsR [gets $fileR]
close $fileR
set j 0
foreach Es $EsR {
puts "Es: $Es"
model basic -ndm 2 -ndf 3
wipe
.....
incr j 1
set dataDir [format "Es%i" $j ]
file mkdir $dataDir; # create data directory
.....
recorder Node -file [format "$dataDir/DispEs%i.out" $j ] -time -node 3 -dof 1 disp; #records displacement
......
}
set fileR [open Es.txt "r"]
set EsR [gets $fileR]
close $fileR
set j 0
foreach Es $EsR {
puts "Es: $Es"
model basic -ndm 2 -ndf 3
wipe
.....
incr j 1
set dataDir [format "Es%i" $j ]
file mkdir $dataDir; # create data directory
.....
recorder Node -file [format "$dataDir/DispEs%i.out" $j ] -time -node 3 -dof 1 disp; #records displacement
......
}
Re: program loop in opensees
hi vesna ,
please give me the solution of my problem with no of random variables..
i have a same type problem in my code,i have a six random variables which have 100 values in matrix form
for example;
var-1 var-2 var-3 var-4 vAR-5 var-6
={40.2285 0.3088 16.1031 12.9999 5.1254 1.6663
40.8183 0.4883 15.6421 5.6726 2.6696 2.1183
37.7136 0.3961 11.8791 6.7538 4.0445 0.5526
40.3427 0.3681 18.1188 7.8508 4.8990 1.4542
39.3762 0.4104 17.0790 2.3890 0.7384 2.1817
..............................................} six variables have 100 values...
i want to write a loop in opensees for calculating this in my code, and each times have each record (results)
please help
please give me the solution of my problem with no of random variables..
i have a same type problem in my code,i have a six random variables which have 100 values in matrix form
for example;
var-1 var-2 var-3 var-4 vAR-5 var-6
={40.2285 0.3088 16.1031 12.9999 5.1254 1.6663
40.8183 0.4883 15.6421 5.6726 2.6696 2.1183
37.7136 0.3961 11.8791 6.7538 4.0445 0.5526
40.3427 0.3681 18.1188 7.8508 4.8990 1.4542
39.3762 0.4104 17.0790 2.3890 0.7384 2.1817
..............................................} six variables have 100 values...
i want to write a loop in opensees for calculating this in my code, and each times have each record (results)
please help
Sumit Jindal
IIT Kanpur (India)
IIT Kanpur (India)