Skip to content

Commit

Permalink
moved __seed to system class, handling tcl arrays in h5md write
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaslandsgesell committed May 25, 2016
1 parent 8e8d1d0 commit 2ad7c1f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
8 changes: 6 additions & 2 deletions scripts/h5md.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,12 @@ proc dump_script_to_h5md {} {
h5mdfile H5Dcreate2 "parameters/files/tclvariables"
h5mdfile H5Dopen2 "parameters/files/tclvariables"
for { set i 0 } { $i < [llength $which] } { incr i } {
h5mdfile H5_write_value value [lindex $which $i] index $i 0
h5mdfile H5_write_value value [set ::[lindex $which $i]] index $i 1
if {[array exists ::[lindex $which $i] ]==0 } {
h5mdfile H5_write_value value [lindex $which $i] index $i 0
h5mdfile H5_write_value value [set ::[lindex $which $i]] index $i 1
} else {
puts "Did not write tcl array variable [lindex $which $i] to h5md dataset"
}
}
h5mdfile H5Dwrite
}
Expand Down
8 changes: 3 additions & 5 deletions src/python/espressomd/_system.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ from cellsystem import CellSystem

import sys

__seed=-10
setable_properties = ["box_l", "max_num_cells", "min_num_cells",
"node_grid", "npt_piston", "npt_p_diff",
"periodicity", "skin", "time",
Expand Down Expand Up @@ -373,12 +372,11 @@ cdef class System:
def __get__(self):
return max_cut_bonded

__seed=None
property seed:
def __set__(self, _seed):
print(_seed)
cdef vector[int] seed_array
global __seed
__seed = _seed
self.__seed = _seed
if(isinstance(_seed, int) and self.n_nodes == 1):
seed_array.resize(1)
seed_array[0] = int(_seed)
Expand All @@ -397,7 +395,7 @@ cdef class System:
"The seed has to be an integer or a list of integers with one integer per node")

def __get__(self):
return __seed
return self.__seed

def change_volume_and_rescale_particles(d_new, dir="xyz"):
"""Change box size and rescale particle coordinates
Expand Down
2 changes: 0 additions & 2 deletions src/python/espressomd/diamond.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ cdef class Diamond:
"Please define a bonded interaction [0] before setting up polymers!")

def __set_params_in_es_core(self):
print(self._params["a"], self._params["bond_length"], self._params["MPC"], self._params["N_CI"], self._params[
"val_nodes"], self._params["val_cM"], self._params["val_CI"], self._params["cM_dist"], self._params["nonet"])
return diamondC(self._params["a"], self._params["bond_length"], self._params["MPC"], self._params["N_CI"], self._params["val_nodes"], self._params["val_cM"], self._params["val_CI"], self._params["cM_dist"], self._params["nonet"])

def _set_params_in_es_core(self):
Expand Down
16 changes: 15 additions & 1 deletion testsuite/tcl/nsquare.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@ proc write_data {file} {
blockfile $f write bonds
close $f
}
proc write_data_h5_old_data {path} {
h5md_init $path
h5md_write_positions;# write OLD positions by hand as we need the OLD positions
}

proc write_data_h5_new_data {path} {
energy [analyze energy total]
pressure [analyze pressure total]
verlet_reuse [setmd verlet_reuse]
h5md_write_forces
}



if { [catch {
############## integ-specific part
Expand All @@ -68,6 +81,7 @@ if { [catch {
inter 0 fene $fene_k $fene_r

read_data "intpbc_system.data.gz"
write_data_h5_old_data "../test_data/nsquare_test_data.h5"

for { set i 0 } { $i <= [setmd max_part] } { incr i } {
set F($i) [part $i pr f]
Expand All @@ -82,7 +96,7 @@ if { [catch {

# here you can create the necessary snapshot
# write_data "intpbc_system.data.gz"

write_data_h5_old_data "../test_data/"
############## end

set toteng [analyze energy total]
Expand Down

0 comments on commit 2ad7c1f

Please sign in to comment.