Skip to content

Commit

Permalink
Merge branch 'main' into xtb
Browse files Browse the repository at this point in the history
  • Loading branch information
ceriottm authored Oct 9, 2024
2 parents 24855a4 + e6e4a50 commit 0bbd1b9
Show file tree
Hide file tree
Showing 12 changed files with 222 additions and 186 deletions.
34 changes: 17 additions & 17 deletions docs/src/features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ falls back to a safe baseline potential when the ML models fail.
| G. Imbalzano, Y. Zhuang, V. Kapil, K. Rossi, E. A. Engel, F.
Grasselli, and M. Ceriotti, *“Uncertainty estimation for molecular
dynamics and sampling”*, J. Chem. Phys. 154(7), 074102 (2021)
| DOI: `10.1063/5.0036522 <dx.doi.org/10.1063/5.0036522>`__ — BibTeX:
| DOI: `10.1063/5.0036522 <http://dx.doi.org/10.1063/5.0036522>`__ — BibTeX:
`fetch <http://www.doi2bib.org/#/doi/10.1063/5.0036522>`__
| F. Musil, M. J. Willatt, M. A. Langovoy, and M. Ceriotti, *“Fast and
Accurate Uncertainty Estimation in Chemical Machine Learning”*,
Journal of Chemical Theory and Computation 15(2), 906–915 (2019)
| DOI:
`10.1021/acs.jctc.8b00959 <dx.doi.org/10.1021/acs.jctc.8b00959>`__ —
`10.1021/acs.jctc.8b00959 <http://dx.doi.org/10.1021/acs.jctc.8b00959>`__ —
BibTeX:
`fetch <http://www.doi2bib.org/#/doi/10.1021/acs.jctc.8b00959>`__
Expand Down Expand Up @@ -132,7 +132,7 @@ direction.
| **Implementation and Theory:**
| M. Hijazi, D. M. Wilkins, *“Fast-forward Langevin dynamics with
momentum flips”*, J. Chem. Phys. 148, 184109 (2018)
| DOI: `10.1063/1.5029833 <dx.doi.org/10.1063/1.5029833>`__ — BibTeX:
| DOI: `10.1063/1.5029833 <http://dx.doi.org/10.1063/1.5029833>`__ — BibTeX:
`fetch <https://www.doi2bib.org/bib/10.1063%2F1.5029833>`__

Expand Down Expand Up @@ -183,7 +183,7 @@ the harmonic Hessian.
Fluctuations in Molecular Crystals: A First-Principles Study of the
Stability of Paracetamol”*, Phs. Rev. Lett. 117, 115702 (2016)
| DOI:
`10.1103/PhysRevLett.117.115702 <dx.doi.org/10.1103/PhysRevLett.117.115702>`__
`10.1103/PhysRevLett.117.115702 <http://dx.doi.org/10.1103/PhysRevLett.117.115702>`__
— BibTeX:
`fetch <http://www.doi2bib.org/#/doi/10.1103/PhysRevLett.117.115702>`__
Expand All @@ -204,7 +204,7 @@ other masses.
| Michele Ceriotti, Thomas E. Markland, “Efficient methods and practical
guidelines for simulating isotope effects.” The Journal of chemical
physics 138(1), 014112 (2013).
| DOI: `10.1063/1.4772676 <dx.doi.org/10.1063/1.4772676>`__ — BibTeX:
| DOI: `10.1063/1.4772676 <http://dx.doi.org/10.1063/1.4772676>`__ — BibTeX:
`fetch <http://www.doi2bib.org/#/doi/10.1063/1.4772676>`__
Generalized Langevin Equation Thermostats
Expand Down Expand Up @@ -296,21 +296,21 @@ adjust the amount of compensation automatically.
Accurate Car-Parrinello-like Approach to Born-Oppenheimer Molecular
Dynamics”*, Phys. Rev. Lett. 98, 066401 (2007)
| DOI:
`10.1103/PhysRevLett.98.066401 <dx.doi.org/10.1103/PhysRevLett.98.066401>`__
`10.1103/PhysRevLett.98.066401 <http://dx.doi.org/10.1103/PhysRevLett.98.066401>`__
— BibTeX:
`fetch <http://www.doi2bib.org/bib/10.1103%2FPhysRevLett.98.066401>`__
| F. R. Krajewski, M. Parrinello, *“Linear scaling electronic structure
calculations and accurate statistical mechanics sampling with noisy
forces”*, Phys. Rev. B 73, 041105 (2006)
| DOI:
`10.1103/PhysRevB.73.041105 <dx.doi.org/10.1103/PhysRevB.73.041105>`__
`10.1103/PhysRevB.73.041105 <http://dx.doi.org/10.1103/PhysRevB.73.041105>`__
— BibTeX:
`fetch <http://www.doi2bib.org/bib/10.1103%2FPhysRevB.73.041105>`__
| Y. Luo, A. Zen, S. Sorella, *“Ab initio molecular dynamics with noisy
forces: Validating the quantum Monte Carlo approach with benchmark
calculations of molecular vibrational properties”*, J. Chem. Phys.
141, 194112 (2014)
| DOI: `10.1063/1.4901430 <dx.doi.org/10.1063/1.4901430>`__ — BibTeX:
| DOI: `10.1063/1.4901430 <http://dx.doi.org/10.1063/1.4901430>`__ — BibTeX:
`fetch <http://www.doi2bib.org/bib/10.1063%2F1.4901430>`__
Multiple Time Step integrators
Expand Down Expand Up @@ -350,7 +350,7 @@ fluctuations of nuclei.
Momentum Distribution in Water”*, J. Phys. Chem. B 122, 6048-6054
(2018)
| DOI:
`10.1021/acs.jpcb.8b03896 <dx.doi.org/10.1021/acs.jpcb.8b03896>`__ —
`10.1021/acs.jpcb.8b03896 <http://dx.doi.org/10.1021/acs.jpcb.8b03896>`__ —
BibTeX:
`fetch <http://www.doi2bib.org/#/doi/10.1021/acs.jpcb.8b03896>`__
| **Theory:**
Expand Down Expand Up @@ -493,20 +493,20 @@ of configurations between parallel calculations.
Ceriotti, C. Corminboeuf, *“Beyond static structures: Putting forth
remd as a tool to solve problems in computational organic chemistry”*,
J. Comput. Chem. 37(1), 83-92 (2016)
| DOI: `10.1002/jcc.24025 <dx.doi.org/10.1002/jcc.24025>`__ — BibTeX:
| DOI: `10.1002/jcc.24025 <http://dx.doi.org/10.1002/jcc.24025>`__ — BibTeX:
`fetch <http://www.doi2bib.org/#/doi/10.1002/jcc.24025>`__
| **Theory:**
| Y. Sugita, Y. Okamoto, *“Replica-exchange molecular dynamics method
for protein folding”*, Chem. Phys. Lett. 314(1-2), 141–151 (1999)
| DOI:
`10.1016/s0009-2614(99)01123-9 <dx.doi.org/10.1016/s0009-2614(99)01123-9>`__
`10.1016/s0009-2614(99)01123-9 <http://dx.doi.org/10.1016/s0009-2614(99)01123-9>`__
— BibTeX:
`fetch <http://www.doi2bib.org/#/doi/10.1016/s0009-2614(99)01123-9>`__
| T. Okabe, M. Kawata, Y. Okamoto, M. Mikami, *“Replica-exchange monte
carlo method for the isobaric–isothermal ensemble”*, Chem. Phys. Lett.
335(5-6), 435-439 (2001)
| DOI: `10.1016/
s0009-2614(01)00055-0 <dx.doi.org/10.1016/s0009-2614(01)00055-0>`__ —
s0009-2614(01)00055-0 <http://dx.doi.org/10.1016/s0009-2614(01)00055-0>`__ —
BibTeX:
`fetch <http://www.doi2bib.org/#/doi/10.1016/s0009-2614(01)00055-0>`__
Expand All @@ -522,7 +522,7 @@ species into its isotopes.
Effects in Water at the Triple Point: Using Theory as a Link Between
Experiments.”* J. Phys. Chem. Lett. 7(12), 2210-2215 (2016)
| DOI:
`10.1021/acs.jpclett.6b00729 <dx.doi.org/10.1021/acs.jpclett.6b00729>`__
`10.1021/acs.jpclett.6b00729 <http://dx.doi.org/10.1021/acs.jpclett.6b00729>`__
— BibTeX:
`fetch <http://www.doi2bib.org/bib/10.1021%2Facs.jpclett.6b00729>`__
| **Theory:**
Expand Down Expand Up @@ -624,13 +624,13 @@ coordinate.
| W. H. Miller, *Semiclassical limit of quantum mechanical transition
state theory for nonseparable systems*, J. Chem. Phys. 62(5) 1899–1906
(1975)
| DOI: `10.1063/1.430676 <dx.doi.org/10.1063/1.430676>`__ — BibTeX:
`fetch <doi2bib.org/#/doi/10.1063/1.430676>`__
| DOI: `10.1063/1.430676 <http://dx.doi.org/10.1063/1.430676>`__ — BibTeX:
`fetch <http://doi2bib.org/#/doi/10.1063/1.430676>`__
| J. O. Richardson, *Ring-polymer instanton theory*, Int. Rev. Phys.
Chem. 37, 171 (2018)
| DOI:
`10.1080/0144235X.2018.1472353 <doi.org/10.1080/0144235X.2018.1472353>`__
— BibTeX: `fetch <doi2bib.org/#/doi/10.1080/0144235X.2018.1472353>`__
`10.1080/0144235X.2018.1472353 <http://doi.org/10.1080/0144235X.2018.1472353>`__
— BibTeX: `fetch <http://doi2bib.org/#/doi/10.1080/0144235X.2018.1472353>`__
Thermodynamic Integrations
--------------------------
Expand Down
3 changes: 2 additions & 1 deletion docs/src/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ modification is necessary:
&END MOTION
The rest of the input file should be the same as for a standard CP2K
calculation, as explained at `www.cp2k.org/ <www.cp2k.org/>`__.
calculation, as explained at it the documentation of
`CP2K <http://www.cp2k.org/>`__.

Quantum-Espresso
^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion docs/src/input-files.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ To help detect any user error the recognized tag names, data types and
acceptable options are all specified in the code in a specialized input
class for each class of object. A full list of all the available tags
and a brief description of their function is given at
`input tags <input-tags.rst>`_.
`input tags <input-tags.html>`_.

.. _inputunits:

Expand Down
16 changes: 10 additions & 6 deletions docs/src/onlinereso.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@ In http://gle4md.org/ one can also obtain colored-noise parameters to
run Path Integral with Generalized Langevin Equation thermostat
(PI+GLE/PIGLET) calculations.

Several examples of usage of i-PI to perform advanced molecular simulations
can be found among the recipes of the
`atomistic cookbook <https://atomistic-cookbook.org/>`_.

Python resources
~~~~~~~~~~~~~~~~

For help with Python programming, see
`www.python.org <www.python.org>`__. For information about the NumPy
mathematical library, see `www.numpy.org <www.numpy.org>`__, and for
`www.python.org <http://www.python.org>`__. For information about the NumPy
mathematical library, see `www.numpy.org <http://www.numpy.org>`__, and for
worked examples of its capabilities see
`www.scipy.org/Tentative_NumPy_Tutorial <www.scipy.org/Tentative_NumPy_Tutorial>`__.
`www.scipy.org/Tentative_NumPy_Tutorial <http://www.scipy.org/Tentative_NumPy_Tutorial>`__.
Finally, see http://hgomersall.github.io/pyFFTW/ for documentation on
the Python FFTW library that is currently implemented with i-PI.

Expand All @@ -47,9 +51,9 @@ touch, we are always glad to help!

There are several Fortran and C libraries that most client codes will
probably need to run, such as FFTW, BLAS and LAPACK. These can be found
at `www.fftw.org <www.fftw.org>`__,
`www.netlib.org/blas <www.netlib.org/blas>`__ and
`www.netlib.org/lapack <www.netlib.org/lapack>`__ respectively.
at `www.fftw.org <http://www.fftw.org>`__,
`www.netlib.org/blas <http://www.netlib.org/blas>`__ and
`www.netlib.org/lapack <http://www.netlib.org/lapack>`__ respectively.

These codes do not come as part of the i-PI package, and must be
downloaded separately.
Expand Down
4 changes: 2 additions & 2 deletions docs/src/units.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ details on how to do this, see :ref:`inputunits` and
Unit Name S.I. Value
=========== ============= ================
Length Bohr radius 5.2917721e-11 m
Time N.A. 2.4188843e-17 s
Time Atomic units 2.4188843e-17 s
Mass Electron mass 9.1093819e-31 kg
Temperature Hartree 315774.66 K
Energy Hartree 4.3597438e-18 J
Pressure N.A. 2.9421912e13 Pa
Pressure Atomic units 2.9421912e13 Pa
=========== ============= ================

Regarding the specification of these units in the i-PI input files, the
Expand Down
1 change: 1 addition & 0 deletions drivers/f90/LJPolymer.f90
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ SUBROUTINE Har_fij(stiffness, x0, rij, r, pot, fij)
fij = f_tot*rij/r

END SUBROUTINE

SUBROUTINE LJ_functions(sigma, eps, r, pot, force)
! Calculates the magnitude of the LJ force and potential between
! a pair of atoms at a given distance from each other.
Expand Down
2 changes: 2 additions & 0 deletions ipi/engine/smotion/dmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def __init__(self, dmdff=""):
super(DMD, self).__init__()
self.dmdff = dmdff

self.mode = "dmd"

def step(self, step=None):
"""Updates driven md time step."""

Expand Down
2 changes: 2 additions & 0 deletions ipi/engine/smotion/metad.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def __init__(self, metaff="", use_energy=False):
self.metaff = metaff
self.use_energy = use_energy

self.mode = "metad"

def bind(self, syslist, prng, omaker):
super(MetaDyn, self).bind(syslist, prng, omaker)

Expand Down
2 changes: 1 addition & 1 deletion ipi/utils/instools.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def get_imvector(h, m3):
verbosity.low,
)

imv = w[:, 0] * (m3[:] ** 0.5)
imv = w[:, 0] / (m3[:] ** 0.5)
imv = imv / np.linalg.norm(imv)

return imv.reshape(1, imv.size)
Expand Down
3 changes: 3 additions & 0 deletions ipi/utils/tools/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .acf_xyz import compute_acf_xyz

__all__ = ["compute_acf_xyz"]
158 changes: 158 additions & 0 deletions ipi/utils/tools/acf_xyz.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
import numpy as np
from ipi.utils.io import read_file_raw
from ipi.utils.units import unit_to_internal


def compute_acf_xyz(
input_file,
maximum_lag,
block_length=None,
length_zeropadding=0,
spectral_windowing="none",
labels=["*"],
atom_mask=None,
timestep=1.0,
time_units="atomic_unit",
skip=0,
compute_derivative=False,
):
"""
Helper functions to compute autocorrelation functions (and their transform)
from an xyz-formatted input (so these are "vectorial" ACFs summed over all
atoms and Cartesian coordinates).
:param input_file: name of the file holding the xyz-formatted trajectory
:param maximum_lag: maximum lag time to compute ACF for
:param block_length: length of trajectory blocks used for averaging
:param length_zeropadding: pad with these many zeros to increase resolution
:param spectral_windowing: window function to smoothen FT
:param labels: list of (space separated) atom labels to include, "*" for all
:param atom_mask: None, or a list of 0 and 1 to act as masks for selecting atoms
:param timestep: the time step between two frames
:param time_units: string providing the units of time given
:param skip: how many frames to skip before starting accumulating ACF
:param compute_derivative: bool (default false) whether to compute derivative ACF
"""
# stores the arguments
ifile = input_file
mlag = maximum_lag or 100
bsize = block_length or (2 * mlag + 1)
npad = length_zeropadding
ftbox = spectral_windowing
fskip = skip
der = compute_derivative

# checks for errors
if mlag <= 0:
raise ValueError("MAXIMUM_LAG should be a non-negative integer.")
if npad < 0:
raise ValueError("LENGTH_ZEROPADDING should be a non-negative integer.")
if bsize < 2 * mlag:
if bsize == -1:
bsize = 2 * mlag
else:
raise ValueError(
"LENGTH_BLOCK should be greater than or equal to 2 * MAXIMUM_LAG."
)

# reads one frame.
ff = open(ifile)
rr = read_file_raw("xyz", ff)
ff.close()

# stores the indices of the "chosen" atoms.
ndof = len(rr["data"])
if atom_mask is None:
if "*" in labels:
labelbool = np.ones(ndof // 3, bool)
else:
labelbool = np.zeros(ndof // 3, bool)
for l in labels:
labelbool = np.logical_or(labelbool, rr["names"] == l)
else:
labelbool = atom_mask
nspecies = labelbool.sum()

# initializes variables.
nblocks = 0
dt = unit_to_internal("time", time_units, timestep)
data = np.zeros((bsize, nspecies, 3), float)
time = np.asarray(list(range(mlag + 1))) * dt
omega = (
np.asarray(list(range(2 * (mlag + npad))))
/ float(2 * (mlag + npad))
* (2 * np.pi / dt)
)
fvvacf = np.zeros_like(omega)
fvvacf2 = np.zeros_like(omega)
vvacf = np.zeros_like(time)
vvacf2 = np.zeros_like(time)

# selects window function for fft.
if ftbox == "none":
win = np.ones(2 * mlag + 1, float)
elif ftbox == "cosine-hanning":
win = np.hanning(2 * mlag + 1)
elif ftbox == "cosine-hamming":
win = np.hamming(2 * mlag + 1)
elif ftbox == "cosine-blackman":
win = np.blackman(2 * mlag + 1)
elif ftbox == "triangle-bartlett":
win = np.bartlett(2 * mlag + 1)

ff = open(ifile)
# Skips the first fskip frames
for x in range(fskip):
rr = read_file_raw("xyz", ff)

while True:
try:
# Reads the data in blocks.
for i in range(bsize):
rr = read_file_raw("xyz", ff)
data[i] = rr["data"].reshape((ndof // 3, 3))[labelbool]

if der is True:
data = np.gradient(data, axis=0) / dt

# Computes the Fourier transform of the data.
fdata = np.fft.rfft(data, axis=0)

# Computes the Fourier transform of the vvac applying the convolution theorem.
tfvvacf = fdata * np.conjugate(fdata)

# Averages over all species and sums over the x,y,z directions. Also multiplies with the time step and a prefactor of (2pi)^-1.
mfvvacf = (
3.0 * np.real(np.mean(tfvvacf, axis=(1, 2))) * dt / (2 * np.pi) / bsize
)

# Computes the inverse Fourier transform to get the vvac.
mvvacf = np.fft.irfft(mfvvacf)[: mlag + 1]

# Applies window in one direction and pads the vvac with zeroes.
mpvvacf = np.append(mvvacf * win[mlag:], np.zeros(npad))

# Recomputes the Fourier transform assuming the data is an even function of time.
mfpvvacf = np.fft.hfft(mpvvacf)

# Accumulates the (f)acfs and their squares.
fvvacf += mfpvvacf
fvvacf2 += mfpvvacf**2
vvacf += mvvacf
vvacf2 += mvvacf**2

nblocks += 1

except EOFError:
break
ff.close()

# Performs the block average of the Fourier transform.
fvvacf = fvvacf / nblocks
fvvacf_err = np.sqrt(fvvacf2 / nblocks - fvvacf**2)

# Computes the inverse Fourier transform to get the vvac.
vvacf = vvacf / nblocks
vvacf_err = np.sqrt(vvacf2 / nblocks - vvacf**2)

return time, vvacf, vvacf_err, omega, fvvacf, fvvacf_err
Loading

0 comments on commit 0bbd1b9

Please sign in to comment.