reproduceable tmp pmfs
This commit is contained in:
@@ -47,7 +47,6 @@ class UmbrellaRunner():
|
|||||||
pmf = np.empty(shape)
|
pmf = np.empty(shape)
|
||||||
pmf.fill(-1)
|
pmf.fill(-1)
|
||||||
return pmf
|
return pmf
|
||||||
|
|
||||||
|
|
||||||
def _get_lambdas_for_index(self, idx):
|
def _get_lambdas_for_index(self, idx):
|
||||||
""" takes a coordinate tuple of the pmf and returns corresponding lambda values """
|
""" takes a coordinate tuple of the pmf and returns corresponding lambda values """
|
||||||
@@ -68,10 +67,21 @@ class UmbrellaRunner():
|
|||||||
if abs(r[i]-lambdas[dimen]) < 0.00001:
|
if abs(r[i]-lambdas[dimen]) < 0.00001:
|
||||||
idx.append(i)
|
idx.append(i)
|
||||||
break
|
break
|
||||||
if len(idx) == len(lambdas):
|
if not len(idx)-1 == dimen:
|
||||||
return tuple(idx)
|
raise ValueError(f"{lambdas} has no index because {lambdas[dimen]} is not in {r}.")
|
||||||
else: # if len differs, theres no index for every dimension
|
|
||||||
raise ValueError("{} has no index.".format(lambdas))
|
return tuple(idx)
|
||||||
|
|
||||||
|
def _get_sampled_lambdas(self, step=None):
|
||||||
|
""" returns an array of all sampled lambdas. If step is given, only return
|
||||||
|
lambdas for this step"""
|
||||||
|
if step is None:
|
||||||
|
sampled_coords = np.where(self.sample_list > 0)
|
||||||
|
else:
|
||||||
|
sampled_coords = np.where(self.sample_list == step)
|
||||||
|
sampled_coords = np.array(sampled_coords).T
|
||||||
|
|
||||||
|
return np.array([self._get_lambdas_for_index(cvs) for cvs in sampled_coords])
|
||||||
|
|
||||||
def _get_root_frames(self, pmf, frames, E_max):
|
def _get_root_frames(self, pmf, frames, E_max):
|
||||||
""" returns the index of all positions in the pmf where the energy is
|
""" returns the index of all positions in the pmf where the energy is
|
||||||
|
|||||||
@@ -33,18 +33,14 @@ class WHAM2DRunner(UmbrellaRunner):
|
|||||||
""" create the metadata file for wham-2d """
|
""" create the metadata file for wham-2d """
|
||||||
path = os.path.join(self.tmp_folder, "{}_metadata.dat".format(self.num_iterations))
|
path = os.path.join(self.tmp_folder, "{}_metadata.dat".format(self.num_iterations))
|
||||||
with open(path, 'w') as out:
|
with open(path, 'w') as out:
|
||||||
for file in os.listdir(self.simulation_folder):
|
for x, y in self._get_sampled_lambdas():
|
||||||
filepath = os.path.join(self.simulation_folder, file, "COLVAR")
|
colvar_file = os.path.join(self.simulation_folder, f"umb_{x}_{y}", "COLVAR")
|
||||||
if not os.path.exists(filepath) and self.verbose:
|
if not os.path.exists(colvar_file) and self.verbose:
|
||||||
print("Not found: {}".format(filepath))
|
print("Not found: {}".format(colvar_file))
|
||||||
continue
|
continue
|
||||||
prefix, x, y = file.split("_")
|
out.write("{file}\t{x}\t{y}\t{fc_x}\t{fc_y}\n".format(
|
||||||
index = self._get_index_for_lambdas((float(x),float(y)))
|
file=colvar_file, x=x, y=y, fc_x=self.whamconfig['fc_x'], fc_y=self.whamconfig['fc_y']
|
||||||
if self.sample_list[index] != 0:
|
))
|
||||||
colvar_file = os.path.join(file, 'COLVAR')
|
|
||||||
out.write("{file}\t{x}\t{y}\t{fc_x}\t{fc_y}\n".format(
|
|
||||||
file=os.path.join(self.simulation_folder, colvar_file), x=x, y=y, fc_x=self.whamconfig['fc_x'], fc_y=self.whamconfig['fc_y']
|
|
||||||
))
|
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user