Skip to content
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

calc_md with pressure 0 corrected #656

Merged
merged 2 commits into from May 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 5 additions & 10 deletions pyiron/lammps/control.py
Expand Up @@ -223,12 +223,12 @@ def pressure_to_lammps(self, pressure, rotation_matrix):
pressure = np.array(all_pressures, dtype=float)

# Cell degrees of freedom can be kept fixed using None for the pressure, check where that's done.
not_none_mask = [p is not None for p in pressure]
not_none_mask = (pressure!=None)
if not np.any(not_none_mask):
raise ValueError("Pressure cannot have a length but all be None")

# If necessary, rotate the pressure tensor to the Lammps coordinate frame
if np.matrix.trace(rotation_matrix) != 3:
if not np.isclose(np.matrix.trace(rotation_matrix), 3):
if not np.all(not_none_mask):
raise ValueError("Cells which are not orthorhombic or rectangular are incompatible with Lammps "
"constant pressure calculations unless the entire pressure tensor is defined."
Expand Down Expand Up @@ -491,16 +491,11 @@ def calc_md(

# Set thermodynamic ensemble
if pressure is not None: # NPT
if not hasattr(pressure, "__len__"):
pressure = pressure * np.ones(3)
else:
pressure = np.array(pressure, dtype=float)

not_none_mask = [p is not None for p in pressure]
if not np.any(not_none_mask):
raise ValueError("Pressure cannot be three times None")
if np.sum(np.array([pressure]).flatten()!=None)==0:
raise ValueError("At least one component of pressure must be other than None")

if len(pressure) > 6:
if hasattr(pressure, "__len__") and len(pressure) > 6:
raise ValueError("Pressure must be a float or a vector with length <= 6")

if temperature is None or temperature.min() <= 0:
Expand Down
1 change: 1 addition & 0 deletions tests/lammps/test_base.py
Expand Up @@ -285,6 +285,7 @@ def test_dump_parser_water(self):
n_print=200,
pressure=0,
)
self.assertFalse('nan' in self.job_water_dump.input.control['fix___ensemble'])
file_directory = os.path.join(
self.execution_path, "..", "static", "lammps_test_files"
)
Expand Down