-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Entries missing from input_parameters #104
Open
Bernadette-Mohr
wants to merge
1
commit into
develop
Choose a base branch
from
103-support-for-umbrella-sampling-calculations-in-nomad
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,812,561
−2
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
# limitations under the License. | ||
# | ||
import os | ||
|
||
import numpy as np | ||
import logging | ||
import re | ||
|
@@ -49,6 +50,7 @@ | |
GeometryOptimizationMethod, | ||
GeometryOptimizationResults, | ||
) | ||
|
||
from .metainfo.gromacs import ( | ||
x_gromacs_section_control_parameters, | ||
x_gromacs_section_input_output_files, | ||
|
@@ -66,7 +68,7 @@ | |
def to_float(string): | ||
try: | ||
value = float(string) | ||
except ValueError: | ||
except (ValueError, TypeError): | ||
value = None | ||
return value | ||
|
||
|
@@ -199,22 +201,31 @@ def init_quantities(self): | |
def str_to_input_parameters(val_in): | ||
re_array = re.compile(r"\s*([\w\-]+)\[[\d ]+\]\s*=\s*\{*(.+)") | ||
re_scalar = re.compile(r"\s*([\w\-]+)\s*[=:]\s*(.+)") | ||
re_comment = re.compile(r"^\S+?(?=[\s;])") | ||
parameters = dict() | ||
val = [line.strip() for line in val_in.splitlines()] | ||
for val_n in val: | ||
val_scalar = re_scalar.match(val_n) | ||
if val_scalar: | ||
parameters[val_scalar.group(1)] = val_scalar.group(2) | ||
val_scalar_group2 = val_scalar.group(2) | ||
inline_comment = re_comment.match(val_scalar_group2) | ||
if inline_comment: | ||
parameters[val_scalar.group(1)] = inline_comment.group(1) | ||
else: | ||
parameters[val_scalar.group(1)] = val_scalar.group(2) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is not functional, but just to avoid calling the group() twice: |
||
continue | ||
val_array = re_array.match(val_n) | ||
if val_array: | ||
# print("val_array", val_array) | ||
parameters.setdefault(val_array.group(1), []) | ||
value = [ | ||
to_float(v) for v in val_array.group(2).rstrip("}").split(",") | ||
] | ||
parameters[val_array.group(1)].append( | ||
value[0] if len(value) == 1 else value | ||
) | ||
# print("\nTEST:", parameters) | ||
|
||
return parameters | ||
|
||
self._quantities = [ | ||
|
@@ -1065,6 +1076,7 @@ def parse_method(self): | |
self.parse_interactions(interactions, sec_model) | ||
|
||
input_parameters = self.input_parameters | ||
# print("input_parameters", input_parameters) | ||
sec_force_calculations = ForceCalculations() | ||
sec_force_field.force_calculations = sec_force_calculations | ||
sec_neighbor_searching = NeighborSearching() | ||
|
@@ -1075,6 +1087,12 @@ def parse_method(self): | |
int(nstlist) if nstlist else None | ||
) | ||
rlist = to_float(input_parameters.get("rlist", None)) | ||
# rlist = ( | ||
# to_float(value) | ||
# if (value := input_parameters.get("rlist")) is not None | ||
# else None | ||
# ) | ||
|
||
sec_neighbor_searching.neighbor_update_cutoff = ( | ||
rlist * ureg.nanometer if rlist else None | ||
) | ||
|
@@ -1197,6 +1215,12 @@ def get_barostat_parameters(self): | |
) | ||
return barostat_parameters | ||
|
||
# TODO: implement | ||
def get_umbrella_sampling_parameters(self): | ||
umbrella_sampling_parameters = {} | ||
umbrella_sampling = self.input_parameters.get("pull", "") | ||
# print("test", umbrella_sampling) | ||
|
||
def get_free_energy_calculation_parameters(self): | ||
free_energy_parameters = {} | ||
free_energy = self.input_parameters.get("free-energy", "") | ||
|
@@ -1241,7 +1265,9 @@ def get_free_energy_calculation_parameters(self): | |
|
||
atoms_info = self.traj_parser._results["atoms_info"] | ||
atoms_moltypes = np.array(atoms_info["moltypes"]) | ||
# print("atoms_moltypes", atoms_moltypes) | ||
couple_moltype = self.input_parameters.get("couple-moltype", "").split() | ||
print("couple_moltype", self.input_parameters.get("couple-moltype", "")) | ||
n_atoms = len(atoms_moltypes) | ||
indices = [] | ||
if len(couple_moltype) == 1 and couple_moltype[0].lower() == "system": | ||
|
@@ -1507,6 +1533,7 @@ def parse_input(self): | |
sec_run.x_gromacs_section_control_parameters = sec_control_parameters | ||
input_parameters = self.input_parameters | ||
input_parameters.update(self.info.get("header", {})) | ||
# print("input_parameters: ", input_parameters) | ||
for key, val in input_parameters.items(): | ||
key = ( | ||
"x_gromacs_inout_control_%s" | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try this:
parameters[val_scalar.group(1)] = inline_comment.group()