**********************
Classical MD with NAMD
**********************

Classical MD can be performed with `NAMD <https://www.ks.uiuc.edu/Research/namd/>`_ via
an :py:obj:`MD` object, as used in the :ref:`Solvation <solvation>` workflow. The following
options are for generic MD settings. For NAMD specific options see :py:obj:`NAMD`.

General options
===============

.. py:attribute:: boundary

   Periodic boundary conditions (PBCs). Allowed values are:

   * ``'periodic'`` (default): With PBCs

   * ``'sphere'``, ``'spherical'``, or ``'droplet'``: Non-periodic without PBCs

.. py:attribute:: chk

   (default: ``''``) Check filename to write out

.. py:attribute:: dcd

   (default: ``''``) DCD filename to write out

.. py:attribute:: driver

   (default: ``'dl_poly'``) We currently only support ``driver='namd'`` for classical MD simulations on biomolecular systems

.. py:attribute:: ensemble

   (default: ``'NPT'``) Ensemble of simulation. No ensemble is applied :py:attr:`periodic` is ``'sphere'``, ``'spherical'``, or ``'droplet'``

.. py:attribute:: ff
   :noindex:

   (default: ``'charmm'``) Name of forcefield scheme. We currently only support the `CHARMM-type forcefield <http://mackerell.umaryland.edu/charmm_ff.shtml>`__ (not to be confused with the `CHARMM program <https://www.charmm.org/>`__). See :ref:`INSTALL <install_charmm_ff>` for installing the CHARMM forcefield data

.. py:attribute:: fix

   (default: ``[]``) List of indices of atoms to fix during an MD simulation. In practice, such a list is typically obtained by :py:func:`Fragment.select`

.. py:attribute:: freq_chk

   (default: ``-1``) Frequency of writing out checkpoint files. If undefined the number will be determined by ChemShell as ceil(:py:attr:`nsteps`/100) when :py:attr:`nsteps` is greater than 100 or ``1`` otherwise

.. py:attribute:: freq_dcd

   (default: ``-1``) Frequency of writing out DCD files. If undefined the number will be determined by ChemShell as ceil(:py:attr:`nsteps`/100) when :py:attr:`nsteps` is greater than 100 or ``1`` otherwise

.. py:attribute:: freq_xst

   (default: ``-1``) Frequency of writing out :py:attr:`XST <xst>` files. If undefined the number will be determined by ChemShell as ceil(:py:attr:`nsteps`/100) when :py:attr:`nsteps` is greater than 100 or ``1`` otherwise

.. py:attribute:: freq_out_energy

   (default: ``-1``) Frequency of writing out energies. If undefined the number will be determined by ChemShell as ceil(:py:attr:`nsteps`/100) when :py:attr:`nsteps` is greater than 100 or ``1`` otherwise

.. py:attribute:: freq_out_pressure

   (default: ``-1``) Frequency of writing out pressures. If undefined the number will be determined by ChemShell as ceil(:py:attr:`nsteps`/100) when :py:attr:`nsteps` is greater than 100 or ``1`` otherwise

.. py:attribute:: langevin

   (default: ``True``) Perform Langevin dynamics

.. py:attribute:: langevin_temperature

   (default: ``None``) Temperature of Langevin dynamics

.. py:attribute:: langevin_damping

   (default: ``1`` ps\ :sup:`-1`) Damping coefficient for Langevin dynamics

.. py:attribute:: langevin_H

   (default: ``False``) Apply Langevin dynamics to hydrogen atoms

.. py:attribute:: langevin_piston

   (default: ``False``) Use the Langevin piston pressure control method

.. py:attribute:: langevin_piston_target

   (default: ``1.01325`` bar) Target pressure of the Langevin piston method
.. py:attribute:: langevin_piston_period

   (default: ``100.0`` femtoseconds) Barostat oscillation time scale for the Langevin piston

.. py:attribute:: langevin_piston_decay

   (default: ``50.0`` femtoseconds) Barostat damping time scale for the Langevin piston

.. py:attribute:: langevin_piston_temp

   (default: ``293.15`` Kelvin) Barostat noise temperature for the Langevin piston

.. py:attribute:: minimise

   (default: ``100``) Number of energy minimisation steps to take, typically before an MD simulations starts

.. py:attribute:: nsnapshots

   (default: ``10``) Number of snapshots to take after a simulation is successfully run. They will be taken only from the second half out of a trajectory to use equilibrated data as much as possible. There is also an independent tool for taking snapshots from an existing DCD trajectory: :py:meth:`tools.takeSnapshots`

.. py:attribute:: nsteps

   (default: ``100``) Number of MD steps to simulate

.. py:attribute:: pbc_wrap

   (default: ``[]``) List of atom indices to perform PBC wrapping

.. py:attribute:: rigid

   Use the rigid bond model by making hydrogen---connected--atom constrained. Accepted values are:

   * ``'all'`` (default) Constrain all hydrogen---connected--atom bonds to the positions defined by the forcefield parameters. Also Constrain all hydrogen---oxygen---hydrogen angles in water molecules

   * ``'water'`` Constrain only hydrogen---oxygen bonds and hydrogen---oxygen---hydrogen angles of water molecules to the positions defined by the forcefield parameters

   * ``'none'`` No rigid bond constraint

.. py:attribute:: seed

   (default: ``2020``) Seed number for generating random numbers

.. py:attribute:: spheric_r0

   (default: ``-1.0`` Bohr) Spherical radius *r*\ :sub:`SBC` in Bohr for non-periodic simulations with spherical boundary conditions (SBCs). The default value ``-1.0`` means that ChemShell will determine it by calculating the system's stretching radius. When defined, it must be a positive decimal number. 

.. py:attribute:: spheric_k

   (default: ``10.0``) Force constant *k*\ :sub:`SBC` for the SBCs harmonic potential. The potential is calculated as *P*\ :sub:`SBC` = *k*\ :sub:`SBC`\ (||\ *r*\ :sub:`i` - *r*\ :sub:`centre`\ || - *r*\ :sub:`SBC`)\ \*\*\ *exp*\ :sub:`SBC`

.. py:attribute:: spheric_exponent

   (default: ``2``) Exponent *exp*\ :sub:`SBC` for the SBCs harmonic potential. A typical value is ``2`` or ``4``

.. py:attribute:: temperature

   (default: ``293.15`` Kelvin) Temperature of simulation

.. py:attribute:: theory
   :noindex:

   (default: ``None``) `Theory <theory>` object for evaluating the energies and gradients

.. py:attribute:: timestep

   (default: ``1.0`` femtosecond) Timestep of MD simulation


