Skip to content

Commit

Permalink
Merge branch 'master' into driver-auto-pes
Browse files Browse the repository at this point in the history
  • Loading branch information
mahrossi authored Nov 24, 2023
2 parents 90c55df + 1d193c6 commit f41eb8c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
38 changes: 29 additions & 9 deletions ipi/engine/motion/dynamics.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
from ipi.engine.thermostats import Thermostat
from ipi.engine.barostats import Barostat
from ipi.utils.softexit import softexit


# __all__ = ['Dynamics', 'NVEIntegrator', 'NVTIntegrator', 'NPTIntegrator', 'NSTIntegrator', 'SCIntegrator`']
from ipi.utils.messages import warning, verbosity


class Dynamics(Motion):
Expand Down Expand Up @@ -327,6 +325,9 @@ def bind(self, motion):
self.coeffsc[::2] /= -3.0
self.coeffsc[1::2] /= 3.0

# check stress tensor
self._stresscheck = True

def pstep(self):
"""Dummy momenta propagator which does nothing."""
pass
Expand Down Expand Up @@ -602,10 +603,20 @@ class NPTIntegrator(NVTIntegrator):
def pstep(self, level=0):
"""Velocity Verlet monemtum propagator."""

if np.array_equiv(self.forces.vir, np.zeros(len(self.forces.vir))):
raise ValueError(
"Seems like no stress tensor was computed by the client. Stopping barostat!"
if self._stresscheck and np.array_equiv(
dstrip(self.forces.vir), np.zeros(len(self.forces.vir))
):
warning(
"Forcefield returned a zero stress tensor. NPT simulation will likely make no sense",
verbosity.low,
)
if verbosity.medium:
raise ValueError(
"Zero stress terminates simulation for medium verbosity and above."
)

self._stresscheck = False

self.barostat.pstep(level)
super(NPTIntegrator, self).pstep(level)
# self.pconstraints()
Expand Down Expand Up @@ -738,10 +749,19 @@ class SCNPTIntegrator(SCIntegrator):
def pstep(self, level=0):
"""Velocity Verlet monemtum propagator."""

if np.array_equiv(self.forces.vir, np.zeros(len(self.forces.vir))):
raise ValueError(
"Seems like no stress tensor was computed by the client. Stopping barostat!"
if self._stresscheck and np.array_equiv(
dstrip(self.forces.vir), np.zeros(len(self.forces.vir))
):
warning(
"Forcefield returned a zero stress tensor. NPT simulation will likely make no sense",
verbosity.low,
)
if verbosity.medium:
raise ValueError(
"Zero stress terminates simulation for medium verbosity and above."
)

self._stresscheck = False

self.barostat.pstep(level)
super(SCNPTIntegrator, self).pstep(level)
Expand Down
4 changes: 2 additions & 2 deletions ipi/engine/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ def load_from_xml(
simulation.bind(read_only)

# echo the input file if verbose enough
if verbosity.level > 0:
if verbosity.low:
print(" # i-PI loaded input file: ", fn_input)
if verbosity.level > 1:
elif verbosity.medium:
print(" --- begin input file content ---")
ifile = open(fn_input, "r")
for line in ifile.readlines():
Expand Down
2 changes: 1 addition & 1 deletion ipi/inputs/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class InputSimulation(Input):
InputAttribute,
{
"dtype": str,
"default": "low",
"default": "medium",
"options": ["quiet", "low", "medium", "high", "debug"],
"help": "The level of output on stdout.",
},
Expand Down

0 comments on commit f41eb8c

Please sign in to comment.