Example #1
0
File: nvt.py Project: boegel/yaff
    def __init__(self, temp, start=0, step=1, select=None, annealing=1.0):
        """
           This is an implementation of the Andersen thermostat. The method
           is described in:

                Andersen, H. C. J. Chem. Phys. 1980, 72, 2384-2393.

           **Arguments:**

           temp
                The average temperature of the NVT ensemble

           **Optional arguments:**

           start
                The first iteration at which this hook is called

           step
                The number of iterations between two subsequent calls to this
                hook.

           select
                An array of atom indexes to indicate which atoms controlled by
                the thermostat.

           annealing
                After every call to this hook, the temperature is multiplied
                with this annealing factor. This effectively cools down the
                system.
        """
        self.temp = temp
        self.select = select
        self.annealing = annealing
        VerletHook.__init__(self, start, step)
Example #2
0
    def __init__(self, temp, start=0, step=1, select=None, annealing=1.0):
        """
           This is an implementation of the Andersen thermostat. The method
           is described in:

                Andersen, H. C. J. Chem. Phys. 1980, 72, 2384-2393.

           **Arguments:**

           temp
                The average temperature of the NVT ensemble

           **Optional arguments:**

           start
                The first iteration at which this hook is called

           step
                The number of iterations between two subsequent calls to this
                hook.

           select
                An array of atom indexes to indicate which atoms controlled by
                the thermostat.

           annealing
                After every call to this hook, the temperature is multiplied
                with this annealing factor. This effectively cools down the
                system.
        """
        self.temp = temp
        self.select = select
        self.annealing = annealing
        VerletHook.__init__(self, start, step)
Example #3
0
    def __init__(self, temp, press, start=0, step=1, amp=1e-3):
        """
           Warning: this code is not fully tested yet!

           **Arguments:**

           temp
                The average temperature of the NpT ensemble

           press
                The external pressure of the NpT ensemble

           **Optional arguments:**

           start
                The first iteration at which this hook is called

           step
                The number of iterations between two subsequent calls to this
                hook.

           amp
                The amplitude of the changes in the logarithm of the volume.
        """
        self.temp = temp
        self.press = press
        self.amp = amp
        self.dim = 3
        self.baro_ndof = 1
        VerletHook.__init__(self, start, step)
Example #4
0
File: npt.py Project: yfyh2013/yaff
    def __init__(self, temp, press, start=0, step=1, amp=1e-3):
        """
           Warning: this code is not fully tested yet!

           **Arguments:**

           temp
                The average temperature of the NpT ensemble

           press
                The external pressure of the NpT ensemble

           **Optional arguments:**

           start
                The first iteration at which this hook is called

           step
                The number of iterations between two subsequent calls to this
                hook.

           amp
                The amplitude of the changes in the logarithm of the volume.
        """
        self.temp = temp
        self.press = press
        self.amp = amp
        self.dim = 3
        self.baro_ndof = 1
        VerletHook.__init__(self, start, step)
Example #5
0
    def __init__(self, temp, start=0, timecon=100*femtosecond, restart=False):
        """
           This is an implementation of the Berendsen thermostat. The algorithm
           is described in:

                Berendsen, H. J. C.; Postma, J. P. M.; van Gunsteren, W. F.;
                Dinola, A.; Haak, J. R. J. Chem. Phys. 1984, 81, 3684-3690

           **Arguments:**

           temp
                The temperature of thermostat.

           **Optional arguments:**

           start
                The step at which the thermostat becomes active.

           timecon
                The time constant of the Berendsen thermostat.

            restart
                Indicates whether the initalisation should be carried out.
        """
        self.temp = temp
        self.timecon = timecon
        self.restart = restart
        VerletHook.__init__(self, start, 1)
Example #6
0
File: nvt.py Project: boegel/yaff
    def __init__(self, temp, a_p, c_p=None, start=0):
        """
            This hook implements the coloured noise thermostat. The equations
            are derived in:

                Ceriotti, M.; Bussi, G.; Parrinello, M J. Chem. Theory Comput.
                2010, 6, 1170-1180.

            **Arguments:**

            temp
                The temperature of thermostat.

            a_p
                Square drift matrix, with elements fitted to the specific problem.


            **Optional arguments:**

            c_p
                Square static covariance matrix. In equilibrium, its elements are fixed.
                For non-equilibrium dynamics, its elements should be fitted.

            start
                The step at which the thermostat becomes active.
        """
        self.temp = temp
        self.ns = int(a_p.shape[0] - 1)
        self.a_p = a_p
        self.c_p = c_p
        if self.c_p is None:
            # Assume equilibrium dynamics if c_p is not provided
            self.c_p = boltzmann * self.temp * np.eye(self.ns + 1)
        VerletHook.__init__(self, start, 1)
Example #7
0
File: npt.py Project: yfyh2013/yaff
    def __init__(self, thermostat, barostat, start=0):
        """
            VerletHook combining an arbitrary Thermostat and Barostat instance, which
            ensures these instances are called in the correct succession, and possible
            coupling between both is handled correctly.

            **Arguments:**

            thermostat
                A Thermostat instance

            barostat
                A Barostat instance

        """
        self.thermostat = thermostat
        self.barostat = barostat
        self.start = start
        # verify if thermostat and barostat instances are currently supported in yaff
        if not self.verify():
            self.barostat = thermostat
            self.thermostat = barostat
            if not self.verify():
                raise TypeError('The Thermostat or Barostat instance is not supported (yet)')
        self.step_thermo = self.thermostat.step
        self.step_baro = self.barostat.step
        VerletHook.__init__(self, start, min(self.step_thermo, self.step_baro))
Example #8
0
    def __init__(self, temp, start=0, timecon=100*femtosecond):
        """
            This is an implementation of the CSVR thermostat. The equations are
            derived in:

                Bussi, G.; Donadio, D.; Parrinello, M. J. Chem. Phys. 2007,
                126, 014101

            The implementation (used here) is derived in

                Bussi, G.; Parrinello, M. Comput. Phys. Commun. 2008, 179, 26-29

           **Arguments:**

           temp
                The temperature of thermostat.

           **Optional arguments:**

           start
                The step at which the thermostat becomes active.

           timecon
                The time constant of the CSVR thermostat.
        """
        self.temp = temp
        self.timecon = timecon
        VerletHook.__init__(self, start, 1)
Example #9
0
File: nvt.py Project: boegel/yaff
    def __init__(self, temp, start=0, timecon=100 * femtosecond):
        """
            This is an implementation of the CSVR thermostat. The equations are
            derived in:

                Bussi, G.; Donadio, D.; Parrinello, M. J. Chem. Phys. 2007,
                126, 014101

            The implementation (used here) is derived in

                Bussi, G.; Parrinello, M. Comput. Phys. Commun. 2008, 179, 26-29

           **Arguments:**

           temp
                The temperature of thermostat.

           **Optional arguments:**

           start
                The step at which the thermostat becomes active.

           timecon
                The time constant of the CSVR thermostat.
        """
        self.temp = temp
        self.timecon = timecon
        VerletHook.__init__(self, start, 1)
Example #10
0
File: nvt.py Project: boegel/yaff
    def __init__(self,
                 temp,
                 start=0,
                 timecon=100 * femtosecond,
                 restart=False):
        """
           This is an implementation of the Berendsen thermostat. The algorithm
           is described in:

                Berendsen, H. J. C.; Postma, J. P. M.; van Gunsteren, W. F.;
                Dinola, A.; Haak, J. R. J. Chem. Phys. 1984, 81, 3684-3690

           **Arguments:**

           temp
                The temperature of thermostat.

           **Optional arguments:**

           start
                The step at which the thermostat becomes active.

           timecon
                The time constant of the Berendsen thermostat.

            restart
                Indicates whether the initalisation should be carried out.
        """
        self.temp = temp
        self.timecon = timecon
        self.restart = restart
        VerletHook.__init__(self, start, 1)
Example #11
0
File: nvt.py Project: tovrstra/yaff
    def __init__(self, temp, start=0, timecon=100*femtosecond, chainlength=3):
        """
           This hook implements the Nose-Hoover-Chain thermostat. The equations
           are derived in:

                Martyna, G. J.; Klein, M. L.; Tuckerman, M. J. Chem. Phys. 1992,
                97, 2635-2643.

           The implementation (used here) of a symplectic integrator of the
           Nose-Hoover-Chain thermostat is discussed in:

                Martyna, G. J.;  Tuckerman, M. E.;  Tobias, D. J.;  Klein,
                M. L. Mol. Phys. 1996, 87, 1117-1157.

           **Arguments:**

           temp
                The temperature of thermostat.

           **Optional arguments:**

           start
                The step at which the thermostat becomes active.

           timecon
                The time constant of the Nose-Hoover thermostat.

           chainlength
                The number of beads in the Nose-Hoover chain.
        """
        self.temp = temp
        # At this point, the timestep and the number of degrees of freedom are
        # not known yet.
        self.chain = NHChain(chainlength, 0.0, temp, 0, timecon)
        VerletHook.__init__(self, start, 1)
Example #12
0
    def __init__(self, temp, a_p, c_p=None, start=0):
        """
            This hook implements the coloured noise thermostat. The equations
            are derived in:

                Ceriotti, M.; Bussi, G.; Parrinello, M J. Chem. Theory Comput.
                2010, 6, 1170-1180.

            **Arguments:**

            temp
                The temperature of thermostat.

            a_p
                Square drift matrix, with elements fitted to the specific problem.


            **Optional arguments:**

            c_p
                Square static covariance matrix. In equilibrium, its elements are fixed.
                For non-equilibrium dynamics, its elements should be fitted.

            start
                The step at which the thermostat becomes active.
        """
        self.temp = temp
        self.ns = int(a_p.shape[0]-1)
        self.a_p = a_p
        self.c_p = c_p
        if self.c_p is None:
            # Assume equilibrium dynamics if c_p is not provided
            self.c_p = boltzmann*self.temp*np.eye(self.ns+1)
        VerletHook.__init__(self, start, 1)
Example #13
0
    def __init__(self, thermostat, barostat, start=0):
        """
            VerletHook combining an arbitrary Thermostat and Barostat instance, which
            ensures these instances are called in the correct succession, and possible
            coupling between both is handled correctly.

            **Arguments:**

            thermostat
                A Thermostat instance

            barostat
                A Barostat instance

        """
        self.thermostat = thermostat
        self.barostat = barostat
        self.start = start
        # verify if thermostat and barostat instances are currently supported in yaff
        if not self.verify():
            self.barostat = thermostat
            self.thermostat = barostat
            if not self.verify():
                raise TypeError('The Thermostat or Barostat instance is not supported (yet)')
        self.step_thermo = self.thermostat.step
        self.step_baro = self.barostat.step
        VerletHook.__init__(self, start, min(self.step_thermo, self.step_baro))
Example #14
0
File: nvt.py Project: boegel/yaff
    def __init__(self,
                 temp,
                 start=0,
                 timecon=100 * femtosecond,
                 chainlength=3,
                 chain_pos0=None,
                 chain_vel0=None,
                 restart=False):
        """
            This hook implements the Nose-Hoover chain thermostat. The equations
            are derived in:

                Martyna, G. J.; Klein, M. L.; Tuckerman, M. J. Chem. Phys. 1992,
                97, 2635-2643.

            The implementation (used here) of a symplectic integrator of the
            Nose-Hoover chain thermostat is discussed in:

                Martyna, G. J.;  Tuckerman, M. E.;  Tobias, D. J.;  Klein,
                M. L. Mol. Phys. 1996, 87, 1117-1157.

            **Arguments:**

            temp
                The temperature of thermostat.

            **Optional arguments:**

            start
                The step at which the thermostat becomes active.

            timecon
                The time constant of the Nose-Hoover thermostat.

            chainlength
                The number of beads in the Nose-Hoover chain.

            chain_pos0
                The initial thermostat chain positions

            chain_vel0
                The initial thermostat chain velocities

            restart
                Indicates whether the initalisation should be carried out
        """
        self.temp = temp
        self.restart = restart
        # At this point, the timestep and the number of degrees of freedom are
        # not known yet
        self.chain = NHChain(chainlength, 0.0, temp, 0, chain_pos0, chain_vel0,
                             timecon)
        VerletHook.__init__(self, start, 1)
Example #15
0
File: npt.py Project: yfyh2013/yaff
    def __init__(self, ff, temp, press, start=0, step=1, timecon=1000*femtosecond, beta=4.57e-5/bar, anisotropic=True, vol_constraint=False, restart=False):
        """
            This hook implements the Berendsen barostat. The equations are derived in:

                Berendsen, H. J. C.; Postma, J. P. M.; van Gunsteren, W. F.;
                Dinola, A.; Haak, J. R. J. Chem. Phys. 1984, 81, 3684-3690

            **Arguments:**

            ff
                A ForceField instance.

            temp
                The temperature of thermostat.

            press
                The applied pressure for the barostat.

            **Optional arguments:**

            start
                The step at which the thermostat becomes active.

            timecon
                The time constant of the Berendsen barostat.

            beta
                The isothermal compressibility, conventionally the compressibility of liquid water

            anisotropic
                Defines whether anisotropic cell fluctuations are allowed.

            vol_constraint
                Defines whether the volume is allowed to fluctuate.
        """
        self.temp = temp
        self.press = press
        self.timecon_press = timecon
        self.beta = beta
        self.mass_press = 3.0*timecon/beta
        self.anisotropic = anisotropic
        self.vol_constraint = vol_constraint
        self.dim = ff.system.cell.nvec
        # determine the number of degrees of freedom associated with the unit cell
        self.baro_ndof = get_ndof_baro(self.dim, self.anisotropic, self.vol_constraint)
        if self.anisotropic:
            # symmetrize the cell tensor
            cell_symmetrize(ff)
        self.cell = ff.system.cell.rvecs.copy()
        self.restart = restart
        VerletHook.__init__(self, start, step)
Example #16
0
    def __init__(self, ff, temp, press, start=0, step=1, timecon=1000*femtosecond, beta=4.57e-5/bar, anisotropic=True, vol_constraint=False, restart=False):
        """
            This hook implements the Berendsen barostat. The equations are derived in:

                Berendsen, H. J. C.; Postma, J. P. M.; van Gunsteren, W. F.;
                Dinola, A.; Haak, J. R. J. Chem. Phys. 1984, 81, 3684-3690

            **Arguments:**

            ff
                A ForceField instance.

            temp
                The temperature of thermostat.

            press
                The applied pressure for the barostat.

            **Optional arguments:**

            start
                The step at which the thermostat becomes active.

            timecon
                The time constant of the Berendsen barostat.

            beta
                The isothermal compressibility, conventionally the compressibility of liquid water

            anisotropic
                Defines whether anisotropic cell fluctuations are allowed.

            vol_constraint
                Defines whether the volume is allowed to fluctuate.
        """
        self.temp = temp
        self.press = press
        self.timecon_press = timecon
        self.beta = beta
        self.mass_press = 3.0*timecon/beta
        self.anisotropic = anisotropic
        self.vol_constraint = vol_constraint
        self.dim = ff.system.cell.nvec
        # determine the number of degrees of freedom associated with the unit cell
        self.baro_ndof = get_ndof_baro(self.dim, self.anisotropic, self.vol_constraint)
        if self.anisotropic:
            # symmetrize the cell tensor
            cell_symmetrize(ff)
        self.cell = ff.system.cell.rvecs.copy()
        self.restart = restart
        VerletHook.__init__(self, start, step)
Example #17
0
    def __init__(self, ff, temp, press, start=0, step=1, timecon=1000*femtosecond, anisotropic=True, vol_constraint=False):
        """
            This hook implements the Langevin barostat. The equations are derived in:

                Feller, S. E.; Zhang, Y.; Pastor, R. W.; Brooks, B. R.
                J. Chem. Phys. 1995, 103, 4613-4621

            **Arguments:**

            ff
                A ForceField instance.

            temp
                The temperature of thermostat.

            press
                The applied pressure for the barostat.

            **Optional arguments:**

            start
                The step at which the barostat becomes active.

            timecon
                The time constant of the Langevin barostat.

            anisotropic
                Defines whether anisotropic cell fluctuations are allowed.

            vol_constraint
                Defines whether the volume is allowed to fluctuate.
        """
        self.temp = temp
        self.press = press
        self.timecon = timecon
        self.anisotropic = anisotropic
        self.vol_constraint = vol_constraint
        self.dim = ff.system.cell.nvec
        # determine the number of degrees of freedom associated with the unit cell
        self.baro_ndof = get_ndof_baro(self.dim, self.anisotropic, self.vol_constraint)
        if self.anisotropic:
            # symmetrize the cell tensor
            cell_symmetrize(ff)
        self.cell = ff.system.cell.rvecs.copy()
        VerletHook.__init__(self, start, step)
Example #18
0
File: npt.py Project: yfyh2013/yaff
    def __init__(self, ff, temp, press, start=0, step=1, timecon=1000*femtosecond, anisotropic=True, vol_constraint=False):
        """
            This hook implements the Langevin barostat. The equations are derived in:

                Feller, S. E.; Zhang, Y.; Pastor, R. W.; Brooks, B. R.
                J. Chem. Phys. 1995, 103, 4613-4621

            **Arguments:**

            ff
                A ForceField instance.

            temp
                The temperature of thermostat.

            press
                The applied pressure for the barostat.

            **Optional arguments:**

            start
                The step at which the barostat becomes active.

            timecon
                The time constant of the Langevin barostat.

            anisotropic
                Defines whether anisotropic cell fluctuations are allowed.

            vol_constraint
                Defines whether the volume is allowed to fluctuate.
        """
        self.temp = temp
        self.press = press
        self.timecon = timecon
        self.anisotropic = anisotropic
        self.vol_constraint = vol_constraint
        self.dim = ff.system.cell.nvec
        # determine the number of degrees of freedom associated with the unit cell
        self.baro_ndof = get_ndof_baro(self.dim, self.anisotropic, self.vol_constraint)
        if self.anisotropic:
            # symmetrize the cell tensor
            cell_symmetrize(ff)
        self.cell = ff.system.cell.rvecs.copy()
        VerletHook.__init__(self, start, step)
Example #19
0
    def __init__(self, temp, start=0, timecon=100*femtosecond, chainlength=3, chain_pos0=None, chain_vel0=None, restart=False):
        """
            This hook implements the Nose-Hoover chain thermostat. The equations
            are derived in:

                Martyna, G. J.; Klein, M. L.; Tuckerman, M. J. Chem. Phys. 1992,
                97, 2635-2643.

            The implementation (used here) of a symplectic integrator of the
            Nose-Hoover chain thermostat is discussed in:

                Martyna, G. J.;  Tuckerman, M. E.;  Tobias, D. J.;  Klein,
                M. L. Mol. Phys. 1996, 87, 1117-1157.

            **Arguments:**

            temp
                The temperature of thermostat.

            **Optional arguments:**

            start
                The step at which the thermostat becomes active.

            timecon
                The time constant of the Nose-Hoover thermostat.

            chainlength
                The number of beads in the Nose-Hoover chain.

            chain_pos0
                The initial thermostat chain positions

            chain_vel0
                The initial thermostat chain velocities

            restart
                Indicates whether the initalisation should be carried out
        """
        self.temp = temp
        self.restart = restart
        # At this point, the timestep and the number of degrees of freedom are
        # not known yet
        self.chain = NHChain(chainlength, 0.0, temp, 0, chain_pos0, chain_vel0, timecon)
        VerletHook.__init__(self, start, 1)
Example #20
0
File: nvt.py Project: boegel/yaff
    def __init__(self, temp, start=0, timecon=100 * femtosecond):
        """
           This is an implementation of the Langevin thermostat. The algorithm
           is described in:

                Bussi, G.; Parrinello, M. Phys. Rev. E 2007, 75, 056707

           **Arguments:**

           temp
                The temperature of thermostat.

           **Optional arguments:**

           start
                The step at which the thermostat becomes active.

           timecon
                The time constant of the Langevin thermostat.
        """
        self.temp = temp
        self.timecon = timecon
        VerletHook.__init__(self, start, 1)
Example #21
0
    def __init__(self, temp, start=0, timecon=100*femtosecond):
        """
           This is an implementation of the Langevin thermostat. The algorithm
           is described in:

                Bussi, G.; Parrinello, M. Phys. Rev. E 2007, 75, 056707

           **Arguments:**

           temp
                The temperature of thermostat.

           **Optional arguments:**

           start
                The step at which the thermostat becomes active.

           timecon
                The time constant of the Langevin thermostat.
        """
        self.temp = temp
        self.timecon = timecon
        VerletHook.__init__(self, start, 1)
Example #22
0
File: npt.py Project: yfyh2013/yaff
    def __init__(self, ff, temp, press, start=0, step=1, timecon=1000*femtosecond, anisotropic=True, vol_constraint=False, baro_thermo=None, vel_press0=None, restart=False):
        """
            This hook implements the Martyna-Tobias-Klein barostat. The equations
            are derived in:

                Martyna, G. J.; Tobias, D. J.; Klein, M. L. J. Chem. Phys. 1994,
                101, 4177-4189.

            The implementation (used here) of a symplectic integrator of this
            barostat is discussed in

                Martyna, G. J.;  Tuckerman, M. E.;  Tobias, D. J.;  Klein,
                M. L. Mol. Phys. 1996, 87, 1117-1157.

            **Arguments:**

            ff
                A ForceField instance.

            temp
                The temperature of thermostat.

            press
                The applied pressure for the barostat.

            **Optional arguments:**

            start
                The step at which the barostat becomes active.

            timecon
                The time constant of the Martyna-Tobias-Klein barostat.

            anisotropic
                Defines whether anisotropic cell fluctuations are allowed.

            vol_constraint
                Defines whether the volume is allowed to fluctuate.

            baro_thermo
                NHCThermostat instance, coupled directly to the barostat

            vel_press0
                The initial barostat velocity tensor

            restart
                If true, the cell is not symmetrized initially
        """
        self.temp = temp
        self.press = press
        self.timecon_press = timecon
        self.anisotropic = anisotropic
        self.vol_constraint = vol_constraint
        self.baro_thermo = baro_thermo
        self.dim = ff.system.cell.nvec
        self.restart = restart
        # determine the number of degrees of freedom associated with the unit cell
        self.baro_ndof = get_ndof_baro(self.dim, self.anisotropic, self.vol_constraint)
        if self.anisotropic and not self.restart:
            # symmetrize the cell tensor
            cell_symmetrize(ff)
        self.cell = ff.system.cell.rvecs.copy()
        self.vel_press = vel_press0
        VerletHook.__init__(self, start, step)
Example #23
0
File: npt.py Project: yfyh2013/yaff
    def __init__(self, ff, temp, press, start=0, step=1, timecon=1000*femtosecond, anisotropic=True, vol_constraint=False, baro_thermo=None, vel_press0=None, restart=False):
        """
            This hook implements the Tadmor-Miller barostat for finite strains.
            The equations are derived in:

                Tadmor, E. B.; Miller, R. E. Modeling Materials: Continuum,
                Atomistic and Multiscale Techniques 2011, 520-527.

            **Arguments:**

            ff
                A ForceField instance.

            temp
                The temperature of thermostat.

            press
                The applied second Piola-Kirchhoff tensor for the barostat.

            **Optional arguments:**

            start
                The step at which the barostat becomes active.

            timecon
                The time constant of the Tadmor-Miller barostat.

            anisotropic
                Defines whether anisotropic cell fluctuations are allowed.

            vol_constraint
                Defines whether the volume is allowed to fluctuate.

            baro_thermo
                NHCThermostat instance, coupled directly to the barostat

            vel_press0
                The initial barostat velocity tensor

            restart
                If true, the cell is not symmetrized initially
        """
        self.temp = temp
        self.press = press
        self.timecon_press = timecon
        self.anisotropic = anisotropic
        self.vol_constraint = vol_constraint
        self.baro_thermo = baro_thermo
        self.dim = ff.system.cell.nvec
        self.restart = restart
        # determine the number of degrees of freedom associated with the unit cell
        self.baro_ndof = get_ndof_baro(self.dim, self.anisotropic, self.vol_constraint)
        if self.anisotropic and not self.restart:
            # symmetrize the cell tensor
            cell_symmetrize(ff)
        self.cell = ff.system.cell.rvecs.copy()
        self.cellinv0 = np.linalg.inv(self.cell)
        self.vol0 = ff.system.cell.volume
        # definition of h0^{-1} S h_0^{-T}
        self.Strans = np.dot(np.dot(self.cellinv0, self.press), self.cellinv0.T)
        self.vel_press = vel_press0
        VerletHook.__init__(self, start, step)
Example #24
0
File: npt.py Project: yfyh2013/yaff
    def __init__(self, ff, temp, press, start=0, step=1, timecon=1000*femtosecond, anisotropic=True, vol_constraint=False, baro_thermo=None, vel_press0=None, restart=False):
        """
            This hook implements the Parrinello-Rahman barostat for finite strains.
            The equations are derived in:

                Parrinello, M.; Rahman, A. J. Appl. Phys. 1981, 52, 7182-7190.

            **Arguments:**

            ff
                A ForceField instance.

            temp
                The temperature of thermostat.

            press
                The applied pressure for the barostat.

            **Optional arguments:**

            start
                The step at which the barostat becomes active.

            timecon
                The time constant of the Tadmor-Miller barostat.

            anisotropic
                Defines whether anisotropic cell fluctuations are allowed.

            vol_constraint
                Defines whether the volume is allowed to fluctuate.

            baro_thermo
                NHCThermostat instance, coupled directly to the barostat

            vel_press0
                The initial barostat velocity tensor

            restart
                If true, the cell is not symmetrized initially
        """

        self.temp = temp
        if isinstance(press, np.ndarray):
            self.press = press
        else:
            self.press = press*np.eye(3)
        self.timecon_press = timecon
        self.anisotropic = anisotropic
        self.vol_constraint = vol_constraint
        self.baro_thermo = baro_thermo
        self.dim = ff.system.cell.nvec
        self.restart = restart
        # determine the number of degrees of freedom associated with the unit cell
        self.baro_ndof = get_ndof_baro(self.dim, self.anisotropic, self.vol_constraint)
        if self.anisotropic and not self.restart:
            # symmetrize the cell and stress tensor
            vc, tn = cell_symmetrize(ff, tensor_list=[self.press])
            self.press = tn[0]
        self.P = np.trace(self.press)/3
        self.S_ani = self.press - self.P*np.eye(3)
        self.S_ani = 0.5*(self.S_ani + self.S_ani.T)    # only symmetric part of stress tensor contributes to individual motion
        self.cellinv0 = np.linalg.inv(ff.system.cell.rvecs.copy())
        self.vol0 = ff.system.cell.volume
        # definition of Sigma = V_0*h_0^{-1} S_ani h_0^{-T}
        self.Sigma = self.vol0*np.dot(np.dot(self.cellinv0.T, self.S_ani), self.cellinv0)
        self.vel_press = vel_press0
        VerletHook.__init__(self, start, step)
Example #25
0
    def __init__(self, ff, temp, press, start=0, step=1, timecon=1000*femtosecond, anisotropic=True, vol_constraint=False, baro_thermo=None, vel_press0=None, restart=False):
        """
            This hook implements the Tadmor-Miller barostat for finite strains.
            The equations are derived in:

                Tadmor, E. B.; Miller, R. E. Modeling Materials: Continuum,
                Atomistic and Multiscale Techniques 2011, 520-527.

            **Arguments:**

            ff
                A ForceField instance.

            temp
                The temperature of thermostat.

            press
                The applied second Piola-Kirchhoff tensor for the barostat.

            **Optional arguments:**

            start
                The step at which the barostat becomes active.

            timecon
                The time constant of the Tadmor-Miller barostat.

            anisotropic
                Defines whether anisotropic cell fluctuations are allowed.

            vol_constraint
                Defines whether the volume is allowed to fluctuate.

            baro_thermo
                NHCThermostat instance, coupled directly to the barostat

            vel_press0
                The initial barostat velocity tensor

            restart
                If true, the cell is not symmetrized initially
        """
        self.temp = temp
        self.press = press
        self.timecon_press = timecon
        self.anisotropic = anisotropic
        self.vol_constraint = vol_constraint
        self.baro_thermo = baro_thermo
        self.dim = ff.system.cell.nvec
        self.restart = restart
        # determine the number of degrees of freedom associated with the unit cell
        self.baro_ndof = get_ndof_baro(self.dim, self.anisotropic, self.vol_constraint)
        if self.anisotropic and not self.restart:
            # symmetrize the cell tensor
            cell_symmetrize(ff)
        self.cell = ff.system.cell.rvecs.copy()
        self.cellinv0 = np.linalg.inv(self.cell)
        self.vol0 = ff.system.cell.volume
        # definition of h0^{-1} S h_0^{-T}
        self.Strans = np.dot(np.dot(self.cellinv0, self.press), self.cellinv0.T)
        self.vel_press = vel_press0
        VerletHook.__init__(self, start, step)
Example #26
0
    def __init__(self, ff, temp, press, start=0, step=1, timecon=1000*femtosecond, anisotropic=True, vol_constraint=False, baro_thermo=None, vel_press0=None, restart=False):
        """
            This hook implements the Parrinello-Rahman barostat for finite strains.
            The equations are derived in:

                Parrinello, M.; Rahman, A. J. Appl. Phys. 1981, 52, 7182-7190.

            **Arguments:**

            ff
                A ForceField instance.

            temp
                The temperature of thermostat.

            press
                The applied pressure for the barostat.

            **Optional arguments:**

            start
                The step at which the barostat becomes active.

            timecon
                The time constant of the Tadmor-Miller barostat.

            anisotropic
                Defines whether anisotropic cell fluctuations are allowed.

            vol_constraint
                Defines whether the volume is allowed to fluctuate.

            baro_thermo
                NHCThermostat instance, coupled directly to the barostat

            vel_press0
                The initial barostat velocity tensor

            restart
                If true, the cell is not symmetrized initially
        """

        self.temp = temp
        if isinstance(press, np.ndarray):
            self.press = press
        else:
            self.press = press*np.eye(3)
        self.timecon_press = timecon
        self.anisotropic = anisotropic
        self.vol_constraint = vol_constraint
        self.baro_thermo = baro_thermo
        self.dim = ff.system.cell.nvec
        self.restart = restart
        # determine the number of degrees of freedom associated with the unit cell
        self.baro_ndof = get_ndof_baro(self.dim, self.anisotropic, self.vol_constraint)
        if self.anisotropic and not self.restart:
            # symmetrize the cell and stress tensor
            vc, tn = cell_symmetrize(ff, tensor_list=[self.press])
            self.press = tn[0]
        self.P = np.trace(self.press)/3
        self.S_ani = self.press - self.P*np.eye(3)
        self.S_ani = 0.5*(self.S_ani + self.S_ani.T)    # only symmetric part of stress tensor contributes to individual motion
        self.cellinv0 = np.linalg.inv(ff.system.cell.rvecs.copy())
        self.vol0 = ff.system.cell.volume
        # definition of Sigma = V_0*h_0^{-1} S_ani h_0^{-T}
        self.Sigma = self.vol0*np.dot(np.dot(self.cellinv0.T, self.S_ani), self.cellinv0)
        self.vel_press = vel_press0
        VerletHook.__init__(self, start, step)
Example #27
0
    def __init__(self, ff, temp, press, start=0, step=1, timecon=1000*femtosecond, anisotropic=True, vol_constraint=False, baro_thermo=None, vel_press0=None, restart=False):
        """
            This hook implements the Martyna-Tobias-Klein barostat. The equations
            are derived in:

                Martyna, G. J.; Tobias, D. J.; Klein, M. L. J. Chem. Phys. 1994,
                101, 4177-4189.

            The implementation (used here) of a symplectic integrator of this
            barostat is discussed in

                Martyna, G. J.;  Tuckerman, M. E.;  Tobias, D. J.;  Klein,
                M. L. Mol. Phys. 1996, 87, 1117-1157.

            **Arguments:**

            ff
                A ForceField instance.

            temp
                The temperature of thermostat.

            press
                The applied pressure for the barostat.

            **Optional arguments:**

            start
                The step at which the barostat becomes active.

            timecon
                The time constant of the Martyna-Tobias-Klein barostat.

            anisotropic
                Defines whether anisotropic cell fluctuations are allowed.

            vol_constraint
                Defines whether the volume is allowed to fluctuate.

            baro_thermo
                NHCThermostat instance, coupled directly to the barostat

            vel_press0
                The initial barostat velocity tensor

            restart
                If true, the cell is not symmetrized initially
        """
        self.temp = temp
        self.press = press
        self.timecon_press = timecon
        self.anisotropic = anisotropic
        self.vol_constraint = vol_constraint
        self.baro_thermo = baro_thermo
        self.dim = ff.system.cell.nvec
        self.restart = restart
        # determine the number of degrees of freedom associated with the unit cell
        self.baro_ndof = get_ndof_baro(self.dim, self.anisotropic, self.vol_constraint)
        if self.anisotropic and not self.restart:
            # symmetrize the cell tensor
            cell_symmetrize(ff)
        self.cell = ff.system.cell.rvecs.copy()
        self.vel_press = vel_press0
        VerletHook.__init__(self, start, step)