Rev. | 541d5f73c5fe4a058d2daff1745e5829b8b66762 |
---|---|
Tamanho | 2,715 bytes |
Hora | 2007-11-20 01:37:45 |
Autor | iselllo |
Mensagem de Log | I modified read_1_particle_kind.tcl which is now able to read and save
|
# first a test on reading a single configuration
set f [open "config_2" "r"]
while { [blockfile $f read auto] != "eof" } {}
close $f
puts "ok reading the block file"
puts "I read a specific configuration"
analyze append
#puts "u is, $u "
set z [analyze config]
puts "z is, $z "
#Now I try saving the configuration to a specific file
set obs [open "my_saved_config.dat" "w"]
#the following line saves the particle positions in a funny way
#i.e. exactly as a TCL list
puts $obs "$z "
close $obs
#z is now a list of 3N particle positions (3 positions x,y,z per particle)
#however, the list should be read as a row, i.e. the 6th position of the list is given by
# [lindex $z 0 5] (arrays are numbered from zero, C-style) i.e. zero-th row and 5-th column (always
#counting from zero).
set zt [lindex $z 0 5]
puts "z(5) is, $zt"
set zlist ""
foreach value [lindex $z 0] {
#puts "value is, $value"
lappend zlist [lindex $value 0]
}
puts "zlist is, $zlist"
#this way I am saving zlist as an array
#Now I save the array to a file I can read with R, Python, etc...
set obs2 [open "example_configuration.dat" "w"]
foreach r $zlist { puts $obs2 "$r" }
close $obs2
puts "OK reading single configuration"
#Now I read and count a set of configurations
#first I remove the previously stored configuration
analyze remove
#The following 2 parameters are needed to read the saved configurations
set my_increase 1
set tot_config 200
#for {set i 0} {$i < $tot_config} {incr i $my_increase} { lappend rdf_single 0}
#puts "rdf_single is $rdf_single"
# the previous avg_single is used only to contain the results of the statistics on a single configuration
# in a convenient way.
set cnt 0
#for {set i 0} {$i < 200000} {incr i 200} { lappend avg_rdf 0}
#this initializes to zero the an array by "back-pushing" (appending) every time a zero element to a list.
set j 0
while {$j< $tot_config} {
puts "j is $j"
set f [open "config_$j" "r"]
while { [blockfile $f read auto] != "eof" } {}
close $f
#Now I try retrieving the info about particle positions
analyze append
#puts "u is, $u "
set w [analyze config]
incr cnt
incr j $my_increase
}
puts "the total number of read configurations is, $cnt"
puts "ok reading the configurations"
puts "w is, $w"
set wlist ""
set flag 0
set i 0
set j 0
while {$j< $tot_config} {
puts "j is, $j"
foreach value [lindex $w $j] {
#puts "value is, $value"
set my_reading [lindex $w ]
#puts "I am reading, $my_reading"
lappend wlist [lindex $value ]
incr i 1
}
incr j $my_increase
}
#puts "wlist is, $wlist"
set obs3 [open "total_configuration.dat" "w"]
foreach r $wlist { puts $obs3 "$r" }
close $obs3
puts "So far so good"