Skip to content

Commit eebb45f

Browse files
committed
Fixed issue with bonds.py
1 parent 835355b commit eebb45f

File tree

7 files changed

+814
-497
lines changed

7 files changed

+814
-497
lines changed

worm_algorithm/bonds.py

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,18 @@ class Bonds(WormSimulation):
3333
T_start (float):
3434
Starting temperature for simulation.
3535
"""
36-
def __init__(self, L, run=False, num_steps=1E7, verbose=True,
37-
T_start=1., T_end=3.5, T_step=0.1, T_arr=None,
38-
block_val=0, write=True, write_blocked=True):
36+
def __init__(self, L, run=False, num_steps=1E7, decay_steps=False,
37+
verbose=True, T_start=1., T_end=3.5, T_step=0.1, T_arr=None,
38+
block_configs=False, block_val=0,
39+
write=True, write_blocked=False):
3940
"""Initialize Bonds class, which can also be used to run the
4041
simulation."""
4142
if T_arr is None:
42-
WormSimulation.__init__(self, L, run, num_steps, verbose,
43-
T_start, T_end, T_step)
43+
WormSimulation.__init__(self, L, run, num_steps, decay_steps,
44+
verbose, T_start, T_end, T_step)
4445
else:
45-
WormSimulation.__init__(self, L, run, num_steps, verbose,
46-
T_arr=T_arr)
46+
WormSimulation.__init__(self, L, run, num_steps, decay_steps,
47+
verbose, T_arr=T_arr)
4748
self._L = L
4849
self._num_bonds = 2*self._L*self._L
4950
self._bonds_dir = '../data/bonds/lattice_{}/'.format(self._L)
@@ -57,7 +58,8 @@ def __init__(self, L, run=False, num_steps=1E7, verbose=True,
5758
self._x_bonds = {}
5859
self._y_bonds = {}
5960
self._config_data = self.set_config_data()
60-
self._blocked_config_data = self.block_configs(block_val)
61+
if block_configs:
62+
self._blocked_config_data = self.block_configs(block_val)
6163
if write:
6264
self.write_config_data()
6365
if write_blocked:
@@ -97,15 +99,25 @@ def _get_map(self):
9799
self._get_raw_bonds()
98100
self._raw_bonds = np.array(self._raw_bonds, dtype=int)
99101
_map = {}
100-
keys = self._raw_bonds[:, 0]
101-
start_sites = self._raw_bonds[:, 1:3]
102-
end_sites = self._raw_bonds[:, 3:]
103-
for idx, key in enumerate(keys):
104-
try:
105-
_map[key].extend([tuple(start_sites[idx]),
106-
tuple(end_sites[idx])])
107-
except KeyError:
108-
_map[key] = [tuple(start_sites[idx]), tuple(end_sites[idx])]
102+
for i in range(len(self._raw_bonds)):
103+
key = self._raw_bonds[i, 0]
104+
sites = self._raw_bonds[i, 1:]
105+
start_site = sites[:2]
106+
end_site = sites[2:]
107+
_map[key] = [tuple(start_site), tuple(end_site)]
108+
#########################################
109+
# BROKEN BELOW
110+
# keys = self._raw_bonds[:, 0]
111+
# start_sites = self._raw_bonds[:, 1:3]
112+
# end_sites = self._raw_bonds[:, 3:]
113+
# for idx, key in enumerate(keys):
114+
# try:
115+
# _map[key].append([tuple(start_site[idx]),
116+
# tuple(start_site[idx])])
117+
# except KeyError:
118+
# _map[key] = [tuple(start_site[idx]), tuple(start_site[idx])]
119+
#########################################
120+
109121
# for i in range(len(self._raw_bonds)):
110122
# key = self._raw_bonds[i, 0]
111123
# sites = self._raw_bonds[i, 1:]

0 commit comments

Comments
 (0)