From e226289cdd3159ffc223640928f6043fc40fd9b5 Mon Sep 17 00:00:00 2001 From: Daniel Bauer Date: Tue, 16 Jul 2019 12:59:49 +0200 Subject: [PATCH 1/5] Update wham2d.py --- adaptiveumbrella/wham2d.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adaptiveumbrella/wham2d.py b/adaptiveumbrella/wham2d.py index a5b7e6b..eaf5ead 100644 --- a/adaptiveumbrella/wham2d.py +++ b/adaptiveumbrella/wham2d.py @@ -84,7 +84,7 @@ class WHAM2DRunner(UmbrellaRunner): max_y=borders[3], frames_y=self.whamconfig['num_bins_y'], tol=self.whamconfig['tolerance'], - temperature=self.whamconfig['temperature'] + temperature=self.whamconfig['temperature'], metafile=metafile_path, outfile=output_path ) From f25288e4f57fd7e9cd1d76442a262021a4629f3d Mon Sep 17 00:00:00 2001 From: Daniel Bauer Date: Tue, 16 Jul 2019 13:00:15 +0200 Subject: [PATCH 2/5] Update __init__.py --- adaptiveumbrella/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adaptiveumbrella/__init__.py b/adaptiveumbrella/__init__.py index 92e10fc..be3b501 100644 --- a/adaptiveumbrella/__init__.py +++ b/adaptiveumbrella/__init__.py @@ -3,4 +3,4 @@ from .runner import UmbrellaRunner from .wham2d import WHAM2DRunner __all__ = ['AdaptiveUmbrella'] -__version__ = "0.3.4" +__version__ = "0.3.5" From 074d399984245eb20e383a9d7b5bb4fc17c9ed3f Mon Sep 17 00:00:00 2001 From: Daniel Bauer Date: Wed, 31 Jul 2019 13:10:14 +0200 Subject: [PATCH 3/5] wham2d can now hide some output when verbose is set to False --- adaptiveumbrella/__init__.py | 2 +- adaptiveumbrella/wham2d.py | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/adaptiveumbrella/__init__.py b/adaptiveumbrella/__init__.py index be3b501..2c12eed 100644 --- a/adaptiveumbrella/__init__.py +++ b/adaptiveumbrella/__init__.py @@ -3,4 +3,4 @@ from .runner import UmbrellaRunner from .wham2d import WHAM2DRunner __all__ = ['AdaptiveUmbrella'] -__version__ = "0.3.5" +__version__ = "0.3.6" diff --git a/adaptiveumbrella/wham2d.py b/adaptiveumbrella/wham2d.py index eaf5ead..8b6379f 100644 --- a/adaptiveumbrella/wham2d.py +++ b/adaptiveumbrella/wham2d.py @@ -21,6 +21,7 @@ class WHAM2DRunner(UmbrellaRunner): def __init__(self): UmbrellaRunner.__init__(self) + self.verbose = False self.WHAM_EXEC = 'wham-2d' self.tmp_folder = "tmp/WHAM" self.simulation_folder = "tmp/simulations" @@ -34,7 +35,7 @@ class WHAM2DRunner(UmbrellaRunner): with open(path, 'w') as out: for file in os.listdir(self.simulation_folder): filepath = os.path.join(self.simulation_folder, file, "COLVAR") - if not os.path.exists(filepath): + if not os.path.exists(filepath) and self.verbose: print("Not found: {}".format(filepath)) continue prefix, x, y = file.split("_") @@ -59,9 +60,9 @@ class WHAM2DRunner(UmbrellaRunner): self._get_lambdas_for_index((nonzero[0].min(), nonzero[1].min())), self._get_lambdas_for_index((nonzero[0].max(), nonzero[1].max())) ]) - + borders = borders.flatten() - # increase borders by 1 lambda step from minimal dimensions + # increase borders by 1 lambda step from minimal dimensions borders[0] -= self.cvs[0][2] borders[1] -= self.cvs[1][2] borders[2] += self.cvs[0][2] @@ -88,8 +89,12 @@ class WHAM2DRunner(UmbrellaRunner): metafile=metafile_path, outfile=output_path ) - print(cmd) - err_code = subprocess.call(cmd, shell=True) + if self.verbose: + print(cmd) + err_code = subprocess.call(cmd, shell=True) + else: + FNULL = open(os.devnull, 'w') + err_code = subprocess.call(cmd, shell=True, stdout=FNULL) if err_code != 0: print("wham exited with error code {}".format(err_code)) exit(1) @@ -118,7 +123,6 @@ class WHAM2DRunner(UmbrellaRunner): def calculate_new_pmf(self): - print("Running wham-2d") metafile_path = self.create_metadata_file() wham_pmf_file = self.get_wham_output_file() self.run_wham2d(metafile_path, wham_pmf_file) From 3f5100b7791fe56956fcf6b9bde124a67bf2d928 Mon Sep 17 00:00:00 2001 From: Daniel Bauer Date: Fri, 16 Aug 2019 14:10:00 +0200 Subject: [PATCH 4/5] function to exclude frames --- adaptiveumbrella/__init__.py | 2 +- adaptiveumbrella/runner.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/adaptiveumbrella/__init__.py b/adaptiveumbrella/__init__.py index 2c12eed..e5d3cf7 100644 --- a/adaptiveumbrella/__init__.py +++ b/adaptiveumbrella/__init__.py @@ -3,4 +3,4 @@ from .runner import UmbrellaRunner from .wham2d import WHAM2DRunner __all__ = ['AdaptiveUmbrella'] -__version__ = "0.3.6" +__version__ = "0.3.8" diff --git a/adaptiveumbrella/runner.py b/adaptiveumbrella/runner.py index 18e4171..fefe551 100755 --- a/adaptiveumbrella/runner.py +++ b/adaptiveumbrella/runner.py @@ -111,6 +111,12 @@ class UmbrellaRunner(): return False return True + def is_valid_frame(self, frame): + """ Allows to filter out frames that should not be sampled depending + on some condition """ + # do not allow frames that are not inside pmf boundaries + return self._is_in_pmf(frame) + def _get_new_frames(self, pmf, frames, root_frames): """ returns a dict of all frames surrounding the root_frames that have not an assigned energy yet, as well as their corresponding root @@ -121,8 +127,8 @@ class UmbrellaRunner(): for frame in root_frames: neighbors = self._generate_neighbor_list(frame) - # remove neighbors that are not inside the pmf - neighbors = [n for n in neighbors if self._is_in_pmf(n)] + # remove neighbors if they are not valid (i.e not part of the pmf) + neighbors = [n for n in neighbors if self.is_valid_frame(n)] # for each neighbor, check if its already in the list and compare root frame energy for n in neighbors: From 37e900dd9118035cf1916a7fe2fd398f7b01a2a4 Mon Sep 17 00:00:00 2001 From: Daniel Bauer Date: Fri, 16 Aug 2019 14:23:47 +0200 Subject: [PATCH 5/5] wham now uses automask --- adaptiveumbrella/wham2d.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/adaptiveumbrella/wham2d.py b/adaptiveumbrella/wham2d.py index 8b6379f..96e6e1b 100644 --- a/adaptiveumbrella/wham2d.py +++ b/adaptiveumbrella/wham2d.py @@ -74,7 +74,7 @@ class WHAM2DRunner(UmbrellaRunner): borders = self.get_wham_borders() - cmd = "{exec} Px={px} {min_x} {max_x} {frames_x} Py={py} {min_y} {max_y} {frames_y} {tol} {temperature} 0 {metafile} {outfile} 0".format( + cmd = "{exec} Px={px} {min_x} {max_x} {frames_x} Py={py} {min_y} {max_y} {frames_y} {tol} {temperature} 0 {metafile} {outfile} {mask}".format( exec=self.WHAM_EXEC, px=self.whamconfig['Px'], min_x=borders[0], @@ -87,7 +87,8 @@ class WHAM2DRunner(UmbrellaRunner): tol=self.whamconfig['tolerance'], temperature=self.whamconfig['temperature'], metafile=metafile_path, - outfile=output_path + outfile=output_path, + mask=1 ) if self.verbose: print(cmd)