diff --git a/cmake/Modules/Packages/USER-PLUMED.cmake b/cmake/Modules/Packages/USER-PLUMED.cmake index 74add65cdc..53abf5771a 100644 --- a/cmake/Modules/Packages/USER-PLUMED.cmake +++ b/cmake/Modules/Packages/USER-PLUMED.cmake @@ -55,8 +55,8 @@ if(DOWNLOAD_PLUMED) endif() include(ExternalProject) ExternalProject_Add(plumed_build - URL https://github.com/plumed/plumed2/releases/download/v2.6.1/plumed-src-2.6.1.tgz - URL_MD5 89a9a450fc6025299fe16af235957163 + URL https://github.com/plumed/plumed2/releases/download/v2.7.0/plumed-src-2.7.0.tgz + URL_MD5 95f29dd0c067577f11972ff90dfc7d12 BUILD_IN_SOURCE 1 CONFIGURE_COMMAND /configure --prefix= ${CONFIGURE_REQUEST_PIC} diff --git a/doc/lammps.1 b/doc/lammps.1 index 5fc4795ba7..299f8538b0 100644 --- a/doc/lammps.1 +++ b/doc/lammps.1 @@ -1,4 +1,4 @@ -.TH LAMMPS "30 November 2020" "2020-10-29" +.TH LAMMPS "24 December 2020" "2020-12-24" .SH NAME .B LAMMPS \- Molecular Dynamics Simulator. diff --git a/doc/src/Build_extras.rst b/doc/src/Build_extras.rst index 6847b8c030..4dd17d71f8 100644 --- a/doc/src/Build_extras.rst +++ b/doc/src/Build_extras.rst @@ -352,7 +352,7 @@ KIM Extra unit tests (CMake only) During development, testing, or debugging, if :doc:`unit testing ` is enabled in LAMMPS, one can also enable extra tests on :doc:`KIM commands ` by setting the -``KIM_EXTRA_UNITTESTS`` to *yes* (or *on*). +``KIM_EXTRA_UNITTESTS`` to *yes* (or *on*). Enabling the extra unit tests have some requirements, @@ -367,9 +367,9 @@ Enabling the extra unit tests have some requirements, *conda-forge* channel as ``conda install kim-property`` if LAMMPS is built in Conda. More detailed information is available at: `kim-property installation `_. -* It is also necessary to install - ``EAM_Dynamo_Mendelev_2007_Zr__MO_848899341753_000``, and - ``EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005`` KIM models. +* It is also necessary to install + ``EAM_Dynamo_Mendelev_2007_Zr__MO_848899341753_000``, and + ``EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005`` KIM models. See `Obtaining KIM Models `_ to learn how to install a pre-build binary of the OpenKIM Repository of Models or see diff --git a/doc/src/Commands_fix.rst b/doc/src/Commands_fix.rst index d1bc20c9ca..26dcc1101c 100644 --- a/doc/src/Commands_fix.rst +++ b/doc/src/Commands_fix.rst @@ -221,6 +221,8 @@ OPT. * :doc:`temp/rescale ` * :doc:`temp/rescale/eff ` * :doc:`tfmc ` + * :doc:`tgnpt/drude ` + * :doc:`tgnvt/drude ` * :doc:`thermal/conductivity ` * :doc:`ti/spring ` * :doc:`tmd ` diff --git a/doc/src/Developer.rst b/doc/src/Developer.rst index a895369a28..3a0c03b7ea 100644 --- a/doc/src/Developer.rst +++ b/doc/src/Developer.rst @@ -13,6 +13,7 @@ of time and requests from the LAMMPS user community. Developer_org Developer_flow Developer_write + Developer_notes Developer_unittest Classes Developer_utils diff --git a/doc/src/Developer_notes.rst b/doc/src/Developer_notes.rst new file mode 100644 index 0000000000..87ef97ea7b --- /dev/null +++ b/doc/src/Developer_notes.rst @@ -0,0 +1,105 @@ +Notes for Developers and Code Maintainers +----------------------------------------- + +This section documents how a few large sections of code with LAMMPS +work at a conceptual level. Comments on code in source files +typically document what a variable stores, what a small section of +code does, or what a function does or its input/outputs. The topics +on this page are intended to document code at a higher level. + +KSpace PPPM FFT grids +^^^^^^^^^^^^^^^^^^^^^ + +The various :doc:`KSpace PPPM ` styles in LAMMPS use +FFTs to solve Poisson's equation. This subsection describes: + +* how FFT grids are defined +* how they are decomposed across processors +* how they are indexed by each processor +* how particle charge and electric field values are mapped to/from + the grid + +An FFT grid cell is a 3d volume; grid points are corners of a grid +cell and the code stores values assigned to grid points in vectors or +3d arrays. A global 3d FFT grid has points indexed 0 to N-1 inclusive +in each dimension. + +Each processor owns two subsets of the grid, each subset is +brick-shaped. Depending on how it is used, these subsets are +allocated as a 1d vector or 3d array. Either way, the ordering of +values within contiguous memory x fastest, then y, z slowest. + +For the ``3d decomposition`` of the grid, the global grid is +partitioned into bricks that correspond to the sub-domains of the +simulation box that each processor owns. Often, this is a regular 3d +array (Px by Py by Pz) of bricks, where P = number of processors = +Px * Py * Pz. More generally it can be a tiled decomposition, where +each processor owns a brick and the union of all the bricks is the +global grid. Tiled decompositions are produced by load balancing with +the RCB algorithm; see the :doc:`balance rcb ` command. + +For the ``FFT decompostion`` of the grid, each processor owns a brick +that spans the entire x dimension of the grid while the y and z +dimensions are partitioned as a regular 2d array (P1 by P2), where P = +P1 * P2. + +The following indices store the inclusive bounds of the brick a +processor owns, within the global grid: + +.. parsed-literal:: + + nxlo_in,nxhi_in,nylo_in,nyhi_in,nzlo_in,nzhi_in = 3d decomposition brick + nxlo_fft,nxhi_fft,nylo_fft,nyhi_fft,nzlo_fft,nzhi_fft = FFT decomposition brick + nxlo_out,nxhi_out,nylo_out,nyhi_out,nzlo_out,nzhi_out = 3d decomposition brick + ghost cells + +The ``in`` and ``fft`` indices are from 0 to N-1 inclusive in each +dimension, where N is the grid size. + +The ``out`` indices index an array which stores the ``in`` subset of +the grid plus ghost cells that surround it. These indices can thus be +< 0 or >= N. + +The number of ghost cells a processor owns in each of the 6 directions +is a function of: + +.. parsed-literal:: + + neighbor skin distance (since atoms can move outside a proc subdomain) + qdist = offset or charge from atom due to TIP4P fictitious charge + order = mapping stencil size + shift = factor used when order is an even number (see below) + +Here is an explanation of how the PPPM variables ``order``, +``nlower`` / ``nupper``, ``shift``, and ``OFFSET`` work. They are the +relevant variables that determine how atom charge is mapped to grid +points and how field values are mapped from grid points to atoms: + +.. parsed-literal:: + + order = # of nearby grid points in each dim that atom charge/field are mapped to/from + nlower,nupper = extent of stencil around the grid point an atom is assigned to + OFFSET = large integer added/subtracted when mapping to avoid int(-0.75) = 0 when -1 is the desired result + +The particle_map() method assigns each atom to a grid point. + +If order is even, say 4: + +.. parsed-literal:: + + atom is assigned to grid point to its left (in each dim) + shift = OFFSET + nlower = -1, nupper = 2, which are offsets from assigned grid point + window of mapping grid pts is thus 2 grid points to left of atom, 2 to right + +If order is odd, say 5: + +.. parsed-literal:: + + atom is assigned to left/right grid pt it is closest to (in each dim) + shift = OFFSET + 0.5 + nlower = 2, nupper = 2 + if point is in left half of cell, then window of affected grid pts is 3 grid points to left of atom, 2 to right + if point is in right half of cell, then window of affected grid pts is 2 grid points to left of atom, 3 to right + +These settings apply to each dimension, so that if order = 5, an +atom's charge is mapped to 125 grid points that surround the atom. diff --git a/doc/src/Howto_drude.rst b/doc/src/Howto_drude.rst index c866340e77..7c1022b784 100644 --- a/doc/src/Howto_drude.rst +++ b/doc/src/Howto_drude.rst @@ -42,10 +42,11 @@ screening. It may be necessary to use the *extra/special/per/atom* keyword of the :doc:`read_data ` command. If using :doc:`fix shake `, make sure no Drude particle is in this fix group. -There are two ways to thermostat the Drude particles at a low +There are three ways to thermostat the Drude particles at a low temperature: use either :doc:`fix langevin/drude ` for a Langevin thermostat, or :doc:`fix drude/transform/\* ` for a Nose-Hoover -thermostat. The former requires use of the command :doc:`comm_modify vel yes `. The latter requires two separate integration +thermostat, or :doc:`fix tgnvt/drude ` for a temperature-grouped Nose-Hoover thermostat. +The first and third require use of the command :doc:`comm_modify vel yes `. The second requires two separate integration fixes like *nvt* or *npt*\ . The correct temperatures of the reduced degrees of freedom can be calculated using the :doc:`compute temp/drude `. This requires also to use the command *comm_modify vel yes*. diff --git a/doc/src/Howto_drude2.rst b/doc/src/Howto_drude2.rst index b0b910a832..d95f5c02aa 100644 --- a/doc/src/Howto_drude2.rst +++ b/doc/src/Howto_drude2.rst @@ -221,6 +221,14 @@ modification of forces but no position/velocity updates), the fix fix NVE all nve +To avoid the flying ice cube artifact, where the atoms progressively freeze and the +center of mass of the whole system drifts faster and faster, the *fix momentum* +can be used. For instance: + +.. code-block:: LAMMPS + + fix MOMENTUM all momentum 100 linear 1 1 1 + Finally, do not forget to update the atom type elements if you use them in a *dump_modify ... element ...* command, by adding the element type of the DPs. Here for instance @@ -376,14 +384,7 @@ For our phenol example, the groups would be defined as Note that with the fixes *drude/transform*\ , it is not required to specify *comm_modify vel yes* because the fixes do it anyway (several -times and for the forces also). To avoid the flying ice cube artifact -:ref:`(Lamoureux and Roux) `, where the atoms progressively freeze and the -center of mass of the whole system drifts faster and faster, the *fix -momentum* can be used. For instance: - -.. code-block:: LAMMPS - - fix MOMENTUM all momentum 100 linear 1 1 1 +times and for the forces also). It is a bit more tricky to run a NPT simulation with Nose-Hoover barostat and thermostat. First, the volume should be integrated only @@ -404,6 +405,31 @@ instructions for thermostatting and barostatting will look like fix NVT DRUDES nvt temp 1. 1. 20 fix INVERSE all drude/transform/inverse +Another option for thermalizing the Drude model is to use the +temperature-grouped Nose-Hoover (TGNH) thermostat proposed by :ref:`(Son) `. +This is implemented as :doc:`fix tgnvt/drude ` and :doc:`fix tgnpt/drude `. +It separates the kinetic energy into three contributions: +the molecular center of mass (COM) motion, the motion of atoms or atom-Drude pairs relative to molecular COMs, +and the relative motion of atom-Drude pairs. +An independent Nose-Hoover chain is applied to each type of motion. +When TGNH is used, the temperatures of molecular, atomic and Drude motion can be printed out with :doc:`thermo_style` command. + +NVT simulation with TGNH thermostat + +.. code-block:: LAMMPS + + comm_modify vel yes + fix TGNVT all tgnvt/drude temp 300. 300. 100 1. 20 + thermo_style custom f_TGNVT[1] f_TGNVT[2] f_TGNVT[3] + +NPT simulation with TGNH thermostat + +.. code-block:: LAMMPS + + comm_modify vel yes + fix TGNPT all tgnpt/drude temp 300. 300. 100 1. 20 iso 1. 1. 500 + thermo_style custom f_TGNPT[1] f_TGNPT[2] f_TGNPT[3] + ---------- **Rigid bodies** @@ -480,3 +506,7 @@ NPT ensemble using Nose-Hoover thermostat: **(SWM4-NDP)** Lamoureux, Harder, Vorobyov, Roux, MacKerell, Chem Phys Let, 418, 245-249 (2006) + +.. _TGNH-Son: + +**(Son)** Son, McDaniel, Cui and Yethiraj, J Phys Chem Lett, 10, 7523 (2019). diff --git a/doc/src/comm_modify.rst b/doc/src/comm_modify.rst index f01f63620f..895d3cf4fd 100644 --- a/doc/src/comm_modify.rst +++ b/doc/src/comm_modify.rst @@ -85,15 +85,15 @@ information is available, then also a heuristic based on that bond length is computed. It is used as communication cutoff, if there is no pair style present and no *comm_modify cutoff* command used. Otherwise a warning is printed, if this bond based estimate is larger than the -communication cutoff used. +communication cutoff used. The *cutoff/multi* option is equivalent to *cutoff*\ , but applies to communication mode *multi* instead. Since in this case the communication cutoffs are determined per atom type, a type specifier is needed and cutoff for one or multiple types can be extended. Also ranges of types -using the usual asterisk notation can be given. For granular pairstyles, +using the usual asterisk notation can be given. For granular pair styles, the default cutoff is set to the sum of the current maximum atomic radii -for each type. +for each type. The *cutoff/bytype* option applies to *multi* and automtically sets communication cutoffs for each particle type based on the largest interaction distance diff --git a/doc/src/fix.rst b/doc/src/fix.rst index 37ddbbeb3e..2e516faa4e 100644 --- a/doc/src/fix.rst +++ b/doc/src/fix.rst @@ -364,6 +364,8 @@ accelerated styles exist. * :doc:`temp/rescale ` - temperature control by velocity rescaling * :doc:`temp/rescale/eff ` - temperature control by velocity rescaling in the electron force field model * :doc:`tfmc ` - perform force-bias Monte Carlo with time-stamped method +* :doc:`tgnvt/drude ` - NVT time integration for Drude polarizable model via temperature-grouped Nose-Hoover +* :doc:`tgnpt/drude ` - NPT time integration for Drude polarizable model via temperature-grouped Nose-Hoover * :doc:`thermal/conductivity ` - Muller-Plathe kinetic energy exchange for thermal conductivity calculation * :doc:`ti/spring ` - * :doc:`tmd ` - guide a group of atoms to a new configuration diff --git a/doc/src/fix_bond_react.rst b/doc/src/fix_bond_react.rst index 16bd4ecb71..38f061e05f 100644 --- a/doc/src/fix_bond_react.rst +++ b/doc/src/fix_bond_react.rst @@ -457,6 +457,23 @@ example, the molecule fragment could consist of only the backbone atoms of a polymer chain. This constraint can be used to enforce a specific relative position and orientation between reacting molecules. +By default, all constraints must be satisfied for the reaction to +occur. In other words, constraints are evaluated as a series of +logical values using the logical AND operator "&&". More complex logic +can be achieved by explicitly adding the logical AND operator "&&" or +the logical OR operator "||" after a given constraint command. If a +logical operator is specified after a constraint, it must be placed +after all constraint parameters, on the same line as the constraint +(one per line). Similarly, parentheses can be used to group +constraints. The expression that results from concatenating all +constraints should be a valid logical expression that can be read by +the :doc:`variable ` command after converting each +constraint to a logical value. Because exactly one constraint is +allowed per line, having a valid logical expression implies that left +parentheses "(" should only appear before a constraint, and right +parentheses ")" should only appear after a constraint and before any +logical operator. + Once a reaction site has been successfully identified, data structures within LAMMPS that store bond topology are updated to reflect the post-reacted molecule template. All force fields with fixed bonds, @@ -599,8 +616,8 @@ reset_mol_ids = yes, custom_charges = no, molecule = off .. _Gissinger: -**(Gissinger)** Gissinger, Jensen and Wise, Polymer, 128, 211 (2017). +**(Gissinger)** Gissinger, Jensen and Wise, Polymer, 128, 211-217 (2017). .. _Gissinger2020: -**(Gissinger)** Gissinger, Jensen and Wise, Macromolecules (2020, in press). +**(Gissinger)** Gissinger, Jensen and Wise, Macromolecules, 53, 22, 9953–9961 (2020). diff --git a/doc/src/fix_drude.rst b/doc/src/fix_drude.rst index b3b04832d2..385a847749 100644 --- a/doc/src/fix_drude.rst +++ b/doc/src/fix_drude.rst @@ -41,12 +41,12 @@ Restrictions """""""""""" This fix should be invoked before any other commands that implement -the Drude oscillator model, such as :doc:`fix langevin/drude `, :doc:`fix drude/transform `, :doc:`compute temp/drude `, :doc:`pair_style thole `. +the Drude oscillator model, such as :doc:`fix langevin/drude `, :doc:`fix tgnvt/drude `, :doc:`fix drude/transform `, :doc:`compute temp/drude `, :doc:`pair_style thole `. Related commands """""""""""""""" -:doc:`fix langevin/drude `, :doc:`fix drude/transform `, :doc:`compute temp/drude `, :doc:`pair_style thole ` +:doc:`fix langevin/drude `, :doc:`fix tgnvt/drude `, :doc:`fix drude/transform `, :doc:`compute temp/drude `, :doc:`pair_style thole ` Default """"""" diff --git a/doc/src/fix_temp_csvr.rst b/doc/src/fix_temp_csvr.rst index 5e6074bc66..440a264ed5 100644 --- a/doc/src/fix_temp_csvr.rst +++ b/doc/src/fix_temp_csvr.rst @@ -124,16 +124,16 @@ temperature is calculated taking the bias into account, bias is removed from each atom, thermostatting is performed on the remaining thermal degrees of freedom, and the bias is added back in. -An important feature of these thermostats is that they have an +An important feature of these thermostats is that they have an associated effective energy that is a constant of motion. -The effective energy is the total energy (kinetic + potential) plus -the accumulated kinetic energy changes due to the thermostat. The -latter quantity is the global scalar computed by these fixes. This -feature is useful to check the integration of the equations of motion -against discretization errors. In other words, the conservation of -the effective energy can be used to choose an appropriate integration -:doc:`timestep `. This is similar to the usual paradigm of -checking the conservation of the total energy in the microcanonical +The effective energy is the total energy (kinetic + potential) plus +the accumulated kinetic energy changes due to the thermostat. The +latter quantity is the global scalar computed by these fixes. This +feature is useful to check the integration of the equations of motion +against discretization errors. In other words, the conservation of +the effective energy can be used to choose an appropriate integration +:doc:`timestep `. This is similar to the usual paradigm of +checking the conservation of the total energy in the microcanonical ensemble. diff --git a/doc/src/fix_tgnh_drude.rst b/doc/src/fix_tgnh_drude.rst new file mode 100644 index 0000000000..92781cd9e8 --- /dev/null +++ b/doc/src/fix_tgnh_drude.rst @@ -0,0 +1,305 @@ +.. index:: fix tgnvt/drude +.. index:: fix tgnpt/drude + +fix tgnvt/drude command +======================= + +fix tgnpt/drude command +======================= + + +Syntax +"""""" + +.. parsed-literal:: + + fix ID group-ID style_name keyword values ... + +* ID, group-ID are documented in :doc:`fix ` command +* style_name = *tgnvt/drude* or *tgnpt/drude* +* one or more keyword/values pairs may be appended + + .. parsed-literal:: + + keyword = *temp* *iso* or *aniso* or *tri* or *x* or *y* or *z* or *xy* or *yz* or *xz* or *couple* or *tchain* or *pchain* or *mtk* or *tloop* or *ploop* or *nreset* or *scalexy* or *scaleyz* or *scalexz* or *flip* or *fixedpoint* + *temp* values = Tstart Tstop Tdamp Tdrude Tdamp_drude + Tstart, Tstop = external temperature at start/end of run (temperature units) + Tdamp = temperature damping parameter (time units) + Tdrude = desired temperature of Drude oscillators (temperature units) + Tdamp_drude = temperature damping parameter for Drude oscillators (time units) + *iso* or *aniso* or *tri* values = Pstart Pstop Pdamp + Pstart,Pstop = scalar external pressure at start/end of run (pressure units) + Pdamp = pressure damping parameter (time units) + *x* or *y* or *z* or *xy* or *yz* or *xz* values = Pstart Pstop Pdamp + Pstart,Pstop = external stress tensor component at start/end of run (pressure units) + Pdamp = stress damping parameter (time units) + *couple* = *none* or *xyz* or *xy* or *yz* or *xz* + *tchain* value = N + N = length of thermostat chain (1 = single thermostat) + *pchain* value = N + N length of thermostat chain on barostat (0 = no thermostat) + *mtk* value = *yes* or *no* = add in MTK adjustment term or not + *tloop* value = M + M = number of sub-cycles to perform on thermostat + *ploop* value = M + M = number of sub-cycles to perform on barostat thermostat + *nreset* value = reset reference cell every this many timesteps + *scalexy* value = *yes* or *no* = scale xy with ly + *scaleyz* value = *yes* or *no* = scale yz with lz + *scalexz* value = *yes* or *no* = scale xz with lz + *flip* value = *yes* or *no* = allow or disallow box flips when it becomes highly skewed + *fixedpoint* values = x y z + x,y,z = perform barostat dilation/contraction around this point (distance units) + +Examples +"""""""" + +.. code-block:: LAMMPS + + comm_modify vel yes + fix 1 all tgnvt/drude temp 300.0 300.0 100.0 1.0 20.0 + fix 1 water tgnpt/drude temp 300.0 300.0 100.0 1.0 20.0 iso 0.0 0.0 1000.0 + fix 2 jello tgnpt/drude temp 300.0 300.0 100.0 1.0 20.0 tri 5.0 5.0 1000.0 + fix 2 ice tgnpt/drude temp 250.0 250.0 100.0 1.0 20.0 x 1.0 1.0 0.5 y 2.0 2.0 0.5 z 3.0 3.0 0.5 yz 0.1 0.1 0.5 xz 0.2 0.2 0.5 xy 0.3 0.3 0.5 nreset 1000 + +Description +""""""""""" + +These commands are variants of the Nose-Hoover fix styles :doc:`fix nvt +` and :doc:`fix npt ` for thermalized Drude polarizable +models. They apply temperature-grouped Nose-Hoover thermostat (TGNH) +proposed by :ref:`(Son) `. When there are fast vibrational +modes with frequencies close to Drude oscillators (e.g. double bonds or +out-of-plane torsions), this thermostat can provide better kinetic +energy equipartitioning. + +The difference between TGNH and the original Nose-Hoover thermostat is that, +TGNH separates the kinetic energy of the group into three contributions: +molecular center of mass (COM) motion, +motion of COM of atom-Drude pairs or non-polarizable atoms relative to molecular COM, +and relative motion of atom-Drude pairs. +An independent Nose-Hoover chain is applied to each type of motion. +The temperatures for these three types of motion are denoted as +molecular translational temperature (:math:`T_\mathrm{M}`), real atomic temperature (:math:`T_\mathrm{R}`) and Drude temperature (:math:`T_\mathrm{D}`), +which are defined in terms of their associated degrees of freedom (DOF): + +.. math:: + + T_\mathrm{M}=\frac{\Sigma_{i}^{N_\mathrm{mol}} M_i V_i^2}{3 \left ( N_\mathrm{mol} - \frac{N_\mathrm{mol}}{N_\mathrm{mol,sys}} \right ) k_\mathrm{B}} + +.. math:: + + T_\mathrm{R}=\frac{\Sigma_{i}^{N_\mathrm{real}} m_i (v_i-v_{M,i})^2}{(N_\mathrm{DOF} - 3 N_\mathrm{mol} + 3 \frac{N_\mathrm{mol}}{N_\mathrm{mol,sys}} - 3 N_\mathrm{drude}) k_\mathrm{B}} + +.. math:: + + T_\mathrm{D}=\frac{\Sigma_{i}^{N_\mathrm{drude}} m_i^{\prime} v_i^{\prime 2}}{3 N_\mathrm{drude} k_\mathrm{B}} + +Here :math:`N_\mathrm{mol}` and :math:`N_\mathrm{mol,sys}` are the numbers of molecules in the group and in the whole system, respectively. +:math:`N_\mathrm{real}` is the number of atom-Drude pairs and non-polarizable atoms in the group. +:math:`N_\mathrm{drude}` is the number of Drude particles in the group. +:math:`N_\mathrm{DOF}` is the DOF of the group. +:math:`M_i` and :math:`V_i` are the mass and the COM velocity of the i-th molecule. +:math:`m_i` is the mass of the i-th atom-Drude pair or non-polarizable atom. +:math:`v_i` is the velocity of COM of i-th atom-Drude pair or non-polarizable atom. +:math:`v_{M,i}` is the COM velocity of the molecule the i-th atom-Drude pair or non-polarizable atom belongs to. +:math:`m_i^\prime` and :math:`v_i^\prime` are the reduced mass and the relative velocity of the i-th atom-Drude pair. + +.. note:: + + These fixes require that each atom knows whether it is a Drude particle or + not. You must therefore use the :doc:`fix drude ` command to + specify the Drude status of each atom type. + + Because the TGNH thermostat thermostats the molecular COM motion, + all atoms belonging to the same molecule must be in the same group. + That is, these fixes can not be applied to a subset of a molecule. + + For this fix to act correctly, ghost atoms need to know their velocity. + You must use the :doc:`comm_modify ` command to enable this. + + These fixes assume that the translational DOF of the whole system is removed. + It is therefore recommended to invoke :doc:`fix momentum ` command so that the :math:`T_\mathrm{M}` is calculated correctly. + +---------- + +The thermostat parameters are specified using the *temp* keyword. +The thermostat is applied to only the translational DOF +for the particles. The translational DOF can also have +a bias velocity removed before thermostatting takes place; see the +description below. The desired temperature for molecular and real atomic motion is a +ramped value during the run from *Tstart* to *Tstop*\ . The *Tdamp* +parameter is specified in time units and determines how rapidly the +temperature is relaxed. For example, a value of 10.0 means to relax +the temperature in a timespan of (roughly) 10 time units (e.g. :math:`\tau` +or fs or ps - see the :doc:`units ` command). +The parameter *Tdrude* is the desired temperature for Drude motion at each timestep. +Similar to *Tdamp*, the *Tdamp_drude* parameter determines the relaxation speed for Drude motion. +Fix group are the only ones whose velocities and positions are updated +by the velocity/position update portion of the integration. +Other thermostat-related keywords are *tchain*\ and *tloop*\ , +which are detailed in :doc:`fix nvt `. + +.. note:: + + A Nose-Hoover thermostat will not work well for arbitrary values + of *Tdamp*\ . If *Tdamp* is too small, the temperature can fluctuate + wildly; if it is too large, the temperature will take a very long time + to equilibrate. A good choice for many models is a *Tdamp* of around + 100 timesteps. A smaller *Tdamp_drude* value would be required + to maintain Drude motion at low temperature. + +.. code-block:: LAMMPS + + fix 1 all nvt temp 300.0 300.0 $(100.0*dt) 1.0 $(20.0*dt) + +---------- + +The barostat parameters for fix style *tgnpt/drude* is specified +using one or more of the *iso*\ , *aniso*\ , *tri*\ , *x*\ , *y*\ , *z*\ , *xy*\ , +*xz*\ , *yz*\ , and *couple* keywords. These keywords give you the +ability to specify all 6 components of an external stress tensor, and +to couple various of these components together so that the dimensions +they represent are varied together during a constant-pressure +simulation. Other barostat-related keywords are *pchain*\ , *mtk*\ , *ploop*\ , +*nreset*\ , *scalexy*\ , *scaleyz*\ , *scalexz*\ , *flip*\ and *fixedpoint*. +The meaning of barostat parameters are detailed in :doc:`fix npt `. + +Regardless of what atoms are in the fix group (the only atoms which +are time integrated), a global pressure or stress tensor is computed +for all atoms. Similarly, when the size of the simulation box is +changed, all atoms are re-scaled to new positions. + +.. note:: + + Unlike the :doc:`fix temp/berendsen ` command + which performs thermostatting but NO time integration, these fixes + perform thermostatting/barostatting AND time integration. Thus you + should not use any other time integration fix, such as :doc:`fix nve ` on atoms to which this fix is applied. + Likewise, these fixes should not be used on atoms that also + have their temperature controlled by another fix - e.g. by :doc:`fix langevin/drude ` command. + +See the :doc:`Howto thermostat ` and :doc:`Howto barostat ` doc pages for a discussion of different +ways to compute temperature and perform thermostatting and +barostatting. + +---------- + +Like other fixes that perform thermostatting, these fixes can +be used with :doc:`compute commands ` that calculate a +temperature after removing a "bias" from the atom velocities. +This is not done by default, but only if the :doc:`fix_modify ` command +is used to assign a temperature compute to this fix that includes such +a bias term. See the doc pages for individual :doc:`compute commands ` to determine which ones include a bias. In +this case, the thermostat works in the following manner: the current +temperature is calculated taking the bias into account, bias is +removed from each atom, thermostatting is performed on the remaining +thermal DOF, and the bias is added back in. + +.. note:: + + However, not all temperature compute commands are valid to be used with these fixes. + Precisely, only temperature compute that does not modify the DOF of the group can be used. + E.g. :doc:`compute temp/ramp ` and :doc:`compute viscosity/cos ` + compute the kinetic energy after remove a velocity gradient without affecting the DOF of the group, + then they can be invoked in this way. + In contrast, :doc:`compute temp/partial ` may remove the DOF at one or more dimensions, + therefore it cannot be used with these fixes. + +---------- + +Restart, fix_modify, output, run start/stop, minimize info +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +These fixes writes the state of all the thermostat and barostat +variables to :doc:`binary restart files `. See the +:doc:`read_restart ` command for info on how to re-specify +a fix in an input script that reads a restart file, so that the +operation of the fix continues in an uninterrupted fashion. + +The :doc:`fix_modify ` *temp* and *press* options are +supported by these fixes. You can use them to assign a +:doc:`compute ` you have defined to this fix which will be used +in its thermostatting or barostatting procedure, as described above. +If you do this, note that the kinetic energy derived from the compute +temperature should be consistent with the virial term computed using +all atoms for the pressure. LAMMPS will warn you if you choose to +compute temperature on a subset of atoms. + +.. note:: + + If both the *temp* and *press* keywords are used in a single + thermo_modify command (or in two separate commands), then the order in + which the keywords are specified is important. Note that a :doc:`pressure compute ` defines its own temperature compute as + an argument when it is specified. The *temp* keyword will override + this (for the pressure compute being used by fix npt), but only if the + *temp* keyword comes after the *press* keyword. If the *temp* keyword + comes before the *press* keyword, then the new pressure compute + specified by the *press* keyword will be unaffected by the *temp* + setting. + +The :doc:`fix_modify ` *energy* option is supported by these +fixes to add the energy change induced by Nose/Hoover thermostatting +and barostatting to the system's potential energy as part of +:doc:`thermodynamic output `. + +These fixes compute a global scalar and a global vector of quantities, +which can be accessed by various :doc:`output commands `. +The scalar value calculated by these fixes is "extensive"; the vector +values are "intensive". +The scalar is the cumulative energy change due to the fix. +The vector stores the three temperatures :math:`T_\mathrm{M}`, :math:`T_\mathrm{R}` and :math:`T_\mathrm{D}`. + +These fixes can ramp their external temperature and pressure over +multiple runs, using the *start* and *stop* keywords of the +:doc:`run ` command. See the :doc:`run ` command for details of +how to do this. + +These fixes are not invoked during :doc:`energy minimization `. + +---------- + +Restrictions +"""""""""""" + +These fixes are only available when LAMMPS was built with the USER-DRUDE package. +These fixes cannot be used with dynamic groups as defined by the :doc:`group ` command. +These fixes cannot be used in 2D simulations. + +*X*\ , *y*\ , *z* cannot be barostatted if the associated dimension is not +periodic. *Xy*\ , *xz*\ , and *yz* can only be barostatted if the +simulation domain is triclinic and the second dimension in the keyword +(\ *y* dimension in *xy*\ ) is periodic. The :doc:`create_box `, +:doc:`read data `, and :doc:`read_restart ` +commands specify whether the simulation box is orthogonal or +non-orthogonal (triclinic) and explain the meaning of the xy,xz,yz +tilt factors. + +For the *temp* keyword, the final *Tstop* cannot be 0.0 since it would +make the external T = 0.0 at some timestep during the simulation which +is not allowed in the Nose/Hoover formulation. + +The *scaleyz yes*\ , *scalexz yes*\ , and *scalexy yes* options +can only be used if the second dimension in the keyword is periodic, +and if the tilt factor is not coupled to the barostat via keywords +*tri*\ , *yz*\ , *xz*\ , and *xy*\ . + +Related commands +"""""""""""""""" + +:doc:`fix drude `, :doc:`fix nvt `, :doc:`fix_npt `, +:doc:`fix_modify ` + +Default +""""""" + +The keyword defaults are tchain = 3, pchain = 3, mtk = yes, tloop = 1, +ploop = 1, nreset = 0, couple = none, +flip = yes, scaleyz = scalexz = scalexy = yes if periodic in second +dimension and not coupled to barostat, otherwise no. + +---------- + +.. _tgnh-Son: + +**(Son)** Son, McDaniel, Cui and Yethiraj, J Phys Chem Lett, 10, 7523 (2019). diff --git a/doc/src/neighbor.rst b/doc/src/neighbor.rst index ac50ca8875..f638160d21 100644 --- a/doc/src/neighbor.rst +++ b/doc/src/neighbor.rst @@ -49,7 +49,7 @@ sometimes be faster. Either style should give the same answers. The *multi* style is a modified binning algorithm that is useful for systems with a wide range of cutoff distances, e.g. due to different -size particles. For granular pairstyles, cutoffs are set to the +size particles. For granular pair styles, cutoffs are set to the sum of the maximum atomic radii for each atom type. For the *bin* style, the bin size is set to 1/2 of the largest cutoff distance between any pair of atom types and a @@ -59,8 +59,10 @@ other type pairs have a much shorter cutoff. For style *multi* the bin size is set to 1/2 of the shortest cutoff distance and multiple sets of bins are defined to search over for different atom types. This imposes some extra setup overhead, but the searches themselves -may be much faster for the short-cutoff cases. See the :doc:`comm_modify mode multi ` command for a communication option -that may also be beneficial for simulations of this kind. +may be much faster for the short-cutoff cases. +See the :doc:`comm_modify mode multi ` command for a +communication option that may also be beneficial for simulations of +this kind. The *bytype* style is an extension of the *multi* style that was presented by Shire, Hanley, and Stratford :ref:`(Shire) `. diff --git a/doc/src/package.rst b/doc/src/package.rst index 725536310a..339a1c7ca7 100644 --- a/doc/src/package.rst +++ b/doc/src/package.rst @@ -18,13 +18,16 @@ Syntax *gpu* args = Ngpu keyword value ... Ngpu = # of GPUs per node zero or more keyword/value pairs may be appended - keywords = *neigh* or *newton* or *binsize* or *split* or *gpuID* or *tpa* or *device* or *blocksize* + keywords = *neigh* or *newton* or *pair/only* or *binsize* or *split* or *gpuID* or *tpa* or *device* or *blocksize* *neigh* value = *yes* or *no* yes = neighbor list build on GPU (default) no = neighbor list build on CPU *newton* = *off* or *on* off = set Newton pairwise flag off (default and required) on = set Newton pairwise flag on (currently not allowed) + *pair/only* = *off* or *on* + off = apply "gpu" suffix to all available styles in the GPU package (default) + on - apply "gpu" suffix only pair styles *binsize* value = size size = bin size for neighbor list construction (distance units) *split* = fraction @@ -65,7 +68,7 @@ Syntax *no_affinity* values = none *kokkos* args = keyword value ... zero or more keyword/value pairs may be appended - keywords = *neigh* or *neigh/qeq* or *neigh/thread* or *newton* or *binsize* or *comm* or *comm/exchange* or *comm/forward* or *comm/reverse* or *cuda/aware* + keywords = *neigh* or *neigh/qeq* or *neigh/thread* or *newton* or *binsize* or *comm* or *comm/exchange* or *comm/forward* or *comm/reverse* or *cuda/aware* or *pair/only* *neigh* value = *full* or *half* full = full neighbor list half = half neighbor list built in thread-safe manner @@ -91,6 +94,9 @@ Syntax *cuda/aware* = *off* or *on* off = do not use CUDA-aware MPI on = use CUDA-aware MPI (default) + *pair/only* = *off* or *on* + off = use device acceleration (e.g. GPU) for all available styles in the KOKKOS package (default) + on = use device acceleration only for pair styles (and host acceleration for others) *omp* args = Nthreads keyword value ... Nthread = # of OpenMP threads to associate with each MPI process zero or more keyword/value pairs may be appended @@ -194,6 +200,14 @@ for compatibility with the package command for other accelerator styles. Note that the newton setting for bonded interactions is not affected by this keyword. +The *pair/only* keyword can change how any "gpu" suffix is applied. +By default a suffix is applied to all styles for which an accelerated +variant is available. However, that is not always the most effective +way to use an accelerator. With *pair/only* set to *on* the suffix +will only by applied to supported pair styles, which tend to be the +most effective in using an accelerator and their operation can be +overlapped with all other computations on the CPU. + The *binsize* keyword sets the size of bins used to bin atoms in neighbor list builds performed on the GPU, if *neigh* = *yes* is set. If *binsize* is set to 0.0 (the default), then bins = the size of the @@ -534,12 +548,20 @@ available (currently only possible with OpenMPI v2.0.0 or later), then the *cuda/aware* keyword is automatically set to *off* by default. When the *cuda/aware* keyword is set to *off* while any of the *comm* keywords are set to *device*\ , the value for these *comm* keywords will -be automatically changed to *host*\ . This setting has no effect if not +be automatically changed to *no*\ . This setting has no effect if not running on GPUs or if using only one MPI rank. CUDA-aware MPI is available for OpenMPI 1.8 (or later versions), Mvapich2 1.9 (or later) when the "MV2_USE_CUDA" environment variable is set to "1", CrayMPI, and IBM Spectrum MPI when the "-gpu" flag is used. +The *pair/only* keyword can change how the KOKKOS suffix "kk" is applied +when using an accelerator device. By default device acceleration is +always used for all available styles. With *pair/only* set to *on* the +suffix setting will choose device acceleration only for pair styles and +run all other force computations concurrently on the host CPU. +The *comm* flags will also automatically be changed to *no*\ . This can +result in better performance for certain configurations and system sizes. + ---------- The *omp* style invokes settings associated with the use of the diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index 0563ac1499..de2065c1e3 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -533,6 +533,7 @@ cuda Cuda CUDA CuH +Cui cuFFT Cummins Curk @@ -869,6 +870,7 @@ equilibrating equilibration Equilibria equilization +equipartitioning Ercolessi Erdmann eradius @@ -3071,9 +3073,11 @@ tex tfac tfmc tfMC -th +tgnpt +tgnvt Thakkar Thaokar +th thb thei Theodorou @@ -3479,6 +3483,7 @@ Yc ycm Yeh yellowgreen +Yethiraj yflag yhi yi diff --git a/examples/USER/drude/README b/examples/USER/drude/README index a305999e89..1a9593ed37 100644 --- a/examples/USER/drude/README +++ b/examples/USER/drude/README @@ -1,8 +1,8 @@ Example simulations of polarizable systems using Drude oscillators ================================================================== -Each example comes in two versions for demonstrating the use of -Nosé-Hoover or Langevin thermostats. +Each example comes in several versions for demonstrating the use of +Langevin, Nosé-Hoover and temperature-grouped Nosé-Hoover thermostats. * `butane` -- simulation in NVT ensemble with Thole damping diff --git a/examples/USER/drude/butane/in.butane.tgnh b/examples/USER/drude/butane/in.butane.tgnh new file mode 100644 index 0000000000..79b9d2dfc5 --- /dev/null +++ b/examples/USER/drude/butane/in.butane.tgnh @@ -0,0 +1,57 @@ +# 250 butane system for drude polarizability example (Langevin) + +units real +boundary p p p + +atom_style full +bond_style harmonic +angle_style harmonic +dihedral_style opls +special_bonds lj/coul 0.0 0.0 0.5 + +pair_style hybrid/overlay lj/cut/coul/long 8.0 8.0 thole 2.089 8.0 +pair_modify mix geometric tail yes +kspace_style pppm 1.0e-4 + +read_data data.butane + +comm_modify vel yes + +group gBUTANE molecule 1:250 +group gCORES type 1 2 3 +group gDRUDES type 4 5 + +pair_coeff 1 1 lj/cut/coul/long 0.065997 3.500000 # C3H C3H +pair_coeff 1 2 lj/cut/coul/long 0.065997 3.500000 # C3H C2H +pair_coeff 1 3 lj/cut/coul/long 0.044496 2.958040 # C3H H +pair_coeff 2 2 lj/cut/coul/long 0.065997 3.500000 # C2H C2H +pair_coeff 2 3 lj/cut/coul/long 0.044496 2.958040 # C2H H +pair_coeff 3 3 lj/cut/coul/long 0.029999 2.500000 # H H +pair_coeff * 4*5 lj/cut/coul/long 0.000000 0.000000 # No lj for drudes +pair_coeff 1 * thole 1.368000 +pair_coeff 2 * thole 1.368000 +pair_coeff 4 * thole 1.368000 +pair_coeff 5 * thole 1.368000 + +neighbor 2.0 bin + +variable vTEMP equal 260.0 +variable vTEMP_D equal 1.0 +variable vPRESS equal 1.0 + +velocity gCORES create ${vTEMP} 12345 +velocity gDRUDES create ${vTEMP_D} 12345 + +fix fDRUDE all drude C C N D D + +fix fSHAKE gCORES shake 0.0001 20 0 b 2 4 + +fix fNVT all tgnvt/drude temp ${vTEMP} ${vTEMP} 100.0 ${vTEMP_D} 20.0 + +compute cTEMP all temp/drude + +thermo_style custom step cpu etotal ke temp pe ebond eangle edihed eimp evdwl ecoul elong press vol c_cTEMP[1] c_cTEMP[2] f_fNVT[1] f_fNVT[2] f_fNVT[3] +thermo 50 + +timestep 0.5 +run 2000 diff --git a/examples/USER/drude/butane/log.12Nov20.butane.tgnh.g++.1 b/examples/USER/drude/butane/log.12Nov20.butane.tgnh.g++.1 new file mode 100644 index 0000000000..7d64a2e939 --- /dev/null +++ b/examples/USER/drude/butane/log.12Nov20.butane.tgnh.g++.1 @@ -0,0 +1,203 @@ +LAMMPS (29 Oct 2020) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:94) + using 1 OpenMP thread(s) per MPI task +# 250 butane system for drude polarizability example (Langevin) + +units real +boundary p p p + +atom_style full +bond_style harmonic +angle_style harmonic +dihedral_style opls +special_bonds lj/coul 0.0 0.0 0.5 + +pair_style hybrid/overlay lj/cut/coul/long 8.0 8.0 thole 2.089 8.0 +pair_modify mix geometric tail yes +kspace_style pppm 1.0e-4 + +read_data data.butane +Reading data file ... + orthogonal box = (-19.099988 -19.099913 -19.099998) to (19.099998 19.099999 19.099987) + 1 by 1 by 1 MPI processor grid + reading atoms ... + 4500 atoms + scanning bonds ... + 5 = max bonds/atom + scanning angles ... + 6 = max angles/atom + scanning dihedrals ... + 9 = max dihedrals/atom + reading bonds ... + 4250 bonds + reading angles ... + 6000 angles + reading dihedrals ... + 6750 dihedrals +Finding 1-2 1-3 1-4 neighbors ... + special bond factors lj: 0.0 0.0 0.5 + special bond factors coul: 0.0 0.0 0.5 + 5 = max # of 1-2 neighbors + 8 = max # of 1-3 neighbors + 12 = max # of 1-4 neighbors + 17 = max # of special neighbors + special bonds CPU = 0.005 seconds + read_data CPU = 0.107 seconds + +comm_modify vel yes + +group gBUTANE molecule 1:250 +4500 atoms in group gBUTANE +group gCORES type 1 2 3 +3500 atoms in group gCORES +group gDRUDES type 4 5 +1000 atoms in group gDRUDES + +pair_coeff 1 1 lj/cut/coul/long 0.065997 3.500000 # C3H C3H +pair_coeff 1 2 lj/cut/coul/long 0.065997 3.500000 # C3H C2H +pair_coeff 1 3 lj/cut/coul/long 0.044496 2.958040 # C3H H +pair_coeff 2 2 lj/cut/coul/long 0.065997 3.500000 # C2H C2H +pair_coeff 2 3 lj/cut/coul/long 0.044496 2.958040 # C2H H +pair_coeff 3 3 lj/cut/coul/long 0.029999 2.500000 # H H +pair_coeff * 4*5 lj/cut/coul/long 0.000000 0.000000 # No lj for drudes +pair_coeff 1 * thole 1.368000 +pair_coeff 2 * thole 1.368000 +pair_coeff 4 * thole 1.368000 +pair_coeff 5 * thole 1.368000 + +neighbor 2.0 bin + +variable vTEMP equal 260.0 +variable vTEMP_D equal 1.0 +variable vPRESS equal 1.0 + +velocity gCORES create ${vTEMP} 12345 +velocity gCORES create 260 12345 +velocity gDRUDES create ${vTEMP_D} 12345 +velocity gDRUDES create 1 12345 + +fix fDRUDE all drude C C N D D + +fix fSHAKE gCORES shake 0.0001 20 0 b 2 4 + 0 = # of size 2 clusters + 500 = # of size 3 clusters + 500 = # of size 4 clusters + 0 = # of frozen angles + find clusters CPU = 0.002 seconds + +fix fNVT all tgnvt/drude temp ${vTEMP} ${vTEMP} 100.0 ${vTEMP_D} 20.0 +fix fNVT all tgnvt/drude temp 260 ${vTEMP} 100.0 ${vTEMP_D} 20.0 +fix fNVT all tgnvt/drude temp 260 260 100.0 ${vTEMP_D} 20.0 +fix fNVT all tgnvt/drude temp 260 260 100.0 1 20.0 + +compute cTEMP all temp/drude + +thermo_style custom step cpu etotal ke temp pe ebond eangle edihed eimp evdwl ecoul elong press vol c_cTEMP[1] c_cTEMP[2] f_fNVT[1] f_fNVT[2] f_fNVT[3] +thermo 50 + +timestep 0.5 +run 2000 +PPPM initialization ... + using 12-bit tables for long-range coulomb (src/kspace.cpp:328) + G vector (1/distance) = 0.36786669 + grid = 36 36 36 + stencil order = 5 + estimated absolute RMS force accuracy = 0.031353958 + estimated relative force accuracy = 9.4421513e-05 + using double precision FFTW3 + 3d grid and FFT values/proc = 79507 46656 +Rebuild special list taking Drude particles into account +Old max number of 1-2 to 1-4 neighbors: 17 +New max number of 1-2 to 1-4 neighbors: 17 (+0) +Neighbor list info ... + update every 1 steps, delay 10 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 10 + ghost atom cutoff = 10 + binsize = 5, bins = 8 8 8 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair lj/cut/coul/long, perpetual + attributes: half, newton on + pair build: half/bin/newton + stencil: half/bin/3d/newton + bin: standard + (2) pair thole, perpetual, skip from (1) + attributes: half, newton on + pair build: skip + stencil: none + bin: none +TGNHC thermostat for Drude model + DOFs of molecules, atoms and dipoles: 747.0 7250.0 3000.0 +Per MPI rank memory allocation (min/avg/max) = 26.74 | 26.74 | 26.74 Mbytes +Step CPU TotEng KinEng Temp PotEng E_bond E_angle E_dihed E_impro E_vdwl E_coul E_long Press Volume c_cTEMP[1] c_cTEMP[2] f_fNVT[1] f_fNVT[2] f_fNVT[3] + 0 0 6535.5187 2714.74 248.45112 3820.7787 3724.3278 140.75328 1.4735401 0 -518.77975 595169.42 -594696.41 4439.7916 55742.797 334.61375 18.435655 235.53872 344.96036 18.435655 + 50 3.1687763 2088.2827 1463.7181 133.95847 624.56452 190.24602 660.52157 113.41252 0 -767.94561 595300.94 -594872.61 2824.2625 55742.797 183.94884 0.5168738 309.18564 171.12124 0.5168738 + 100 6.392197 2119.741 1619.097 148.17863 500.64399 180.00042 696.41212 164.28885 0 -972.75524 595305.17 -594872.47 1212.6136 55742.797 203.63725 0.14080733 399.49069 183.54186 0.14080733 + 150 9.5800587 2141.3837 1671.6283 152.98627 469.75531 135.1638 703.8743 168.6738 0 -966.11416 595300.45 -594872.29 4391.1694 55742.797 210.25781 0.10918071 418.15558 188.92417 0.10918071 + 200 12.853705 2171.9506 1663.8326 152.27281 508.11794 189.68939 718.42616 166.2915 0 -990.53041 595295.36 -594871.12 2071.4055 55742.797 209.24314 0.19965091 435.49843 186.01763 0.19965091 + 250 16.067977 2208.7064 1678.7069 153.6341 529.99951 152.56393 831.36872 167.05009 0 -1047.6813 595297.24 -594870.54 1092.2375 55742.797 210.84693 0.91289443 438.53468 187.47449 0.91289443 + 300 19.290601 2251.9246 1764.9742 161.52921 486.95043 145.17235 805.81497 155.39025 0 -1045.9572 595297.21 -594870.68 2438.7801 55742.797 220.85043 3.177778 427.70756 199.6284 3.177778 + 350 22.523101 2270.9632 1684.9306 154.20368 586.03264 186.29543 828.98436 164.45539 0 -1016.9035 595293.56 -594870.36 2804.0926 55742.797 211.53678 1.1611927 408.91355 191.2877 1.1611927 + 400 25.747934 2299.236 1742.1505 159.44041 557.0855 171.75438 844.97783 181.89643 0 -1068.3059 595296.85 -594870.09 346.86959 55742.797 219.02792 0.38093991 392.66374 201.22808 0.38093991 + 450 28.921993 2335.9622 1666.2461 152.49369 669.71602 137.8956 986.46039 179.59582 0 -1060.189 595295.82 -594869.86 -125.83593 55742.797 209.50259 0.31748182 376.15783 192.41804 0.31748182 + 500 32.312988 2377.923 1744.8977 159.69183 633.02533 192.86619 865.11335 173.23166 0 -1020.1061 595291.45 -594869.53 3306.7537 55742.797 219.29509 0.59010722 361.05703 204.77946 0.59010722 + 550 36.691992 2428.1816 1631.766 149.33809 796.41562 183.75276 1043.9175 175.64604 0 -1030.3844 595293.08 -594869.6 1566.0362 55742.797 204.67411 1.6260367 344.40559 190.36165 1.6260367 + 600 41.042781 2475.0304 1615.769 147.87406 859.26146 195.35951 1102.8743 185.82441 0 -1049.7179 595293.93 -594869 751.07631 55742.797 202.5711 1.8674049 324.5681 190.08503 1.8674049 + 650 45.328915 2516.5445 1706.6033 156.18716 809.94113 177.34479 1029.3219 186.91492 0 -1005.4619 595290.9 -594869.08 2456.1336 55742.797 214.42466 0.73094758 306.66872 205.00907 0.73094758 + 700 49.764606 2566.0671 1658.8261 151.81461 907.24102 186.97528 1088.6916 184.51371 0 -976.01174 595292.41 -594869.33 403.91053 55742.797 208.52534 0.43420426 292.04619 200.0061 0.43420426 + 750 54.232008 2621.7889 1798.1047 164.5613 823.68424 181.39689 1029.9425 187.40871 0 -1005.4402 595300.06 -594869.68 93.345406 55742.797 226.01979 0.50741755 278.62961 220.69269 0.50741755 + 800 58.691111 2682.2116 1697.0698 155.31465 985.14182 215.09199 1113.1134 201.785 0 -975.13212 595300.04 -594869.76 -978.97822 55742.797 213.08116 1.115316 269.45572 207.36081 1.115316 + 850 63.191067 2745.8302 1887.0667 172.70304 858.76349 213.25376 980.55106 184.54859 0 -948.21117 595298.22 -594869.6 -1842.9661 55742.797 236.69142 1.8946563 265.28903 233.84282 1.8946563 + 900 68.297608 2799.3194 1855.1338 169.78056 944.1856 201.04167 1103.4608 183.6645 0 -978.27382 595303.89 -594869.59 -1771.6573 55742.797 232.95614 1.1425454 262.10904 230.04879 1.1425454 + 950 72.791466 2852.8885 1809.5899 165.61241 1043.2986 249.1926 1129.6516 191.5705 0 -961.04118 595303.8 -594869.88 -2342.8998 55742.797 227.44427 0.56184866 253.71617 224.83147 0.56184866 + 1000 77.035667 2910.6565 1900.2429 173.90892 1010.4136 196.79043 1117.444 178.94619 0 -911.75161 595298.72 -594869.74 -30.451099 55742.797 238.87602 0.48940683 245.53211 238.28906 0.48940683 + 1050 81.411119 2970.473 1950.8452 178.54 1019.6278 226.17987 1113.3407 186.50456 0 -935.79287 595298.24 -594868.85 -835.03656 55742.797 245.11923 0.81684119 243.27893 245.41028 0.81684119 + 1100 85.352255 3032.1777 1913.2921 175.10317 1118.8856 252.39337 1183.7624 209.49478 0 -958.58165 595300.89 -594869.07 -2339.7573 55742.797 240.10633 1.5863163 244.29251 239.77436 1.5863163 + 1150 88.542324 3088.7233 2015.1572 184.4258 1073.5661 215.84757 1132.2268 209.14846 0 -912.58909 595297.76 -594868.83 53.404069 55742.797 252.92982 1.5639609 247.6541 253.57807 1.5639609 + 1200 92.122601 3137.9447 1895.1546 173.44324 1242.7901 238.97673 1266.308 207.46165 0 -898.18367 595297.09 -594868.86 -940.55827 55742.797 238.13441 0.75999751 245.44164 237.48006 0.75999751 + 1250 95.311451 3187.5696 2117.7204 193.81231 1069.8492 181.35781 1173.5116 216.10446 0 -933.15422 595300.81 -594868.78 -1638.23 55742.797 266.21428 0.54658889 243.60628 268.65384 0.54658889 + 1300 98.511654 3238.1405 2050.9414 187.70074 1187.1991 249.20898 1196.3016 223.50078 0 -909.6591 595296.3 -594868.46 -1547.4617 55742.797 257.76705 0.6695258 252.14097 258.4534 0.6695258 + 1350 101.52721 3288.0387 2035.6917 186.3051 1252.347 218.31874 1254.421 222.85512 0 -868.43705 595293.49 -594868.3 390.90212 55742.797 255.64252 1.2189872 257.21253 255.58654 1.2189872 + 1400 104.52829 3334.0324 2200.7086 201.40733 1133.3238 203.591 1213.1272 225.86605 0 -936.79465 595295.53 -594868 1372.2474 55742.797 276.25415 1.6144005 265.70225 277.45567 1.6144005 + 1450 107.57536 3365.7397 2053.535 187.9381 1312.2047 229.27407 1349.3993 233.25524 0 -924.22271 595292.17 -594867.67 -836.52213 55742.797 257.94919 1.053914 270.4816 256.76466 1.053914 + 1500 110.67807 3391.6801 2142.1349 196.04671 1249.5452 216.36803 1271.289 236.65847 0 -894.899 595287.51 -594867.38 1789.6923 55742.797 269.25236 0.63559736 274.68538 268.80398 0.63559736 + 1550 113.65872 3411.9839 2115.0942 193.57196 1296.8897 192.92659 1363.4027 230.98652 0 -914.70137 595291.47 -594867.19 2191.6084 55742.797 265.85125 0.63359087 272.59399 265.26653 0.63359087 + 1600 116.66477 3424.9783 2002.6546 183.28156 1422.3237 261.62038 1419.7862 242.17905 0 -928.05995 595294.38 -594867.58 -1278.1217 55742.797 251.58666 0.95135757 265.94171 250.2117 0.95135757 + 1650 119.69122 3429.9661 2102.8573 192.45205 1327.1088 253.88883 1296.8164 239.01537 0 -888.25345 595293.11 -594867.47 948.16575 55742.797 263.99864 1.4686915 261.93718 264.32028 1.4686915 + 1700 122.69838 3421.465 2141.4791 195.98669 1279.9859 181.31236 1326.081 226.54243 0 -878.86521 595292.19 -594867.28 241.93125 55742.797 268.9293 1.2770595 262.79349 269.67278 1.2770595 + 1750 125.70436 3402.5396 2090.1999 191.29365 1312.3397 263.74025 1296.4274 228.60032 0 -905.54661 595296.37 -594867.25 -1707.3557 55742.797 262.65583 0.80319616 257.84463 263.26023 0.80319616 + 1800 128.64288 3381.1607 2133.1735 195.22657 1247.9872 234.93738 1242.035 231.34689 0 -887.78079 595295.05 -594867.6 -6.7713651 55742.797 268.11425 0.66416955 258.06107 269.26102 0.66416955 + 1850 131.64553 3358.3375 2097.2908 191.9426 1261.0467 207.32514 1269.9582 225.83462 0 -867.84477 595293.05 -594867.28 1032.3077 55742.797 263.55741 0.77783532 261.21918 263.90739 0.77783532 + 1900 134.66459 3335.0634 2130.3209 194.96549 1204.7425 244.28549 1208.9691 209.87044 0 -885.54671 595293.8 -594866.63 -302.54262 55742.797 267.53309 1.2569444 256.95232 268.73397 1.2569444 + 1950 137.77487 3309.5009 2065.148 189.00092 1244.3529 244.25407 1240.7976 222.92873 0 -891.58467 595294.86 -594866.9 -2000.0789 55742.797 259.29344 1.3652015 254.19331 259.92622 1.3652015 + 2000 140.88126 3284.0767 2005.7474 183.56462 1278.3292 226.17277 1236.5565 225.16671 0 -837.57878 595295.52 -594867.51 942.09961 55742.797 251.97128 0.96329477 250.4516 252.23212 0.96329477 +Loop time of 140.882 on 1 procs for 2000 steps with 4500 atoms + +Performance: 0.613 ns/day, 39.134 hours/ns, 14.196 timesteps/s +100.0% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 90.189 | 90.189 | 90.189 | 0.0 | 64.02 +Bond | 5.0432 | 5.0432 | 5.0432 | 0.0 | 3.58 +Kspace | 39.478 | 39.478 | 39.478 | 0.0 | 28.02 +Neigh | 2.4322 | 2.4322 | 2.4322 | 0.0 | 1.73 +Comm | 0.62876 | 0.62876 | 0.62876 | 0.0 | 0.45 +Output | 0.021652 | 0.021652 | 0.021652 | 0.0 | 0.02 +Modify | 2.9918 | 2.9918 | 2.9918 | 0.0 | 2.12 +Other | | 0.09631 | | | 0.07 + +Nlocal: 4500.00 ave 4500 max 4500 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 9440.00 ave 9440 max 9440 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 811251.0 ave 811251 max 811251 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 811251 +Ave neighs/atom = 180.27800 +Ave special neighs/atom = 13.333333 +Neighbor list builds = 31 +Dangerous builds = 0 +Total wall time: 0:02:21 diff --git a/examples/USER/drude/butane/log.12Nov20.butane.tgnh.g++.4 b/examples/USER/drude/butane/log.12Nov20.butane.tgnh.g++.4 new file mode 100644 index 0000000000..5cadbab3d2 --- /dev/null +++ b/examples/USER/drude/butane/log.12Nov20.butane.tgnh.g++.4 @@ -0,0 +1,203 @@ +LAMMPS (29 Oct 2020) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:94) + using 1 OpenMP thread(s) per MPI task +# 250 butane system for drude polarizability example (Langevin) + +units real +boundary p p p + +atom_style full +bond_style harmonic +angle_style harmonic +dihedral_style opls +special_bonds lj/coul 0.0 0.0 0.5 + +pair_style hybrid/overlay lj/cut/coul/long 8.0 8.0 thole 2.089 8.0 +pair_modify mix geometric tail yes +kspace_style pppm 1.0e-4 + +read_data data.butane +Reading data file ... + orthogonal box = (-19.099988 -19.099913 -19.099998) to (19.099998 19.099999 19.099987) + 2 by 1 by 2 MPI processor grid + reading atoms ... + 4500 atoms + scanning bonds ... + 5 = max bonds/atom + scanning angles ... + 6 = max angles/atom + scanning dihedrals ... + 9 = max dihedrals/atom + reading bonds ... + 4250 bonds + reading angles ... + 6000 angles + reading dihedrals ... + 6750 dihedrals +Finding 1-2 1-3 1-4 neighbors ... + special bond factors lj: 0.0 0.0 0.5 + special bond factors coul: 0.0 0.0 0.5 + 5 = max # of 1-2 neighbors + 8 = max # of 1-3 neighbors + 12 = max # of 1-4 neighbors + 17 = max # of special neighbors + special bonds CPU = 0.002 seconds + read_data CPU = 0.135 seconds + +comm_modify vel yes + +group gBUTANE molecule 1:250 +4500 atoms in group gBUTANE +group gCORES type 1 2 3 +3500 atoms in group gCORES +group gDRUDES type 4 5 +1000 atoms in group gDRUDES + +pair_coeff 1 1 lj/cut/coul/long 0.065997 3.500000 # C3H C3H +pair_coeff 1 2 lj/cut/coul/long 0.065997 3.500000 # C3H C2H +pair_coeff 1 3 lj/cut/coul/long 0.044496 2.958040 # C3H H +pair_coeff 2 2 lj/cut/coul/long 0.065997 3.500000 # C2H C2H +pair_coeff 2 3 lj/cut/coul/long 0.044496 2.958040 # C2H H +pair_coeff 3 3 lj/cut/coul/long 0.029999 2.500000 # H H +pair_coeff * 4*5 lj/cut/coul/long 0.000000 0.000000 # No lj for drudes +pair_coeff 1 * thole 1.368000 +pair_coeff 2 * thole 1.368000 +pair_coeff 4 * thole 1.368000 +pair_coeff 5 * thole 1.368000 + +neighbor 2.0 bin + +variable vTEMP equal 260.0 +variable vTEMP_D equal 1.0 +variable vPRESS equal 1.0 + +velocity gCORES create ${vTEMP} 12345 +velocity gCORES create 260 12345 +velocity gDRUDES create ${vTEMP_D} 12345 +velocity gDRUDES create 1 12345 + +fix fDRUDE all drude C C N D D + +fix fSHAKE gCORES shake 0.0001 20 0 b 2 4 + 0 = # of size 2 clusters + 500 = # of size 3 clusters + 500 = # of size 4 clusters + 0 = # of frozen angles + find clusters CPU = 0.003 seconds + +fix fNVT all tgnvt/drude temp ${vTEMP} ${vTEMP} 100.0 ${vTEMP_D} 20.0 +fix fNVT all tgnvt/drude temp 260 ${vTEMP} 100.0 ${vTEMP_D} 20.0 +fix fNVT all tgnvt/drude temp 260 260 100.0 ${vTEMP_D} 20.0 +fix fNVT all tgnvt/drude temp 260 260 100.0 1 20.0 + +compute cTEMP all temp/drude + +thermo_style custom step cpu etotal ke temp pe ebond eangle edihed eimp evdwl ecoul elong press vol c_cTEMP[1] c_cTEMP[2] f_fNVT[1] f_fNVT[2] f_fNVT[3] +thermo 50 + +timestep 0.5 +run 2000 +PPPM initialization ... + using 12-bit tables for long-range coulomb (src/kspace.cpp:328) + G vector (1/distance) = 0.36786669 + grid = 36 36 36 + stencil order = 5 + estimated absolute RMS force accuracy = 0.031353958 + estimated relative force accuracy = 9.4421513e-05 + using double precision FFTW3 + 3d grid and FFT values/proc = 26875 11664 +Rebuild special list taking Drude particles into account +Old max number of 1-2 to 1-4 neighbors: 17 +New max number of 1-2 to 1-4 neighbors: 17 (+0) +Neighbor list info ... + update every 1 steps, delay 10 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 10 + ghost atom cutoff = 10 + binsize = 5, bins = 8 8 8 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair lj/cut/coul/long, perpetual + attributes: half, newton on + pair build: half/bin/newton + stencil: half/bin/3d/newton + bin: standard + (2) pair thole, perpetual, skip from (1) + attributes: half, newton on + pair build: skip + stencil: none + bin: none +TGNHC thermostat for Drude model + DOFs of molecules, atoms and dipoles: 747.0 7250.0 3000.0 +Per MPI rank memory allocation (min/avg/max) = 17.33 | 17.61 | 17.71 Mbytes +Step CPU TotEng KinEng Temp PotEng E_bond E_angle E_dihed E_impro E_vdwl E_coul E_long Press Volume c_cTEMP[1] c_cTEMP[2] f_fNVT[1] f_fNVT[2] f_fNVT[3] + 0 0 6535.5187 2714.74 248.45112 3820.7787 3724.3278 140.75328 1.4735401 0 -518.77975 595169.42 -594696.41 4439.7916 55742.797 334.61375 18.435655 235.53872 344.96036 18.435655 + 50 1.2808116 2088.3442 1463.7416 133.96062 624.60259 190.28732 660.54143 113.40785 0 -767.95454 595300.93 -594872.61 2824.0523 55742.797 183.9497 0.52468068 309.23594 171.11764 0.52468068 + 100 2.5584104 2119.7471 1619.1466 148.18318 500.60051 180.0129 696.37693 164.27736 0 -972.76956 595305.17 -594872.47 1212.1148 55742.797 203.64285 0.14251823 399.52878 183.54411 0.14251823 + 150 3.8010236 2141.3696 1671.6877 152.99171 469.68182 135.1764 703.84494 168.6598 0 -966.14516 595300.44 -594872.29 4390.752 55742.797 210.26485 0.11034179 418.18146 188.92927 0.11034179 + 200 5.1283429 2171.9547 1663.9057 152.2795 508.04901 189.69207 718.41361 166.26728 0 -990.56316 595295.36 -594871.12 2071.2788 55742.797 209.25133 0.20233224 435.53114 186.0233 0.20233224 + 250 6.4042978 2208.7763 1678.8339 153.64571 529.94239 152.60724 831.35366 166.99449 0 -1047.7147 595297.24 -594870.54 1092.02 55742.797 210.85827 0.9252592 438.54342 187.4861 0.9252592 + 300 7.6759895 2251.8197 1764.844 161.5173 486.97577 145.12518 805.82891 155.36767 0 -1045.8941 595297.22 -594870.68 2440.3181 55742.797 220.83898 3.1684561 427.70245 199.61611 3.1684561 + 350 8.9352416 2270.8953 1684.8322 154.19468 586.06305 186.26267 828.9806 164.47014 0 -1016.8664 595293.58 -594870.36 2805.0915 55742.797 211.52748 1.151954 408.90784 191.27829 1.151954 + 400 10.226474 2299.1993 1742.2608 159.4505 556.93851 171.73982 844.94626 181.87018 0 -1068.3641 595296.84 -594870.09 346.42411 55742.797 219.04152 0.38166821 392.61871 201.24772 0.38166821 + 450 11.460384 2335.947 1666.1971 152.4892 669.74994 137.90858 986.43107 179.60302 0 -1060.1348 595295.81 -594869.87 -124.88535 55742.797 209.49545 0.32005879 376.11474 192.41461 0.32005879 + 500 12.727526 2377.9345 1744.9374 159.69546 632.99715 192.8966 865.02273 173.24203 0 -1020.0569 595291.42 -594869.52 3307.6909 55742.797 219.29743 0.59718599 361.06132 204.78161 0.59718599 + 550 14.002285 2428.2193 1631.8271 149.34369 796.3922 183.78402 1043.8511 175.66575 0 -1030.3885 595293.08 -594869.6 1565.6449 55742.797 204.6776 1.6372397 344.46071 190.35982 1.6372397 + 600 15.309195 2474.8599 1615.6237 147.86076 859.23616 195.26628 1102.8384 185.89393 0 -1049.6659 595293.91 -594869.01 751.15809 55742.797 202.55856 1.8521167 324.58977 190.06895 1.8521167 + 650 16.528946 2516.5107 1706.7483 156.20043 809.76241 177.33665 1029.1545 186.8922 0 -1005.4741 595290.93 -594869.08 2457.4736 55742.797 214.44458 0.72647262 306.69821 205.02801 0.72647262 + 700 17.788857 2566.0306 1658.7538 151.808 907.27687 187.0133 1088.6084 184.61388 0 -976.00491 595292.38 -594869.33 403.14977 55742.797 208.51586 0.43547213 292.00328 200.00013 0.43547213 + 750 19.056136 2621.8108 1798.0665 164.5578 823.74429 181.38067 1030.1211 187.24746 0 -1005.3911 595300.06 -594869.68 92.552993 55742.797 226.01327 0.51200863 278.52415 220.69636 0.51200863 + 800 20.328816 2682.2638 1697.1503 155.32202 985.11349 215.11037 1113.1057 201.61206 0 -974.97574 595300.02 -594869.76 -976.02218 55742.797 213.08709 1.1265124 269.37146 207.37604 1.1265124 + 850 21.675028 2745.7956 1887.1133 172.70731 858.68222 213.20281 980.38605 184.58101 0 -948.10772 595298.22 -594869.6 -1838.829 55742.797 236.69968 1.8882632 265.22854 233.85817 1.8882632 + 900 22.973234 2799.2121 1855.3963 169.80459 943.81573 200.99559 1103.2167 183.64073 0 -978.26954 595303.83 -594869.59 -1773.6417 55742.797 232.99302 1.1323134 262.06588 230.09392 1.1323134 + 950 24.248459 2852.9103 1809.6345 165.6165 1043.2758 249.23659 1129.5155 191.54177 0 -960.95833 595303.82 -594869.88 -2343.6579 55742.797 227.45041 0.56047502 253.63589 224.84652 0.56047502 + 1000 25.536354 2910.7011 1900.5669 173.93856 1010.1343 196.76213 1117.2835 179.06956 0 -911.9529 595298.71 -594869.74 -33.375682 55742.797 238.91568 0.49230975 245.54917 238.33106 0.49230975 + 1050 27.032801 2970.593 1950.7545 178.53171 1019.8385 226.09391 1113.2803 186.61907 0 -935.59614 595298.29 -594868.85 -832.86686 55742.797 245.10467 0.82528071 243.25364 245.39681 0.82528071 + 1100 28.276849 3032.248 1914.0097 175.16884 1118.2383 252.4222 1183.4081 209.13741 0 -958.53105 595300.88 -594869.07 -2341.1239 55742.797 240.19374 1.5939531 244.2841 239.87168 1.5939531 + 1150 29.492505 3088.6987 2014.6006 184.37485 1074.0982 215.76487 1132.4575 209.01044 0 -912.08646 595297.78 -594868.83 59.335425 55742.797 252.86479 1.5506297 247.67435 253.50422 1.5506297 + 1200 30.792128 3137.976 1895.5574 173.4801 1242.4187 239.01663 1266.2435 206.94828 0 -898.01399 595297.09 -594868.87 -935.85119 55742.797 238.18675 0.75585601 245.80184 237.50082 0.75585601 + 1250 32.351654 3187.6007 2118.7576 193.90723 1068.8431 181.27841 1173.4284 215.72666 0 -933.61935 595300.82 -594868.79 -1641.4966 55742.797 266.34429 0.54783845 244.09536 268.74691 0.54783845 + 1300 34.279555 3238.1339 2050.9128 187.69812 1187.2212 249.09831 1195.8579 223.95802 0 -909.52255 595296.29 -594868.46 -1548.7665 55742.797 257.76137 0.67507496 252.48992 258.41118 0.67507496 + 1350 36.142639 3287.8996 2035.6486 186.30115 1252.251 218.35091 1254.3488 223.36318 0 -868.93347 595293.43 -594868.31 385.64561 55742.797 255.63367 1.2281317 257.51447 255.54567 1.2281317 + 1400 37.680265 3333.7702 2200.7264 201.40895 1133.0439 203.40304 1213.391 225.99045 0 -937.20521 595295.47 -594868.01 1368.2351 55742.797 276.25818 1.6096154 265.82263 277.44771 1.6096154 + 1450 38.930719 3365.4323 2053.468 187.93197 1311.9643 229.10608 1350.1009 232.99574 0 -924.67313 595292.11 -594867.67 -844.05749 55742.797 257.94445 1.0440927 270.14303 256.79431 1.0440927 + 1500 40.161434 3391.3707 2141.7727 196.01356 1249.598 216.2106 1271.1542 236.52415 0 -894.39832 595287.52 -594867.41 1800.4964 55742.797 269.20769 0.63415006 273.93125 268.83182 0.63415006 + 1550 41.331434 3411.6894 2114.0335 193.47488 1297.6559 192.9656 1363.167 231.27359 0 -913.98645 595291.45 -594867.21 2209.1641 55742.797 265.71649 0.63741948 271.92193 265.18682 0.63741948 + 1600 42.514856 3424.7938 2003.2634 183.33728 1421.5305 261.67378 1419.189 241.66354 0 -927.77417 595294.37 -594867.6 -1282.8296 55742.797 251.6594 0.96160577 265.79668 250.30691 0.96160577 + 1650 43.712954 3429.9764 2104.4785 192.60041 1325.4979 253.75783 1296.7732 237.25083 0 -887.95744 595293.15 -594867.48 966.66903 55742.797 264.20211 1.4699573 262.83185 264.45262 1.4699573 + 1700 44.988869 3421.4427 2141.3199 195.97211 1280.1228 180.56711 1326.1422 227.27194 0 -878.75929 595292.2 -594867.3 269.33339 55742.797 268.91342 1.2659937 264.28353 269.50173 1.2659937 + 1750 46.32512 3402.6047 2089.4689 191.22675 1313.1357 263.71155 1295.9383 229.85515 0 -905.40883 595296.3 -594867.26 -1711.6299 55742.797 262.56648 0.79625261 258.49733 263.09439 0.79625261 + 1800 47.626741 3381.3633 2132.4465 195.16003 1248.9167 234.45582 1241.8128 232.64927 0 -887.43322 595295.06 -594867.63 6.1750563 55742.797 268.02308 0.66339407 257.61935 269.20593 0.66339407 + 1850 48.859097 3358.9769 2090.1997 191.29363 1268.7772 207.84877 1271.8504 229.08032 0 -865.66614 595292.95 -594867.29 1046.4693 55742.797 262.66189 0.78698303 260.47063 262.99635 0.78698303 + 1900 50.086851 3336.417 2129.6659 194.90555 1206.7511 244.28118 1211.1819 208.93923 0 -884.87319 595293.88 -594866.65 -289.20276 55742.797 267.44697 1.2668343 256.868 268.64764 1.2668343 + 1950 51.245913 3311.0369 2068.2384 189.28375 1242.7985 243.85893 1242.1317 220.07989 0 -891.04779 595294.68 -594866.91 -1991.6618 55742.797 259.6859 1.3553911 254.54251 260.3233 1.3553911 + 2000 52.444694 3285.8337 2003.2382 183.33497 1282.5955 227.01654 1237.0479 227.77755 0 -837.34967 595295.6 -594867.49 937.91227 55742.797 251.65869 0.95505158 250.48617 251.88363 0.95505158 +Loop time of 52.4449 on 4 procs for 2000 steps with 4500 atoms + +Performance: 1.647 ns/day, 14.568 hours/ns, 38.135 timesteps/s +98.1% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 26.398 | 27.961 | 29.034 | 18.3 | 53.31 +Bond | 1.3959 | 1.5762 | 1.7169 | 9.5 | 3.01 +Kspace | 17.592 | 18.436 | 19.757 | 18.9 | 35.15 +Neigh | 0.8492 | 0.85015 | 0.85101 | 0.1 | 1.62 +Comm | 1.311 | 1.6626 | 2.0789 | 22.0 | 3.17 +Output | 0.010571 | 0.011494 | 0.013821 | 1.3 | 0.02 +Modify | 1.8078 | 1.8237 | 1.8372 | 0.8 | 3.48 +Other | | 0.1236 | | | 0.24 + +Nlocal: 1125.00 ave 1220 max 1043 min +Histogram: 1 0 1 0 0 0 1 0 0 1 +Nghost: 5813.50 ave 5907 max 5699 min +Histogram: 1 0 0 1 0 0 0 0 1 1 +Neighs: 202807.0 ave 217353 max 190808 min +Histogram: 1 1 0 0 0 0 1 0 0 1 + +Total # of neighbors = 811227 +Ave neighs/atom = 180.27267 +Ave special neighs/atom = 13.333333 +Neighbor list builds = 31 +Dangerous builds = 0 +Total wall time: 0:00:52 diff --git a/examples/USER/drude/ethanol/in.ethanol.tgnh b/examples/USER/drude/ethanol/in.ethanol.tgnh new file mode 100644 index 0000000000..8d476da68a --- /dev/null +++ b/examples/USER/drude/ethanol/in.ethanol.tgnh @@ -0,0 +1,79 @@ +units real +boundary p p p + +atom_style full +bond_style harmonic +angle_style harmonic +dihedral_style opls +special_bonds lj/coul 0.0 0.0 0.5 + +pair_style hybrid/overlay lj/cut/coul/long 8.0 8.0 thole 2.600 8.0 +kspace_style pppm 1.0e-4 + +comm_modify vel yes +read_data data.ethanol + +pair_coeff 1 1 lj/cut/coul/long 0.065997 3.500000 # C3H C3H +pair_coeff 1 2 lj/cut/coul/long 0.065997 3.500000 # C3H CTO +pair_coeff 1 3 lj/cut/coul/long 0.044496 2.958040 # C3H H +pair_coeff 1 4 lj/cut/coul/long 0.105921 3.304542 # C3H OH +pair_coeff 1 5 lj/cut/coul/long 0.000000 0.000000 # C3H HO +pair_coeff 2 2 lj/cut/coul/long 0.065997 3.500000 # CTO CTO +pair_coeff 2 3 lj/cut/coul/long 0.044496 2.958040 # CTO H +pair_coeff 2 4 lj/cut/coul/long 0.105921 3.304542 # CTO OH +pair_coeff 2 5 lj/cut/coul/long 0.000000 0.000000 # CTO HO +pair_coeff 3 3 lj/cut/coul/long 0.029999 2.500000 # H H +pair_coeff 3 4 lj/cut/coul/long 0.071413 2.792848 # H OH +pair_coeff 3 5 lj/cut/coul/long 0.000000 0.000000 # H HO +pair_coeff 4 4 lj/cut/coul/long 0.169996 3.120000 # OH OH +pair_coeff 4 5 lj/cut/coul/long 0.000000 0.000000 # OH HO +pair_coeff 5 5 lj/cut/coul/long 0.000000 0.000000 # HO HO +pair_coeff * 6*8 lj/cut/coul/long 0.000000 0.000000 # No lj for drudes +pair_coeff 1 1 thole 2.051000 +pair_coeff 1 2 thole 1.580265 +pair_coeff 1 4 thole 1.416087 +pair_coeff 1 6 thole 2.051000 +pair_coeff 1 7 thole 1.580265 +pair_coeff 1 8 thole 1.416087 +pair_coeff 2 2 thole 1.217570 +pair_coeff 2 4 thole 1.091074 +pair_coeff 2 6 thole 1.580265 +pair_coeff 2 7 thole 1.217570 +pair_coeff 2 8 thole 1.091074 +pair_coeff 4 4 thole 0.977720 +pair_coeff 4 6 thole 1.416087 +pair_coeff 4 7 thole 1.091074 +pair_coeff 4 8 thole 0.977720 +pair_coeff 6 6 thole 2.051000 +pair_coeff 6 7 thole 1.580265 +pair_coeff 6 8 thole 1.416087 +pair_coeff 7 7 thole 1.217570 +pair_coeff 7 8 thole 1.091074 +pair_coeff 8 8 thole 0.977720 + +group gETHANOL molecule 1:250 +group gATOMS type 1 2 3 4 5 +group gDRUDES type 6 7 8 + +neighbor 2.0 bin + +variable vTEMP equal 300.0 +variable vTEMP_D equal 1.0 +variable vPRESS equal 1.0 + +velocity gATOMS create ${vTEMP} 12345 +velocity gDRUDES create ${vTEMP_D} 12345 + +fix fDRUDE all drude C C N C N D D D + +fix fSHAKE gATOMS shake 0.0001 20 0 b 2 3 5 + +fix fNPT all tgnpt/drude temp ${vTEMP} ${vTEMP} 100.0 ${vTEMP_D} 20.0 iso ${vPRESS} ${vPRESS} 1000 + +compute cTEMP all temp/drude + +thermo_style custom step cpu etotal ke temp pe ebond eangle edihed eimp evdwl ecoul elong press vol c_cTEMP[1] c_cTEMP[2] f_fNPT[1] f_fNPT[2] f_fNPT[3] +thermo 20 + +timestep 0.5 +run 2000 diff --git a/examples/USER/drude/ethanol/log.12Nov20.ethanol.tgnh.g++.1 b/examples/USER/drude/ethanol/log.12Nov20.ethanol.tgnh.g++.1 new file mode 100644 index 0000000000..d6c39edb32 --- /dev/null +++ b/examples/USER/drude/ethanol/log.12Nov20.ethanol.tgnh.g++.1 @@ -0,0 +1,287 @@ +LAMMPS (29 Oct 2020) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:94) + using 1 OpenMP thread(s) per MPI task +units real +boundary p p p + +atom_style full +bond_style harmonic +angle_style harmonic +dihedral_style opls +special_bonds lj/coul 0.0 0.0 0.5 + +pair_style hybrid/overlay lj/cut/coul/long 8.0 8.0 thole 2.600 8.0 +kspace_style pppm 1.0e-4 + +comm_modify vel yes +read_data data.ethanol +Reading data file ... + orthogonal box = (-14.013845 -14.027809 -14.018882) to (14.016930 14.017730 14.085730) + 1 by 1 by 1 MPI processor grid + reading atoms ... + 3000 atoms + scanning bonds ... + 5 = max bonds/atom + scanning angles ... + 6 = max angles/atom + scanning dihedrals ... + 9 = max dihedrals/atom + reading bonds ... + 2750 bonds + reading angles ... + 3250 angles + reading dihedrals ... + 3000 dihedrals +Finding 1-2 1-3 1-4 neighbors ... + special bond factors lj: 0.0 0.0 0.5 + special bond factors coul: 0.0 0.0 0.5 + 5 = max # of 1-2 neighbors + 6 = max # of 1-3 neighbors + 10 = max # of 1-4 neighbors + 11 = max # of special neighbors + special bonds CPU = 0.003 seconds + read_data CPU = 0.062 seconds + +pair_coeff 1 1 lj/cut/coul/long 0.065997 3.500000 # C3H C3H +pair_coeff 1 2 lj/cut/coul/long 0.065997 3.500000 # C3H CTO +pair_coeff 1 3 lj/cut/coul/long 0.044496 2.958040 # C3H H +pair_coeff 1 4 lj/cut/coul/long 0.105921 3.304542 # C3H OH +pair_coeff 1 5 lj/cut/coul/long 0.000000 0.000000 # C3H HO +pair_coeff 2 2 lj/cut/coul/long 0.065997 3.500000 # CTO CTO +pair_coeff 2 3 lj/cut/coul/long 0.044496 2.958040 # CTO H +pair_coeff 2 4 lj/cut/coul/long 0.105921 3.304542 # CTO OH +pair_coeff 2 5 lj/cut/coul/long 0.000000 0.000000 # CTO HO +pair_coeff 3 3 lj/cut/coul/long 0.029999 2.500000 # H H +pair_coeff 3 4 lj/cut/coul/long 0.071413 2.792848 # H OH +pair_coeff 3 5 lj/cut/coul/long 0.000000 0.000000 # H HO +pair_coeff 4 4 lj/cut/coul/long 0.169996 3.120000 # OH OH +pair_coeff 4 5 lj/cut/coul/long 0.000000 0.000000 # OH HO +pair_coeff 5 5 lj/cut/coul/long 0.000000 0.000000 # HO HO +pair_coeff * 6*8 lj/cut/coul/long 0.000000 0.000000 # No lj for drudes +pair_coeff 1 1 thole 2.051000 +pair_coeff 1 2 thole 1.580265 +pair_coeff 1 4 thole 1.416087 +pair_coeff 1 6 thole 2.051000 +pair_coeff 1 7 thole 1.580265 +pair_coeff 1 8 thole 1.416087 +pair_coeff 2 2 thole 1.217570 +pair_coeff 2 4 thole 1.091074 +pair_coeff 2 6 thole 1.580265 +pair_coeff 2 7 thole 1.217570 +pair_coeff 2 8 thole 1.091074 +pair_coeff 4 4 thole 0.977720 +pair_coeff 4 6 thole 1.416087 +pair_coeff 4 7 thole 1.091074 +pair_coeff 4 8 thole 0.977720 +pair_coeff 6 6 thole 2.051000 +pair_coeff 6 7 thole 1.580265 +pair_coeff 6 8 thole 1.416087 +pair_coeff 7 7 thole 1.217570 +pair_coeff 7 8 thole 1.091074 +pair_coeff 8 8 thole 0.977720 + +group gETHANOL molecule 1:250 +3000 atoms in group gETHANOL +group gATOMS type 1 2 3 4 5 +2250 atoms in group gATOMS +group gDRUDES type 6 7 8 +750 atoms in group gDRUDES + +neighbor 2.0 bin + +variable vTEMP equal 300.0 +variable vTEMP_D equal 1.0 +variable vPRESS equal 1.0 + +velocity gATOMS create ${vTEMP} 12345 +velocity gATOMS create 300 12345 +velocity gDRUDES create ${vTEMP_D} 12345 +velocity gDRUDES create 1 12345 + +fix fDRUDE all drude C C N C N D D D + +fix fSHAKE gATOMS shake 0.0001 20 0 b 2 3 5 + 250 = # of size 2 clusters + 250 = # of size 3 clusters + 250 = # of size 4 clusters + 0 = # of frozen angles + find clusters CPU = 0.001 seconds + +fix fNPT all tgnpt/drude temp ${vTEMP} ${vTEMP} 100.0 ${vTEMP_D} 20.0 iso ${vPRESS} ${vPRESS} 1000 +fix fNPT all tgnpt/drude temp 300 ${vTEMP} 100.0 ${vTEMP_D} 20.0 iso ${vPRESS} ${vPRESS} 1000 +fix fNPT all tgnpt/drude temp 300 300 100.0 ${vTEMP_D} 20.0 iso ${vPRESS} ${vPRESS} 1000 +fix fNPT all tgnpt/drude temp 300 300 100.0 1 20.0 iso ${vPRESS} ${vPRESS} 1000 +fix fNPT all tgnpt/drude temp 300 300 100.0 1 20.0 iso 1 ${vPRESS} 1000 +fix fNPT all tgnpt/drude temp 300 300 100.0 1 20.0 iso 1 1 1000 + +compute cTEMP all temp/drude + +thermo_style custom step cpu etotal ke temp pe ebond eangle edihed eimp evdwl ecoul elong press vol c_cTEMP[1] c_cTEMP[2] f_fNPT[1] f_fNPT[2] f_fNPT[3] +thermo 20 + +timestep 0.5 +run 2000 +PPPM initialization ... + using 12-bit tables for long-range coulomb (src/kspace.cpp:328) + G vector (1/distance) = 0.37973843 + grid = 30 30 30 + stencil order = 5 + estimated absolute RMS force accuracy = 0.028997858 + estimated relative force accuracy = 8.7326188e-05 + using double precision FFTW3 + 3d grid and FFT values/proc = 50653 27000 +Rebuild special list taking Drude particles into account +Old max number of 1-2 to 1-4 neighbors: 11 +New max number of 1-2 to 1-4 neighbors: 11 (+0) +Neighbor list info ... + update every 1 steps, delay 10 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 10 + ghost atom cutoff = 10 + binsize = 5, bins = 6 6 6 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair lj/cut/coul/long, perpetual + attributes: half, newton on + pair build: half/bin/newton + stencil: half/bin/3d/newton + bin: standard + (2) pair thole, perpetual, skip from (1) + attributes: half, newton on + pair build: skip + stencil: none + bin: none +TGNHC thermostat for Drude model + DOFs of molecules, atoms and dipoles: 747.0 4500.0 2250.0 +Per MPI rank memory allocation (min/avg/max) = 22.99 | 22.99 | 22.99 Mbytes +Step CPU TotEng KinEng Temp PotEng E_bond E_angle E_dihed E_impro E_vdwl E_coul E_long Press Volume c_cTEMP[1] c_cTEMP[2] f_fNPT[1] f_fNPT[2] f_fNPT[3] + 0 0 13868.828 2013.3852 270.28772 11855.443 3145.896 51.880809 0.00019113234 0 8481.5109 514734.14 -514557.98 170210.19 22094.109 381.62759 10.134301 291.07893 396.91308 10.134301 + 20 1.299002 9802.0013 5175.0939 694.7326 4626.9074 1138.6388 2334.7257 132.32135 0 1890.1205 514082.52 -514951.42 83148.665 22175.038 987.97886 9.5650257 2458.1912 744.58226 9.5650257 + 40 2.6585262 9235.2784 5579.5869 749.03392 3655.6915 905.50827 1897.9797 277.48003 0 1696.6242 513843.84 -514965.74 60300.581 22359.787 1068.9505 1.5632512 2851.9591 773.68368 1.5632512 + 60 4.0767848 8671.8892 5504.7567 738.98831 3167.1326 829.06537 2052.5827 330.50295 0 997.94126 513948.25 -514991.2 48878.532 22600.438 1054.9063 0.8609188 3046.3154 725.0357 0.8609188 + 80 5.4198065 8041.4551 5718.4601 767.67701 2322.9951 733.58679 1714.9273 332.16847 0 607.45721 513906.05 -514971.19 46156.9 22855.703 1095.9536 0.67476425 2911.1504 795.36156 0.67476425 + 100 6.8445274 7424.1846 5485.2445 736.36888 1938.9402 725.61122 1556.2473 334.28427 0 311.33112 513993.29 -514981.82 35649.376 23094.997 1051.3109 0.5222695 2722.3778 774.61471 0.5222695 + 120 8.1987147 6864.2981 5106.0869 685.46872 1758.2112 639.80517 1608.9702 330.7119 0 225.63755 513930.12 -514977.04 28592.139 23302.575 978.67156 0.41481306 2531.1524 721.61219 0.41481306 + 140 9.6125531 6355.2419 4782.2344 641.99302 1573.0074 692.8178 1572.2236 329.75157 0 62.526757 513879.29 -514963.61 24166.914 23482.684 916.61358 0.35571984 2382.5955 673.87165 0.35571984 + 160 10.981043 5871.6552 4610.4861 618.9366 1261.169 680.52384 1414.3474 329.28182 0 -159.78058 513987.52 -514990.72 27542.211 23647.419 883.68752 0.35918951 2123.8994 678.40147 0.35918951 + 180 12.332621 5435.5691 4279.3184 574.47885 1156.2507 684.91656 1423.9511 309.44801 0 -233.41405 513945.61 -514974.26 18688.318 23808.753 820.22155 0.31322062 1867.6728 646.89147 0.31322062 + 200 13.684023 5063.6933 3974.692 533.58416 1089.0012 610.82746 1398.9423 299.55778 0 -238.71277 514006.42 -514988.03 14346.596 23962.516 761.81108 0.34323344 1649.6269 614.94153 0.34323344 + 220 15.025737 4729.6345 3862.1044 518.46979 867.53006 589.15408 1361.5835 291.68077 0 -382.15023 514000.76 -514993.5 14084.228 24106.002 740.21384 0.37572015 1480.8499 617.76172 0.37572015 + 240 16.361954 4425.17 3701.2817 496.88008 723.88831 584.37459 1295.507 282.13297 0 -468.19466 514014.29 -514984.22 13175.309 24240.893 709.36164 0.42725973 1335.0379 605.97228 0.42725973 + 260 17.686205 4147.8236 3444.1814 462.36555 703.6422 561.69812 1304.6664 277.46507 0 -505.18688 514062.51 -514997.51 9960.5444 24367.441 660.03654 0.51674844 1202.6787 570.39815 0.51663293 + 280 19.001433 3906.0499 3263.3789 438.09363 642.67099 612.03629 1258.9736 278.79088 0 -503.36734 513978.2 -514981.97 5911.2321 24482.777 625.29586 0.70431199 1076.194 550.86363 0.70431199 + 300 20.239475 3688.6521 3138.7761 421.36628 549.87595 589.66541 1229.0183 274.52568 0 -529.41366 513980.02 -514993.93 8818.9035 24585 601.19081 1.2138917 967.42544 540.79666 1.2138917 + 320 21.55208 3484.9768 3041.6682 408.32999 443.30859 581.36133 1221.761 276.40415 0 -581.91733 513938.29 -514992.59 9181.7725 24679.377 582.27807 1.9067083 865.20562 535.70028 1.9067083 + 340 22.866527 3301.111 2892.7326 388.33607 408.3784 575.39496 1150.6761 289.75308 0 -522.13929 513897.14 -514982.44 7705.6777 24768.367 553.48144 2.4790842 782.86323 515.77305 2.4790842 + 360 24.169391 3134.601 2727.1786 366.11121 407.42236 560.04836 1167.7896 290.8151 0 -534.37256 513917.26 -514994.12 5173.1603 24851.201 521.90957 2.0935593 720.9275 489.22054 2.0935593 + 380 25.499891 2978.9742 2626.4574 352.58985 352.51679 565.92745 1159.8532 276.01665 0 -574.15206 513906.53 -514981.66 5406.7601 24926.52 502.85217 1.5076664 663.92569 476.44959 1.5078823 + 400 26.749513 2830.4515 2571.0905 345.15709 259.36106 608.49648 1122.7921 254.35509 0 -631.46578 513898.27 -514993.09 6598.5441 24996.189 492.43661 1.0446762 619.49263 471.67242 1.0443567 + 420 28.295841 2690.9016 2510.0923 336.96837 180.80925 579.44132 1054.4508 246.41333 0 -619.58628 513907.01 -514986.92 3344.148 25062.431 480.89086 0.69994647 565.8201 467.11319 0.69994647 + 440 29.740652 2568.0899 2415.0979 324.2158 152.99201 549.56174 1062.4133 248.3112 0 -625.52103 513895.56 -514977.34 1508.2507 25122.432 462.77313 0.4830629 522.5615 453.15678 0.4830629 + 460 31.033999 2452.8301 2374.2562 318.73299 78.573926 560.62424 1025.2699 241.11159 0 -664.87807 513904.81 -514988.36 2645.1623 25175.119 454.98091 0.39620035 489.058 449.62743 0.39620035 + 480 32.287371 2343.6513 2309.9229 310.09654 33.728418 543.67605 1036.735 236.6691 0 -646.19525 513846.07 -514983.23 4840.3297 25223.454 442.64176 0.41089885 466.91678 438.90721 0.41089885 + 500 33.575452 2237.0869 2186.7578 293.56219 50.329153 569.29753 1077.789 237.78011 0 -644.2024 513802.59 -514992.93 3147.641 25270.717 419.03821 0.39338041 448.26725 414.46511 0.39352695 + 520 34.882586 2139.9267 2184.6613 293.28075 -44.734618 598.44589 949.76187 230.75426 0 -639.80829 513811.79 -514995.68 89.417432 25315.104 418.62009 0.43123772 424.93066 417.85161 0.43123772 + 540 36.099168 2047.6906 2096.7059 281.47314 -49.015331 603.23512 994.03336 236.23878 0 -642.85411 513760.61 -515000.28 2488.0247 25353.845 401.6824 0.6095642 402.80198 401.76434 0.6095642 + 560 37.392444 1959.8223 2108.0902 283.00143 -148.26783 556.77844 933.83445 228.23222 0 -640.71325 513772.73 -514999.13 3943.0471 25390.643 403.78476 0.79631768 387.29154 406.79182 0.79631768 + 580 38.599277 1877.9441 2032.3004 272.827 -154.35632 567.35925 915.88654 217.432 0 -638.21268 513777.18 -514994 990.21765 25427.432 389.08915 1.184871 380.81536 390.72199 1.184871 + 600 39.880662 1802.0089 2025.4302 271.90471 -223.42134 546.62696 900.79592 214.83879 0 -668.01506 513782.41 -515000.08 13.167029 25461.023 387.51997 1.7732181 375.29493 389.80736 1.773544 + 620 41.151704 1729.2181 1934.4658 259.69315 -205.24769 550.82063 913.19495 217.45935 0 -675.32746 513791.35 -515002.74 241.52954 25490.189 369.99117 1.9848435 365.94576 370.90937 1.9848435 + 640 42.367107 1658.2621 1869.4172 250.96067 -211.15505 560.62227 911.72129 213.95368 0 -665.21833 513766.85 -514999.08 3632.223 25516.498 357.58414 1.8379694 353.567 358.48938 1.8379694 + 660 43.641386 1588.4137 1852.2333 248.65382 -263.8196 577.15612 856.06817 203.8208 0 -643.32076 513743.58 -515001.12 1748.9053 25544.141 354.40947 1.5590879 342.18406 356.67449 1.5598187 + 680 44.916294 1522.8833 1803.3756 242.0949 -280.4923 569.2594 868.20962 207.92742 0 -667.28233 513741.85 -515000.45 -707.71197 25570.844 345.28497 0.99527257 329.41069 348.14899 0.99572941 + 700 46.126721 1461.9096 1769.8128 237.58924 -307.90315 542.7914 861.81473 203.22264 0 -674.68634 513754.76 -514995.8 1167.0096 25593.851 338.95839 0.74443058 320.56652 342.23742 0.74427874 + 720 47.342692 1403.7901 1774.9009 238.2723 -371.11079 533.63282 871.2916 186.94204 0 -661.24368 513696.56 -514998.29 1734.2343 25615.595 339.99734 0.59618884 315.31635 344.32074 0.59612251 + 740 48.606886 1347.7019 1788.1767 240.05451 -440.47482 551.44173 832.07818 173.00046 0 -679.31011 513685.34 -515003.03 1108.3607 25637.321 342.57548 0.51883795 311.99896 347.87957 0.51883795 + 760 49.886167 1294.2014 1732.3399 232.55868 -438.13849 563.187 825.18662 175.50788 0 -672.34818 513677.51 -515007.18 -2118.7763 25657.738 331.88911 0.47758368 305.31362 336.52173 0.47757969 + 780 51.181176 1243.7936 1720.77 231.00547 -476.9764 565.28094 800.5385 187.89263 0 -663.7818 513643.08 -515009.99 142.9942 25673.523 329.66915 0.48221433 293.10673 335.95739 0.48257178 + 800 52.501053 1195.7584 1713.4482 230.02255 -517.6898 575.29743 793.40588 182.96177 0 -652.3437 513594.18 -515011.19 2569.2035 25687.829 328.22734 0.57136512 282.06342 336.10937 0.57136512 + 820 53.730285 1149.3704 1688.6401 226.69218 -539.26966 566.02535 783.51259 170.42752 0 -645.21365 513596.56 -515010.58 158.43243 25703.753 323.41372 0.70633792 274.90722 331.6814 0.70633792 + 840 55.059346 1107.3402 1626.7277 218.38072 -519.38749 557.00463 817.13283 161.18356 0 -661.6802 513616.64 -515009.67 -859.99932 25718.477 311.42538 0.98533165 274.36623 317.78482 0.98533165 + 860 56.26804 1067.0989 1619.5401 217.41582 -552.44114 567.51474 819.44456 157.01002 0 -653.65749 513563.92 -515006.67 -110.22037 25730.521 309.90587 1.3158099 279.28284 315.1959 1.3158099 + 880 57.552129 1028.7737 1622.6482 217.83307 -593.87455 579.7559 769.38822 163.25737 0 -641.48094 513545.77 -515010.56 2044.3918 25741.489 310.33341 1.7085038 277.85767 315.93127 1.7085038 + 900 58.752011 990.85148 1635.8709 219.60816 -645.01941 590.07687 741.99946 160.20976 0 -648.65733 513521.95 -515010.6 -616.21441 25753.742 312.82551 1.8081896 279.97773 318.48679 1.8081896 + 920 60.02342 953.65737 1657.228 222.47525 -703.57061 574.2732 734.42873 151.5283 0 -657.51865 513506.29 -515012.57 -2391.2196 25763.907 316.97803 1.6721323 286.84832 322.1911 1.6717714 + 940 61.246864 917.3708 1532.2653 205.69958 -614.89448 576.8991 775.3663 162.78532 0 -639.35069 513524.45 -515015.04 564.89367 25770.107 293.21271 1.2280076 293.75433 293.31884 1.2282942 + 960 62.520232 883.18364 1537.9463 206.46223 -654.76268 563.51425 761.32405 161.47799 0 -631.38061 513503.44 -515013.14 1374.3226 25776.278 294.40866 0.9786147 300.31219 293.62423 0.97818807 + 980 63.72859 851.43088 1538.0246 206.47273 -686.59368 565.62724 756.61795 152.08723 0 -645.22417 513500.66 -515016.36 -203.76984 25783.711 294.53876 0.71003563 300.78246 293.69924 0.71029723 + 1000 65.325249 822.29342 1546.1186 207.55932 -723.82514 573.24707 705.27714 145.40402 0 -627.3824 513491.87 -515012.24 -1482.5195 25790.098 296.12917 0.61958842 301.40343 295.45106 0.61958842 + 1020 67.066265 795.41337 1551.6368 208.30012 -756.22343 597.40466 700.03219 143.14559 0 -631.02663 513445.32 -515011.1 748.62224 25794.159 297.21498 0.5543604 297.93873 297.29299 0.5543604 + 1040 68.784411 769.92029 1548.9081 207.9338 -778.9878 581.53993 723.87795 137.61133 0 -624.63041 513420.31 -515017.7 1356.2174 25798.811 296.7141 0.50251818 294.64447 297.25547 0.50251818 + 1060 70.531164 745.98628 1514.0024 203.24787 -768.0161 590.02417 718.13714 148.25485 0 -620.67061 513412.77 -515016.53 -984.90789 25804.672 289.98962 0.57944566 296.06714 289.17408 0.57944566 + 1080 72.339286 724.41988 1468.7378 197.17131 -744.31795 587.12574 750.82761 166.43289 0 -611.54088 513376.94 -515014.1 -1369.9774 25808.741 281.26901 0.68044534 297.86474 278.70146 0.68043227 + 1100 74.081078 705.1492 1475.7507 198.11275 -770.60147 596.03939 703.74275 166.87407 0 -604.94878 513382.71 -515015.02 322.11458 25810.632 282.54351 0.84350846 304.3263 279.11613 0.84359917 + 1120 75.92559 688.04772 1517.3948 203.70329 -829.34708 589.83314 688.24666 158.8665 0 -610.41803 513358.01 -515013.88 1171.4548 25812.799 290.41298 1.1090646 307.74167 287.73002 1.1090646 + 1140 77.724149 672.36504 1512.4831 203.04391 -840.11804 611.8019 686.11567 154.1589 0 -600.4798 513325.18 -515016.9 -1129.2791 25816.098 289.32063 1.4608372 307.70226 286.46216 1.4608372 + 1160 79.533442 657.64948 1524.9394 204.71611 -867.2899 614.09367 686.86805 145.77079 0 -587.50349 513287.47 -515013.99 -1405.9783 25817.666 291.61223 1.6855491 302.37391 290.02089 1.6855106 + 1180 81.243201 643.07936 1483.2148 199.11478 -840.13545 607.70554 729.46823 145.73396 0 -581.12793 513268.2 -515010.11 951.82863 25817.313 283.62844 1.6507547 296.31179 281.7127 1.6507678 + 1200 83.124235 628.84892 1508.103 202.45591 -879.25413 610.27958 699.47204 146.65751 0 -581.22705 513258.98 -515013.42 845.8635 25818.085 288.47775 1.4683346 288.26595 288.70552 1.4687429 + 1220 84.861868 615.48595 1506.3938 202.22645 -890.90781 640.61601 705.74981 149.24915 0 -568.44006 513197.45 -515015.53 -989.87699 25819.897 288.2897 1.1425522 284.47457 289.11499 1.1433225 + 1240 86.657973 603.46611 1521.8 204.29466 -918.3339 627.93094 681.9999 147.50604 0 -563.03024 513206.69 -515019.43 -1294.0886 25820.275 291.33208 0.93495852 284.52005 292.65658 0.93566845 + 1260 88.527368 592.83025 1550.0222 208.08336 -957.19193 638.74876 684.27892 144.10419 0 -567.28292 513161.98 -515019.02 366.82518 25818.88 296.84123 0.70423253 289.40784 298.27306 0.70423253 + 1280 90.26083 583.62238 1500.3203 201.41111 -916.69791 658.39007 717.40575 149.49357 0 -560.74831 513138.12 -515019.36 468.99306 25817.909 287.36089 0.59306602 294.54267 286.36029 0.59306602 + 1300 92.13165 575.42151 1519.3082 203.96014 -943.88664 655.72041 704.25181 141.32573 0 -550.47558 513125.5 -515020.21 -1022.3924 25817.559 291.00356 0.58689962 300.73954 289.58167 0.58691655 + 1320 93.894194 568.3477 1518.4074 203.83922 -950.05966 670.96379 726.82052 139.93925 0 -527.97883 513058.34 -515018.15 -972.06273 25815.822 290.83615 0.57457637 307.54777 288.256 0.57459152 + 1340 95.719114 562.07892 1523.1375 204.47422 -961.05857 677.25051 688.02873 138.64793 0 -528.35304 513081.3 -515017.94 1058.9949 25813.039 291.70253 0.66885112 312.02785 288.52311 0.66873042 + 1360 97.524416 556.93389 1560.3959 209.47598 -1003.462 665.73523 686.80959 139.77318 0 -523.04289 513045.29 -515018.03 937.16072 25811.796 298.7948 0.7861094 312.82634 296.66456 0.78666076 + 1380 99.357452 553.33396 1516.3062 203.55714 -962.97224 678.04454 713.74957 137.42774 0 -517.91272 513044.03 -515018.31 -292.99291 25811.915 290.25807 0.98357958 308.02329 287.50255 0.98357958 + 1400 101.09848 550.59887 1532.5676 205.74016 -981.9687 668.87709 700.85053 135.12927 0 -539.20798 513074.89 -515022.51 -1158.8487 25811.561 293.25245 1.2705054 302.5546 291.90379 1.2705054 + 1420 102.92972 548.73321 1476.7658 198.24903 -928.03261 677.96546 739.35433 145.56163 0 -552.34431 513084.77 -515023.34 9.5625031 25809.75 282.48418 1.436009 300.29464 279.71597 1.436009 + 1440 104.66752 547.12666 1527.8761 205.11036 -980.74947 650.61377 711.8671 147.59824 0 -556.66671 513090.53 -515024.69 1019.1836 25808.157 292.23402 1.5483375 300.12772 291.11848 1.5483375 + 1460 106.50314 545.65053 1490.3999 200.07935 -944.74941 670.75445 719.7737 150.18449 0 -549.39105 513087.25 -515023.32 -1319.4425 25807.672 285.07809 1.4821899 301.34029 282.56847 1.4823299 + 1480 108.28741 544.77516 1526.097 204.87152 -981.32183 652.3433 696.79415 149.20209 0 -556.6563 513098.18 -515021.18 -742.16174 25805.656 292.01497 1.2636175 302.51451 290.4664 1.2639932 + 1500 110.12511 545.19541 1545.583 207.48742 -1000.3876 645.73389 715.44716 136.9985 0 -567.26011 513090.87 -515022.18 -400.28471 25802.486 295.86865 0.987897 302.34922 294.99013 0.987897 + 1520 111.89057 546.1418 1523.2045 204.48322 -977.06274 643.78664 737.65713 128.87884 0 -556.6123 513087.83 -515018.61 382.6378 25799.004 291.65193 0.81691637 299.79434 290.49472 0.81691637 + 1540 113.68915 548.12322 1532.5317 205.73534 -984.40845 662.00085 713.14115 141.83628 0 -546.54637 513065.85 -515020.69 -558.02865 25796.128 293.49257 0.69415483 292.07299 293.92389 0.69415483 + 1560 115.74426 551.58749 1524.0291 204.59391 -972.44159 662.89347 709.62799 163.91089 0 -538.91833 513050.59 -515020.55 -1648.6737 25792.534 291.9015 0.60340834 283.91962 293.42109 0.60340834 + 1580 118.02455 556.31359 1557.1932 209.04604 -1000.8797 650.22504 703.18471 164.34921 0 -547.76291 513048.79 -515019.67 218.40066 25787.071 298.26162 0.59762744 279.75915 301.53187 0.59762744 + 1600 119.98362 561.8489 1536.2864 206.2394 -974.4375 650.4012 725.52549 152.37926 0 -524.6233 513039.24 -515017.36 724.91327 25782.038 294.23674 0.63726972 276.89513 297.31161 0.63726972 + 1620 121.24569 568.29298 1516.8518 203.6304 -948.55886 669.43634 758.17152 141.59579 0 -508.64869 513005.84 -515014.95 305.45057 25778.393 290.46698 0.74019001 276.01771 293.0592 0.74019001 + 1640 122.52086 575.42679 1531.3719 205.57965 -955.94515 683.26836 731.47049 143.09022 0 -504.62735 513005.89 -515015.04 -1258.1839 25775.243 293.18351 0.89655264 276.95868 296.07228 0.89655264 + 1660 123.85319 583.33428 1520.971 204.18338 -937.63676 670.138 752.36615 158.20486 0 -497.10065 512993.63 -515014.87 990.4476 25771.018 291.11283 1.0757415 276.8874 293.66833 1.0757415 + 1680 125.13263 591.99646 1532.4661 205.72654 -940.46967 689.25478 743.16987 168.03522 0 -502.0189 512975.1 -515014.01 1349.4251 25768.301 293.2049 1.3360644 279.26444 295.71449 1.3360644 + 1700 126.41729 600.72595 1576.928 211.69534 -976.20204 698.82384 728.20266 164.32429 0 -509.63109 512960.78 -515018.71 -714.74537 25767.499 301.65964 1.4963853 288.03969 304.12166 1.4963853 + 1720 127.8002 608.72776 1572.2293 211.06457 -963.50155 686.50487 751.5254 162.66596 0 -520.30848 512974.4 -515018.29 -1233.7505 25765.895 300.75432 1.507047 296.46478 301.66689 1.507047 + 1740 129.05369 615.86972 1571.5987 210.97992 -955.72903 672.03255 760.03518 170.57691 0 -531.78859 512987.74 -515014.32 -5.6954413 25762.646 300.66959 1.422713 303.78613 300.35269 1.422713 + 1760 130.46587 622.55796 1579.5377 212.04568 -956.97974 706.80226 734.80437 178.63803 0 -529.02192 512966.71 -515014.91 1439.5408 25759.728 302.30266 1.1633531 310.55359 301.13515 1.1641118 + 1780 131.77476 628.52662 1584.4407 212.70388 -955.91404 676.79766 773.29727 172.22703 0 -534.56221 512976.35 -515020.03 -1144.3707 25758.632 303.36936 0.86750014 314.93649 301.6529 0.86760316 + 1800 133.12003 634.21603 1614.4896 216.73781 -980.27353 677.17437 758.17735 157.86038 0 -522.96761 512972.14 -515022.66 -952.36111 25756.246 309.15671 0.80472277 318.00054 307.89448 0.80488217 + 1820 134.41588 639.49479 1633.2745 219.2596 -993.77971 706.25176 736.76382 153.75695 0 -523.32693 512955.21 -515022.44 534.27821 25752.618 312.8094 0.68438418 326.33448 310.77281 0.68437053 + 1840 135.69809 643.87101 1634.8429 219.47015 -990.97185 701.84421 766.76216 151.35177 0 -502.94871 512911.91 -515019.89 654.67154 25749.912 313.13395 0.62866073 330.35595 310.48258 0.62856511 + 1860 137.01849 646.9769 1624.5262 218.08519 -977.54933 717.81093 788.02881 151.94179 0 -495.90915 512881.92 -515021.34 -1064.2782 25748.146 311.14125 0.66359764 330.55161 308.12656 0.66359764 + 1880 138.29577 648.32991 1639.5616 220.10361 -991.23166 726.93665 759.79041 159.81907 0 -493.81895 512873.87 -515017.83 -1411.6366 25744.916 313.99078 0.74007658 329.3198 311.65549 0.74007658 + 1900 139.67366 648.89417 1644.4291 220.75706 -995.53493 724.72865 762.39029 163.96612 0 -495.61342 512866.53 -515017.54 1351.1833 25740.228 314.85836 0.89300573 324.54001 313.46241 0.89316115 + 1920 140.93714 648.51479 1660.4204 222.90381 -1011.9056 683.6849 759.17365 164.85228 0 -494.26512 512891.03 -515016.38 401.57284 25737.361 317.86954 1.0199045 319.35529 317.83552 1.0202343 + 1940 142.29997 646.69169 1612.2108 216.43189 -965.51908 714.97385 778.57354 175.15205 0 -508.7717 512893.53 -515018.97 -1076.6986 25735.181 308.53939 1.2258299 312.47436 308.09188 1.2258299 + 1960 143.5485 643.66804 1612.4723 216.467 -968.80423 729.94319 778.86473 177.62474 0 -483.88964 512849.44 -515020.79 -696.10678 25731.708 308.50602 1.4206534 300.71602 310.00483 1.4206534 + 1980 144.89715 639.49991 1600.0251 214.79602 -960.52514 725.68053 773.8468 176.16615 0 -469.86188 512851.09 -515017.45 822.18174 25727.586 306.08335 1.5058554 291.63271 308.68799 1.505066 + 2000 146.15013 633.86554 1648.9263 221.36078 -1015.0607 703.29388 761.03433 170.08933 0 -468.34451 512835.81 -515016.94 763.74636 25724.778 315.51687 1.3681009 284.57812 320.86295 1.3683497 +Loop time of 146.15 on 1 procs for 2000 steps with 3000 atoms + +Performance: 0.591 ns/day, 40.597 hours/ns, 13.685 timesteps/s +100.0% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 92.462 | 92.462 | 92.462 | 0.0 | 63.26 +Bond | 2.9377 | 2.9377 | 2.9377 | 0.0 | 2.01 +Kspace | 28.493 | 28.493 | 28.493 | 0.0 | 19.50 +Neigh | 4.3811 | 4.3811 | 4.3811 | 0.0 | 3.00 +Comm | 0.86167 | 0.86167 | 0.86167 | 0.0 | 0.59 +Output | 0.040132 | 0.040132 | 0.040132 | 0.0 | 0.03 +Modify | 16.886 | 16.886 | 16.886 | 0.0 | 11.55 +Other | | 0.08886 | | | 0.06 + +Nlocal: 3000.00 ave 3000 max 3000 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 10696.0 ave 10696 max 10696 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 737603.0 ave 737603 max 737603 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 737603 +Ave neighs/atom = 245.86767 +Ave special neighs/atom = 10.500000 +Neighbor list builds = 59 +Dangerous builds = 0 +Total wall time: 0:02:26 diff --git a/examples/USER/drude/ethanol/log.12Nov20.ethanol.tgnh.g++.4 b/examples/USER/drude/ethanol/log.12Nov20.ethanol.tgnh.g++.4 new file mode 100644 index 0000000000..d8b7046fbc --- /dev/null +++ b/examples/USER/drude/ethanol/log.12Nov20.ethanol.tgnh.g++.4 @@ -0,0 +1,287 @@ +LAMMPS (29 Oct 2020) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:94) + using 1 OpenMP thread(s) per MPI task +units real +boundary p p p + +atom_style full +bond_style harmonic +angle_style harmonic +dihedral_style opls +special_bonds lj/coul 0.0 0.0 0.5 + +pair_style hybrid/overlay lj/cut/coul/long 8.0 8.0 thole 2.600 8.0 +kspace_style pppm 1.0e-4 + +comm_modify vel yes +read_data data.ethanol +Reading data file ... + orthogonal box = (-14.013845 -14.027809 -14.018882) to (14.016930 14.017730 14.085730) + 1 by 2 by 2 MPI processor grid + reading atoms ... + 3000 atoms + scanning bonds ... + 5 = max bonds/atom + scanning angles ... + 6 = max angles/atom + scanning dihedrals ... + 9 = max dihedrals/atom + reading bonds ... + 2750 bonds + reading angles ... + 3250 angles + reading dihedrals ... + 3000 dihedrals +Finding 1-2 1-3 1-4 neighbors ... + special bond factors lj: 0.0 0.0 0.5 + special bond factors coul: 0.0 0.0 0.5 + 5 = max # of 1-2 neighbors + 6 = max # of 1-3 neighbors + 10 = max # of 1-4 neighbors + 11 = max # of special neighbors + special bonds CPU = 0.003 seconds + read_data CPU = 0.115 seconds + +pair_coeff 1 1 lj/cut/coul/long 0.065997 3.500000 # C3H C3H +pair_coeff 1 2 lj/cut/coul/long 0.065997 3.500000 # C3H CTO +pair_coeff 1 3 lj/cut/coul/long 0.044496 2.958040 # C3H H +pair_coeff 1 4 lj/cut/coul/long 0.105921 3.304542 # C3H OH +pair_coeff 1 5 lj/cut/coul/long 0.000000 0.000000 # C3H HO +pair_coeff 2 2 lj/cut/coul/long 0.065997 3.500000 # CTO CTO +pair_coeff 2 3 lj/cut/coul/long 0.044496 2.958040 # CTO H +pair_coeff 2 4 lj/cut/coul/long 0.105921 3.304542 # CTO OH +pair_coeff 2 5 lj/cut/coul/long 0.000000 0.000000 # CTO HO +pair_coeff 3 3 lj/cut/coul/long 0.029999 2.500000 # H H +pair_coeff 3 4 lj/cut/coul/long 0.071413 2.792848 # H OH +pair_coeff 3 5 lj/cut/coul/long 0.000000 0.000000 # H HO +pair_coeff 4 4 lj/cut/coul/long 0.169996 3.120000 # OH OH +pair_coeff 4 5 lj/cut/coul/long 0.000000 0.000000 # OH HO +pair_coeff 5 5 lj/cut/coul/long 0.000000 0.000000 # HO HO +pair_coeff * 6*8 lj/cut/coul/long 0.000000 0.000000 # No lj for drudes +pair_coeff 1 1 thole 2.051000 +pair_coeff 1 2 thole 1.580265 +pair_coeff 1 4 thole 1.416087 +pair_coeff 1 6 thole 2.051000 +pair_coeff 1 7 thole 1.580265 +pair_coeff 1 8 thole 1.416087 +pair_coeff 2 2 thole 1.217570 +pair_coeff 2 4 thole 1.091074 +pair_coeff 2 6 thole 1.580265 +pair_coeff 2 7 thole 1.217570 +pair_coeff 2 8 thole 1.091074 +pair_coeff 4 4 thole 0.977720 +pair_coeff 4 6 thole 1.416087 +pair_coeff 4 7 thole 1.091074 +pair_coeff 4 8 thole 0.977720 +pair_coeff 6 6 thole 2.051000 +pair_coeff 6 7 thole 1.580265 +pair_coeff 6 8 thole 1.416087 +pair_coeff 7 7 thole 1.217570 +pair_coeff 7 8 thole 1.091074 +pair_coeff 8 8 thole 0.977720 + +group gETHANOL molecule 1:250 +3000 atoms in group gETHANOL +group gATOMS type 1 2 3 4 5 +2250 atoms in group gATOMS +group gDRUDES type 6 7 8 +750 atoms in group gDRUDES + +neighbor 2.0 bin + +variable vTEMP equal 300.0 +variable vTEMP_D equal 1.0 +variable vPRESS equal 1.0 + +velocity gATOMS create ${vTEMP} 12345 +velocity gATOMS create 300 12345 +velocity gDRUDES create ${vTEMP_D} 12345 +velocity gDRUDES create 1 12345 + +fix fDRUDE all drude C C N C N D D D + +fix fSHAKE gATOMS shake 0.0001 20 0 b 2 3 5 + 250 = # of size 2 clusters + 250 = # of size 3 clusters + 250 = # of size 4 clusters + 0 = # of frozen angles + find clusters CPU = 0.001 seconds + +fix fNPT all tgnpt/drude temp ${vTEMP} ${vTEMP} 100.0 ${vTEMP_D} 20.0 iso ${vPRESS} ${vPRESS} 1000 +fix fNPT all tgnpt/drude temp 300 ${vTEMP} 100.0 ${vTEMP_D} 20.0 iso ${vPRESS} ${vPRESS} 1000 +fix fNPT all tgnpt/drude temp 300 300 100.0 ${vTEMP_D} 20.0 iso ${vPRESS} ${vPRESS} 1000 +fix fNPT all tgnpt/drude temp 300 300 100.0 1 20.0 iso ${vPRESS} ${vPRESS} 1000 +fix fNPT all tgnpt/drude temp 300 300 100.0 1 20.0 iso 1 ${vPRESS} 1000 +fix fNPT all tgnpt/drude temp 300 300 100.0 1 20.0 iso 1 1 1000 + +compute cTEMP all temp/drude + +thermo_style custom step cpu etotal ke temp pe ebond eangle edihed eimp evdwl ecoul elong press vol c_cTEMP[1] c_cTEMP[2] f_fNPT[1] f_fNPT[2] f_fNPT[3] +thermo 20 + +timestep 0.5 +run 2000 +PPPM initialization ... + using 12-bit tables for long-range coulomb (src/kspace.cpp:328) + G vector (1/distance) = 0.37973843 + grid = 30 30 30 + stencil order = 5 + estimated absolute RMS force accuracy = 0.028997858 + estimated relative force accuracy = 8.7326188e-05 + using double precision FFTW3 + 3d grid and FFT values/proc = 17908 7200 +Rebuild special list taking Drude particles into account +Old max number of 1-2 to 1-4 neighbors: 11 +New max number of 1-2 to 1-4 neighbors: 11 (+0) +Neighbor list info ... + update every 1 steps, delay 10 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 10 + ghost atom cutoff = 10 + binsize = 5, bins = 6 6 6 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair lj/cut/coul/long, perpetual + attributes: half, newton on + pair build: half/bin/newton + stencil: half/bin/3d/newton + bin: standard + (2) pair thole, perpetual, skip from (1) + attributes: half, newton on + pair build: skip + stencil: none + bin: none +TGNHC thermostat for Drude model + DOFs of molecules, atoms and dipoles: 747.0 4500.0 2250.0 +Per MPI rank memory allocation (min/avg/max) = 16.30 | 16.32 | 16.34 Mbytes +Step CPU TotEng KinEng Temp PotEng E_bond E_angle E_dihed E_impro E_vdwl E_coul E_long Press Volume c_cTEMP[1] c_cTEMP[2] f_fNPT[1] f_fNPT[2] f_fNPT[3] + 0 0 13868.828 2013.3852 270.28772 11855.443 3145.896 51.880809 0.00019113234 0 8481.5109 514734.14 -514557.98 170210.19 22094.109 381.62759 10.134301 291.07893 396.91308 10.134301 + 20 0.5489804 9803.4819 5175.7976 694.82706 4627.6843 1139.1179 2334.7381 132.32214 0 1890.1377 514082.74 -514951.37 83147.098 22175.037 987.97841 9.8830686 2458.1459 744.58371 9.8830686 + 40 1.1305859 9235.5604 5579.723 749.0522 3655.8374 905.64066 1897.9743 277.47993 0 1696.6152 513843.93 -514965.8 60300.791 22359.784 1068.9531 1.6180875 2851.9045 773.69577 1.6180875 + 60 1.7763265 8672.0018 5504.7529 738.98781 3167.2488 829.16747 2052.5807 330.50296 0 997.97233 513948.23 -514991.2 48877.822 22600.434 1054.8974 0.8814188 3046.2785 725.0302 0.8814188 + 80 2.3974232 8041.5241 5718.5668 767.69134 2322.9573 733.63486 1714.8909 332.16188 0 607.44872 513906.01 -514971.19 46157.199 22855.699 1095.9682 0.68487797 2911.1669 795.37545 0.68487797 + 100 3.0302813 7424.2386 5485.3388 736.38155 1938.8999 725.65842 1556.2309 334.30067 0 311.29882 513993.24 -514981.83 35648.625 23094.994 1051.3251 0.52778467 2722.3899 774.63067 0.52778467 + 120 3.6273007 6864.3426 5106.0771 685.46741 1758.2655 639.83956 1608.9962 330.73079 0 225.62345 513930.12 -514977.04 28591.458 23302.572 978.66797 0.41866327 2531.1648 721.6052 0.41866327 + 140 4.196656 6355.3019 4782.0272 641.9652 1573.2747 692.74007 1572.242 329.76251 0 62.485696 513879.64 -514963.6 24167.635 23482.68 916.57384 0.35834425 2382.631 673.81858 0.35834425 + 160 4.779717 5871.7118 4610.7111 618.9668 1261.0006 680.57069 1414.3177 329.24321 0 -159.81123 513987.38 -514990.7 27541.231 23647.415 883.72945 0.36200572 2123.9268 678.44584 0.36200572 + 180 5.338641 5435.6217 4279.7314 574.5343 1155.8903 684.86021 1423.9782 309.42239 0 -233.49805 513945.42 -514974.29 18687.102 23808.747 820.29876 0.31648848 1867.6601 646.98347 0.31648848 + 200 5.9102262 5063.7313 3974.8766 533.60893 1088.8548 610.8373 1399.1355 299.45065 0 -238.66713 514006.14 -514988.04 14346.964 23962.508 761.84531 0.34591369 1649.624 614.98194 0.34591369 + 220 6.4670983 4729.6679 3862.1203 518.47192 867.54758 589.19356 1361.7383 291.57325 0 -382.16606 514000.72 -514993.51 14083.524 24105.992 740.21525 0.37963928 1480.8429 617.76448 0.37963928 + 240 7.0337756 4425.2126 3701.4126 496.89765 723.79998 584.3439 1295.3888 282.13205 0 -468.28082 514014.44 -514984.22 13173.086 24240.879 709.38377 0.43418988 1335.0115 606.00249 0.43418988 + 260 7.6151553 4147.9089 3443.8677 462.32342 704.04123 561.65864 1304.8745 277.43914 0 -505.26328 514062.78 -514997.45 9958.5179 24367.421 659.97189 0.52765671 1202.5793 570.33937 0.52753359 + 280 8.1803862 3906.1678 3262.9801 438.0401 643.18765 611.98615 1259.2636 278.89902 0 -503.31011 513978.3 -514981.95 5914.4091 24482.749 625.21285 0.7191852 1076.0582 550.78956 0.7191852 + 300 8.7043311 3688.7789 3139.2097 421.42449 549.56918 589.70836 1228.8579 274.66549 0 -529.44562 513979.71 -514993.93 8820.6294 24584.968 601.2678 1.2327257 967.30569 540.9051 1.2327257 + 320 9.2828722 3485.0301 3041.6251 408.32421 443.40492 581.268 1221.8962 276.57911 0 -581.90861 513938.2 -514992.63 9180.621 24679.345 582.26671 1.9139563 865.07721 535.70848 1.9139563 + 340 9.8440863 3301.0782 2892.3054 388.27872 408.77286 575.63973 1150.7154 289.94072 0 -522.07034 513896.97 -514982.42 7703.8271 24768.334 553.40856 2.4558958 782.77492 515.70254 2.4558958 + 360 10.398275 3134.468 2727.432 366.14522 407.03603 560.03929 1167.6565 290.68699 0 -534.30813 513917.05 -514994.09 5177.6501 24851.165 521.97249 2.0603668 720.8089 489.31359 2.0603668 + 380 10.971208 2978.8927 2626.9512 352.65614 351.94143 566.26677 1159.7933 275.53948 0 -574.10697 513905.99 -514981.54 5406.9463 24926.487 502.95796 1.4831172 663.80755 476.59194 1.4833313 + 400 11.487591 2830.3779 2572.5528 345.3534 257.82518 609.13682 1122.447 253.59547 0 -631.51589 513897.17 -514993.01 6594.5632 24996.158 492.72116 1.0347263 619.38728 472.02151 1.0352452 + 420 12.147771 2690.8114 2511.4485 337.15043 179.36289 580.62912 1054.4972 245.98614 0 -619.15187 513904.39 -514986.98 3340.3887 25062.398 481.15102 0.69884987 565.60536 467.45245 0.69884987 + 440 12.683915 2567.8386 2417.1223 324.48758 150.71626 550.84021 1061.6154 248.79898 0 -625.11745 513892.15 -514977.57 1516.8529 25122.396 463.15967 0.48668891 522.23117 453.66261 0.48668891 + 460 13.219765 2452.4983 2377.8819 319.21973 74.616329 562.85065 1024.1437 240.77499 0 -664.71238 513899.97 -514988.41 2625.4899 25175.085 455.6735 0.40127583 488.72927 450.48999 0.40127583 + 480 13.734817 2343.3317 2306.9816 309.70169 36.35008 544.98865 1036.7003 239.14437 0 -646.5969 513844.75 -514982.63 4826.9949 25223.402 442.07562 0.41558073 466.54905 438.30802 0.41558073 + 500 14.2704 2236.968 2183.0006 293.0578 53.967445 569.68824 1077.5153 241.06612 0 -644.36418 513802.58 -514992.52 3137.1149 25270.633 418.31485 0.39923526 447.67208 413.72065 0.39935381 + 520 14.830149 2139.9757 2184.3136 293.23408 -44.337922 598.68848 949.68592 231.65813 0 -640.55841 513811.34 -514995.15 74.532539 25314.977 418.54937 0.44074429 424.27621 417.87775 0.44074429 + 540 15.342945 2047.7713 2097.3453 281.55898 -49.574068 603.65225 992.19405 234.95516 0 -644.08949 513763.2 -514999.49 2503.1827 25353.667 401.80131 0.61813129 402.19428 402.00395 0.61813129 + 560 15.876281 1959.9733 2106.7002 282.81483 -146.72689 554.39132 933.09924 226.68229 0 -642.41154 513779.76 -514998.25 3929.9055 25390.434 403.5098 0.81842484 386.57171 406.59055 0.81842484 + 580 16.38257 1878.3658 2030.0966 272.53115 -151.7308 563.56362 914.74758 216.22925 0 -639.68928 513785.76 -514992.34 1013.3048 25427.188 388.65548 1.2108332 381.10541 390.16777 1.2108332 + 600 16.920685 1802.551 2017.1476 270.7928 -214.59656 542.55586 900.05624 215.01335 0 -670.18556 513796.03 -514998.07 18.493782 25460.775 385.93337 1.7700661 377.13463 387.65116 1.7700661 + 620 17.474131 1730.0309 1927.5545 258.76534 -197.52353 548.09305 912.68313 219.66229 0 -677.86412 513801.32 -515001.42 211.58879 25489.947 368.6727 1.9725715 368.40356 368.96285 1.9725715 + 640 17.983631 1659.1463 1874.5489 251.64958 -215.40256 560.91381 910.47755 215.67628 0 -668.88025 513765.74 -514999.33 3576.6139 25516.217 358.58525 1.8035012 356.22593 359.21531 1.8035012 + 660 18.557287 1589.2837 1850.4075 248.40872 -261.12386 578.2925 854.48492 205.27001 0 -645.94735 513747.59 -515000.82 1704.7835 25543.749 354.0776 1.5147284 344.22319 355.94967 1.5157289 + 680 19.099188 1523.7572 1809.2809 242.88766 -285.52371 571.10597 870.42753 209.32749 0 -670.04285 513734.83 -515001.17 -730.02178 25570.285 346.40935 1.010892 331.62309 349.09523 1.010892 + 700 19.606934 1462.426 1781.0971 239.10411 -318.67111 547.9598 858.22372 204.5839 0 -674.26004 513742.06 -514997.24 1193.1019 25593.123 341.12225 0.74301975 322.22823 344.48583 0.74301975 + 720 20.138988 1403.965 1772.7176 237.9792 -368.75257 537.38813 872.15383 187.31368 0 -658.83726 513691.57 -514998.34 1717.9835 25614.736 339.57934 0.59520661 315.58412 343.78893 0.59520661 + 740 20.654731 1347.9142 1778.2063 238.71603 -430.29207 554.12065 833.24568 175.13397 0 -676.57227 513685.79 -515002.01 1164.2855 25636.35 340.66194 0.52336173 311.70411 345.69611 0.52336173 + 760 21.20085 1294.8201 1727.5363 231.91382 -432.71627 562.83637 826.41881 177.39944 0 -670.89859 513677.68 -515006.15 -2179.3296 25656.719 330.96325 0.48927201 305.61756 335.39128 0.48927201 + 780 21.736798 1244.1479 1729.459 232.17193 -485.31103 563.29093 800.45744 179.65918 0 -660.60078 513641.9 -515010.01 140.35372 25672.399 331.32725 0.49993893 293.14787 337.88591 0.49993893 + 800 22.313875 1195.9276 1716.8118 230.47411 -520.8842 572.20526 790.59915 174.22123 0 -646.04585 513597.21 -515009.08 2706.2932 25686.61 328.8596 0.60065349 282.54175 336.7676 0.60065349 + 820 22.880819 1149.3267 1681.646 225.75325 -532.31925 564.24784 783.06404 168.40012 0 -638.53799 513598.2 -515007.69 291.5994 25702.646 322.07401 0.70343079 279.53588 329.34955 0.70332477 + 840 23.400356 1107.2877 1640.6002 220.24304 -533.31252 558.56409 815.12167 157.71519 0 -653.87313 513597.92 -515008.76 -762.24777 25717.669 314.07832 1.0007715 278.89623 320.12842 1.0010942 + 860 23.930137 1066.5896 1621.3757 217.66224 -554.78609 569.30332 821.05893 152.83409 0 -645.45431 513552.23 -515004.75 100.50325 25730.157 310.25167 1.3271389 283.08497 314.96823 1.3271389 + 880 24.425549 1027.6567 1624.8454 218.12803 -597.18868 587.96681 765.45362 159.91238 0 -628.42404 513525.88 -515007.98 2270.6911 25741.827 310.74777 1.7225758 280.31191 316.00736 1.7225758 + 900 24.945527 989.67183 1619.7368 217.44223 -630.06494 605.34666 753.15286 166.12808 0 -637.67643 513491.85 -515008.87 -504.34781 25755.03 309.75098 1.7673447 280.95321 314.73839 1.7673447 + 920 25.481976 952.75609 1646.0573 220.97563 -693.30118 586.10824 737.80362 161.44982 0 -645.91448 513480.65 -515013.4 -2245.0436 25766.26 314.83888 1.6620102 286.24272 319.79545 1.6618169 + 940 26.009417 916.27341 1558.2262 209.18472 -641.95282 584.88671 784.61327 161.29551 0 -636.55462 513482.98 -515019.17 351.20595 25773.56 298.17626 1.2572795 293.25423 299.19214 1.2573671 + 960 26.54868 881.26579 1570.5631 210.84088 -689.29727 567.48803 757.85558 154.89763 0 -628.37927 513476.62 -515017.78 1224.7198 25780.472 300.67272 0.95167357 297.40913 301.41483 0.95167357 + 980 27.082306 848.00567 1563.3504 209.87262 -715.34478 576.51161 766.15302 148.2325 0 -637.27495 513450.83 -515019.79 -304.57224 25788.336 299.38564 0.72910884 295.89994 300.16415 0.72910884 + 1000 27.619404 817.47747 1553.8221 208.59349 -736.34466 586.86696 709.60783 150.55877 0 -608.57994 513440.8 -515015.6 -1422.5332 25794.968 297.60262 0.62762006 294.24682 298.35812 0.62773318 + 1020 28.12313 789.1786 1563.9655 209.95519 -774.78691 608.04057 694.03517 152.80101 0 -605.61567 513386.72 -515010.76 1005.4938 25799.349 299.58342 0.54306229 290.32557 301.31971 0.54293571 + 1040 28.647646 762.65087 1534.0005 205.93252 -771.3496 587.61838 735.74998 150.09823 0 -603.04152 513371.63 -515013.4 1470.8094 25804.634 293.84005 0.54036941 291.28531 294.46003 0.54036941 + 1060 29.166844 737.77923 1518.4576 203.84597 -780.67842 594.18573 720.72071 149.63679 0 -601.17736 513365.82 -515009.86 -729.10372 25811.329 290.84548 0.57532052 295.86391 290.20631 0.57532052 + 1080 29.694185 715.33941 1497.4861 201.03063 -782.14665 601.83156 732.61956 157.72044 0 -593.12281 513331.09 -515012.29 -1329.475 25816.507 286.76945 0.70534246 298.86373 284.95298 0.70534246 + 1100 30.187888 694.69953 1511.5454 202.91803 -816.84589 616.66719 703.13897 158.99611 0 -577.76244 513295.95 -515013.83 324.57282 25819.509 289.39998 0.85625823 302.74025 287.37843 0.85625823 + 1120 30.72232 675.80012 1511.985 202.97705 -836.18488 604.64779 695.06693 153.9432 0 -584.60486 513304.31 -515009.54 1125.7488 25822.677 289.3669 1.1300709 304.44007 287.0563 1.1300629 + 1140 31.225571 658.36551 1521.8389 204.29988 -863.47335 629.12728 674.88861 150.24405 0 -590.89933 513286.66 -515013.49 -980.39731 25826.849 291.15043 1.376207 307.33908 288.65717 1.3761333 + 1160 31.744542 641.31431 1531.9582 205.65836 -890.64389 626.42495 680.62653 148.56061 0 -577.09298 513242.55 -515011.72 -1275.5851 25829.398 292.96469 1.6693561 303.6583 291.38487 1.6693561 + 1180 32.314241 624.85166 1471.4431 197.53448 -846.59145 617.3346 711.86666 153.07391 0 -572.06725 513251.25 -515008.05 1129.9547 25830.175 281.38976 1.6087801 294.57721 279.38824 1.6087801 + 1200 32.836834 609.19491 1498.3739 201.14982 -889.17902 629.25511 684.67985 160.94667 0 -569.8543 513217.89 -515012.1 714.83828 25832.193 286.64705 1.3880783 283.02115 287.44058 1.3888122 + 1220 33.330996 594.74278 1478.8355 198.52688 -884.09277 636.92004 698.39685 160.32561 0 -562.35565 513195.99 -515013.37 -758.81758 25835.054 283.01514 1.1229017 278.46407 283.95841 1.1229296 + 1240 33.860993 582.31866 1493.1918 200.45414 -910.87313 618.74977 681.25809 152.31533 0 -562.54483 513217.1 -515017.75 -1008.5931 25836.703 285.8671 0.88995954 281.0699 286.85402 0.88995954 + 1260 34.359886 571.65412 1485.3064 199.39557 -913.6523 627.02685 698.36302 149.47819 0 -579.83549 513207.17 -515015.85 -191.59975 25836.765 284.43438 0.70581205 287.41841 284.12865 0.70581205 + 1280 34.886036 563.01807 1489.0976 199.90452 -926.07957 639.7656 697.32018 156.99221 0 -585.76217 513181.62 -515016.02 169.07813 25836.47 285.20229 0.61087596 293.46017 284.02179 0.61087596 + 1300 35.37543 555.84411 1527.2006 205.01966 -971.35646 641.09274 662.1865 159.13537 0 -579.97157 513161.92 -515015.72 -1463.4981 25836.182 292.51734 0.58590366 295.34409 292.24276 0.58590366 + 1320 35.905183 550.05933 1490.5448 200.09879 -940.48543 625.52991 696.21744 165.64927 0 -566.29494 513152.4 -515013.99 -1001.3282 25833.961 285.49188 0.58134778 295.28397 284.05681 0.58136859 + 1340 36.400304 545.82552 1477.3653 198.3295 -931.53974 649.76738 698.13673 166.18782 0 -561.79356 513131.65 -515015.49 256.39573 25830.414 282.92884 0.6685389 293.55866 281.35291 0.66910289 + 1360 36.922034 543.45958 1491.565 200.23575 -948.10541 625.58496 716.94864 163.71131 0 -571.55519 513134.22 -515017.02 297.35038 25827.363 285.59777 0.79202277 296.88495 283.9144 0.79202277 + 1380 37.451357 542.88076 1508.4282 202.49956 -965.54741 646.84583 717.12486 157.01613 0 -570.9963 513101.79 -515017.33 -727.70264 25824.817 288.73715 1.0078391 299.43294 287.15417 1.0078391 + 1400 37.973437 543.25917 1541.9768 207.00331 -998.71768 642.88473 676.64442 147.18972 0 -575.45961 513127.78 -515017.75 -1351.9224 25821.311 295.05395 1.2758201 298.33888 294.70535 1.2758201 + 1420 38.477087 544.25328 1494.226 200.59298 -949.97275 637.44698 691.08413 146.44269 0 -570.05548 513163.4 -515018.29 -270.25101 25816.213 285.82275 1.45608 293.72434 284.70163 1.45608 + 1440 39.004978 546.23983 1496.1396 200.84988 -949.89981 631.74619 738.457 152.80933 0 -573.9543 513118.44 -515017.39 211.73327 25811.001 286.12443 1.60978 287.34634 286.11175 1.60978 + 1460 39.506582 548.84457 1466.6766 196.8946 -917.83206 633.37692 721.14643 162.99807 0 -556.88904 513139.89 -515018.35 -423.45238 25806.343 280.53109 1.4808771 287.46457 279.56727 1.4808771 + 1480 40.013021 551.95616 1529.776 205.3654 -977.81982 643.3714 687.91646 168.45052 0 -559.19128 513096.53 -515014.9 -1060.0608 25801.347 292.71931 1.2657554 295.62549 292.43217 1.2657554 + 1500 40.538129 555.97974 1537.2966 206.37501 -981.31688 625.22061 717.66026 158.35427 0 -572.42591 513106.71 -515016.83 -521.38973 25795.193 294.26369 1.0278009 305.22402 292.64051 1.0278009 + 1520 41.025889 561.04463 1546.2574 207.57796 -985.21278 635.77714 721.02166 143.98506 0 -562.3667 513090.07 -515013.7 480.66458 25788.679 296.07983 0.80049966 308.03207 294.29295 0.80049966 + 1540 41.55805 566.68767 1533.2704 205.83452 -966.58278 654.42171 733.05018 143.06827 0 -536.78594 513051.91 -515012.25 -13.266306 25783.154 293.62787 0.70845158 300.7356 292.64315 0.70845158 + 1560 42.081834 573.47741 1545.9514 207.53687 -972.47397 667.35837 705.11749 148.50883 0 -511.03863 513035.3 -515017.72 -1128.9314 25777.865 296.082 0.65411382 299.13367 295.77283 0.65411382 + 1580 42.665773 580.84578 1594.8648 214.10328 -1014.0191 665.14281 711.19644 150.09976 0 -528.59268 513008.73 -515020.6 202.40236 25771.588 305.48503 0.59346496 305.13087 305.74762 0.59346496 + 1600 43.198806 587.93053 1593.0533 213.8601 -1005.1228 667.00914 717.18229 154.08514 0 -518.43498 512998.02 -515022.99 1129.067 25765.95 305.11474 0.64754135 305.66863 305.22598 0.64754135 + 1620 43.714818 594.73059 1540.0228 206.74099 -945.29217 676.98346 739.79112 155.99494 0 -494.24155 512994.51 -515018.33 526.11962 25762.249 294.90314 0.75499506 297.8325 294.6134 0.75499506 + 1640 44.259458 602.01816 1574.0462 211.30848 -972.02805 663.3896 727.17417 151.24073 0 -494.0956 513000.57 -515020.3 -575.47503 25759.514 301.37613 0.86690808 296.74738 302.34638 0.86686227 + 1660 44.764134 609.8688 1585.4465 212.83891 -975.57766 664.90151 754.20462 143.39975 0 -512.60013 512995.21 -515020.69 120.01767 25756.288 303.44799 1.1375937 302.29356 303.8427 1.1375483 + 1680 45.295079 617.0121 1599.4294 214.71606 -982.41735 673.71348 740.31978 139.29744 0 -523.39592 513004.17 -515016.52 1018.995 25753.537 306.06349 1.2857605 306.24911 306.23701 1.2851446 + 1700 45.797194 622.7816 1587.5062 213.11542 -964.72461 681.14985 737.5354 142.64373 0 -527.89471 513016.69 -515014.85 -762.54382 25752.152 303.67113 1.5346092 313.56414 302.2316 1.5344941 + 1720 46.320299 627.3514 1607.6889 215.82486 -980.33755 664.85413 752.47086 151.63477 0 -558.53514 513025.83 -515016.59 -1533.2781 25749.855 307.5455 1.5204255 324.85436 304.8785 1.5204255 + 1740 46.830115 630.51695 1598.6908 214.6169 -968.17382 653.58364 747.05167 160.79211 0 -580.54509 513063.86 -515012.91 -682.94257 25745.444 305.87278 1.3989272 333.2609 301.5297 1.3989272 + 1760 47.394788 632.38111 1593.237 213.88475 -960.85589 650.78705 764.11644 167.2889 0 -573.51639 513045.53 -515015.07 563.26755 25740.336 304.94629 1.1225547 334.94227 300.17035 1.1225547 + 1780 47.922889 633.30997 1598.6499 214.61141 -965.33996 653.54119 765.83593 164.00427 0 -562.23222 513033.51 -515020 -1327.8381 25735.912 306.08499 0.88668411 334.15679 301.62884 0.88668411 + 1800 48.463113 633.70382 1649.9701 221.50091 -1016.2663 659.96781 745.28779 159.23213 0 -549.62971 512990.43 -515021.55 -1220.9829 25730.022 315.99137 0.72802345 326.79654 314.40852 0.72802345 + 1820 48.984029 633.58292 1659.156 222.73407 -1025.573 665.57877 731.85128 149.46328 0 -533.84488 512983.77 -515022.39 259.29033 25722.788 317.77089 0.68459607 313.70692 318.65732 0.68459607 + 1840 49.535432 632.84896 1602.3796 215.1121 -969.53059 677.68273 790.85762 153.52845 0 -510.95603 512938.27 -515018.91 271.83168 25716.16 306.91304 0.62307528 301.73642 307.97704 0.62193772 + 1860 50.131212 631.44034 1614.3342 216.71695 -982.89384 704.07775 755.95641 164.4832 0 -496.35082 512910.85 -515021.91 193.91175 25710.384 309.1988 0.63700741 295.94067 311.60525 0.63654587 + 1880 50.855644 629.18958 1597.9323 214.51508 -968.74275 705.91154 777.10222 163.27419 0 -490.72673 512895.73 -515020.04 -974.53867 25705.004 306.00767 0.74633313 296.65573 307.7641 0.74633313 + 1900 51.442767 625.97644 1641.4591 220.35835 -1015.4827 686.52567 770.03702 156.74058 0 -497.98541 512884.62 -515015.42 634.14021 25698.897 314.30703 0.85093529 303.58173 316.29697 0.85093529 + 1920 52.143124 621.81199 1629.0055 218.68651 -1007.1935 697.66793 744.88149 154.37261 0 -496.80305 512905.46 -515012.77 706.77423 25693.859 311.83949 1.0371868 309.16955 312.48998 1.0372355 + 1940 52.903306 616.46004 1627.6423 218.50351 -1011.1823 701.93564 779.10792 151.5545 0 -486.4562 512854.72 -515012.04 -356.74685 25690.093 311.50393 1.2116518 310.99764 311.79486 1.2113866 + 1960 53.626542 609.78344 1638.9504 220.02157 -1029.167 696.4213 776.28011 154.35764 0 -474.71134 512832.29 -515013.81 -303.73538 25686.165 313.59711 1.3852662 315.5116 313.48837 1.3852662 + 1980 54.31028 600.96661 1637.173 219.78295 -1036.2064 718.42192 759.0789 153.6092 0 -472.50282 512815.84 -515010.66 -151.6766 25681.92 313.21609 1.4792586 321.24113 312.09275 1.4792586 + 2000 54.986641 589.81965 1648.0734 221.24629 -1058.2538 690.75922 747.98481 160.84305 0 -487.54224 512840.7 -515011 980.73982 25677.907 315.36457 1.3399431 321.77651 314.51049 1.3399431 +Loop time of 54.9868 on 4 procs for 2000 steps with 3000 atoms + +Performance: 1.571 ns/day, 15.274 hours/ns, 36.372 timesteps/s +98.8% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 27.901 | 28.34 | 29.027 | 7.9 | 51.54 +Bond | 0.92918 | 0.94546 | 0.97217 | 1.7 | 1.72 +Kspace | 14.647 | 15.356 | 15.836 | 11.2 | 27.93 +Neigh | 1.6543 | 1.6584 | 1.6622 | 0.2 | 3.02 +Comm | 1.5279 | 1.6227 | 1.7184 | 5.6 | 2.95 +Output | 0.022354 | 0.027337 | 0.040941 | 4.8 | 0.05 +Modify | 5.7813 | 6.226 | 6.5243 | 12.2 | 11.32 +Other | | 0.8108 | | | 1.47 + +Nlocal: 750.000 ave 763 max 736 min +Histogram: 1 0 0 0 1 0 1 0 0 1 +Nghost: 6184.00 ave 6204 max 6165 min +Histogram: 1 0 0 1 0 0 1 0 0 1 +Neighs: 185088.0 ave 189615 max 180533 min +Histogram: 2 0 0 0 0 0 0 0 0 2 + +Total # of neighbors = 740354 +Ave neighs/atom = 246.78467 +Ave special neighs/atom = 10.500000 +Neighbor list builds = 63 +Dangerous builds = 0 +Total wall time: 0:00:55 diff --git a/lib/plumed/Install.py b/lib/plumed/Install.py index 33bb40c9d9..c11d5bfee9 100644 --- a/lib/plumed/Install.py +++ b/lib/plumed/Install.py @@ -17,7 +17,7 @@ parser = ArgumentParser(prog='Install.py', # settings -version = "2.6.1" +version = "2.7.0" mode = "static" # help message @@ -49,6 +49,7 @@ checksums = { \ '2.5.4' : 'f31b7d16a4be2e30aa7d5c19c3d37853', \ '2.6.0' : '204d2edae58d9b10ba3ad460cad64191', \ '2.6.1' : '89a9a450fc6025299fe16af235957163', \ + '2.7.0' : '95f29dd0c067577f11972ff90dfc7d12', \ } # parse and process arguments diff --git a/python/lammps/core.py b/python/lammps/core.py index 161583b78c..c0cbaac533 100644 --- a/python/lammps/core.py +++ b/python/lammps/core.py @@ -77,7 +77,7 @@ class lammps(object): modpath = dirname(abspath(getsourcefile(lambda:0))) # for windows installers the shared library is in a different folder - winpath = abspath(os.path.join(modpath,'..','bin')) + winpath = abspath(os.path.join(modpath,'..','..','bin')) self.lib = None self.lmp = None diff --git a/src/GPU/fix_gpu.cpp b/src/GPU/fix_gpu.cpp index 5774d1ea50..8f88dfd61d 100644 --- a/src/GPU/fix_gpu.cpp +++ b/src/GPU/fix_gpu.cpp @@ -120,6 +120,7 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) : double binsize = 0.0; char *opencl_flags = nullptr; int block_pair = -1; + int pair_only_flag = 0; int iarg = 4; while (iarg < narg) { @@ -169,6 +170,12 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) : if (iarg+2 > narg) error->all(FLERR,"Illegal package gpu command"); block_pair = utils::inumeric(FLERR,arg[iarg+1],false,lmp); iarg += 2; + } else if (strcmp(arg[iarg],"pair/only") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal package gpu command"); + if (strcmp(arg[iarg+1],"off") == 0) pair_only_flag = 0; + else if (strcmp(arg[iarg+1],"on") == 0) pair_only_flag = 1; + else error->all(FLERR,"Illegal package gpu command"); + iarg += 2; } else error->all(FLERR,"Illegal package gpu command"); } @@ -186,6 +193,16 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) : if (force->newton_pair || force->newton_bond) force->newton = 1; else force->newton = 0; + if (pair_only_flag) { + lmp->suffixp = lmp->suffix; + lmp->suffix = nullptr; + } else { + if (lmp->suffixp) { + lmp->suffix = lmp->suffixp; + lmp->suffixp = nullptr; + } + } + // pass params to GPU library // change binsize default (0.0) to -1.0 used by GPU lib diff --git a/src/GPU/pair_lj_cubic_gpu.cpp b/src/GPU/pair_lj_cubic_gpu.cpp index a669d52a19..35062a5d71 100644 --- a/src/GPU/pair_lj_cubic_gpu.cpp +++ b/src/GPU/pair_lj_cubic_gpu.cpp @@ -16,10 +16,11 @@ ------------------------------------------------------------------------- */ #include "pair_lj_cubic_gpu.h" + #include #include - #include + #include "atom.h" #include "atom_vec.h" #include "comm.h" @@ -36,6 +37,8 @@ #include "gpu_extra.h" #include "suffix.h" +#include "pair_lj_cubic_const.h" + using namespace LAMMPS_NS; using namespace PairLJCubicConstants; diff --git a/src/KIM/pair_kim.cpp b/src/KIM/pair_kim.cpp index ad671de5b3..ee6f5f98a5 100644 --- a/src/KIM/pair_kim.cpp +++ b/src/KIM/pair_kim.cpp @@ -941,7 +941,7 @@ void PairKIM::set_argument_pointers() // Set KIM pointer appropriately for particleVirial if (KIM_SupportStatus_Equal(kim_model_support_for_particleVirial, - KIM_SUPPORT_STATUS_required) + KIM_SUPPORT_STATUS_required) && (vflag_atom == 0)) { // reallocate per-atom virial array if necessary if (atom->nmax > maxvatom) { diff --git a/src/KOKKOS/atom_vec_angle_kokkos.cpp b/src/KOKKOS/atom_vec_angle_kokkos.cpp index 827929f1a4..b15fc2965b 100644 --- a/src/KOKKOS/atom_vec_angle_kokkos.cpp +++ b/src/KOKKOS/atom_vec_angle_kokkos.cpp @@ -24,8 +24,6 @@ using namespace LAMMPS_NS; -#define DELTA 10 - /* ---------------------------------------------------------------------- */ AtomVecAngleKokkos::AtomVecAngleKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) @@ -59,6 +57,7 @@ AtomVecAngleKokkos::AtomVecAngleKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) void AtomVecAngleKokkos::grow(int n) { + auto DELTA = LMP_KOKKOS_AV_DELTA; int step = MAX(DELTA,nmax*0.01); if (n == 0) nmax += step; else nmax = n; diff --git a/src/KOKKOS/atom_vec_atomic_kokkos.cpp b/src/KOKKOS/atom_vec_atomic_kokkos.cpp index b25cefae34..013b55c959 100644 --- a/src/KOKKOS/atom_vec_atomic_kokkos.cpp +++ b/src/KOKKOS/atom_vec_atomic_kokkos.cpp @@ -24,8 +24,6 @@ using namespace LAMMPS_NS; -#define DELTA 10 - /* ---------------------------------------------------------------------- */ AtomVecAtomicKokkos::AtomVecAtomicKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) @@ -55,6 +53,7 @@ AtomVecAtomicKokkos::AtomVecAtomicKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) void AtomVecAtomicKokkos::grow(int n) { + auto DELTA = LMP_KOKKOS_AV_DELTA; int step = MAX(DELTA,nmax*0.01); if (n == 0) nmax += step; else nmax = n; diff --git a/src/KOKKOS/atom_vec_bond_kokkos.cpp b/src/KOKKOS/atom_vec_bond_kokkos.cpp index 8908ad9b29..91d7dbef63 100644 --- a/src/KOKKOS/atom_vec_bond_kokkos.cpp +++ b/src/KOKKOS/atom_vec_bond_kokkos.cpp @@ -24,8 +24,6 @@ using namespace LAMMPS_NS; -#define DELTA 10 - /* ---------------------------------------------------------------------- */ AtomVecBondKokkos::AtomVecBondKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) @@ -58,6 +56,7 @@ AtomVecBondKokkos::AtomVecBondKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) void AtomVecBondKokkos::grow(int n) { + auto DELTA = LMP_KOKKOS_AV_DELTA; int step = MAX(DELTA,nmax*0.01); if (n == 0) nmax += step; else nmax = n; diff --git a/src/KOKKOS/atom_vec_charge_kokkos.cpp b/src/KOKKOS/atom_vec_charge_kokkos.cpp index 6dd3880c20..698703371f 100644 --- a/src/KOKKOS/atom_vec_charge_kokkos.cpp +++ b/src/KOKKOS/atom_vec_charge_kokkos.cpp @@ -24,8 +24,6 @@ using namespace LAMMPS_NS; -#define DELTA 10 - /* ---------------------------------------------------------------------- */ AtomVecChargeKokkos::AtomVecChargeKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) @@ -58,6 +56,7 @@ AtomVecChargeKokkos::AtomVecChargeKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) void AtomVecChargeKokkos::grow(int n) { + auto DELTA = LMP_KOKKOS_AV_DELTA; int step = MAX(DELTA,nmax*0.01); if (n == 0) nmax += step; else nmax = n; diff --git a/src/KOKKOS/atom_vec_dpd_kokkos.cpp b/src/KOKKOS/atom_vec_dpd_kokkos.cpp index cd4bb76d05..8a733f66e4 100644 --- a/src/KOKKOS/atom_vec_dpd_kokkos.cpp +++ b/src/KOKKOS/atom_vec_dpd_kokkos.cpp @@ -24,8 +24,6 @@ using namespace LAMMPS_NS; -#define DELTA 10 - /* ---------------------------------------------------------------------- */ AtomVecDPDKokkos::AtomVecDPDKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) @@ -60,6 +58,7 @@ AtomVecDPDKokkos::AtomVecDPDKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) void AtomVecDPDKokkos::grow(int n) { + auto DELTA = LMP_KOKKOS_AV_DELTA; int step = MAX(DELTA,nmax*0.01); if (n == 0) nmax += step; else nmax = n; diff --git a/src/KOKKOS/atom_vec_full_kokkos.cpp b/src/KOKKOS/atom_vec_full_kokkos.cpp index 032b36ff4a..2c85e4129b 100644 --- a/src/KOKKOS/atom_vec_full_kokkos.cpp +++ b/src/KOKKOS/atom_vec_full_kokkos.cpp @@ -24,8 +24,6 @@ using namespace LAMMPS_NS; -#define DELTA 10 - /* ---------------------------------------------------------------------- */ AtomVecFullKokkos::AtomVecFullKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) @@ -58,6 +56,7 @@ AtomVecFullKokkos::AtomVecFullKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) void AtomVecFullKokkos::grow(int n) { + auto DELTA = LMP_KOKKOS_AV_DELTA; int step = MAX(DELTA,nmax*0.01); if (n == 0) nmax += step; else nmax = n; diff --git a/src/KOKKOS/atom_vec_kokkos.cpp b/src/KOKKOS/atom_vec_kokkos.cpp index e6caa59859..35ed9160d2 100644 --- a/src/KOKKOS/atom_vec_kokkos.cpp +++ b/src/KOKKOS/atom_vec_kokkos.cpp @@ -16,6 +16,7 @@ #include "atom_kokkos.h" #include "atom_masks.h" #include "comm_kokkos.h" +#include "error.h" #include "domain.h" using namespace LAMMPS_NS; @@ -32,6 +33,22 @@ AtomVecKokkos::AtomVecKokkos(LAMMPS *lmp) : AtomVec(lmp) no_border_vel_flag = 1; } +/* ---------------------------------------------------------------------- + roundup N so it is a multiple of DELTA + error if N exceeds 32-bit int, since will be used as arg to grow() + overload needed because Kokkos uses a smaller DELTA than in atom_vec.cpp + and an exponential instead of a linear growth +------------------------------------------------------------------------- */ + +bigint AtomVecKokkos::roundup(bigint n) +{ + auto DELTA = LMP_KOKKOS_AV_DELTA; + if (n % DELTA) n = n/DELTA * DELTA + DELTA; + if (n > MAXSMALLINT) + error->one(FLERR,"Too many atoms created on one or more procs"); + return n; +} + /* ---------------------------------------------------------------------- */ template diff --git a/src/KOKKOS/atom_vec_kokkos.h b/src/KOKKOS/atom_vec_kokkos.h index 09f02f61e2..9fbf172535 100644 --- a/src/KOKKOS/atom_vec_kokkos.h +++ b/src/KOKKOS/atom_vec_kokkos.h @@ -36,6 +36,7 @@ class AtomVecKokkos : public AtomVec { public: AtomVecKokkos(class LAMMPS *); virtual ~AtomVecKokkos() {} + bigint roundup(bigint); virtual int pack_comm(int, int *, double *, int, int *); virtual int pack_comm_vel(int, int *, double *, int, int *); virtual void unpack_comm(int, int, double *); diff --git a/src/KOKKOS/atom_vec_molecular_kokkos.cpp b/src/KOKKOS/atom_vec_molecular_kokkos.cpp index f54005e87a..20a748191c 100644 --- a/src/KOKKOS/atom_vec_molecular_kokkos.cpp +++ b/src/KOKKOS/atom_vec_molecular_kokkos.cpp @@ -24,8 +24,6 @@ using namespace LAMMPS_NS; -#define DELTA 10 - /* ---------------------------------------------------------------------- */ AtomVecMolecularKokkos::AtomVecMolecularKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) @@ -58,6 +56,7 @@ AtomVecMolecularKokkos::AtomVecMolecularKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) void AtomVecMolecularKokkos::grow(int n) { + auto DELTA = LMP_KOKKOS_AV_DELTA; int step = MAX(DELTA,nmax*0.01); if (n == 0) nmax += step; else nmax = n; diff --git a/src/KOKKOS/atom_vec_sphere_kokkos.cpp b/src/KOKKOS/atom_vec_sphere_kokkos.cpp index f5973c9ab9..22d10e4632 100644 --- a/src/KOKKOS/atom_vec_sphere_kokkos.cpp +++ b/src/KOKKOS/atom_vec_sphere_kokkos.cpp @@ -30,8 +30,6 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define DELTA 10 - /* ---------------------------------------------------------------------- */ AtomVecSphereKokkos::AtomVecSphereKokkos(LAMMPS *lmp) : AtomVecKokkos(lmp) @@ -91,6 +89,7 @@ void AtomVecSphereKokkos::init() void AtomVecSphereKokkos::grow(int n) { + auto DELTA = LMP_KOKKOS_AV_DELTA; int step = MAX(DELTA,nmax*0.01); if (n == 0) nmax += step; else nmax = n; diff --git a/src/KOKKOS/compute_orientorder_atom_kokkos.cpp b/src/KOKKOS/compute_orientorder_atom_kokkos.cpp index 1323e589d3..3703769e90 100644 --- a/src/KOKKOS/compute_orientorder_atom_kokkos.cpp +++ b/src/KOKKOS/compute_orientorder_atom_kokkos.cpp @@ -21,6 +21,7 @@ #include "atom_masks.h" #include "kokkos.h" #include "math_const.h" +#include "math_special.h" #include "memory_kokkos.h" #include "neigh_list.h" #include "neigh_request.h" @@ -32,6 +33,7 @@ using namespace LAMMPS_NS; using namespace MathConst; +using namespace MathSpecial; using namespace std; #ifdef DBL_EPSILON diff --git a/src/KOKKOS/kokkos.cpp b/src/KOKKOS/kokkos.cpp index 64455fef4f..ff1b736bf0 100644 --- a/src/KOKKOS/kokkos.cpp +++ b/src/KOKKOS/kokkos.cpp @@ -301,6 +301,7 @@ KokkosLMP::~KokkosLMP() void KokkosLMP::accelerator(int narg, char **arg) { + int pair_only_flag = 0; int iarg = 0; while (iarg < narg) { if (strcmp(arg[iarg],"neigh") == 0) { @@ -390,6 +391,12 @@ void KokkosLMP::accelerator(int narg, char **arg) else if (strcmp(arg[iarg+1],"on") == 0) gpu_aware_flag = 1; else error->all(FLERR,"Illegal package kokkos command"); iarg += 2; + } else if (strcmp(arg[iarg],"pair/only") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); + if (strcmp(arg[iarg+1],"off") == 0) pair_only_flag = 0; + else if (strcmp(arg[iarg+1],"on") == 0) pair_only_flag = 1; + else error->all(FLERR,"Illegal package kokkos command"); + iarg += 2; } else if (strcmp(arg[iarg],"neigh/thread") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); if (strcmp(arg[iarg+1],"off") == 0) neigh_thread = 0; @@ -402,39 +409,52 @@ void KokkosLMP::accelerator(int narg, char **arg) #ifdef LMP_KOKKOS_GPU + if (pair_only_flag) { + lmp->suffixp = lmp->suffix; + lmp->suffix = new char[7]; + strcpy(lmp->suffix,"kk/host"); + } else { + // restore settings to regular suffix use, if previously, pair/only was used + if (lmp->suffixp) { + delete[] lmp->suffix; + lmp->suffix = lmp->suffixp; + lmp->suffixp = nullptr; + } + } + int nmpi = 0; MPI_Comm_size(world,&nmpi); - // if "cuda/aware off" and "comm device", change to "comm host" + // if "cuda/aware off" or "pair/only on", and "comm device", change to "comm no" - if (!gpu_aware_flag && nmpi > 1) { + if ((!gpu_aware_flag && nmpi > 1) || pair_only_flag) { if (exchange_comm_classic == 0 && exchange_comm_on_host == 0) { - exchange_comm_on_host = 1; + exchange_comm_classic = 1; exchange_comm_changed = 1; } if (forward_comm_classic == 0 && forward_comm_on_host == 0) { - forward_comm_on_host = 1; + forward_comm_classic = 1; forward_comm_changed = 1; } if (reverse_comm_classic == 0 && reverse_comm_on_host == 0) { - reverse_comm_on_host = 1; + reverse_comm_classic = 1; reverse_comm_changed = 1; } } - // if "cuda/aware on" and comm flags were changed previously, change them back + // if "cuda/aware on" and "pair/only off", and comm flags were changed previously, change them back - if (gpu_aware_flag) { + if (gpu_aware_flag && !pair_only_flag) { if (exchange_comm_changed) { - exchange_comm_on_host = 0; + exchange_comm_classic = 0; exchange_comm_changed = 0; } if (forward_comm_changed) { - forward_comm_on_host = 0; + forward_comm_classic = 0; forward_comm_changed = 0; } if (reverse_comm_changed) { - reverse_comm_on_host = 0; + reverse_comm_classic = 0; reverse_comm_changed = 0; } } diff --git a/src/KOKKOS/kokkos_type.h b/src/KOKKOS/kokkos_type.h index 580b22d35f..72513d2b17 100644 --- a/src/KOKKOS/kokkos_type.h +++ b/src/KOKKOS/kokkos_type.h @@ -15,6 +15,7 @@ #define LMP_LMPTYPE_KOKKOS_H #include "pointers.h" +#include "lmptype.h" #include #include @@ -40,7 +41,7 @@ enum{FULL=1u,HALFTHREAD=2u,HALF=4u}; #endif #define MAX_TYPES_STACKPARAMS 12 -#define NeighClusterSize 8 +static constexpr LAMMPS_NS::bigint LMP_KOKKOS_AV_DELTA = 10; namespace Kokkos { using NoInit = ViewAllocateWithoutInitializing; diff --git a/src/KOKKOS/pair_zbl_kokkos.cpp b/src/KOKKOS/pair_zbl_kokkos.cpp index 2cbe65dcf7..4e7e67a074 100644 --- a/src/KOKKOS/pair_zbl_kokkos.cpp +++ b/src/KOKKOS/pair_zbl_kokkos.cpp @@ -30,6 +30,8 @@ #include "atom_masks.h" #include "kokkos.h" +#include "pair_zbl_const.h" + // From J.F. Zeigler, J. P. Biersack and U. Littmark, // "The Stopping and Range of Ions in Matter" volume 1, Pergamon, 1985. diff --git a/src/MANYBODY/pair_comb.h b/src/MANYBODY/pair_comb.h index 7a3d279033..f809dfaf0e 100644 --- a/src/MANYBODY/pair_comb.h +++ b/src/MANYBODY/pair_comb.h @@ -38,7 +38,7 @@ class PairComb : public Pair { virtual double yasu_char(double *, int &); double enegtot; - static const int NPARAMS_PER_LINE = 49; + static constexpr int NPARAMS_PER_LINE = 49; protected: struct Param { diff --git a/src/MANYBODY/pair_comb3.h b/src/MANYBODY/pair_comb3.h index 567859127b..b1c216fee6 100644 --- a/src/MANYBODY/pair_comb3.h +++ b/src/MANYBODY/pair_comb3.h @@ -37,7 +37,7 @@ class PairComb3 : public Pair { virtual double combqeq(double *, int &); double enegtot; - static const int NPARAMS_PER_LINE = 74; + static constexpr int NPARAMS_PER_LINE = 74; protected: // general potential parameters diff --git a/src/MANYBODY/pair_gw.h b/src/MANYBODY/pair_gw.h index 77ff5c0399..2dbf3dcf84 100644 --- a/src/MANYBODY/pair_gw.h +++ b/src/MANYBODY/pair_gw.h @@ -34,7 +34,7 @@ class PairGW : public Pair { void init_style(); double init_one(int, int); - static const int NPARAMS_PER_LINE = 17; + static constexpr int NPARAMS_PER_LINE = 17; protected: struct Param { diff --git a/src/MANYBODY/pair_gw_zbl.h b/src/MANYBODY/pair_gw_zbl.h index 95129c4eb8..de344e94f7 100644 --- a/src/MANYBODY/pair_gw_zbl.h +++ b/src/MANYBODY/pair_gw_zbl.h @@ -29,7 +29,7 @@ class PairGWZBL : public PairGW { PairGWZBL(class LAMMPS *); ~PairGWZBL() {} - static const int NPARAMS_PER_LINE = 21; + static constexpr int NPARAMS_PER_LINE = 21; private: double global_a_0; // Bohr radius for Coulomb repulsion diff --git a/src/MANYBODY/pair_nb3b_harmonic.h b/src/MANYBODY/pair_nb3b_harmonic.h index 0267b6d0e2..b68974e15f 100644 --- a/src/MANYBODY/pair_nb3b_harmonic.h +++ b/src/MANYBODY/pair_nb3b_harmonic.h @@ -34,7 +34,7 @@ class PairNb3bHarmonic : public Pair { double init_one(int, int); void init_style(); - static const int NPARAMS_PER_LINE = 6; + static constexpr int NPARAMS_PER_LINE = 6; protected: struct Param { diff --git a/src/MANYBODY/pair_sw.h b/src/MANYBODY/pair_sw.h index 441b1c0303..4fdc538430 100644 --- a/src/MANYBODY/pair_sw.h +++ b/src/MANYBODY/pair_sw.h @@ -34,7 +34,7 @@ class PairSW : public Pair { virtual double init_one(int, int); virtual void init_style(); - static const int NPARAMS_PER_LINE = 14; + static constexpr int NPARAMS_PER_LINE = 14; struct Param { double epsilon,sigma; diff --git a/src/MANYBODY/pair_tersoff.h b/src/MANYBODY/pair_tersoff.h index 8ebbc83544..eb29cc227d 100644 --- a/src/MANYBODY/pair_tersoff.h +++ b/src/MANYBODY/pair_tersoff.h @@ -34,7 +34,7 @@ class PairTersoff : public Pair { virtual void init_style(); double init_one(int, int); - static const int NPARAMS_PER_LINE = 17; + static constexpr int NPARAMS_PER_LINE = 17; protected: diff --git a/src/MANYBODY/pair_tersoff_mod.h b/src/MANYBODY/pair_tersoff_mod.h index 2cdbae9518..4f1d7a12a6 100644 --- a/src/MANYBODY/pair_tersoff_mod.h +++ b/src/MANYBODY/pair_tersoff_mod.h @@ -30,7 +30,7 @@ class PairTersoffMOD : public PairTersoff { PairTersoffMOD(class LAMMPS *); ~PairTersoffMOD() {} - static const int NPARAMS_PER_LINE = 20; + static constexpr int NPARAMS_PER_LINE = 20; protected: virtual void read_file(char *); diff --git a/src/MANYBODY/pair_tersoff_mod_c.h b/src/MANYBODY/pair_tersoff_mod_c.h index bad5f988be..4949cb76db 100644 --- a/src/MANYBODY/pair_tersoff_mod_c.h +++ b/src/MANYBODY/pair_tersoff_mod_c.h @@ -29,7 +29,7 @@ class PairTersoffMODC : public PairTersoffMOD { PairTersoffMODC(class LAMMPS *lmp) : PairTersoffMOD(lmp) {}; ~PairTersoffMODC() {} - static const int NPARAMS_PER_LINE = 21; + static constexpr int NPARAMS_PER_LINE = 21; protected: void read_file(char *); diff --git a/src/MANYBODY/pair_tersoff_zbl.h b/src/MANYBODY/pair_tersoff_zbl.h index be3f496b62..42483b7d89 100644 --- a/src/MANYBODY/pair_tersoff_zbl.h +++ b/src/MANYBODY/pair_tersoff_zbl.h @@ -29,7 +29,7 @@ class PairTersoffZBL : public PairTersoff { PairTersoffZBL(class LAMMPS *); ~PairTersoffZBL() {} - static const int NPARAMS_PER_LINE = 21; + static constexpr int NPARAMS_PER_LINE = 21; protected: double global_a_0; // Bohr radius for Coulomb repulsion diff --git a/src/MANYBODY/pair_vashishta.h b/src/MANYBODY/pair_vashishta.h index bd250d328a..19a8e01cd9 100644 --- a/src/MANYBODY/pair_vashishta.h +++ b/src/MANYBODY/pair_vashishta.h @@ -34,7 +34,7 @@ class PairVashishta : public Pair { double init_one(int, int); void init_style(); - static const int NPARAMS_PER_LINE = 17; + static constexpr int NPARAMS_PER_LINE = 17; struct Param { double bigb,gamma,r0,bigc,costheta; diff --git a/src/RIGID/fix_shake.cpp b/src/RIGID/fix_shake.cpp index 98700403b6..61ba36ea2b 100644 --- a/src/RIGID/fix_shake.cpp +++ b/src/RIGID/fix_shake.cpp @@ -2542,13 +2542,13 @@ void FixShake::stats() const auto bcnt = b_count_all[i]/2; if (bcnt) mesg += fmt::format("{:>6d} {:<9.6} {:<11.6} {:>8d}\n",i, - b_ave_all[i]/bcnt,b_max_all[i]-b_min_all[i],bcnt); + b_ave_all[i]/bcnt/2.0,b_max_all[i]-b_min_all[i],bcnt); } for (i = 1; i < na; i++) { const auto acnt = a_count_all[i]/3; if (acnt) mesg += fmt::format("{:>6d} {:<9.6} {:<11.6} {:>8d}\n",i, - a_ave_all[i]/acnt,a_max_all[i]-a_min_all[i],acnt); + a_ave_all[i]/acnt/3.0,a_max_all[i]-a_min_all[i],acnt); } utils::logmesg(lmp,mesg); } diff --git a/src/RIGID/rigid_const.h b/src/RIGID/rigid_const.h index 3aae988197..b345a6b9dc 100644 --- a/src/RIGID/rigid_const.h +++ b/src/RIGID/rigid_const.h @@ -33,21 +33,21 @@ namespace LAMMPS_NS { TORQUE = 1<<8 }; - static const double TOLERANCE = 1.0e-6; - static const double EPSILON = 1.0e-7; - static const double BIG = 1.0e20; + static constexpr double TOLERANCE = 1.0e-6; + static constexpr double EPSILON = 1.0e-7; + static constexpr double BIG = 1.0e20; // moment of inertia prefactor for sphere - static const double SINERTIA = 0.4; + static constexpr double SINERTIA = 0.4; // moment of inertia prefactor for ellipsoid - static const double EINERTIA = 0.2; + static constexpr double EINERTIA = 0.2; // moment of inertia prefactor for line segment - static const double LINERTIA = 1.0/12.0; + static constexpr double LINERTIA = 1.0/12.0; - static const int MAXLINE = 1024; - static const int CHUNK = 1024; - static const int DELTA_BODY = 10000; - static const int ATTRIBUTE_PERBODY = 20; + static constexpr int MAXLINE = 1024; + static constexpr int CHUNK = 1024; + static constexpr int DELTA_BODY = 10000; + static constexpr int ATTRIBUTE_PERBODY = 20; } } diff --git a/src/SNAP/sna.cpp b/src/SNAP/sna.cpp index 6d4197b59b..3c7a40c0dc 100644 --- a/src/SNAP/sna.cpp +++ b/src/SNAP/sna.cpp @@ -18,6 +18,7 @@ #include "sna.h" #include #include "math_const.h" +#include "math_special.h" #include "memory.h" #include "error.h" #include "comm.h" @@ -25,6 +26,7 @@ using namespace std; using namespace LAMMPS_NS; using namespace MathConst; +using namespace MathSpecial; /* ---------------------------------------------------------------------- @@ -1363,196 +1365,6 @@ void SNA::destroy_twojmax_arrays() } -/* ---------------------------------------------------------------------- - factorial n, wrapper for precomputed table -------------------------------------------------------------------------- */ - -double SNA::factorial(int n) -{ - if (n < 0 || n > nmaxfactorial) { - char str[128]; - sprintf(str, "Invalid argument to factorial %d", n); - error->all(FLERR, str); - } - - return nfac_table[n]; -} - -/* ---------------------------------------------------------------------- - factorial n table, size SNA::nmaxfactorial+1 -------------------------------------------------------------------------- */ - -const double SNA::nfac_table[] = { - 1, - 1, - 2, - 6, - 24, - 120, - 720, - 5040, - 40320, - 362880, - 3628800, - 39916800, - 479001600, - 6227020800, - 87178291200, - 1307674368000, - 20922789888000, - 355687428096000, - 6.402373705728e+15, - 1.21645100408832e+17, - 2.43290200817664e+18, - 5.10909421717094e+19, - 1.12400072777761e+21, - 2.5852016738885e+22, - 6.20448401733239e+23, - 1.5511210043331e+25, - 4.03291461126606e+26, - 1.08888694504184e+28, - 3.04888344611714e+29, - 8.8417619937397e+30, - 2.65252859812191e+32, - 8.22283865417792e+33, - 2.63130836933694e+35, - 8.68331761881189e+36, - 2.95232799039604e+38, - 1.03331479663861e+40, - 3.71993326789901e+41, - 1.37637530912263e+43, - 5.23022617466601e+44, - 2.03978820811974e+46, - 8.15915283247898e+47, - 3.34525266131638e+49, - 1.40500611775288e+51, - 6.04152630633738e+52, - 2.65827157478845e+54, - 1.1962222086548e+56, - 5.50262215981209e+57, - 2.58623241511168e+59, - 1.24139155925361e+61, - 6.08281864034268e+62, - 3.04140932017134e+64, - 1.55111875328738e+66, - 8.06581751709439e+67, - 4.27488328406003e+69, - 2.30843697339241e+71, - 1.26964033536583e+73, - 7.10998587804863e+74, - 4.05269195048772e+76, - 2.35056133128288e+78, - 1.3868311854569e+80, - 8.32098711274139e+81, - 5.07580213877225e+83, - 3.14699732603879e+85, - 1.98260831540444e+87, - 1.26886932185884e+89, - 8.24765059208247e+90, - 5.44344939077443e+92, - 3.64711109181887e+94, - 2.48003554243683e+96, - 1.71122452428141e+98, - 1.19785716699699e+100, - 8.50478588567862e+101, - 6.12344583768861e+103, - 4.47011546151268e+105, - 3.30788544151939e+107, - 2.48091408113954e+109, - 1.88549470166605e+111, - 1.45183092028286e+113, - 1.13242811782063e+115, - 8.94618213078297e+116, - 7.15694570462638e+118, - 5.79712602074737e+120, - 4.75364333701284e+122, - 3.94552396972066e+124, - 3.31424013456535e+126, - 2.81710411438055e+128, - 2.42270953836727e+130, - 2.10775729837953e+132, - 1.85482642257398e+134, - 1.65079551609085e+136, - 1.48571596448176e+138, - 1.3520015276784e+140, - 1.24384140546413e+142, - 1.15677250708164e+144, - 1.08736615665674e+146, - 1.03299784882391e+148, - 9.91677934870949e+149, - 9.61927596824821e+151, - 9.42689044888324e+153, - 9.33262154439441e+155, - 9.33262154439441e+157, - 9.42594775983835e+159, - 9.61446671503512e+161, - 9.90290071648618e+163, - 1.02990167451456e+166, - 1.08139675824029e+168, - 1.14628056373471e+170, - 1.22652020319614e+172, - 1.32464181945183e+174, - 1.44385958320249e+176, - 1.58824554152274e+178, - 1.76295255109024e+180, - 1.97450685722107e+182, - 2.23119274865981e+184, - 2.54355973347219e+186, - 2.92509369349301e+188, - 3.3931086844519e+190, - 3.96993716080872e+192, - 4.68452584975429e+194, - 5.5745857612076e+196, - 6.68950291344912e+198, - 8.09429852527344e+200, - 9.8750442008336e+202, - 1.21463043670253e+205, - 1.50614174151114e+207, - 1.88267717688893e+209, - 2.37217324288005e+211, - 3.01266001845766e+213, - 3.8562048236258e+215, - 4.97450422247729e+217, - 6.46685548922047e+219, - 8.47158069087882e+221, - 1.118248651196e+224, - 1.48727070609069e+226, - 1.99294274616152e+228, - 2.69047270731805e+230, - 3.65904288195255e+232, - 5.01288874827499e+234, - 6.91778647261949e+236, - 9.61572319694109e+238, - 1.34620124757175e+241, - 1.89814375907617e+243, - 2.69536413788816e+245, - 3.85437071718007e+247, - 5.5502938327393e+249, - 8.04792605747199e+251, - 1.17499720439091e+254, - 1.72724589045464e+256, - 2.55632391787286e+258, - 3.80892263763057e+260, - 5.71338395644585e+262, - 8.62720977423323e+264, - 1.31133588568345e+267, - 2.00634390509568e+269, - 3.08976961384735e+271, - 4.78914290146339e+273, - 7.47106292628289e+275, - 1.17295687942641e+278, - 1.85327186949373e+280, - 2.94670227249504e+282, - 4.71472363599206e+284, - 7.59070505394721e+286, - 1.22969421873945e+289, - 2.0044015765453e+291, - 3.28721858553429e+293, - 5.42391066613159e+295, - 9.00369170577843e+297, - 1.503616514865e+300, // nmaxfactorial = 167 -}; - /* ---------------------------------------------------------------------- the function delta given by VMK Eq. 8.2(1) ------------------------------------------------------------------------- */ diff --git a/src/SNAP/sna.h b/src/SNAP/sna.h index 30c4aa6bbc..746b55fb70 100644 --- a/src/SNAP/sna.h +++ b/src/SNAP/sna.h @@ -100,10 +100,6 @@ private: double** dulist_r, ** dulist_i; int elem_duarray; // element of j in derivative - static const int nmaxfactorial = 167; - static const double nfac_table[]; - double factorial(int); - void create_twojmax_arrays(); void destroy_twojmax_arrays(); void init_clebsch_gordan(); diff --git a/src/USER-DRUDE/fix_tgnh_drude.cpp b/src/USER-DRUDE/fix_tgnh_drude.cpp new file mode 100644 index 0000000000..e2122e6792 --- /dev/null +++ b/src/USER-DRUDE/fix_tgnh_drude.cpp @@ -0,0 +1,2363 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://lammps.sandia.gov/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +/* ------------------------------------------------------------------------------------- + Contributing authors: Mark Stevens (SNL), Aidan Thompson (SNL), Zheng Gong (ENS Lyon) +---------------------------------------------------------------------------------------- */ + +#include "fix_tgnh_drude.h" +#include +#include +#include "atom.h" +#include "force.h" +#include "group.h" +#include "comm.h" +#include "neighbor.h" +#include "irregular.h" +#include "modify.h" +#include "fix_deform.h" +#include "compute.h" +#include "kspace.h" +#include "update.h" +#include "respa.h" +#include "domain.h" +#include "memory.h" +#include "error.h" + +using namespace LAMMPS_NS; +using namespace FixConst; + +#define DELTAFLIP 0.1 +#define TILTMAX 1.5 + +enum{NOBIAS,BIAS}; +enum{NONE,XYZ,XY,YZ,XZ}; +enum{ISO,ANISO,TRICLINIC}; + +/* ---------------------------------------------------------------------- + NVT,NPH,NPT integrators for improved Nose-Hoover equations of motion + ---------------------------------------------------------------------- */ + +FixTGNHDrude::FixTGNHDrude(LAMMPS *lmp, int narg, char **arg) : + Fix(lmp, narg, arg), + rfix(nullptr), irregular(nullptr), id_temp(nullptr), id_press(nullptr), + etamol(nullptr), etamol_dot(nullptr), etamol_dotdot(nullptr), etamol_mass(nullptr), + etaint(nullptr), etaint_dot(nullptr), etaint_dotdot(nullptr), etaint_mass(nullptr), + etadrude(nullptr), etadrude_dot(nullptr), etadrude_dotdot(nullptr), etadrude_mass(nullptr), + etap(nullptr), etap_dot(nullptr), etap_dotdot(nullptr), etap_mass(nullptr) +{ + if (narg < 4) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + + restart_global = 1; + dynamic_group_allow = 0; + time_integrate = 1; + scalar_flag = 1; + vector_flag = 1; + global_freq = 1; + extscalar = 1; + extvector = 0; + + // default values + + pcouple = NONE; + mtchain = mpchain = 3; + nc_tchain = nc_pchain = 1; + mtk_flag = 1; + deviatoric_flag = 0; + nreset_h0 = 0; + flipflag = 1; + + tcomputeflag = 0; + pcomputeflag = 0; + id_temp = nullptr; + id_press = nullptr; + + // turn on tilt factor scaling, whenever applicable + + dimension = domain->dimension; + + scaleyz = scalexz = scalexy = 0; + if (domain->yperiodic && domain->xy != 0.0) scalexy = 1; + if (domain->zperiodic && dimension == 3) { + if (domain->yz != 0.0) scaleyz = 1; + if (domain->xz != 0.0) scalexz = 1; + } + + // set fixed-point to default = center of cell + + fixedpoint[0] = 0.5*(domain->boxlo[0]+domain->boxhi[0]); + fixedpoint[1] = 0.5*(domain->boxlo[1]+domain->boxhi[1]); + fixedpoint[2] = 0.5*(domain->boxlo[2]+domain->boxhi[2]); + + tstat_flag = 0; + double t_period = 0.0, tdrude_period = 0.0; + + double p_period[6]; + for (int i = 0; i < 6; i++) { + p_start[i] = p_stop[i] = p_period[i] = p_target[i] = 0.0; + p_flag[i] = 0; + } + + // process keywords + + int iarg = 3; + + while (iarg < narg) { + if (strcmp(arg[iarg],"temp") == 0) { + if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + tstat_flag = 1; + t_start = utils::numeric(FLERR,arg[iarg+1],false,lmp); + t_target = t_start; + t_stop = utils::numeric(FLERR,arg[iarg+2],false,lmp); + t_period = utils::numeric(FLERR,arg[iarg+3],false,lmp); + if (t_start <= 0.0 || t_stop <= 0.0) + error->all(FLERR, + "Target temperature for fix nvt/npt/nph cannot be 0.0"); + tdrude_target = utils::numeric(FLERR,arg[iarg+4],false,lmp); + tdrude_period = utils::numeric(FLERR,arg[iarg+5],false,lmp); + iarg += 6; + + } else if (strcmp(arg[iarg],"iso") == 0) { + if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + pcouple = XYZ; + p_start[0] = p_start[1] = p_start[2] = utils::numeric(FLERR,arg[iarg+1],false,lmp); + p_stop[0] = p_stop[1] = p_stop[2] = utils::numeric(FLERR,arg[iarg+2],false,lmp); + p_period[0] = p_period[1] = p_period[2] = utils::numeric(FLERR,arg[iarg+3],false,lmp); + p_flag[0] = p_flag[1] = p_flag[2] = 1; + if (dimension == 2) { + p_start[2] = p_stop[2] = p_period[2] = 0.0; + p_flag[2] = 0; + } + iarg += 4; + } else if (strcmp(arg[iarg],"aniso") == 0) { + if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + pcouple = NONE; + p_start[0] = p_start[1] = p_start[2] = utils::numeric(FLERR,arg[iarg+1],false,lmp); + p_stop[0] = p_stop[1] = p_stop[2] = utils::numeric(FLERR,arg[iarg+2],false,lmp); + p_period[0] = p_period[1] = p_period[2] = utils::numeric(FLERR,arg[iarg+3],false,lmp); + p_flag[0] = p_flag[1] = p_flag[2] = 1; + if (dimension == 2) { + p_start[2] = p_stop[2] = p_period[2] = 0.0; + p_flag[2] = 0; + } + iarg += 4; + } else if (strcmp(arg[iarg],"tri") == 0) { + if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + pcouple = NONE; + scalexy = scalexz = scaleyz = 0; + p_start[0] = p_start[1] = p_start[2] = utils::numeric(FLERR,arg[iarg+1],false,lmp); + p_stop[0] = p_stop[1] = p_stop[2] = utils::numeric(FLERR,arg[iarg+2],false,lmp); + p_period[0] = p_period[1] = p_period[2] = utils::numeric(FLERR,arg[iarg+3],false,lmp); + p_flag[0] = p_flag[1] = p_flag[2] = 1; + p_start[3] = p_start[4] = p_start[5] = 0.0; + p_stop[3] = p_stop[4] = p_stop[5] = 0.0; + p_period[3] = p_period[4] = p_period[5] = utils::numeric(FLERR,arg[iarg+3],false,lmp); + p_flag[3] = p_flag[4] = p_flag[5] = 1; + if (dimension == 2) { + p_start[2] = p_stop[2] = p_period[2] = 0.0; + p_flag[2] = 0; + p_start[3] = p_stop[3] = p_period[3] = 0.0; + p_flag[3] = 0; + p_start[4] = p_stop[4] = p_period[4] = 0.0; + p_flag[4] = 0; + } + iarg += 4; + } else if (strcmp(arg[iarg],"x") == 0) { + if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + p_start[0] = utils::numeric(FLERR,arg[iarg+1],false,lmp); + p_stop[0] = utils::numeric(FLERR,arg[iarg+2],false,lmp); + p_period[0] = utils::numeric(FLERR,arg[iarg+3],false,lmp); + p_flag[0] = 1; + deviatoric_flag = 1; + iarg += 4; + } else if (strcmp(arg[iarg],"y") == 0) { + if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + p_start[1] = utils::numeric(FLERR,arg[iarg+1],false,lmp); + p_stop[1] = utils::numeric(FLERR,arg[iarg+2],false,lmp); + p_period[1] = utils::numeric(FLERR,arg[iarg+3],false,lmp); + p_flag[1] = 1; + deviatoric_flag = 1; + iarg += 4; + } else if (strcmp(arg[iarg],"z") == 0) { + if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + p_start[2] = utils::numeric(FLERR,arg[iarg+1],false,lmp); + p_stop[2] = utils::numeric(FLERR,arg[iarg+2],false,lmp); + p_period[2] = utils::numeric(FLERR,arg[iarg+3],false,lmp); + p_flag[2] = 1; + deviatoric_flag = 1; + iarg += 4; + if (dimension == 2) + error->all(FLERR,"Invalid fix nvt/npt/nph command for a 2d simulation"); + + } else if (strcmp(arg[iarg],"yz") == 0) { + if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + p_start[3] = utils::numeric(FLERR,arg[iarg+1],false,lmp); + p_stop[3] = utils::numeric(FLERR,arg[iarg+2],false,lmp); + p_period[3] = utils::numeric(FLERR,arg[iarg+3],false,lmp); + p_flag[3] = 1; + deviatoric_flag = 1; + scaleyz = 0; + iarg += 4; + if (dimension == 2) + error->all(FLERR,"Invalid fix nvt/npt/nph command for a 2d simulation"); + } else if (strcmp(arg[iarg],"xz") == 0) { + if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + p_start[4] = utils::numeric(FLERR,arg[iarg+1],false,lmp); + p_stop[4] = utils::numeric(FLERR,arg[iarg+2],false,lmp); + p_period[4] = utils::numeric(FLERR,arg[iarg+3],false,lmp); + p_flag[4] = 1; + deviatoric_flag = 1; + scalexz = 0; + iarg += 4; + if (dimension == 2) + error->all(FLERR,"Invalid fix nvt/npt/nph command for a 2d simulation"); + } else if (strcmp(arg[iarg],"xy") == 0) { + if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + p_start[5] = utils::numeric(FLERR,arg[iarg+1],false,lmp); + p_stop[5] = utils::numeric(FLERR,arg[iarg+2],false,lmp); + p_period[5] = utils::numeric(FLERR,arg[iarg+3],false,lmp); + p_flag[5] = 1; + deviatoric_flag = 1; + scalexy = 0; + iarg += 4; + + } else if (strcmp(arg[iarg],"couple") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (strcmp(arg[iarg+1],"xyz") == 0) pcouple = XYZ; + else if (strcmp(arg[iarg+1],"xy") == 0) pcouple = XY; + else if (strcmp(arg[iarg+1],"yz") == 0) pcouple = YZ; + else if (strcmp(arg[iarg+1],"xz") == 0) pcouple = XZ; + else if (strcmp(arg[iarg+1],"none") == 0) pcouple = NONE; + else error->all(FLERR,"Illegal fix nvt/npt/nph command"); + iarg += 2; + } else if (strcmp(arg[iarg],"tchain") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + mtchain = utils::inumeric(FLERR,arg[iarg+1],false,lmp); + if (mtchain < 1) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + iarg += 2; + } else if (strcmp(arg[iarg],"pchain") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + mpchain = utils::inumeric(FLERR,arg[iarg+1],false,lmp); + if (mpchain < 0) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + iarg += 2; + } else if (strcmp(arg[iarg],"mtk") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (strcmp(arg[iarg+1],"yes") == 0) mtk_flag = 1; + else if (strcmp(arg[iarg+1],"no") == 0) mtk_flag = 0; + else error->all(FLERR,"Illegal fix nvt/npt/nph command"); + iarg += 2; + } else if (strcmp(arg[iarg],"tloop") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + nc_tchain = utils::inumeric(FLERR,arg[iarg+1],false,lmp); + if (nc_tchain < 0) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + iarg += 2; + } else if (strcmp(arg[iarg],"ploop") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + nc_pchain = utils::inumeric(FLERR,arg[iarg+1],false,lmp); + if (nc_pchain < 0) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + iarg += 2; + } else if (strcmp(arg[iarg],"nreset") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + nreset_h0 = utils::inumeric(FLERR,arg[iarg+1],false,lmp); + if (nreset_h0 < 0) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + iarg += 2; + } else if (strcmp(arg[iarg],"scalexy") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (strcmp(arg[iarg+1],"yes") == 0) scalexy = 1; + else if (strcmp(arg[iarg+1],"no") == 0) scalexy = 0; + else error->all(FLERR,"Illegal fix nvt/npt/nph command"); + iarg += 2; + } else if (strcmp(arg[iarg],"scalexz") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (strcmp(arg[iarg+1],"yes") == 0) scalexz = 1; + else if (strcmp(arg[iarg+1],"no") == 0) scalexz = 0; + else error->all(FLERR,"Illegal fix nvt/npt/nph command"); + iarg += 2; + } else if (strcmp(arg[iarg],"scaleyz") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (strcmp(arg[iarg+1],"yes") == 0) scaleyz = 1; + else if (strcmp(arg[iarg+1],"no") == 0) scaleyz = 0; + else error->all(FLERR,"Illegal fix nvt/npt/nph command"); + iarg += 2; + } else if (strcmp(arg[iarg],"flip") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + if (strcmp(arg[iarg+1],"yes") == 0) flipflag = 1; + else if (strcmp(arg[iarg+1],"no") == 0) flipflag = 0; + else error->all(FLERR,"Illegal fix nvt/npt/nph command"); + iarg += 2; + } else if (strcmp(arg[iarg],"fixedpoint") == 0) { + if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); + fixedpoint[0] = utils::numeric(FLERR,arg[iarg+1],false,lmp); + fixedpoint[1] = utils::numeric(FLERR,arg[iarg+2],false,lmp); + fixedpoint[2] = utils::numeric(FLERR,arg[iarg+3],false,lmp); + iarg += 4; + } else error->all(FLERR,"Illegal fix nvt/npt/nph command"); + } + + // error checks + + if (dimension == 2 && (p_flag[2] || p_flag[3] || p_flag[4])) + error->all(FLERR,"Invalid fix nvt/npt/nph command for a 2d simulation"); + if (dimension == 2 && (pcouple == YZ || pcouple == XZ)) + error->all(FLERR,"Invalid fix nvt/npt/nph command for a 2d simulation"); + if (dimension == 2 && (scalexz == 1 || scaleyz == 1 )) + error->all(FLERR,"Invalid fix nvt/npt/nph command for a 2d simulation"); + + if (pcouple == XYZ && (p_flag[0] == 0 || p_flag[1] == 0)) + error->all(FLERR,"Invalid fix nvt/npt/nph command pressure settings"); + if (pcouple == XYZ && dimension == 3 && p_flag[2] == 0) + error->all(FLERR,"Invalid fix nvt/npt/nph command pressure settings"); + if (pcouple == XY && (p_flag[0] == 0 || p_flag[1] == 0)) + error->all(FLERR,"Invalid fix nvt/npt/nph command pressure settings"); + if (pcouple == YZ && (p_flag[1] == 0 || p_flag[2] == 0)) + error->all(FLERR,"Invalid fix nvt/npt/nph command pressure settings"); + if (pcouple == XZ && (p_flag[0] == 0 || p_flag[2] == 0)) + error->all(FLERR,"Invalid fix nvt/npt/nph command pressure settings"); + + // require periodicity in tensile dimension + + if (p_flag[0] && domain->xperiodic == 0) + error->all(FLERR,"Cannot use fix nvt/npt/nph on a non-periodic dimension"); + if (p_flag[1] && domain->yperiodic == 0) + error->all(FLERR,"Cannot use fix nvt/npt/nph on a non-periodic dimension"); + if (p_flag[2] && domain->zperiodic == 0) + error->all(FLERR,"Cannot use fix nvt/npt/nph on a non-periodic dimension"); + + // require periodicity in 2nd dim of off-diagonal tilt component + + if (p_flag[3] && domain->zperiodic == 0) + error->all(FLERR, + "Cannot use fix nvt/npt/nph on a 2nd non-periodic dimension"); + if (p_flag[4] && domain->zperiodic == 0) + error->all(FLERR, + "Cannot use fix nvt/npt/nph on a 2nd non-periodic dimension"); + if (p_flag[5] && domain->yperiodic == 0) + error->all(FLERR, + "Cannot use fix nvt/npt/nph on a 2nd non-periodic dimension"); + + if (scaleyz == 1 && domain->zperiodic == 0) + error->all(FLERR,"Cannot use fix nvt/npt/nph " + "with yz scaling when z is non-periodic dimension"); + if (scalexz == 1 && domain->zperiodic == 0) + error->all(FLERR,"Cannot use fix nvt/npt/nph " + "with xz scaling when z is non-periodic dimension"); + if (scalexy == 1 && domain->yperiodic == 0) + error->all(FLERR,"Cannot use fix nvt/npt/nph " + "with xy scaling when y is non-periodic dimension"); + + if (p_flag[3] && scaleyz == 1) + error->all(FLERR,"Cannot use fix nvt/npt/nph with " + "both yz dynamics and yz scaling"); + if (p_flag[4] && scalexz == 1) + error->all(FLERR,"Cannot use fix nvt/npt/nph with " + "both xz dynamics and xz scaling"); + if (p_flag[5] && scalexy == 1) + error->all(FLERR,"Cannot use fix nvt/npt/nph with " + "both xy dynamics and xy scaling"); + + if (!domain->triclinic && (p_flag[3] || p_flag[4] || p_flag[5])) + error->all(FLERR,"Can not specify Pxy/Pxz/Pyz in " + "fix nvt/npt/nph with non-triclinic box"); + + if (pcouple == XYZ && dimension == 3 && + (p_start[0] != p_start[1] || p_start[0] != p_start[2] || + p_stop[0] != p_stop[1] || p_stop[0] != p_stop[2] || + p_period[0] != p_period[1] || p_period[0] != p_period[2])) + error->all(FLERR,"Invalid fix nvt/npt/nph pressure settings"); + if (pcouple == XYZ && dimension == 2 && + (p_start[0] != p_start[1] || p_stop[0] != p_stop[1] || + p_period[0] != p_period[1])) + error->all(FLERR,"Invalid fix nvt/npt/nph pressure settings"); + if (pcouple == XY && + (p_start[0] != p_start[1] || p_stop[0] != p_stop[1] || + p_period[0] != p_period[1])) + error->all(FLERR,"Invalid fix nvt/npt/nph pressure settings"); + if (pcouple == YZ && + (p_start[1] != p_start[2] || p_stop[1] != p_stop[2] || + p_period[1] != p_period[2])) + error->all(FLERR,"Invalid fix nvt/npt/nph pressure settings"); + if (pcouple == XZ && + (p_start[0] != p_start[2] || p_stop[0] != p_stop[2] || + p_period[0] != p_period[2])) + error->all(FLERR,"Invalid fix nvt/npt/nph pressure settings"); + + if ((tstat_flag && t_period <= 0.0) || + (p_flag[0] && p_period[0] <= 0.0) || + (p_flag[1] && p_period[1] <= 0.0) || + (p_flag[2] && p_period[2] <= 0.0) || + (p_flag[3] && p_period[3] <= 0.0) || + (p_flag[4] && p_period[4] <= 0.0) || + (p_flag[5] && p_period[5] <= 0.0)) + error->all(FLERR,"Fix nvt/npt/nph damping parameters must be > 0.0"); + + // set pstat_flag and box change and restart_pbc variables + + pre_exchange_flag = 0; + pstat_flag = 0; + pstyle = ISO; + + for (int i = 0; i < 6; i++) + if (p_flag[i]) pstat_flag = 1; + + if (pstat_flag) { + if (p_flag[0]) box_change |= BOX_CHANGE_X; + if (p_flag[1]) box_change |= BOX_CHANGE_Y; + if (p_flag[2]) box_change |= BOX_CHANGE_Z; + if (p_flag[3]) box_change |= BOX_CHANGE_YZ; + if (p_flag[4]) box_change |= BOX_CHANGE_XZ; + if (p_flag[5]) box_change |= BOX_CHANGE_XY; + no_change_box = 1; + + // pstyle = TRICLINIC if any off-diagonal term is controlled -> 6 dof + // else pstyle = ISO if XYZ coupling or XY coupling in 2d -> 1 dof + // else pstyle = ANISO -> 3 dof + + if (p_flag[3] || p_flag[4] || p_flag[5]) pstyle = TRICLINIC; + else if (pcouple == XYZ || (dimension == 2 && pcouple == XY)) pstyle = ISO; + else pstyle = ANISO; + + // pre_exchange only required if flips can occur due to shape changes + + if (flipflag && (p_flag[3] || p_flag[4] || p_flag[5])) + pre_exchange_flag = pre_exchange_migrate = 1; + if (flipflag && (domain->yz != 0.0 || domain->xz != 0.0 || domain->xy != 0.0)) + pre_exchange_flag = pre_exchange_migrate = 1; + } + + // convert input periods to frequencies + + t_freq = tdrude_freq = 0.0; + p_freq[0] = p_freq[1] = p_freq[2] = p_freq[3] = p_freq[4] = p_freq[5] = 0.0; + + if (tstat_flag) { + t_freq = 1.0 / t_period; + tdrude_freq = 1.0 / tdrude_period; + } + if (p_flag[0]) p_freq[0] = 1.0 / p_period[0]; + if (p_flag[1]) p_freq[1] = 1.0 / p_period[1]; + if (p_flag[2]) p_freq[2] = 1.0 / p_period[2]; + if (p_flag[3]) p_freq[3] = 1.0 / p_period[3]; + if (p_flag[4]) p_freq[4] = 1.0 / p_period[4]; + if (p_flag[5]) p_freq[5] = 1.0 / p_period[5]; + + // Nose/Hoover temp and pressure init + + size_vector = 3; + + if (tstat_flag) { + int ich; + + etaint = new double[mtchain]; + // add one extra dummy thermostat for eta_dot, set to zero + etaint_dot = new double[mtchain+1]; + etaint_dot[mtchain] = 0.0; + etaint_dotdot = new double[mtchain]; + for (ich = 0; ich < mtchain; ich++) { + etaint[ich] = etaint_dot[ich] = etaint_dotdot[ich] = 0.0; + } + etaint_mass = new double[mtchain]; + + etamol = new double[mtchain]; + // add one extra dummy thermostat for eta_dot, set to zero + etamol_dot = new double[mtchain+1]; + etamol_dot[mtchain] = 0.0; + etamol_dotdot = new double[mtchain]; + for (ich = 0; ich < mtchain; ich++) { + etamol[ich] = etamol_dot[ich] = etamol_dotdot[ich] = 0.0; + } + etamol_mass = new double[mtchain]; + + etadrude = new double[mtchain]; + // add one extra dummy thermostat for eta_dot, set to zero + etadrude_dot = new double[mtchain+1]; + etadrude_dot[mtchain] = 0.0; + etadrude_dotdot = new double[mtchain]; + for (ich = 0; ich < mtchain; ich++) { + etadrude[ich] = etadrude_dot[ich] = etadrude_dotdot[ich] = 0.0; + } + etadrude_mass = new double[mtchain]; + } + + if (pstat_flag) { + omega[0] = omega[1] = omega[2] = 0.0; + omega_dot[0] = omega_dot[1] = omega_dot[2] = 0.0; + omega_mass[0] = omega_mass[1] = omega_mass[2] = 0.0; + omega[3] = omega[4] = omega[5] = 0.0; + omega_dot[3] = omega_dot[4] = omega_dot[5] = 0.0; + omega_mass[3] = omega_mass[4] = omega_mass[5] = 0.0; + + if (mpchain) { + int ich; + etap = new double[mpchain]; + + // add one extra dummy thermostat, set to zero + + etap_dot = new double[mpchain+1]; + etap_dot[mpchain] = 0.0; + etap_dotdot = new double[mpchain]; + for (ich = 0; ich < mpchain; ich++) { + etap[ich] = etap_dot[ich] = + etap_dotdot[ich] = 0.0; + } + etap_mass = new double[mpchain]; + } + } + + nrigid = 0; + rfix = nullptr; + + if (pre_exchange_flag) irregular = new Irregular(lmp); + else irregular = nullptr; + + // initialize vol0,t0 to zero to signal uninitialized + // values then assigned in init(), if necessary + + vol0 = t0 = 0.0; + + // find fix drude + int ifix; + for (ifix = 0; ifix < modify->nfix; ifix++) + if (strcmp(modify->fix[ifix]->style,"drude") == 0) break; + if (ifix == modify->nfix) error->all(FLERR, "fix tgnh/drude requires fix drude"); + fix_drude = (FixDrude *) modify->fix[ifix]; + + // make sure ghost atoms have velocity + if (!comm->ghost_velocity) + error->all(FLERR,"fix tgnh/drude requires ghost velocities. Use comm_modify vel yes"); +} + +/* ---------------------------------------------------------------------- */ + +FixTGNHDrude::~FixTGNHDrude() +{ + if (copymode) return; + + delete [] rfix; + + delete irregular; + + // delete temperature and pressure if fix created them + + if (tcomputeflag) modify->delete_compute(id_temp); + delete [] id_temp; + + if (tstat_flag) { + delete [] etaint; + delete [] etaint_dot; + delete [] etaint_dotdot; + delete [] etaint_mass; + delete [] etamol; + delete [] etamol_dot; + delete [] etamol_dotdot; + delete [] etamol_mass; + delete [] etadrude; + delete [] etadrude_dot; + delete [] etadrude_dotdot; + delete [] etadrude_mass; + } + + if (pstat_flag) { + if (pcomputeflag) modify->delete_compute(id_press); + delete [] id_press; + if (mpchain) { + delete [] etap; + delete [] etap_dot; + delete [] etap_dotdot; + delete [] etap_mass; + } + } +} + +/* ---------------------------------------------------------------------- */ + +int FixTGNHDrude::setmask() +{ + int mask = 0; + mask |= INITIAL_INTEGRATE; + mask |= FINAL_INTEGRATE; + mask |= THERMO_ENERGY; + mask |= INITIAL_INTEGRATE_RESPA; + mask |= FINAL_INTEGRATE_RESPA; + if (pre_exchange_flag) mask |= PRE_EXCHANGE; + return mask; +} + +/* ---------------------------------------------------------------------- */ + +void FixTGNHDrude::init() +{ + // ensure no conflict with fix deform + + if (pstat_flag) + for (int i = 0; i < modify->nfix; i++) + if (strcmp(modify->fix[i]->style,"deform") == 0) { + int *dimflag = ((FixDeform *) modify->fix[i])->dimflag; + if ((p_flag[0] && dimflag[0]) || (p_flag[1] && dimflag[1]) || + (p_flag[2] && dimflag[2]) || (p_flag[3] && dimflag[3]) || + (p_flag[4] && dimflag[4]) || (p_flag[5] && dimflag[5])) + error->all(FLERR,"Cannot use fix npt and fix deform on " + "same component of stress tensor"); + } + + // set temperature and pressure ptrs + + int icompute = modify->find_compute(id_temp); + if (icompute < 0) + error->all(FLERR,"Temperature ID for fix nvt/npt does not exist"); + temperature = modify->compute[icompute]; + + if (temperature->tempbias) which = BIAS; + else which = NOBIAS; + + if (pstat_flag) { + icompute = modify->find_compute(id_press); + if (icompute < 0) + error->all(FLERR,"Pressure ID for fix npt/nph does not exist"); + pressure = modify->compute[icompute]; + } + + // set timesteps and frequencies + + dtv = update->dt; + dtf = 0.5 * update->dt * force->ftm2v; + dthalf = 0.5 * update->dt; + dt4 = 0.25 * update->dt; + dt8 = 0.125 * update->dt; + dto = dthalf; + + p_freq_max = 0.0; + if (pstat_flag) { + p_freq_max = MAX(p_freq[0],p_freq[1]); + p_freq_max = MAX(p_freq_max,p_freq[2]); + if (pstyle == TRICLINIC) { + p_freq_max = MAX(p_freq_max,p_freq[3]); + p_freq_max = MAX(p_freq_max,p_freq[4]); + p_freq_max = MAX(p_freq_max,p_freq[5]); + } + } + + // tally the number of dimensions that are barostatted + // set initial volume and reference cell, if not already done + + if (pstat_flag) { + pdim = p_flag[0] + p_flag[1] + p_flag[2]; + if (vol0 == 0.0) { + if (dimension == 3) vol0 = domain->xprd * domain->yprd * domain->zprd; + else vol0 = domain->xprd * domain->yprd; + h0_inv[0] = domain->h_inv[0]; + h0_inv[1] = domain->h_inv[1]; + h0_inv[2] = domain->h_inv[2]; + h0_inv[3] = domain->h_inv[3]; + h0_inv[4] = domain->h_inv[4]; + h0_inv[5] = domain->h_inv[5]; + } + } + + boltz = force->boltz; + nktv2p = force->nktv2p; + + if (force->kspace) kspace_flag = 1; + else kspace_flag = 0; + + if (strstr(update->integrate_style,"respa")) { + nlevels_respa = ((Respa *) update->integrate)->nlevels; + step_respa = ((Respa *) update->integrate)->step; + dto = 0.5*step_respa[0]; + } + + // detect if any rigid fixes exist so rigid bodies move when box is remapped + // rfix[] = indices to each fix rigid + + delete [] rfix; + nrigid = 0; + rfix = nullptr; + + for (int i = 0; i < modify->nfix; i++) + if (modify->fix[i]->rigid_flag) nrigid++; + if (nrigid) { + rfix = new int[nrigid]; + nrigid = 0; + for (int i = 0; i < modify->nfix; i++) + if (modify->fix[i]->rigid_flag) rfix[nrigid++] = i; + } +} + +/* ---------------------------------------------------------------------- + compute T,P before integrator starts +------------------------------------------------------------------------- */ + +void FixTGNHDrude::setup_mol_mass_dof() { + double *mass = atom->mass; + int *mask = atom->mask; + tagint *molecule = atom->molecule; + int *type = atom->type; + int *drudetype = fix_drude->drudetype; + int n_drude, n_drude_tmp = 0; + tagint id_mol = 0, n_mol_in_group = 0; + + for (int i = 0; i < atom->nlocal; i++) { + // molecule id starts from 1. max(id_mol) equals to the number of molecules in the system + id_mol = std::max(id_mol, molecule[i]); + if (mask[i] & groupbit) { + if (drudetype[type[i]] == DRUDE_TYPE) + n_drude_tmp++; + } + } + MPI_Allreduce(&n_drude_tmp, &n_drude, 1, MPI_LMP_TAGINT, MPI_SUM, world); + MPI_Allreduce(&id_mol, &n_mol, 1, MPI_LMP_TAGINT, MPI_MAX, world); + + // use flag_mol to determine the number of molecules in the fix group + int *flag_mol = new int[n_mol + 1]; + int *flag_mol_tmp = new int[n_mol + 1]; + memset(flag_mol_tmp, 0, sizeof(int) * (n_mol + 1)); + for (int i = 0; i < atom->nlocal; i++) { + if (mask[i] & groupbit) { + flag_mol_tmp[molecule[i]] = 1; + } + } + MPI_Allreduce(flag_mol_tmp, flag_mol, n_mol + 1, MPI_INT, MPI_SUM, world); + for (int i = 1; i < n_mol + 1; i++) { + if (flag_mol[i]) + n_mol_in_group++; + } + delete[] flag_mol; + delete[] flag_mol_tmp; + + // length of v_mol set to n_mol+1, so that the subscript start from 1, we can call v_mol[n_mol] + memory->create(v_mol, n_mol + 1, 3, "fix_tgnh_drude::v_mol"); + memory->create(v_mol_tmp, n_mol + 1, 3, "fix_tgnh_drude::v_mol_tmp"); + memory->create(mass_mol, n_mol + 1, "fix_tgnh_drude::mass_mol"); + + double *mass_tmp = new double[n_mol + 1]; + memset(mass_tmp, 0, sizeof(double) * (n_mol + 1)); + for (int i = 0; i < atom->nlocal; i++) { + id_mol = molecule[i]; + mass_tmp[id_mol] += mass[type[i]]; + } + MPI_Allreduce(mass_tmp, mass_mol, n_mol + 1, MPI_DOUBLE, MPI_SUM, world); + delete[] mass_tmp; + + // DOFs + t_current = temperature->compute_scalar(); + tdof = temperature->dof; + // remove DOFs of COM translational motion based on the number of molecules in the group + dof_mol = 3.0 * n_mol_in_group - 3.0 * n_mol_in_group / n_mol; + dof_drude = 3.0 * n_drude; + dof_int = tdof - dof_mol - dof_drude; + + if (comm->me == 0) { + if (screen) { + fprintf(screen, "TGNHC thermostat for Drude model\n"); + fprintf(screen, " DOFs of molecules, atoms and dipoles: %.1f %.1f %.1f\n", + dof_mol, dof_int, dof_drude); + } + if (logfile) { + fprintf(logfile, "TGNHC thermostat for Drude model\n"); + fprintf(logfile, " DOFs of molecules, atoms and dipoles: %.1f %.1f %.1f\n", + dof_mol, dof_int, dof_drude); + } + } + if (dof_mol <=0 or dof_int <=0 or dof_drude <=0) + error->all(FLERR, "TGNHC thermostat requires DOFs of molecules, atoms and dipoles larger than 0"); +} + +void FixTGNHDrude::setup(int /*vflag*/) +{ + setup_mol_mass_dof(); + // t_target is needed by NVT and NPT in compute_scalar() + // If no thermostat or using fix nphug, + // t_target must be defined by other means. + + if (tstat_flag && strstr(style,"nphug") == nullptr) { + compute_temp_target(); + } else if (pstat_flag) { + + // t0 = reference temperature for masses + // cannot be done in init() b/c temperature cannot be called there + // is b/c Modify::init() inits computes after fixes due to dof dependence + // guesstimate a unit-dependent t0 if actual T = 0.0 + // if it was read in from a restart file, leave it be + + if (t0 == 0.0) { + t0 = temperature->compute_scalar(); + if (t0 == 0.0) { + if (strcmp(update->unit_style,"lj") == 0) t0 = 1.0; + else t0 = 300.0; + } + } + t_target = t0; + } + + if (pstat_flag) compute_press_target(); + + if (pstat_flag) { + if (pstyle == ISO) pressure->compute_scalar(); + else pressure->compute_vector(); + couple(); + pressure->addstep(update->ntimestep+1); + } + + // masses and initial forces on thermostat variables + + if (tstat_flag) { + etaint_mass[0] = ke2int_target / (t_freq * t_freq); + etamol_mass[0] = ke2mol_target / (t_freq * t_freq); + etadrude_mass[0] = ke2drude_target / (tdrude_freq * tdrude_freq); + for (int ich = 1; ich < mtchain; ich++) { + etaint_mass[ich] = boltz * t_target / (t_freq * t_freq); + etamol_mass[ich] = boltz * t_target / (t_freq * t_freq); + etadrude_mass[ich] = boltz * tdrude_target / (tdrude_freq * tdrude_freq); + + etaint_dotdot[ich] = (etaint_mass[ich - 1] * etaint_dot[ich - 1] * etaint_dot[ich - 1] - + boltz * t_target) / etaint_mass[ich]; + etamol_dotdot[ich] = (etamol_mass[ich - 1] * etamol_dot[ich - 1] * etamol_dot[ich - 1] - + boltz * t_target) / etamol_mass[ich]; + etadrude_dotdot[ich] = (etadrude_mass[ich - 1] * etadrude_dot[ich - 1] * etadrude_dot[ich - 1] - + boltz * tdrude_target) / etadrude_mass[ich]; + } + } + + // masses and initial forces on barostat variables + + if (pstat_flag) { + double kt = boltz * t_target; + double nkt = (atom->natoms + 1) * kt; + + for (int i = 0; i < 3; i++) + if (p_flag[i]) + omega_mass[i] = nkt/(p_freq[i]*p_freq[i]); + + if (pstyle == TRICLINIC) { + for (int i = 3; i < 6; i++) + if (p_flag[i]) omega_mass[i] = nkt/(p_freq[i]*p_freq[i]); + } + + // masses and initial forces on barostat thermostat variables + + if (mpchain) { + etap_mass[0] = boltz * t_target / (p_freq_max*p_freq_max); + for (int ich = 1; ich < mpchain; ich++) + etap_mass[ich] = boltz * t_target / (p_freq_max*p_freq_max); + for (int ich = 1; ich < mpchain; ich++) + etap_dotdot[ich] = + (etap_mass[ich-1]*etap_dot[ich-1]*etap_dot[ich-1] - + boltz * t_target) / etap_mass[ich]; + } + } +} + +/* ---------------------------------------------------------------------- + 1st half of Verlet update +------------------------------------------------------------------------- */ + +void FixTGNHDrude::initial_integrate(int /*vflag*/) +{ + // update eta_press_dot + + if (pstat_flag && mpchain) nhc_press_integrate(); + + // update eta_dot + + if (tstat_flag) { + compute_temp_target(); + nhc_temp_integrate(); + } + + // need to recompute pressure to account for change in KE + // t_current is up-to-date, but compute_temperature is not + // compute appropriately coupled elements of mvv_current + + if (pstat_flag) { + if (pstyle == ISO) { + temperature->compute_scalar(); + pressure->compute_scalar(); + } else { + temperature->compute_vector(); + pressure->compute_vector(); + } + couple(); + pressure->addstep(update->ntimestep+1); + } + + if (pstat_flag) { + compute_press_target(); + nh_omega_dot(); + nh_v_press(); + } + + nve_v(); + + // remap simulation box by 1/2 step + + if (pstat_flag) remap(); + + nve_x(); + + // remap simulation box by 1/2 step + // redo KSpace coeffs since volume has changed + + if (pstat_flag) { + remap(); + if (kspace_flag) force->kspace->setup(); + } +} + +/* ---------------------------------------------------------------------- + 2nd half of Verlet update +------------------------------------------------------------------------- */ + +void FixTGNHDrude::final_integrate() +{ + nve_v(); + + // re-compute temp before nh_v_press() + // only needed for temperature computes with BIAS on reneighboring steps: + // b/c some biases store per-atom values (e.g. temp/profile) + // per-atom values are invalid if reneigh/comm occurred + // since temp->compute() in initial_integrate() + + if (which == BIAS && neighbor->ago == 0) + t_current = temperature->compute_scalar(); + + if (pstat_flag) nh_v_press(); + + // compute new T,P after velocities rescaled by nh_v_press() + // compute appropriately coupled elements of mvv_current + + t_current = temperature->compute_scalar(); + tdof = temperature->dof; + + // need to recompute pressure to account for change in KE + // t_current is up-to-date, but compute_temperature is not + // compute appropriately coupled elements of mvv_current + + if (pstat_flag) { + if (pstyle == ISO) pressure->compute_scalar(); + else { + temperature->compute_vector(); + pressure->compute_vector(); + } + couple(); + pressure->addstep(update->ntimestep+1); + } + + if (pstat_flag) nh_omega_dot(); + + // update eta_dot + // update eta_press_dot + + if (tstat_flag) nhc_temp_integrate(); + if (pstat_flag && mpchain) nhc_press_integrate(); +} + +/* ---------------------------------------------------------------------- */ + +void FixTGNHDrude::initial_integrate_respa(int /*vflag*/, int ilevel, int /*iloop*/) +{ + // set timesteps by level + + dtv = step_respa[ilevel]; + dtf = 0.5 * step_respa[ilevel] * force->ftm2v; + dthalf = 0.5 * step_respa[ilevel]; + + // outermost level - update eta_dot and omega_dot, apply to v + // all other levels - NVE update of v + // x,v updates only performed for atoms in group + + if (ilevel == nlevels_respa-1) { + + // update eta_press_dot + + if (pstat_flag && mpchain) nhc_press_integrate(); + + // update eta_dot + + if (tstat_flag) { + compute_temp_target(); + nhc_temp_integrate(); + } + + // recompute pressure to account for change in KE + // t_current is up-to-date, but compute_temperature is not + // compute appropriately coupled elements of mvv_current + + if (pstat_flag) { + if (pstyle == ISO) { + temperature->compute_scalar(); + pressure->compute_scalar(); + } else { + temperature->compute_vector(); + pressure->compute_vector(); + } + couple(); + pressure->addstep(update->ntimestep+1); + } + + if (pstat_flag) { + compute_press_target(); + nh_omega_dot(); + nh_v_press(); + } + + nve_v(); + + } else nve_v(); + + // innermost level - also update x only for atoms in group + // if barostat, perform 1/2 step remap before and after + + if (ilevel == 0) { + if (pstat_flag) remap(); + nve_x(); + if (pstat_flag) remap(); + } + + // if barostat, redo KSpace coeffs at outermost level, + // since volume has changed + + if (ilevel == nlevels_respa-1 && kspace_flag && pstat_flag) + force->kspace->setup(); +} + +/* ---------------------------------------------------------------------- */ + +void FixTGNHDrude::final_integrate_respa(int ilevel, int /*iloop*/) +{ + // set timesteps by level + + dtf = 0.5 * step_respa[ilevel] * force->ftm2v; + dthalf = 0.5 * step_respa[ilevel]; + + // outermost level - update eta_dot and omega_dot, apply via final_integrate + // all other levels - NVE update of v + + if (ilevel == nlevels_respa-1) final_integrate(); + else nve_v(); +} + +/* ---------------------------------------------------------------------- */ + +void FixTGNHDrude::couple() +{ + double *tensor = pressure->vector; + + if (pstyle == ISO) + p_current[0] = p_current[1] = p_current[2] = pressure->scalar; + else if (pcouple == XYZ) { + double ave = 1.0/3.0 * (tensor[0] + tensor[1] + tensor[2]); + p_current[0] = p_current[1] = p_current[2] = ave; + } else if (pcouple == XY) { + double ave = 0.5 * (tensor[0] + tensor[1]); + p_current[0] = p_current[1] = ave; + p_current[2] = tensor[2]; + } else if (pcouple == YZ) { + double ave = 0.5 * (tensor[1] + tensor[2]); + p_current[1] = p_current[2] = ave; + p_current[0] = tensor[0]; + } else if (pcouple == XZ) { + double ave = 0.5 * (tensor[0] + tensor[2]); + p_current[0] = p_current[2] = ave; + p_current[1] = tensor[1]; + } else { + p_current[0] = tensor[0]; + p_current[1] = tensor[1]; + p_current[2] = tensor[2]; + } + + if (!std::isfinite(p_current[0]) || !std::isfinite(p_current[1]) || !std::isfinite(p_current[2])) + error->all(FLERR,"Non-numeric pressure - simulation unstable"); + + // switch order from xy-xz-yz to Voigt + + if (pstyle == TRICLINIC) { + p_current[3] = tensor[5]; + p_current[4] = tensor[4]; + p_current[5] = tensor[3]; + + if (!std::isfinite(p_current[3]) || !std::isfinite(p_current[4]) || !std::isfinite(p_current[5])) + error->all(FLERR,"Non-numeric pressure - simulation unstable"); + } +} + +/* ---------------------------------------------------------------------- + change box size + remap all atoms or dilate group atoms depending on allremap flag + if rigid bodies exist, scale rigid body centers-of-mass +------------------------------------------------------------------------- */ + +void FixTGNHDrude::remap() +{ + int i; + double oldlo,oldhi; + double expfac; + + double **x = atom->x; + int *mask = atom->mask; + int nlocal = atom->nlocal; + double *h = domain->h; + + // omega is not used, except for book-keeping + + for (int i = 0; i < 6; i++) omega[i] += dto*omega_dot[i]; + + // convert pertinent atoms and rigid bodies to lamda coords + + domain->x2lamda(nlocal); + + if (nrigid) + for (i = 0; i < nrigid; i++) + modify->fix[rfix[i]]->deform(0); + + // reset global and local box to new size/shape + + // this operation corresponds to applying the + // translate and scale operations + // corresponding to the solution of the following ODE: + // + // h_dot = omega_dot * h + // + // where h_dot, omega_dot and h are all upper-triangular + // 3x3 tensors. In Voigt notation, the elements of the + // RHS product tensor are: + // h_dot = [0*0, 1*1, 2*2, 1*3+3*2, 0*4+5*3+4*2, 0*5+5*1] + // + // Ordering of operations preserves time symmetry. + + double dto2 = dto/2.0; + double dto4 = dto/4.0; + double dto8 = dto/8.0; + + // off-diagonal components, first half + + if (pstyle == TRICLINIC) { + + if (p_flag[4]) { + expfac = exp(dto8*omega_dot[0]); + h[4] *= expfac; + h[4] += dto4*(omega_dot[5]*h[3]+omega_dot[4]*h[2]); + h[4] *= expfac; + } + + if (p_flag[3]) { + expfac = exp(dto4*omega_dot[1]); + h[3] *= expfac; + h[3] += dto2*(omega_dot[3]*h[2]); + h[3] *= expfac; + } + + if (p_flag[5]) { + expfac = exp(dto4*omega_dot[0]); + h[5] *= expfac; + h[5] += dto2*(omega_dot[5]*h[1]); + h[5] *= expfac; + } + + if (p_flag[4]) { + expfac = exp(dto8*omega_dot[0]); + h[4] *= expfac; + h[4] += dto4*(omega_dot[5]*h[3]+omega_dot[4]*h[2]); + h[4] *= expfac; + } + } + + // scale diagonal components + // scale tilt factors with cell, if set + + if (p_flag[0]) { + oldlo = domain->boxlo[0]; + oldhi = domain->boxhi[0]; + expfac = exp(dto*omega_dot[0]); + domain->boxlo[0] = (oldlo-fixedpoint[0])*expfac + fixedpoint[0]; + domain->boxhi[0] = (oldhi-fixedpoint[0])*expfac + fixedpoint[0]; + } + + if (p_flag[1]) { + oldlo = domain->boxlo[1]; + oldhi = domain->boxhi[1]; + expfac = exp(dto*omega_dot[1]); + domain->boxlo[1] = (oldlo-fixedpoint[1])*expfac + fixedpoint[1]; + domain->boxhi[1] = (oldhi-fixedpoint[1])*expfac + fixedpoint[1]; + if (scalexy) h[5] *= expfac; + } + + if (p_flag[2]) { + oldlo = domain->boxlo[2]; + oldhi = domain->boxhi[2]; + expfac = exp(dto*omega_dot[2]); + domain->boxlo[2] = (oldlo-fixedpoint[2])*expfac + fixedpoint[2]; + domain->boxhi[2] = (oldhi-fixedpoint[2])*expfac + fixedpoint[2]; + if (scalexz) h[4] *= expfac; + if (scaleyz) h[3] *= expfac; + } + + // off-diagonal components, second half + + if (pstyle == TRICLINIC) { + + if (p_flag[4]) { + expfac = exp(dto8*omega_dot[0]); + h[4] *= expfac; + h[4] += dto4*(omega_dot[5]*h[3]+omega_dot[4]*h[2]); + h[4] *= expfac; + } + + if (p_flag[3]) { + expfac = exp(dto4*omega_dot[1]); + h[3] *= expfac; + h[3] += dto2*(omega_dot[3]*h[2]); + h[3] *= expfac; + } + + if (p_flag[5]) { + expfac = exp(dto4*omega_dot[0]); + h[5] *= expfac; + h[5] += dto2*(omega_dot[5]*h[1]); + h[5] *= expfac; + } + + if (p_flag[4]) { + expfac = exp(dto8*omega_dot[0]); + h[4] *= expfac; + h[4] += dto4*(omega_dot[5]*h[3]+omega_dot[4]*h[2]); + h[4] *= expfac; + } + + } + + domain->yz = h[3]; + domain->xz = h[4]; + domain->xy = h[5]; + + // tilt factor to cell length ratio can not exceed TILTMAX in one step + + if (domain->yz < -TILTMAX*domain->yprd || + domain->yz > TILTMAX*domain->yprd || + domain->xz < -TILTMAX*domain->xprd || + domain->xz > TILTMAX*domain->xprd || + domain->xy < -TILTMAX*domain->xprd || + domain->xy > TILTMAX*domain->xprd) + error->all(FLERR,"Fix npt/nph has tilted box too far in one step - " + "periodic cell is too far from equilibrium state"); + + domain->set_global_box(); + domain->set_local_box(); + + // convert pertinent atoms and rigid bodies back to box coords + + domain->lamda2x(nlocal); + + if (nrigid) + for (i = 0; i < nrigid; i++) + modify->fix[rfix[i]]->deform(1); +} + +/* ---------------------------------------------------------------------- + pack entire state of Fix into one write +------------------------------------------------------------------------- */ + +void FixTGNHDrude::write_restart(FILE *fp) +{ + int nsize = size_restart_global(); + + double *list; + memory->create(list,nsize,"nh:list"); + + pack_restart_data(list); + + if (comm->me == 0) { + int size = nsize * sizeof(double); + fwrite(&size,sizeof(int),1,fp); + fwrite(list,sizeof(double),nsize,fp); + } + + memory->destroy(list); +} + +/* ---------------------------------------------------------------------- + calculate the number of data to be packed +------------------------------------------------------------------------- */ + +int FixTGNHDrude::size_restart_global() +{ + int nsize = 2; + if (tstat_flag) nsize += 1 + 6*mtchain; + if (pstat_flag) { + nsize += 16 + 2*mpchain; + if (deviatoric_flag) nsize += 6; + } + + return nsize; +} + +/* ---------------------------------------------------------------------- + pack restart data +------------------------------------------------------------------------- */ + +int FixTGNHDrude::pack_restart_data(double *list) +{ + int n = 0; + + list[n++] = tstat_flag; + if (tstat_flag) { + list[n++] = mtchain; + for (int ich = 0; ich < mtchain; ich++){ + list[n++] = etamol[ich]; + list[n++] = etaint[ich]; + list[n++] = etadrude[ich]; + } + for (int ich = 0; ich < mtchain; ich++) { + list[n++] = etamol_dot[ich]; + list[n++] = etaint_dot[ich]; + list[n++] = etadrude_dot[ich]; + } + } + + list[n++] = pstat_flag; + if (pstat_flag) { + list[n++] = omega[0]; + list[n++] = omega[1]; + list[n++] = omega[2]; + list[n++] = omega[3]; + list[n++] = omega[4]; + list[n++] = omega[5]; + list[n++] = omega_dot[0]; + list[n++] = omega_dot[1]; + list[n++] = omega_dot[2]; + list[n++] = omega_dot[3]; + list[n++] = omega_dot[4]; + list[n++] = omega_dot[5]; + list[n++] = vol0; + list[n++] = t0; + list[n++] = mpchain; + if (mpchain) { + for (int ich = 0; ich < mpchain; ich++) + list[n++] = etap[ich]; + for (int ich = 0; ich < mpchain; ich++) + list[n++] = etap_dot[ich]; + } + + list[n++] = deviatoric_flag; + if (deviatoric_flag) { + list[n++] = h0_inv[0]; + list[n++] = h0_inv[1]; + list[n++] = h0_inv[2]; + list[n++] = h0_inv[3]; + list[n++] = h0_inv[4]; + list[n++] = h0_inv[5]; + } + } + + return n; +} + +/* ---------------------------------------------------------------------- + use state info from restart file to restart the Fix +------------------------------------------------------------------------- */ + +void FixTGNHDrude::restart(char *buf) +{ + int n = 0; + double *list = (double *) buf; + int flag = static_cast (list[n++]); + if (flag) { + int m = static_cast (list[n++]); + if (tstat_flag && m == mtchain) { + for (int ich = 0; ich < mtchain; ich++){ + etamol[ich] = list[n++]; + etaint[ich] = list[n++]; + etadrude[ich] = list[n++]; + } + for (int ich = 0; ich < mtchain; ich++){ + etamol_dot[ich] = list[n++]; + etaint_dot[ich] = list[n++]; + etadrude_dot[ich] = list[n++]; + } + } else n += 2*m; + } + flag = static_cast (list[n++]); + if (flag) { + omega[0] = list[n++]; + omega[1] = list[n++]; + omega[2] = list[n++]; + omega[3] = list[n++]; + omega[4] = list[n++]; + omega[5] = list[n++]; + omega_dot[0] = list[n++]; + omega_dot[1] = list[n++]; + omega_dot[2] = list[n++]; + omega_dot[3] = list[n++]; + omega_dot[4] = list[n++]; + omega_dot[5] = list[n++]; + vol0 = list[n++]; + t0 = list[n++]; + int m = static_cast (list[n++]); + if (pstat_flag && m == mpchain) { + for (int ich = 0; ich < mpchain; ich++) + etap[ich] = list[n++]; + for (int ich = 0; ich < mpchain; ich++) + etap_dot[ich] = list[n++]; + } else n+=2*m; + flag = static_cast (list[n++]); + if (flag) { + h0_inv[0] = list[n++]; + h0_inv[1] = list[n++]; + h0_inv[2] = list[n++]; + h0_inv[3] = list[n++]; + h0_inv[4] = list[n++]; + h0_inv[5] = list[n++]; + } + } +} + +/* ---------------------------------------------------------------------- */ + +int FixTGNHDrude::modify_param(int narg, char **arg) +{ + if (strcmp(arg[0],"temp") == 0) { + if (narg < 2) error->all(FLERR,"Illegal fix_modify command"); + if (tcomputeflag) { + modify->delete_compute(id_temp); + tcomputeflag = 0; + } + delete [] id_temp; + int n = strlen(arg[1]) + 1; + id_temp = new char[n]; + strcpy(id_temp,arg[1]); + + int icompute = modify->find_compute(arg[1]); + if (icompute < 0) + error->all(FLERR,"Could not find fix_modify temperature ID"); + temperature = modify->compute[icompute]; + + if (temperature->tempflag == 0) + error->all(FLERR, + "Fix_modify temperature ID does not compute temperature"); + if (temperature->igroup != 0 && comm->me == 0) + error->warning(FLERR,"Temperature for fix modify is not for group all"); + + // reset id_temp of pressure to new temperature ID + + if (pstat_flag) { + icompute = modify->find_compute(id_press); + if (icompute < 0) + error->all(FLERR,"Pressure ID for fix modify does not exist"); + modify->compute[icompute]->reset_extra_compute_fix(id_temp); + } + + return 2; + + } else if (strcmp(arg[0],"press") == 0) { + if (narg < 2) error->all(FLERR,"Illegal fix_modify command"); + if (!pstat_flag) error->all(FLERR,"Illegal fix_modify command"); + if (pcomputeflag) { + modify->delete_compute(id_press); + pcomputeflag = 0; + } + delete [] id_press; + int n = strlen(arg[1]) + 1; + id_press = new char[n]; + strcpy(id_press,arg[1]); + + int icompute = modify->find_compute(arg[1]); + if (icompute < 0) error->all(FLERR,"Could not find fix_modify pressure ID"); + pressure = modify->compute[icompute]; + + if (pressure->pressflag == 0) + error->all(FLERR,"Fix_modify pressure ID does not compute pressure"); + return 2; + } + + return 0; +} + +/* ---------------------------------------------------------------------- */ + +double FixTGNHDrude::compute_scalar() +{ + int i; + double volume; + double energy; + double kt = boltz * t_target; + double kt_drude = boltz * tdrude_target; + double lkt_press = 0.0; + int ich; + if (dimension == 3) volume = domain->xprd * domain->yprd * domain->zprd; + else volume = domain->xprd * domain->yprd; + + energy = 0.0; + + // thermostat chain energy is equivalent to Eq. (2) in + // Martyna, Tuckerman, Tobias, Klein, Mol Phys, 87, 1117 + // Sum(0.5*p_eta_k^2/Q_k,k=1,M) + L*k*T*eta_1 + Sum(k*T*eta_k,k=2,M), + // where L = tdof + // M = mtchain + // p_eta_k = Q_k*eta_dot[k-1] + // Q_1 = L*k*T/t_freq^2 + // Q_k = k*T/t_freq^2, k > 1 + + if (tstat_flag) { + energy += ke2mol_target * etamol[0] + 0.5 * etamol_mass[0] * etamol_dot[0] * etamol_dot[0]; + energy += ke2int_target * etaint[0] + 0.5 * etaint_mass[0] * etaint_dot[0] * etaint_dot[0]; + energy += ke2drude_target * etadrude[0] + 0.5 * etadrude_mass[0] * etadrude_dot[0] * etadrude_dot[0]; + for (ich = 1; ich < mtchain; ich++){ + energy += kt * etamol[ich] + 0.5*etamol_mass[ich]*etamol_dot[ich]*etamol_dot[ich]; + energy += kt * etaint[ich] + 0.5*etaint_mass[ich]*etaint_dot[ich]*etaint_dot[ich]; + energy += kt_drude * etadrude[ich] + 0.5*etadrude_mass[ich]*etadrude_dot[ich]*etadrude_dot[ich]; + } + } + + // barostat energy is equivalent to Eq. (8) in + // Martyna, Tuckerman, Tobias, Klein, Mol Phys, 87, 1117 + // Sum(0.5*p_omega^2/W + P*V), + // where N = natoms + // p_omega = W*omega_dot + // W = N*k*T/p_freq^2 + // sum is over barostatted dimensions + + if (pstat_flag) { + for (i = 0; i < 3; i++) { + if (p_flag[i]) { + energy += 0.5*omega_dot[i]*omega_dot[i]*omega_mass[i] + + p_hydro*(volume-vol0) / (pdim*nktv2p); + lkt_press += kt; + } + } + + if (pstyle == TRICLINIC) { + for (i = 3; i < 6; i++) { + if (p_flag[i]) { + energy += 0.5*omega_dot[i]*omega_dot[i]*omega_mass[i]; + lkt_press += kt; + } + } + } + + // extra contributions from thermostat chain for barostat + + if (mpchain) { + energy += lkt_press * etap[0] + 0.5*etap_mass[0]*etap_dot[0]*etap_dot[0]; + for (ich = 1; ich < mpchain; ich++) + energy += kt * etap[ich] + + 0.5*etap_mass[ich]*etap_dot[ich]*etap_dot[ich]; + } + + // extra contribution from strain energy + + if (deviatoric_flag) energy += compute_strain_energy(); + } + + return energy; +} + +/* ---------------------------------------------------------------------- */ + +double FixTGNHDrude::compute_vector(int n) +{ + if (!temp_computed_end_of_step) + compute_temp_mol_int_drude(true); + switch (n){ + case 0: + return t_mol; + case 1: + return t_int; + case 2: + return t_drude; + default: + return 0.0; + } +} + +/* ---------------------------------------------------------------------- */ + +void FixTGNHDrude::reset_target(double t_new) +{ + t_target = t_start = t_stop = t_new; +} + +/* ---------------------------------------------------------------------- */ + +void FixTGNHDrude::reset_dt() +{ + dtv = update->dt; + dtf = 0.5 * update->dt * force->ftm2v; + dthalf = 0.5 * update->dt; + dt4 = 0.25 * update->dt; + dt8 = 0.125 * update->dt; + dto = dthalf; + + // If using respa, then remap is performed in innermost level + + if (strstr(update->integrate_style,"respa")) + dto = 0.5*step_respa[0]; +} + +void FixTGNHDrude::compute_temp_mol_int_drude(bool end_of_step) { + double **v = atom->v; + double *mass = atom->mass; + tagint *molecule = atom->molecule; + int *type = atom->type; + int *mask = atom->mask; + int *drudetype = fix_drude->drudetype; + tagint *drudeid = fix_drude->drudeid; + int imol, ci, di; + double mass_com, mass_reduced, mass_core, mass_drude; + double vint, vcom, vrel; + // use array instead of two numbers to save MPI_Allreduce() + double ke2_int_drude_tmp[2] = {0.0, 0.0}; + double ke2_int_drude[2]; + + memset(*v_mol_tmp, 0, sizeof(double) * (n_mol + 1) * 3); // the length of v_mol is n_mol+1 + + /** + * If there are velocity bias, need to remove them before calculate kinetic energies + */ + for (int i = 0; i < atom->nlocal; i++) { + if (mask[i] & groupbit) { + if (which == BIAS) + temperature->remove_bias(i, v[i]); + + imol = molecule[i]; + for (int k = 0; k < 3; k++) + v_mol_tmp[imol][k] += v[i][k] * mass[type[i]]; + + if (which == BIAS) + temperature->restore_bias(i, v[i]); + } + } + MPI_Allreduce(*v_mol_tmp, *v_mol, (n_mol + 1) * 3, MPI_DOUBLE, MPI_SUM, world); + + ke2mol = 0; + for (int i = 1; i < n_mol + 1; i++) { + for (int k = 0; k < 3; k++) { + v_mol[i][k] /= mass_mol[i]; + ke2mol += mass_mol[i] * (v_mol[i][k] * v_mol[i][k]); + } + } + ke2mol *= force->mvv2e; + t_mol = ke2mol / dof_mol / boltz; + + /** + * Have to call remove_bias at the innermost loop, because drude atom may be a ghost + */ + for (int i = 0; i < atom->nlocal; i++) { + if (mask[i] & groupbit) { + imol = molecule[i]; + if (drudetype[type[i]] == NOPOL_TYPE) { + if (which == BIAS) + temperature->remove_bias(i, v[i]); + for (int k = 0; k < 3; k++) { + vint = v[i][k] - v_mol[imol][k]; + ke2_int_drude_tmp[0] += mass[type[i]] * vint * vint; + } + if (which == BIAS) + temperature->restore_bias(i, v[i]); + } else if (drudetype[type[i]] == CORE_TYPE) { + /** + * have to use closet_image() + * even though all images have the same velocity and it's sort of read-only + * but the bias velocity may depends on it's position like in compute vis/pp + */ + ci = i; + di = domain->closest_image(i, atom->map(drudeid[i])); + if (which == BIAS) { + temperature->remove_bias(ci, v[ci]); + temperature->remove_bias(di, v[di]); + } + mass_core = mass[type[ci]]; + mass_drude = mass[type[di]]; + mass_com = mass_core + mass_drude; + mass_reduced = mass_core * mass_drude / mass_com; + for (int k = 0; k < 3; k++) { + vcom = (mass_core * v[ci][k] + mass_drude * v[di][k]) / mass_com; + vint = vcom - v_mol[imol][k]; + ke2_int_drude_tmp[0] += mass_com * vint * vint; + vrel = v[di][k] - v[ci][k]; + ke2_int_drude_tmp[1] += mass_reduced * vrel * vrel; + } + if (which == BIAS) { + temperature->restore_bias(ci, v[ci]); + temperature->restore_bias(di, v[di]); + } + } + } + } + MPI_Allreduce(ke2_int_drude_tmp, ke2_int_drude, 2, MPI_DOUBLE, MPI_SUM, world); + ke2int = ke2_int_drude[0] * force->mvv2e; + ke2drude = ke2_int_drude[1] * force->mvv2e; + t_int = ke2int / dof_int / boltz; + t_drude = ke2drude / dof_drude / boltz; + + temp_computed_end_of_step = end_of_step; +} + +/* ---------------------------------------------------------------------- + perform half-step update of chain thermostat variables +------------------------------------------------------------------------- */ + +void FixTGNHDrude::nhc_temp_integrate() +{ + compute_temp_mol_int_drude(false); + + // update masses of thermostat in case target temperature changes + etamol_mass[0] = ke2mol_target / (t_freq*t_freq); + etaint_mass[0] = ke2int_target / (t_freq*t_freq); + for (int ich = 1; ich < mtchain; ich++){ + etamol_mass[ich] = boltz * t_target / (t_freq*t_freq); + etaint_mass[ich] = boltz * t_target / (t_freq*t_freq); + } + + // thermostat for molecular COM + factor_eta_mol = propagate(etamol, etamol_dot, etamol_dotdot, etamol_mass, + ke2mol, ke2mol_target, t_target); + factor_eta_int = propagate(etaint, etaint_dot, etaint_dotdot, etaint_mass, + ke2int, ke2int_target, t_target); + factor_eta_drude = propagate(etadrude, etadrude_dot, etadrude_dotdot, etadrude_mass, + ke2drude, ke2drude_target, tdrude_target); + + nh_v_temp(); +} + +double FixTGNHDrude::propagate(double *eta, double *eta_dot, double *eta_dotdot, const double *eta_mass, + const double &ke2, const double &ke2_target, const double &tt) const { + int ich; + double expfac; + double ncfac = 1.0 / nc_tchain; + double factor_eta = 1.0; + + eta_dotdot[0] = (ke2 - ke2_target) / eta_mass[0]; + for (int iloop = 0; iloop < nc_tchain; iloop++) { + for (ich = mtchain - 1; ich > 0; ich--) { + expfac = exp(-ncfac * dt8 * eta_dot[ich + 1]); + eta_dot[ich] *= expfac; + eta_dot[ich] += eta_dotdot[ich] * ncfac * dt4; + eta_dot[ich] *= expfac; + } + expfac = exp(-ncfac * dt8 * eta_dot[1]); + eta_dot[0] *= expfac; + eta_dot[0] += eta_dotdot[0] * ncfac * dt4; + eta_dot[0] *= expfac; + factor_eta *= exp(-ncfac * dthalf * eta_dot[0]); + + for (ich = 0; ich < mtchain; ich++) + eta[ich] += ncfac * dthalf * eta_dot[ich]; + + eta_dotdot[0] = (ke2 * factor_eta * factor_eta - ke2_target) / eta_mass[0]; + eta_dot[0] *= expfac; + eta_dot[0] += eta_dotdot[0] * ncfac * dt4; + eta_dot[0] *= expfac; + for (ich = 1; ich < mtchain; ich++) { + expfac = exp(-ncfac * dt8 * eta_dot[ich + 1]); + eta_dot[ich] *= expfac; + eta_dotdot[ich] = (eta_mass[ich - 1] * eta_dot[ich - 1] * eta_dot[ich - 1] + - boltz * tt) / eta_mass[ich]; + eta_dot[ich] += eta_dotdot[ich] * ncfac * dt4; + eta_dot[ich] *= expfac; + } + } + return factor_eta; +} + +/* ---------------------------------------------------------------------- + perform half-step update of chain thermostat variables for barostat + scale barostat velocities +------------------------------------------------------------------------- */ + +void FixTGNHDrude::nhc_press_integrate() +{ + int ich,i,pdof; + double expfac,factor_etap,kecurrent; + double kt = boltz * t_target; + double lkt_press; + + // Update masses, to preserve initial freq, if t_target changed + double nkt = (atom->natoms + 1) * kt; + for (int i = 0; i < 3; i++) + if (p_flag[i]) + omega_mass[i] = nkt / (p_freq[i] * p_freq[i]); + if (pstyle == TRICLINIC) { + for (int i = 3; i < 6; i++) + if (p_flag[i]) omega_mass[i] = nkt / (p_freq[i] * p_freq[i]); + } + if (mpchain) { + etap_mass[0] = kt / (p_freq_max * p_freq_max); + for (int ich = 1; ich < mpchain; ich++) + etap_mass[ich] = kt / (p_freq_max * p_freq_max); + for (int ich = 1; ich < mpchain; ich++) + etap_dotdot[ich] = (etap_mass[ich - 1] * etap_dot[ich - 1] * etap_dot[ich - 1] + - kt) / etap_mass[ich]; + } + + kecurrent = 0.0; + pdof = 0; + for (i = 0; i < 3; i++) + if (p_flag[i]) { + kecurrent += omega_mass[i]*omega_dot[i]*omega_dot[i]; + pdof++; + } + + if (pstyle == TRICLINIC) { + for (i = 3; i < 6; i++) + if (p_flag[i]) { + kecurrent += omega_mass[i]*omega_dot[i]*omega_dot[i]; + pdof++; + } + } + + if (pstyle == ISO) lkt_press = kt; + else lkt_press = pdof * kt; + etap_dotdot[0] = (kecurrent - lkt_press)/etap_mass[0]; + + double ncfac = 1.0/nc_pchain; + for (int iloop = 0; iloop < nc_pchain; iloop++) { + + for (ich = mpchain-1; ich > 0; ich--) { + expfac = exp(-ncfac*dt8*etap_dot[ich+1]); + etap_dot[ich] *= expfac; + etap_dot[ich] += etap_dotdot[ich] * ncfac*dt4; + etap_dot[ich] *= expfac; + } + + expfac = exp(-ncfac*dt8*etap_dot[1]); + etap_dot[0] *= expfac; + etap_dot[0] += etap_dotdot[0] * ncfac*dt4; + etap_dot[0] *= expfac; + + for (ich = 0; ich < mpchain; ich++) + etap[ich] += ncfac*dthalf*etap_dot[ich]; + + factor_etap = exp(-ncfac*dthalf*etap_dot[0]); + for (i = 0; i < 3; i++) + if (p_flag[i]) omega_dot[i] *= factor_etap; + + if (pstyle == TRICLINIC) { + for (i = 3; i < 6; i++) + if (p_flag[i]) omega_dot[i] *= factor_etap; + } + + kecurrent = 0.0; + for (i = 0; i < 3; i++) + if (p_flag[i]) kecurrent += omega_mass[i]*omega_dot[i]*omega_dot[i]; + + if (pstyle == TRICLINIC) { + for (i = 3; i < 6; i++) + if (p_flag[i]) kecurrent += omega_mass[i]*omega_dot[i]*omega_dot[i]; + } + + etap_dotdot[0] = (kecurrent - lkt_press)/etap_mass[0]; + + etap_dot[0] *= expfac; + etap_dot[0] += etap_dotdot[0] * ncfac*dt4; + etap_dot[0] *= expfac; + + for (ich = 1; ich < mpchain; ich++) { + expfac = exp(-ncfac*dt8*etap_dot[ich+1]); + etap_dot[ich] *= expfac; + etap_dotdot[ich] = + (etap_mass[ich-1]*etap_dot[ich-1]*etap_dot[ich-1] - kt) / etap_mass[ich]; + etap_dot[ich] += etap_dotdot[ich] * ncfac*dt4; + etap_dot[ich] *= expfac; + } + } +} + +/* ---------------------------------------------------------------------- + perform half-step barostat scaling of velocities +-----------------------------------------------------------------------*/ + +void FixTGNHDrude::nh_v_press() +{ + double factor[3]; + double **v = atom->v; + int *mask = atom->mask; + int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; + + factor[0] = exp(-dt4*(omega_dot[0]+mtk_term2)); + factor[1] = exp(-dt4*(omega_dot[1]+mtk_term2)); + factor[2] = exp(-dt4*(omega_dot[2]+mtk_term2)); + + if (which == NOBIAS) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + v[i][0] *= factor[0]; + v[i][1] *= factor[1]; + v[i][2] *= factor[2]; + if (pstyle == TRICLINIC) { + v[i][0] += -dthalf*(v[i][1]*omega_dot[5] + v[i][2]*omega_dot[4]); + v[i][1] += -dthalf*v[i][2]*omega_dot[3]; + } + v[i][0] *= factor[0]; + v[i][1] *= factor[1]; + v[i][2] *= factor[2]; + } + } + } else if (which == BIAS) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + temperature->remove_bias(i,v[i]); + v[i][0] *= factor[0]; + v[i][1] *= factor[1]; + v[i][2] *= factor[2]; + if (pstyle == TRICLINIC) { + v[i][0] += -dthalf*(v[i][1]*omega_dot[5] + v[i][2]*omega_dot[4]); + v[i][1] += -dthalf*v[i][2]*omega_dot[3]; + } + v[i][0] *= factor[0]; + v[i][1] *= factor[1]; + v[i][2] *= factor[2]; + temperature->restore_bias(i,v[i]); + } + } + } +} + +/* ---------------------------------------------------------------------- + perform half-step update of velocities +-----------------------------------------------------------------------*/ + +void FixTGNHDrude::nve_v() +{ + double dtfm; + double **v = atom->v; + double **f = atom->f; + double *rmass = atom->rmass; + double *mass = atom->mass; + int *type = atom->type; + int *mask = atom->mask; + int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; + + if (rmass) { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + dtfm = dtf / rmass[i]; + v[i][0] += dtfm*f[i][0]; + v[i][1] += dtfm*f[i][1]; + v[i][2] += dtfm*f[i][2]; + } + } + } else { + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + dtfm = dtf / mass[type[i]]; + v[i][0] += dtfm*f[i][0]; + v[i][1] += dtfm*f[i][1]; + v[i][2] += dtfm*f[i][2]; + } + } + } +} + +/* ---------------------------------------------------------------------- + perform full-step update of positions +-----------------------------------------------------------------------*/ + +void FixTGNHDrude::nve_x() +{ + double **x = atom->x; + double **v = atom->v; + int *mask = atom->mask; + int nlocal = atom->nlocal; + if (igroup == atom->firstgroup) nlocal = atom->nfirst; + + // x update by full step only for atoms in group + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + x[i][0] += dtv * v[i][0]; + x[i][1] += dtv * v[i][1]; + x[i][2] += dtv * v[i][2]; + } + } +} + +/* ---------------------------------------------------------------------- + perform half-step thermostat scaling of velocities +-----------------------------------------------------------------------*/ + +void FixTGNHDrude::nh_v_temp() +{ + double **v = atom->v; + double *mass = atom->mass; + int *mask = atom->mask; + int *type = atom->type; + tagint *molecule = atom->molecule; + int *drudetype = fix_drude->drudetype; + tagint *drudeid = fix_drude->drudeid; + + int imol, i, j, ci, di, itype; + double mass_com, mass_core, mass_drude; + double vint, vcom, vrel; + + /** + * If there are velocity bias, need to remove them before scale velocity + * Have to call remove_bias at the innermost loop, because drude atom may be a ghost + */ + for (i = 0; i < atom->nlocal; i++) { + if (mask[i] & groupbit) { + imol = molecule[i]; + itype = drudetype[type[i]]; + if (itype == NOPOL_TYPE) { + if (which == BIAS) + temperature->remove_bias(i, v[i]); + for (int k = 0; k < 3; k++) { + vint = v[i][k] - v_mol[imol][k]; + vint *= factor_eta_int; + v[i][k] = v_mol[imol][k] * factor_eta_mol + vint; + } + if (which == BIAS) + temperature->restore_bias(i, v[i]); + } else { + // have to use closest_image() because we are manipulating the velocity + j = domain->closest_image(i, atom->map(drudeid[i])); + if (itype == DRUDE_TYPE && j < atom->nlocal) continue; + if (itype == CORE_TYPE) { + ci = i; + di = j; + } else { + ci = j; + di = i; + } + if (which == BIAS) { + temperature->remove_bias(ci, v[ci]); + temperature->remove_bias(di, v[di]); + } + mass_core = mass[type[ci]]; + mass_drude = mass[type[di]]; + mass_com = mass_core + mass_drude; + for (int k = 0; k < 3; k++) { + vcom = (mass_core * v[ci][k] + mass_drude * v[di][k]) / mass_com; + vint = vcom - v_mol[imol][k]; + vrel = v[di][k] - v[ci][k]; + vint *= factor_eta_int; + vrel *= factor_eta_drude; + v[ci][k] = v_mol[imol][k] * factor_eta_mol + vint - vrel * mass_drude / mass_com; + v[di][k] = v_mol[imol][k] * factor_eta_mol + vint + vrel * mass_core / mass_com; + } + if (which == BIAS) { + temperature->restore_bias(ci, v[ci]); + temperature->restore_bias(di, v[di]); + } + } + } + } +} + +/* ---------------------------------------------------------------------- + compute sigma tensor + needed whenever p_target or h0_inv changes +-----------------------------------------------------------------------*/ + +void FixTGNHDrude::compute_sigma() +{ + // if nreset_h0 > 0, reset vol0 and h0_inv + // every nreset_h0 timesteps + + if (nreset_h0 > 0) { + int delta = update->ntimestep - update->beginstep; + if (delta % nreset_h0 == 0) { + if (dimension == 3) vol0 = domain->xprd * domain->yprd * domain->zprd; + else vol0 = domain->xprd * domain->yprd; + h0_inv[0] = domain->h_inv[0]; + h0_inv[1] = domain->h_inv[1]; + h0_inv[2] = domain->h_inv[2]; + h0_inv[3] = domain->h_inv[3]; + h0_inv[4] = domain->h_inv[4]; + h0_inv[5] = domain->h_inv[5]; + } + } + + // generate upper-triangular half of + // sigma = vol0*h0inv*(p_target-p_hydro)*h0inv^t + // units of sigma are are PV/L^2 e.g. atm.A + // + // [ 0 5 4 ] [ 0 5 4 ] [ 0 5 4 ] [ 0 - - ] + // [ 5 1 3 ] = [ - 1 3 ] [ 5 1 3 ] [ 5 1 - ] + // [ 4 3 2 ] [ - - 2 ] [ 4 3 2 ] [ 4 3 2 ] + + sigma[0] = + vol0*(h0_inv[0]*((p_target[0]-p_hydro)*h0_inv[0] + + p_target[5]*h0_inv[5]+p_target[4]*h0_inv[4]) + + h0_inv[5]*(p_target[5]*h0_inv[0] + + (p_target[1]-p_hydro)*h0_inv[5]+p_target[3]*h0_inv[4]) + + h0_inv[4]*(p_target[4]*h0_inv[0]+p_target[3]*h0_inv[5] + + (p_target[2]-p_hydro)*h0_inv[4])); + sigma[1] = + vol0*(h0_inv[1]*((p_target[1]-p_hydro)*h0_inv[1] + + p_target[3]*h0_inv[3]) + + h0_inv[3]*(p_target[3]*h0_inv[1] + + (p_target[2]-p_hydro)*h0_inv[3])); + sigma[2] = + vol0*(h0_inv[2]*((p_target[2]-p_hydro)*h0_inv[2])); + sigma[3] = + vol0*(h0_inv[1]*(p_target[3]*h0_inv[2]) + + h0_inv[3]*((p_target[2]-p_hydro)*h0_inv[2])); + sigma[4] = + vol0*(h0_inv[0]*(p_target[4]*h0_inv[2]) + + h0_inv[5]*(p_target[3]*h0_inv[2]) + + h0_inv[4]*((p_target[2]-p_hydro)*h0_inv[2])); + sigma[5] = + vol0*(h0_inv[0]*(p_target[5]*h0_inv[1]+p_target[4]*h0_inv[3]) + + h0_inv[5]*((p_target[1]-p_hydro)*h0_inv[1]+p_target[3]*h0_inv[3]) + + h0_inv[4]*(p_target[3]*h0_inv[1]+(p_target[2]-p_hydro)*h0_inv[3])); +} + +/* ---------------------------------------------------------------------- + compute strain energy +-----------------------------------------------------------------------*/ + +double FixTGNHDrude::compute_strain_energy() +{ + // compute strain energy = 0.5*Tr(sigma*h*h^t) in energy units + + double* h = domain->h; + double d0,d1,d2; + + d0 = + sigma[0]*(h[0]*h[0]+h[5]*h[5]+h[4]*h[4]) + + sigma[5]*( h[1]*h[5]+h[3]*h[4]) + + sigma[4]*( h[2]*h[4]); + d1 = + sigma[5]*( h[5]*h[1]+h[4]*h[3]) + + sigma[1]*( h[1]*h[1]+h[3]*h[3]) + + sigma[3]*( h[2]*h[3]); + d2 = + sigma[4]*( h[4]*h[2]) + + sigma[3]*( h[3]*h[2]) + + sigma[2]*( h[2]*h[2]); + + double energy = 0.5*(d0+d1+d2)/nktv2p; + return energy; +} + +/* ---------------------------------------------------------------------- + compute deviatoric barostat force = h*sigma*h^t +-----------------------------------------------------------------------*/ + +void FixTGNHDrude::compute_deviatoric() +{ + // generate upper-triangular part of h*sigma*h^t + // units of fdev are are PV, e.g. atm*A^3 + // [ 0 5 4 ] [ 0 5 4 ] [ 0 5 4 ] [ 0 - - ] + // [ 5 1 3 ] = [ - 1 3 ] [ 5 1 3 ] [ 5 1 - ] + // [ 4 3 2 ] [ - - 2 ] [ 4 3 2 ] [ 4 3 2 ] + + double* h = domain->h; + + fdev[0] = + h[0]*(sigma[0]*h[0]+sigma[5]*h[5]+sigma[4]*h[4]) + + h[5]*(sigma[5]*h[0]+sigma[1]*h[5]+sigma[3]*h[4]) + + h[4]*(sigma[4]*h[0]+sigma[3]*h[5]+sigma[2]*h[4]); + fdev[1] = + h[1]*( sigma[1]*h[1]+sigma[3]*h[3]) + + h[3]*( sigma[3]*h[1]+sigma[2]*h[3]); + fdev[2] = + h[2]*( sigma[2]*h[2]); + fdev[3] = + h[1]*( sigma[3]*h[2]) + + h[3]*( sigma[2]*h[2]); + fdev[4] = + h[0]*( sigma[4]*h[2]) + + h[5]*( sigma[3]*h[2]) + + h[4]*( sigma[2]*h[2]); + fdev[5] = + h[0]*( sigma[5]*h[1]+sigma[4]*h[3]) + + h[5]*( sigma[1]*h[1]+sigma[3]*h[3]) + + h[4]*( sigma[3]*h[1]+sigma[2]*h[3]); +} + +/* ---------------------------------------------------------------------- + compute target temperature and kinetic energy +-----------------------------------------------------------------------*/ + +void FixTGNHDrude::compute_temp_target() +{ + double delta = update->ntimestep - update->beginstep; + if (delta != 0.0) delta /= update->endstep - update->beginstep; + + t_target = t_start + delta * (t_stop-t_start); + ke2mol_target = dof_mol * boltz * t_target; + ke2int_target = dof_int * boltz * t_target; + ke2drude_target = dof_drude * boltz * tdrude_target; +} + +/* ---------------------------------------------------------------------- + compute hydrostatic target pressure +-----------------------------------------------------------------------*/ + +void FixTGNHDrude::compute_press_target() +{ + double delta = update->ntimestep - update->beginstep; + if (delta != 0.0) delta /= update->endstep - update->beginstep; + + p_hydro = 0.0; + for (int i = 0; i < 3; i++) + if (p_flag[i]) { + p_target[i] = p_start[i] + delta * (p_stop[i]-p_start[i]); + p_hydro += p_target[i]; + } + if (pdim > 0) p_hydro /= pdim; + + if (pstyle == TRICLINIC) + for (int i = 3; i < 6; i++) + p_target[i] = p_start[i] + delta * (p_stop[i]-p_start[i]); + + // if deviatoric, recompute sigma each time p_target changes + + if (deviatoric_flag) compute_sigma(); +} + +/* ---------------------------------------------------------------------- + update omega_dot, omega +-----------------------------------------------------------------------*/ + +void FixTGNHDrude::nh_omega_dot() +{ + double f_omega,volume; + + if (dimension == 3) volume = domain->xprd*domain->yprd*domain->zprd; + else volume = domain->xprd*domain->yprd; + + if (deviatoric_flag) compute_deviatoric(); + + mtk_term1 = 0.0; + if (mtk_flag) { + if (pstyle == ISO) { + mtk_term1 = tdof * boltz * t_current; + mtk_term1 /= pdim * atom->natoms; + } else { + double *mvv_current = temperature->vector; + for (int i = 0; i < 3; i++) + if (p_flag[i]) + mtk_term1 += mvv_current[i]; + mtk_term1 /= pdim * atom->natoms; + } + } + + for (int i = 0; i < 3; i++) + if (p_flag[i]) { + f_omega = (p_current[i]-p_hydro)*volume / + (omega_mass[i] * nktv2p) + mtk_term1 / omega_mass[i]; + if (deviatoric_flag) f_omega -= fdev[i]/(omega_mass[i] * nktv2p); + omega_dot[i] += f_omega*dthalf; + } + + mtk_term2 = 0.0; + if (mtk_flag) { + for (int i = 0; i < 3; i++) + if (p_flag[i]) + mtk_term2 += omega_dot[i]; + if (pdim > 0) mtk_term2 /= pdim * atom->natoms; + } + + if (pstyle == TRICLINIC) { + for (int i = 3; i < 6; i++) { + if (p_flag[i]) { + f_omega = p_current[i]*volume/(omega_mass[i] * nktv2p); + if (deviatoric_flag) + f_omega -= fdev[i]/(omega_mass[i] * nktv2p); + omega_dot[i] += f_omega*dthalf; + } + } + } +} + +/* ---------------------------------------------------------------------- + if any tilt ratios exceed limits, set flip = 1 and compute new tilt values + do not flip in x or y if non-periodic (can tilt but not flip) + this is b/c the box length would be changed (dramatically) by flip + if yz tilt exceeded, adjust C vector by one B vector + if xz tilt exceeded, adjust C vector by one A vector + if xy tilt exceeded, adjust B vector by one A vector + check yz first since it may change xz, then xz check comes after + if any flip occurs, create new box in domain + image_flip() adjusts image flags due to box shape change induced by flip + remap() puts atoms outside the new box back into the new box + perform irregular on atoms in lamda coords to migrate atoms to new procs + important that image_flip comes before remap, since remap may change + image flags to new values, making eqs in doc of Domain:image_flip incorrect +------------------------------------------------------------------------- */ + +void FixTGNHDrude::pre_exchange() +{ + double xprd = domain->xprd; + double yprd = domain->yprd; + + // flip is only triggered when tilt exceeds 0.5 by DELTAFLIP + // this avoids immediate re-flipping due to tilt oscillations + + double xtiltmax = (0.5+DELTAFLIP)*xprd; + double ytiltmax = (0.5+DELTAFLIP)*yprd; + + int flipxy,flipxz,flipyz; + flipxy = flipxz = flipyz = 0; + + if (domain->yperiodic) { + if (domain->yz < -ytiltmax) { + domain->yz += yprd; + domain->xz += domain->xy; + flipyz = 1; + } else if (domain->yz >= ytiltmax) { + domain->yz -= yprd; + domain->xz -= domain->xy; + flipyz = -1; + } + } + + if (domain->xperiodic) { + if (domain->xz < -xtiltmax) { + domain->xz += xprd; + flipxz = 1; + } else if (domain->xz >= xtiltmax) { + domain->xz -= xprd; + flipxz = -1; + } + if (domain->xy < -xtiltmax) { + domain->xy += xprd; + flipxy = 1; + } else if (domain->xy >= xtiltmax) { + domain->xy -= xprd; + flipxy = -1; + } + } + + int flip = 0; + if (flipxy || flipxz || flipyz) flip = 1; + + if (flip) { + domain->set_global_box(); + domain->set_local_box(); + + domain->image_flip(flipxy,flipxz,flipyz); + + double **x = atom->x; + imageint *image = atom->image; + int nlocal = atom->nlocal; + for (int i = 0; i < nlocal; i++) domain->remap(x[i],image[i]); + + domain->x2lamda(atom->nlocal); + irregular->migrate_atoms(); + domain->lamda2x(atom->nlocal); + } +} + +/* ---------------------------------------------------------------------- + memory usage of Irregular +------------------------------------------------------------------------- */ + +double FixTGNHDrude::memory_usage() +{ + double bytes = 0.0; + if (irregular) bytes += irregular->memory_usage(); + return bytes; +} diff --git a/src/USER-DRUDE/fix_tgnh_drude.h b/src/USER-DRUDE/fix_tgnh_drude.h new file mode 100644 index 0000000000..4d29bb90e7 --- /dev/null +++ b/src/USER-DRUDE/fix_tgnh_drude.h @@ -0,0 +1,295 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifndef LMP_FIX_TGNH_DRUDE_H +#define LMP_FIX_TGNH_DRUDE_H + +#include "fix.h" +#include "fix_drude.h" + +namespace LAMMPS_NS { + +class FixTGNHDrude : public Fix { + public: + FixTGNHDrude(class LAMMPS *, int, char **); + virtual ~FixTGNHDrude(); + int setmask(); + virtual void init(); + virtual void setup(int); + virtual void initial_integrate(int); + virtual void final_integrate(); + void initial_integrate_respa(int, int, int); + void final_integrate_respa(int, int); + virtual void pre_exchange(); + double compute_scalar(); + virtual double compute_vector(int); + void write_restart(FILE *); + virtual int pack_restart_data(double *); // pack restart data + virtual void restart(char *); + int modify_param(int, char **); + void reset_target(double); + void reset_dt(); + double memory_usage(); + + protected: + int dimension,which; + double dtv,dtf,dthalf,dt4,dt8,dto; + double boltz,nktv2p,tdof; + double vol0; // reference volume + double t0; // reference temperature + // used for barostat mass + double t_start,t_stop; + double t_current,t_target; + double t_freq; + + int tstat_flag; // 1 if control T + int pstat_flag; // 1 if control P + + int pstyle,pcouple; + int p_flag[6]; // 1 if control P on this dim, 0 if not + double p_start[6],p_stop[6]; + double p_freq[6],p_target[6]; + double omega[6],omega_dot[6]; + double omega_mass[6]; + double p_current[6]; + int kspace_flag; // 1 if KSpace invoked, 0 if not + int nrigid; // number of rigid fixes + int *rfix; // indices of rigid fixes + class Irregular *irregular; // for migrating atoms after box flips + + int nlevels_respa; + double *step_respa; + + char *id_temp,*id_press; + class Compute *temperature,*pressure; + int tcomputeflag,pcomputeflag; // 1 = compute was created by fix + // 0 = created externally + + double *etamol; + double *etamol_dot; // chain thermostat for motion of whole molecules + double *etamol_dotdot; + double *etamol_mass; + + double *etaint; + double *etaint_dot; // chain thermostat for internal DOFs + double *etaint_dotdot; + double *etaint_mass; + + double *etadrude; + double *etadrude_dot; // chain thermostat for Drude relative motions + double *etadrude_dotdot; + double *etadrude_mass; + + double *etap; // chain thermostat for barostat + double *etap_dot; + double *etap_dotdot; + double *etap_mass; + + int mtchain; // length of chain + int mpchain; // length of chain + + int mtk_flag; // 0 if using Hoover barostat + int pdim; // number of barostatted dims + double p_freq_max; // maximum barostat frequency + + double p_hydro; // hydrostatic target pressure + + int nc_tchain,nc_pchain; + double sigma[6]; // scaled target stress + double fdev[6]; // deviatoric force on barostat + int deviatoric_flag; // 0 if target stress tensor is hydrostatic + double h0_inv[6]; // h_inv of reference (zero strain) box + int nreset_h0; // interval for resetting h0 + + double mtk_term1,mtk_term2; // Martyna-Tobias-Klein corrections + + int scaleyz; // 1 if yz scaled with lz + int scalexz; // 1 if xz scaled with lz + int scalexy; // 1 if xy scaled with ly + int flipflag; // 1 if box flips are invoked as needed + + int pre_exchange_flag; // set if pre_exchange needed for box flips + + double fixedpoint[3]; // location of dilation fixed-point + + void couple(); + virtual void remap(); + void nhc_temp_integrate(); + void nhc_press_integrate(); + + virtual void nve_x(); // may be overwritten by child classes + virtual void nve_v(); + virtual void nh_v_press(); + virtual void nh_v_temp(); + virtual void compute_temp_target(); + virtual int size_restart_global(); + + void compute_sigma(); + void compute_deviatoric(); + double compute_strain_energy(); + void compute_press_target(); + void nh_omega_dot(); + + + class FixDrude * fix_drude; + int n_mol; // number of molecules in the system + double *mass_mol; + double dof_mol, dof_int, dof_drude; // DOFs of different modes in the fix group + void setup_mol_mass_dof(); + double **v_mol, **v_mol_tmp; + void compute_temp_mol_int_drude(bool); // calculate the temperatures of three sets of DOFs + bool temp_computed_end_of_step = false; + double tdrude_target, tdrude_freq; + double t_mol, t_int, t_drude; + double ke2mol, ke2int, ke2drude; + double ke2mol_target, ke2int_target, ke2drude_target; + double factor_eta_mol, factor_eta_int, factor_eta_drude; + double propagate(double *, double *, double *, const double *, const double &, const double &, const double &) const; +}; + +} + +#endif + +/* ERROR/WARNING messages: + +E: Illegal ... command + +Self-explanatory. Check the input script syntax and compare to the +documentation for the command. You can use -echo screen as a +command-line option when running LAMMPS to see the offending line. + +E: Target temperature for fix nvt/npt/nph cannot be 0.0 + +Self-explanatory. + +E: Invalid fix nvt/npt/nph command for a 2d simulation + +Cannot control z dimension in a 2d model. + +E: Fix nvt/npt/nph dilate group ID does not exist + +Self-explanatory. + +E: Invalid fix nvt/npt/nph command pressure settings + +If multiple dimensions are coupled, those dimensions must be +specified. + +E: Cannot use fix nvt/npt/nph on a non-periodic dimension + +When specifying a diagonal pressure component, the dimension must be +periodic. + +E: Cannot use fix nvt/npt/nph on a 2nd non-periodic dimension + +When specifying an off-diagonal pressure component, the 2nd of the two +dimensions must be periodic. E.g. if the xy component is specified, +then the y dimension must be periodic. + +E: Cannot use fix nvt/npt/nph with yz scaling when z is non-periodic dimension + +The 2nd dimension in the barostatted tilt factor must be periodic. + +E: Cannot use fix nvt/npt/nph with xz scaling when z is non-periodic dimension + +The 2nd dimension in the barostatted tilt factor must be periodic. + +E: Cannot use fix nvt/npt/nph with xy scaling when y is non-periodic dimension + +The 2nd dimension in the barostatted tilt factor must be periodic. + +E: Cannot use fix nvt/npt/nph with both yz dynamics and yz scaling + +Self-explanatory. + +E: Cannot use fix nvt/npt/nph with both xz dynamics and xz scaling + +Self-explanatory. + +E: Cannot use fix nvt/npt/nph with both xy dynamics and xy scaling + +Self-explanatory. + +E: Can not specify Pxy/Pxz/Pyz in fix nvt/npt/nph with non-triclinic box + +Only triclinic boxes can be used with off-diagonal pressure components. +See the region prism command for details. + +E: Invalid fix nvt/npt/nph pressure settings + +Settings for coupled dimensions must be the same. + +E: Using update dipole flag requires atom style sphere + +Self-explanatory. + +E: Using update dipole flag requires atom attribute mu + +Self-explanatory. + +E: Fix nvt/npt/nph damping parameters must be > 0.0 + +Self-explanatory. + +E: Cannot use fix npt and fix deform on same component of stress tensor + +This would be changing the same box dimension twice. + +E: Temperature ID for fix nvt/npt does not exist + +Self-explanatory. + +E: Pressure ID for fix npt/nph does not exist + +Self-explanatory. + +E: Non-numeric pressure - simulation unstable + +UNDOCUMENTED + +E: Fix npt/nph has tilted box too far in one step - periodic cell is too far from equilibrium state + +Self-explanatory. The change in the box tilt is too extreme +on a short timescale. + +E: Could not find fix_modify temperature ID + +The compute ID for computing temperature does not exist. + +E: Fix_modify temperature ID does not compute temperature + +The compute ID assigned to the fix must compute temperature. + +W: Temperature for fix modify is not for group all + +The temperature compute is being used with a pressure calculation +which does operate on group all, so this may be inconsistent. + +E: Pressure ID for fix modify does not exist + +Self-explanatory. + +E: Could not find fix_modify pressure ID + +The compute ID for computing pressure does not exist. + +E: Fix_modify pressure ID does not compute pressure + +The compute ID assigned to the fix must compute pressure. + +U: The dlm flag must be used with update dipole + +Self-explanatory. + +*/ diff --git a/src/USER-DRUDE/fix_tgnpt_drude.cpp b/src/USER-DRUDE/fix_tgnpt_drude.cpp new file mode 100644 index 0000000000..987af367c3 --- /dev/null +++ b/src/USER-DRUDE/fix_tgnpt_drude.cpp @@ -0,0 +1,57 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://lammps.sandia.gov/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#include "fix_tgnpt_drude.h" +#include + +#include "modify.h" +#include "error.h" + +using namespace LAMMPS_NS; +using namespace FixConst; + +/* ---------------------------------------------------------------------- */ + +FixTGNPTDrude::FixTGNPTDrude(LAMMPS *lmp, int narg, char **arg) : + FixTGNHDrude(lmp, narg, arg) +{ + if (!tstat_flag) + error->all(FLERR,"Temperature control must be used with fix npt"); + if (!pstat_flag) + error->all(FLERR,"Pressure control must be used with fix npt"); + + // create a new compute temp style + // id = fix-ID + temp + // compute group = all since pressure is always global (group all) + // and thus its KE/temperature contribution should use group all + + std::string tcmd = id + std::string("_temp"); + id_temp = new char[tcmd.size()+1]; + strcpy(id_temp, tcmd.c_str()); + + tcmd += " all temp"; + modify->add_compute(tcmd); + tcomputeflag = 1; + + // create a new compute pressure style + // id = fix-ID + press, compute group = all + // pass id_temp as 4th arg to pressure constructor + + std::string pcmd = id + std::string("_press"); + id_press = new char[pcmd.size()+1]; + strcpy(id_press, pcmd.c_str()); + + pcmd += " all pressure " + std::string(id_temp); + modify->add_compute(pcmd); + pcomputeflag = 1; +} diff --git a/src/USER-DRUDE/fix_tgnpt_drude.h b/src/USER-DRUDE/fix_tgnpt_drude.h new file mode 100644 index 0000000000..afb55ae0d7 --- /dev/null +++ b/src/USER-DRUDE/fix_tgnpt_drude.h @@ -0,0 +1,48 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef FIX_CLASS + +FixStyle(tgnpt/drude,FixTGNPTDrude) + +#else + +#ifndef LMP_FIX_TGNPT_DRUDE_H +#define LMP_FIX_TGNPT_DRUDE_H + +#include "fix_tgnh_drude.h" + +namespace LAMMPS_NS { + +class FixTGNPTDrude : public FixTGNHDrude { + public: + FixTGNPTDrude(class LAMMPS *, int, char **); + ~FixTGNPTDrude() {} +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Temperature control must be used with fix npt + +Self-explanatory. + +E: Pressure control must be used with fix npt + +Self-explanatory. + +*/ diff --git a/src/USER-DRUDE/fix_tgnvt_drude.cpp b/src/USER-DRUDE/fix_tgnvt_drude.cpp new file mode 100644 index 0000000000..bd6809aaed --- /dev/null +++ b/src/USER-DRUDE/fix_tgnvt_drude.cpp @@ -0,0 +1,44 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://lammps.sandia.gov/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#include "fix_tgnvt_drude.h" +#include + +#include "group.h" +#include "modify.h" +#include "error.h" + +using namespace LAMMPS_NS; +using namespace FixConst; + +/* ---------------------------------------------------------------------- */ + +FixTGNVTDrude::FixTGNVTDrude(LAMMPS *lmp, int narg, char **arg) : + FixTGNHDrude(lmp, narg, arg) +{ + if (!tstat_flag) + error->all(FLERR,"Temperature control must be used with fix nvt"); + if (pstat_flag) + error->all(FLERR,"Pressure control can not be used with fix nvt"); + + // create a new compute temp style + // id = fix-ID + temp + + std::string tcmd = id + std::string("_temp"); + id_temp = new char[tcmd.size()+1]; + strcpy(id_temp, tcmd.c_str()); + + tcmd += fmt::format(" {} temp", group->names[igroup]); + modify->add_compute(tcmd); + tcomputeflag = 1; +} diff --git a/src/USER-DRUDE/fix_tgnvt_drude.h b/src/USER-DRUDE/fix_tgnvt_drude.h new file mode 100644 index 0000000000..64f2e52e9c --- /dev/null +++ b/src/USER-DRUDE/fix_tgnvt_drude.h @@ -0,0 +1,48 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifdef FIX_CLASS + +FixStyle(tgnvt/drude,FixTGNVTDrude) + +#else + +#ifndef LMP_FIX_TGNVT_DRUDE_H +#define LMP_FIX_TGNVT_DRUDE_H + +#include "fix_tgnh_drude.h" + +namespace LAMMPS_NS { + +class FixTGNVTDrude: public FixTGNHDrude { + public: + FixTGNVTDrude(class LAMMPS *, int, char **); + ~FixTGNVTDrude() {} +}; + +} + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Temperature control must be used with fix nvt + +Self-explanatory. + +E: Pressure control can not be used with fix nvt + +Self-explanatory. + +*/ diff --git a/src/USER-MISC/pair_edip.cpp b/src/USER-MISC/pair_edip.cpp index b29f499de8..12390ba69d 100644 --- a/src/USER-MISC/pair_edip.cpp +++ b/src/USER-MISC/pair_edip.cpp @@ -46,7 +46,7 @@ using namespace LAMMPS_NS; // max number of interaction per atom for f(Z) environment potential -#define leadDimInteractionList 64 +static constexpr int leadDimInteractionList = 64; /* ---------------------------------------------------------------------- */ diff --git a/src/USER-MISC/pair_edip_multi.cpp b/src/USER-MISC/pair_edip_multi.cpp index 811f80abfc..9d36db7041 100644 --- a/src/USER-MISC/pair_edip_multi.cpp +++ b/src/USER-MISC/pair_edip_multi.cpp @@ -32,13 +32,11 @@ #include "error.h" #include "citeme.h" - using namespace LAMMPS_NS; #define MAXLINE 1024 #define DELTA 4 - static const char cite_pair_edip[] = "@article{cjiang2012\n" " author = {Jian, Chao and Morgan, Dane, and Szlufarska, Izabella},\n" @@ -56,7 +54,9 @@ static const char cite_pair_edip[] = " year = {2010},\n" "}\n\n"; +// max number of interaction per atom for f(Z) environment potential +static constexpr int leadDimInteractionList = 64; /* ---------------------------------------------------------------------- */ @@ -94,7 +94,6 @@ PairEDIPMulti::~PairEDIPMulti() memory->destroy(cutsq); delete [] map; -//XXX deallocateGrids(); deallocatePreLoops(); } } diff --git a/src/USER-MISC/pair_edip_multi.h b/src/USER-MISC/pair_edip_multi.h index 26433a66fa..5120ece5d2 100644 --- a/src/USER-MISC/pair_edip_multi.h +++ b/src/USER-MISC/pair_edip_multi.h @@ -36,17 +36,17 @@ class PairEDIPMulti : public Pair { protected: struct Param { - double A, B;//coefficients for pair interaction I-J - double cutoffA;//cut-off distance for pair interaction I-J - double cutoffC;//lower cut-off distance for calculating Z_I - double alpha;//coefficient for calculating Z_I - double beta;//attractive term for pair I-J - double sigma;//cut-off coefficient for pair I-J - double rho;//pair I-J - double gamma;//coefficient for three-body interaction I-J-K - double eta, lambda;//coefficients for function h(l,Z) - double mu, Q0;//coefficients for function Q(Z) - double u1, u2, u3, u4;//coefficients for function tau(Z) + double A, B; // coefficients for pair interaction I-J + double cutoffA; // cut-off distance for pair interaction I-J + double cutoffC; // lower cut-off distance for calculating Z_I + double alpha; // coefficient for calculating Z_I + double beta; // attractive term for pair I-J + double sigma; // cut-off coefficient for pair I-J + double rho; // pair I-J + double gamma; // coefficient for three-body interaction I-J-K + double eta, lambda; // coefficients for function h(l,Z) + double mu, Q0; // coefficients for function Q(Z) + double u1, u2, u3, u4; // coefficients for function tau(Z) double cutsq; int ielement,jelement,kelement; }; @@ -62,10 +62,6 @@ class PairEDIPMulti : public Pair { int maxparam; // max # of parameter sets Param *params; // parameter set for an I-J-K interaction - // max number of interaction per atom for f(Z) environment potential - - static const int leadDimInteractionList = 64; - void allocate(); void allocatePreLoops(void); void deallocatePreLoops(void); diff --git a/src/USER-MISC/pair_tersoff_table.h b/src/USER-MISC/pair_tersoff_table.h index faa704191c..d63a5be5a6 100644 --- a/src/USER-MISC/pair_tersoff_table.h +++ b/src/USER-MISC/pair_tersoff_table.h @@ -43,7 +43,7 @@ class PairTersoffTable : public Pair { void init_style(); double init_one(int, int); - static const int NPARAMS_PER_LINE = 17; + static constexpr int NPARAMS_PER_LINE = 17; protected: struct Param { diff --git a/src/USER-OMP/pair_edip_omp.cpp b/src/USER-OMP/pair_edip_omp.cpp index 2eb8384113..106d038743 100644 --- a/src/USER-OMP/pair_edip_omp.cpp +++ b/src/USER-OMP/pair_edip_omp.cpp @@ -28,7 +28,7 @@ using namespace LAMMPS_NS; // max number of interaction per atom for f(Z) environment potential -#define leadDimInteractionList 64 +static constexpr int leadDimInteractionList = 64; /* ---------------------------------------------------------------------- */ diff --git a/src/USER-OMP/pair_lj_cubic_omp.cpp b/src/USER-OMP/pair_lj_cubic_omp.cpp index 872574a3b2..e96b3d0a79 100644 --- a/src/USER-OMP/pair_lj_cubic_omp.cpp +++ b/src/USER-OMP/pair_lj_cubic_omp.cpp @@ -23,6 +23,8 @@ #include #include "omp_compat.h" +#include "pair_lj_cubic_const.h" + using namespace LAMMPS_NS; using namespace PairLJCubicConstants; diff --git a/src/USER-OMP/pair_zbl_omp.cpp b/src/USER-OMP/pair_zbl_omp.cpp index 993e75f499..6794789f25 100644 --- a/src/USER-OMP/pair_zbl_omp.cpp +++ b/src/USER-OMP/pair_zbl_omp.cpp @@ -24,7 +24,6 @@ #include "omp_compat.h" using namespace LAMMPS_NS; -using namespace PairZBLConstants; /* ---------------------------------------------------------------------- */ diff --git a/src/USER-PLUMED/fix_plumed.cpp b/src/USER-PLUMED/fix_plumed.cpp index ed7f05f2ae..1fc19a7724 100644 --- a/src/USER-PLUMED/fix_plumed.cpp +++ b/src/USER-PLUMED/fix_plumed.cpp @@ -78,9 +78,9 @@ FixPlumed::FixPlumed(LAMMPS *lmp, int narg, char **arg) : int api_version=0; p->cmd("getApiVersion",&api_version); - if ((api_version < 5) || (api_version > 7)) + if ((api_version < 5) || (api_version > 8)) error->all(FLERR,"Incompatible API version for PLUMED in fix plumed. " - "Only Plumed 2.4.x, 2.5.x, and 2.6.x are tested and supported."); + "Only Plumed 2.4.x, 2.5.x, 2.6.x, 2.7.x are tested and supported."); #if !defined(MPI_STUBS) // If the -partition option is activated then enable diff --git a/src/USER-REACTION/fix_bond_react.cpp b/src/USER-REACTION/fix_bond_react.cpp index efadec1b91..2bfc7714be 100644 --- a/src/USER-REACTION/fix_bond_react.cpp +++ b/src/USER-REACTION/fix_bond_react.cpp @@ -82,6 +82,9 @@ enum{ACCEPT,REJECT,PROCEED,CONTINUE,GUESSFAIL,RESTORE}; // types of available reaction constraints enum{DISTANCE,ANGLE,DIHEDRAL,ARRHENIUS,RMSD}; +// ID type used by constraint +enum{ATOM,FRAG}; + // keyword values that accept variables as input enum{NEVERY,RMIN,RMAX,PROB}; @@ -115,7 +118,6 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) : global_freq = 1; extvector = 0; rxnID = 0; - nconstraints = 0; narrhenius = 0; status = PROCEED; @@ -206,7 +208,9 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) : memory->create(stabilize_steps_flag,nreacts,"bond/react:stabilize_steps_flag"); memory->create(custom_charges_fragid,nreacts,"bond/react:custom_charges_fragid"); memory->create(molecule_keyword,nreacts,"bond/react:molecule_keyword"); - memory->create(constraints,1,MAXCONARGS,"bond/react:constraints"); + memory->create(nconstraints,nreacts,"bond/react:nconstraints"); + memory->create(constraintstr,nreacts,MAXLINE,"bond/react:constraintstr"); + memory->create(constraints,0,nreacts,"bond/react:constraints"); memory->create(var_flag,NUMVARVALS,nreacts,"bond/react:var_flag"); memory->create(var_id,NUMVARVALS,nreacts,"bond/react:var_id"); memory->create(iatomtype,nreacts,"bond/react:iatomtype"); @@ -227,6 +231,7 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) : stabilize_steps_flag[i] = 0; custom_charges_fragid[i] = -1; molecule_keyword[i] = OFF; + nconstraints[i] = 0; // set default limit duration to 60 timesteps limit_duration[i] = 60; reaction_count[i] = 0; @@ -440,9 +445,11 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) : rrhandom = new class RanMars*[narrhenius]; int tmp = 0; - for (int i = 0; i < nconstraints; i++) { - if (constraints[i][1] == ARRHENIUS) { - rrhandom[tmp++] = new RanMars(lmp,(int) constraints[i][6] + me); + for (int i = 0; i < nreacts; i++) { + for (int j = 0; j < nconstraints[i]; j++) { + if (constraints[j][i].type == ARRHENIUS) { + rrhandom[tmp++] = new RanMars(lmp,(int) constraints[j][i].par[4] + me); + } } } @@ -562,6 +569,9 @@ FixBondReact::~FixBondReact() memory->destroy(stabilize_steps_flag); memory->destroy(custom_charges_fragid); memory->destroy(molecule_keyword); + memory->destroy(constraints); + memory->destroy(nconstraints); + // need to delete rxn_name and constraintstr memory->destroy(iatomtype); memory->destroy(jatomtype); @@ -1795,163 +1805,178 @@ int FixBondReact::check_constraints() tagint atom1,atom2; double **x = atom->x; - for (int i = 0; i < nconstraints; i++) { - if (constraints[i][0] == rxnID) { - if (constraints[i][1] == DISTANCE) { - get_IDcoords((int) constraints[i][2], (int) constraints[i][3], x1); - get_IDcoords((int) constraints[i][4], (int) constraints[i][5], x2); - delx = x1[0] - x2[0]; - dely = x1[1] - x2[1]; - delz = x1[2] - x2[2]; - domain->minimum_image(delx,dely,delz); // ghost location fix - rsq = delx*delx + dely*dely + delz*delz; - if (rsq < constraints[i][6] || rsq > constraints[i][7]) return 0; - } else if (constraints[i][1] == ANGLE) { - get_IDcoords((int) constraints[i][2], (int) constraints[i][3], x1); - get_IDcoords((int) constraints[i][4], (int) constraints[i][5], x2); - get_IDcoords((int) constraints[i][6], (int) constraints[i][7], x3); + int *satisfied; + memory->create(satisfied,nconstraints[rxnID],"bond/react:satisfied"); + for (int i = 0; i < nconstraints[rxnID]; i++) + satisfied[i] = 1; - // 1st bond - delx1 = x1[0] - x2[0]; - dely1 = x1[1] - x2[1]; - delz1 = x1[2] - x2[2]; - domain->minimum_image(delx1,dely1,delz1); // ghost location fix - rsq1 = delx1*delx1 + dely1*dely1 + delz1*delz1; - r1 = sqrt(rsq1); + for (int i = 0; i < nconstraints[rxnID]; i++) { + if (constraints[i][rxnID].type == DISTANCE) { + get_IDcoords(constraints[i][rxnID].idtype[0], constraints[i][rxnID].id[0], x1); + get_IDcoords(constraints[i][rxnID].idtype[1], constraints[i][rxnID].id[1], x2); + delx = x1[0] - x2[0]; + dely = x1[1] - x2[1]; + delz = x1[2] - x2[2]; + domain->minimum_image(delx,dely,delz); // ghost location fix + rsq = delx*delx + dely*dely + delz*delz; + if (rsq < constraints[i][rxnID].par[0] || rsq > constraints[i][rxnID].par[1]) satisfied[i] = 0; + } else if (constraints[i][rxnID].type == ANGLE) { + get_IDcoords(constraints[i][rxnID].idtype[0], constraints[i][rxnID].id[0], x1); + get_IDcoords(constraints[i][rxnID].idtype[1], constraints[i][rxnID].id[1], x2); + get_IDcoords(constraints[i][rxnID].idtype[2], constraints[i][rxnID].id[2], x3); - // 2nd bond - delx2 = x3[0] - x2[0]; - dely2 = x3[1] - x2[1]; - delz2 = x3[2] - x2[2]; - domain->minimum_image(delx2,dely2,delz2); // ghost location fix - rsq2 = delx2*delx2 + dely2*dely2 + delz2*delz2; - r2 = sqrt(rsq2); + // 1st bond + delx1 = x1[0] - x2[0]; + dely1 = x1[1] - x2[1]; + delz1 = x1[2] - x2[2]; + domain->minimum_image(delx1,dely1,delz1); // ghost location fix + rsq1 = delx1*delx1 + dely1*dely1 + delz1*delz1; + r1 = sqrt(rsq1); - // angle (cos and sin) - c = delx1*delx2 + dely1*dely2 + delz1*delz2; - c /= r1*r2; - if (c > 1.0) c = 1.0; - if (c < -1.0) c = -1.0; - if (acos(c) < constraints[i][8] || acos(c) > constraints[i][9]) return 0; - } else if (constraints[i][1] == DIHEDRAL) { - // phi calculation from dihedral style harmonic - get_IDcoords((int) constraints[i][2], (int) constraints[i][3], x1); - get_IDcoords((int) constraints[i][4], (int) constraints[i][5], x2); - get_IDcoords((int) constraints[i][6], (int) constraints[i][7], x3); - get_IDcoords((int) constraints[i][8], (int) constraints[i][9], x4); + // 2nd bond + delx2 = x3[0] - x2[0]; + dely2 = x3[1] - x2[1]; + delz2 = x3[2] - x2[2]; + domain->minimum_image(delx2,dely2,delz2); // ghost location fix + rsq2 = delx2*delx2 + dely2*dely2 + delz2*delz2; + r2 = sqrt(rsq2); - vb1x = x1[0] - x2[0]; - vb1y = x1[1] - x2[1]; - vb1z = x1[2] - x2[2]; - domain->minimum_image(vb1x,vb1y,vb1z); + // angle (cos and sin) + c = delx1*delx2 + dely1*dely2 + delz1*delz2; + c /= r1*r2; + if (c > 1.0) c = 1.0; + if (c < -1.0) c = -1.0; + if (acos(c) < constraints[i][rxnID].par[0] || acos(c) > constraints[i][rxnID].par[1]) satisfied[i] = 0; + } else if (constraints[i][rxnID].type == DIHEDRAL) { + // phi calculation from dihedral style harmonic + get_IDcoords(constraints[i][rxnID].idtype[0], constraints[i][rxnID].id[0], x1); + get_IDcoords(constraints[i][rxnID].idtype[1], constraints[i][rxnID].id[1], x2); + get_IDcoords(constraints[i][rxnID].idtype[2], constraints[i][rxnID].id[2], x3); + get_IDcoords(constraints[i][rxnID].idtype[3], constraints[i][rxnID].id[3], x4); - vb2x = x3[0] - x2[0]; - vb2y = x3[1] - x2[1]; - vb2z = x3[2] - x2[2]; - domain->minimum_image(vb2x,vb2y,vb2z); + vb1x = x1[0] - x2[0]; + vb1y = x1[1] - x2[1]; + vb1z = x1[2] - x2[2]; + domain->minimum_image(vb1x,vb1y,vb1z); - vb2xm = -vb2x; - vb2ym = -vb2y; - vb2zm = -vb2z; - domain->minimum_image(vb2xm,vb2ym,vb2zm); + vb2x = x3[0] - x2[0]; + vb2y = x3[1] - x2[1]; + vb2z = x3[2] - x2[2]; + domain->minimum_image(vb2x,vb2y,vb2z); - vb3x = x4[0] - x3[0]; - vb3y = x4[1] - x3[1]; - vb3z = x4[2] - x3[2]; - domain->minimum_image(vb3x,vb3y,vb3z); + vb2xm = -vb2x; + vb2ym = -vb2y; + vb2zm = -vb2z; + domain->minimum_image(vb2xm,vb2ym,vb2zm); - ax = vb1y*vb2zm - vb1z*vb2ym; - ay = vb1z*vb2xm - vb1x*vb2zm; - az = vb1x*vb2ym - vb1y*vb2xm; - bx = vb3y*vb2zm - vb3z*vb2ym; - by = vb3z*vb2xm - vb3x*vb2zm; - bz = vb3x*vb2ym - vb3y*vb2xm; + vb3x = x4[0] - x3[0]; + vb3y = x4[1] - x3[1]; + vb3z = x4[2] - x3[2]; + domain->minimum_image(vb3x,vb3y,vb3z); - rasq = ax*ax + ay*ay + az*az; - rbsq = bx*bx + by*by + bz*bz; - rgsq = vb2xm*vb2xm + vb2ym*vb2ym + vb2zm*vb2zm; - rg = sqrt(rgsq); + ax = vb1y*vb2zm - vb1z*vb2ym; + ay = vb1z*vb2xm - vb1x*vb2zm; + az = vb1x*vb2ym - vb1y*vb2xm; + bx = vb3y*vb2zm - vb3z*vb2ym; + by = vb3z*vb2xm - vb3x*vb2zm; + bz = vb3x*vb2ym - vb3y*vb2xm; - ra2inv = rb2inv = 0.0; - if (rasq > 0) ra2inv = 1.0/rasq; - if (rbsq > 0) rb2inv = 1.0/rbsq; - rabinv = sqrt(ra2inv*rb2inv); + rasq = ax*ax + ay*ay + az*az; + rbsq = bx*bx + by*by + bz*bz; + rgsq = vb2xm*vb2xm + vb2ym*vb2ym + vb2zm*vb2zm; + rg = sqrt(rgsq); - c = (ax*bx + ay*by + az*bz)*rabinv; - s = rg*rabinv*(ax*vb3x + ay*vb3y + az*vb3z); + ra2inv = rb2inv = 0.0; + if (rasq > 0) ra2inv = 1.0/rasq; + if (rbsq > 0) rb2inv = 1.0/rbsq; + rabinv = sqrt(ra2inv*rb2inv); - if (c > 1.0) c = 1.0; - if (c < -1.0) c = -1.0; - phi = atan2(s,c); + c = (ax*bx + ay*by + az*bz)*rabinv; + s = rg*rabinv*(ax*vb3x + ay*vb3y + az*vb3z); - ANDgate = 0; - if (constraints[i][10] < constraints[i][11]) { - if (phi > constraints[i][10] && phi < constraints[i][11]) ANDgate = 1; - } else { - if (phi > constraints[i][10] || phi < constraints[i][11]) ANDgate = 1; - } - if (constraints[i][12] < constraints[i][13]) { - if (phi > constraints[i][12] && phi < constraints[i][13]) ANDgate = 1; - } else { - if (phi > constraints[i][12] || phi < constraints[i][13]) ANDgate = 1; - } - if (ANDgate != 1) return 0; - } else if (constraints[i][1] == ARRHENIUS) { - t = get_temperature(); - prrhob = constraints[i][3]*pow(t,constraints[i][4])* - exp(-constraints[i][5]/(force->boltz*t)); - if (prrhob < rrhandom[(int) constraints[i][2]]->uniform()) return 0; - } else if (constraints[i][1] == RMSD) { - // call superpose - int iatom; - int iref = -1; // choose first atom as reference - int n2superpose = 0; - double **xfrozen; // coordinates for the "frozen" target molecule - double **xmobile; // coordinates for the "mobile" molecule - int ifragment = constraints[i][3]; - if (ifragment >= 0) { - for (int j = 0; j < onemol->natoms; j++) - if (onemol->fragmentmask[ifragment][j]) n2superpose++; - memory->create(xfrozen,n2superpose,3,"bond/react:xfrozen"); - memory->create(xmobile,n2superpose,3,"bond/react:xmobile"); - int myincr = 0; - for (int j = 0; j < onemol->natoms; j++) { - if (onemol->fragmentmask[ifragment][j]) { - iatom = atom->map(glove[j][1]); - if (iref == -1) iref = iatom; - iatom = domain->closest_image(iref,iatom); - for (int k = 0; k < 3; k++) { - xfrozen[myincr][k] = x[iatom][k]; - xmobile[myincr][k] = onemol->x[j][k]; - } - myincr++; - } - } - } else { - int iatom; - int iref = -1; // choose first atom as reference - n2superpose = onemol->natoms; - memory->create(xfrozen,n2superpose,3,"bond/react:xfrozen"); - memory->create(xmobile,n2superpose,3,"bond/react:xmobile"); - for (int j = 0; j < n2superpose; j++) { + if (c > 1.0) c = 1.0; + if (c < -1.0) c = -1.0; + phi = atan2(s,c); + + ANDgate = 0; + if (constraints[i][rxnID].par[0] < constraints[i][rxnID].par[1]) { + if (phi > constraints[i][rxnID].par[0] && phi < constraints[i][rxnID].par[1]) ANDgate = 1; + } else { + if (phi > constraints[i][rxnID].par[0] || phi < constraints[i][rxnID].par[1]) ANDgate = 1; + } + if (constraints[i][rxnID].par[2] < constraints[i][rxnID].par[3]) { + if (phi > constraints[i][rxnID].par[2] && phi < constraints[i][rxnID].par[3]) ANDgate = 1; + } else { + if (phi > constraints[i][rxnID].par[2] || phi < constraints[i][rxnID].par[3]) ANDgate = 1; + } + if (ANDgate != 1) satisfied[i] = 0; + } else if (constraints[i][rxnID].type == ARRHENIUS) { + t = get_temperature(); + prrhob = constraints[i][rxnID].par[1]*pow(t,constraints[i][rxnID].par[2])* + exp(-constraints[i][rxnID].par[3]/(force->boltz*t)); + if (prrhob < rrhandom[(int) constraints[i][rxnID].par[0]]->uniform()) satisfied[i] = 0; + } else if (constraints[i][rxnID].type == RMSD) { + // call superpose + int iatom; + int iref = -1; // choose first atom as reference + int n2superpose = 0; + double **xfrozen; // coordinates for the "frozen" target molecule + double **xmobile; // coordinates for the "mobile" molecule + int ifragment = constraints[i][rxnID].id[0]; + if (ifragment >= 0) { + for (int j = 0; j < onemol->natoms; j++) + if (onemol->fragmentmask[ifragment][j]) n2superpose++; + memory->create(xfrozen,n2superpose,3,"bond/react:xfrozen"); + memory->create(xmobile,n2superpose,3,"bond/react:xmobile"); + int myincr = 0; + for (int j = 0; j < onemol->natoms; j++) { + if (onemol->fragmentmask[ifragment][j]) { iatom = atom->map(glove[j][1]); if (iref == -1) iref = iatom; iatom = domain->closest_image(iref,iatom); for (int k = 0; k < 3; k++) { - xfrozen[j][k] = x[iatom][k]; - xmobile[j][k] = onemol->x[j][k]; + xfrozen[myincr][k] = x[iatom][k]; + xmobile[myincr][k] = onemol->x[j][k]; } + myincr++; + } + } + } else { + int iatom; + int iref = -1; // choose first atom as reference + n2superpose = onemol->natoms; + memory->create(xfrozen,n2superpose,3,"bond/react:xfrozen"); + memory->create(xmobile,n2superpose,3,"bond/react:xmobile"); + for (int j = 0; j < n2superpose; j++) { + iatom = atom->map(glove[j][1]); + if (iref == -1) iref = iatom; + iatom = domain->closest_image(iref,iatom); + for (int k = 0; k < 3; k++) { + xfrozen[j][k] = x[iatom][k]; + xmobile[j][k] = onemol->x[j][k]; } } - Superpose3D superposer(n2superpose); - double rmsd = superposer.Superpose(xfrozen, xmobile); - if (rmsd > constraints[i][2]) return 0; - memory->destroy(xfrozen); - memory->destroy(xmobile); } + Superpose3D superposer(n2superpose); + double rmsd = superposer.Superpose(xfrozen, xmobile); + memory->destroy(xfrozen); + memory->destroy(xmobile); + if (rmsd > constraints[i][rxnID].par[0]) satisfied[i] = 0; } } + if (nconstraints[rxnID] > 0) { + char evalstr[MAXLINE],*ptr,valstr; + strcpy(evalstr,constraintstr[rxnID]); + for (int i = 0; i < nconstraints[rxnID]; i++) { + sprintf(&valstr,"%d", satisfied[i]); + ptr = strchr(evalstr,'C'); + *ptr = valstr; + } + double verdict = input->variable->evaluate_boolean(evalstr); + if (verdict == 0.0) return 0; + } + // let's also check chirality within 'check_constraint' for (int i = 0; i < onemol->natoms; i++) { if (chiral_atoms[i][0][rxnID] == 1) { @@ -1975,6 +2000,7 @@ int FixBondReact::check_constraints() } } + memory->destroy(satisfied); return 1; } @@ -1987,7 +2013,7 @@ fragment: given pre-reacted molID (onemol) and fragID, void FixBondReact::get_IDcoords(int mode, int myID, double *center) { double **x = atom->x; - if (mode == 1) { + if (mode == ATOM) { int iatom = atom->map(glove[myID-1][1]); for (int i = 0; i < 3; i++) center[i] = x[iatom][i]; @@ -3216,8 +3242,8 @@ void FixBondReact::read(int myrxn) else if (strstr(line,"deleteIDs")) sscanf(line,"%d",&ndelete); else if (strstr(line,"chiralIDs")) sscanf(line,"%d",&nchiral); else if (strstr(line,"constraints")) { - sscanf(line,"%d",&nconstr); - memory->grow(constraints,nconstraints+nconstr,MAXCONARGS,"bond/react:constraints"); + sscanf(line,"%d",&nconstraints[myrxn]); + memory->grow(constraints,nconstraints[myrxn],nreacts,"bond/react:constraints"); } else break; } @@ -3252,7 +3278,7 @@ void FixBondReact::read(int myrxn) } else if (strcmp(keyword,"ChiralIDs") == 0) { ChiralCenters(line, myrxn); } else if (strcmp(keyword,"Constraints") == 0) { - Constraints(line, myrxn); + ReadConstraints(line, myrxn); } else error->one(FLERR,"Bond/react: Unknown section in map file"); parse_keyword(1,line,keyword); @@ -3350,69 +3376,89 @@ void FixBondReact::ChiralCenters(char *line, int myrxn) } } -void FixBondReact::Constraints(char *line, int myrxn) +void FixBondReact::ReadConstraints(char *line, int myrxn) { double tmp[MAXCONARGS]; - char **strargs; + char **strargs,*ptr; memory->create(strargs,MAXCONARGS,MAXLINE,"bond/react:strargs"); char *constraint_type = new char[MAXLINE]; - for (int i = 0; i < nconstr; i++) { + strcpy(constraintstr[myrxn],"("); // string for boolean constraint logic + for (int i = 0; i < nconstraints[myrxn]; i++) { readline(line); + if (ptr = strrchr(line,'(')) { // reverse char search + strncat(constraintstr[myrxn],line,ptr-line+1); + line = ptr + 1; + } + // 'C' indicates where to sub in next constraint + strcat(constraintstr[myrxn],"C"); + if (ptr = strchr(line,')')) { + strncat(constraintstr[myrxn],ptr,strrchr(line,')')-ptr+1); + } + if (ptr = strstr(line,"&&")) { + strcat(constraintstr[myrxn],"&&"); + *ptr = '\0'; + } else if (ptr = strstr(line,"||")) { + strcat(constraintstr[myrxn],"||"); + *ptr = '\0'; + } else if (i+1 < nconstraints[myrxn]){ + strcat(constraintstr[myrxn],"&&"); + } + if (ptr = strchr(line,')')) + *ptr = '\0'; sscanf(line,"%s",constraint_type); - constraints[nconstraints][0] = myrxn; if (strcmp(constraint_type,"distance") == 0) { - constraints[nconstraints][1] = DISTANCE; + constraints[i][myrxn].type = DISTANCE; sscanf(line,"%*s %s %s %lg %lg",strargs[0],strargs[1],&tmp[0],&tmp[1]); - readID(strargs[0], nconstraints, 2, 3); - readID(strargs[1], nconstraints, 4, 5); + readID(strargs[0], i, myrxn, 0); + readID(strargs[1], i, myrxn, 1); // cutoffs - constraints[nconstraints][6] = tmp[0]*tmp[0]; // using square of distance - constraints[nconstraints][7] = tmp[1]*tmp[1]; + constraints[i][myrxn].par[0] = tmp[0]*tmp[0]; // using square of distance + constraints[i][myrxn].par[1] = tmp[1]*tmp[1]; } else if (strcmp(constraint_type,"angle") == 0) { - constraints[nconstraints][1] = ANGLE; + constraints[i][myrxn].type = ANGLE; sscanf(line,"%*s %s %s %s %lg %lg",strargs[0],strargs[1],strargs[2],&tmp[0],&tmp[1]); - readID(strargs[0], nconstraints, 2, 3); - readID(strargs[1], nconstraints, 4, 5); - readID(strargs[2], nconstraints, 6, 7); - constraints[nconstraints][8] = tmp[0]/180.0 * MY_PI; - constraints[nconstraints][9] = tmp[1]/180.0 * MY_PI; + readID(strargs[0], i, myrxn, 0); + readID(strargs[1], i, myrxn, 1); + readID(strargs[2], i, myrxn, 2); + constraints[i][myrxn].par[0] = tmp[0]/180.0 * MY_PI; + constraints[i][myrxn].par[1] = tmp[1]/180.0 * MY_PI; } else if (strcmp(constraint_type,"dihedral") == 0) { - constraints[nconstraints][1] = DIHEDRAL; + constraints[i][myrxn].type = DIHEDRAL; tmp[2] = 181.0; // impossible range tmp[3] = 182.0; sscanf(line,"%*s %s %s %s %s %lg %lg %lg %lg",strargs[0],strargs[1], strargs[2],strargs[3],&tmp[0],&tmp[1],&tmp[2],&tmp[3]); - readID(strargs[0], nconstraints, 2, 3); - readID(strargs[1], nconstraints, 4, 5); - readID(strargs[2], nconstraints, 6, 7); - readID(strargs[3], nconstraints, 8, 9); - constraints[nconstraints][10] = tmp[0]/180.0 * MY_PI; - constraints[nconstraints][11] = tmp[1]/180.0 * MY_PI; - constraints[nconstraints][12] = tmp[2]/180.0 * MY_PI; - constraints[nconstraints][13] = tmp[3]/180.0 * MY_PI; + readID(strargs[0], i, myrxn, 0); + readID(strargs[1], i, myrxn, 1); + readID(strargs[2], i, myrxn, 2); + readID(strargs[3], i, myrxn, 3); + constraints[i][myrxn].par[0] = tmp[0]/180.0 * MY_PI; + constraints[i][myrxn].par[1] = tmp[1]/180.0 * MY_PI; + constraints[i][myrxn].par[2] = tmp[2]/180.0 * MY_PI; + constraints[i][myrxn].par[3] = tmp[3]/180.0 * MY_PI; } else if (strcmp(constraint_type,"arrhenius") == 0) { - constraints[nconstraints][1] = ARRHENIUS; - constraints[nconstraints][2] = narrhenius++; + constraints[i][myrxn].type = ARRHENIUS; + constraints[i][myrxn].par[0] = narrhenius++; sscanf(line,"%*s %lg %lg %lg %lg",&tmp[0],&tmp[1],&tmp[2],&tmp[3]); - constraints[nconstraints][3] = tmp[0]; - constraints[nconstraints][4] = tmp[1]; - constraints[nconstraints][5] = tmp[2]; - constraints[nconstraints][6] = tmp[3]; + constraints[i][myrxn].par[1] = tmp[0]; + constraints[i][myrxn].par[2] = tmp[1]; + constraints[i][myrxn].par[3] = tmp[2]; + constraints[i][myrxn].par[4] = tmp[3]; } else if (strcmp(constraint_type,"rmsd") == 0) { - constraints[nconstraints][1] = RMSD; + constraints[i][myrxn].type = RMSD; strcpy(strargs[0],"0"); sscanf(line,"%*s %lg %s",&tmp[0],strargs[0]); - constraints[nconstraints][2] = tmp[0]; // RMSDmax - constraints[nconstraints][3] = -1; // optional molecule fragment + constraints[i][myrxn].par[0] = tmp[0]; // RMSDmax + constraints[i][myrxn].id[0] = -1; // optional molecule fragment if (isalpha(strargs[0][0])) { int ifragment = onemol->findfragment(strargs[0]); if (ifragment < 0) error->one(FLERR,"Bond/react: Molecule fragment does not exist"); - else constraints[nconstraints][3] = ifragment; + else constraints[i][myrxn].id[0] = ifragment; } } else error->one(FLERR,"Bond/react: Illegal constraint type in 'Constraints' section of map file"); - nconstraints++; } + strcat(constraintstr[myrxn],")"); // close boolean constraint logic string delete [] constraint_type; memory->destroy(strargs); } @@ -3422,18 +3468,18 @@ if ID starts with character, assume it is a pre-reaction molecule fragment ID otherwise, it is a pre-reaction atom ID ---------------------------------------------------------------------- */ -void FixBondReact::readID(char *strarg, int iconstr, int mode, int myID) +void FixBondReact::readID(char *strarg, int iconstr, int myrxn, int i) { if (isalpha(strarg[0])) { - constraints[iconstr][mode] = 0; // fragment vs. atom ID flag + constraints[iconstr][myrxn].idtype[i] = FRAG; // fragment vs. atom ID flag int ifragment = onemol->findfragment(strarg); if (ifragment < 0) error->one(FLERR,"Bond/react: Molecule fragment does not exist"); - constraints[iconstr][myID] = ifragment; + constraints[iconstr][myrxn].id[i] = ifragment; } else { - constraints[iconstr][mode] = 1; // fragment vs. atom ID flag + constraints[iconstr][myrxn].idtype[i] = ATOM; // fragment vs. atom ID flag int iatom = atoi(strarg); if (iatom > onemol->natoms) error->one(FLERR,"Bond/react: Invalid template atom ID in map file"); - constraints[iconstr][myID] = iatom; + constraints[iconstr][myrxn].id[i] = iatom; } } diff --git a/src/USER-REACTION/fix_bond_react.h b/src/USER-REACTION/fix_bond_react.h index 6105859136..a66f57c2bc 100644 --- a/src/USER-REACTION/fix_bond_react.h +++ b/src/USER-REACTION/fix_bond_react.h @@ -31,7 +31,9 @@ namespace LAMMPS_NS { class FixBondReact : public Fix { public: - enum {MAXLINE=256}; + enum {MAXLINE=256}; // max length of line read from files + enum {MAXCONIDS=4}; // max # of IDs used by any constraint + enum {MAXCONPAR=4}; // max # of constraint parameters FixBondReact(class LAMMPS *, int, char **); ~FixBondReact(); @@ -66,9 +68,9 @@ class FixBondReact : public Fix { int *stabilize_steps_flag; int *custom_charges_fragid; int *molecule_keyword; - int nconstraints; + int *nconstraints; + char **constraintstr; int narrhenius; - double **constraints; int **var_flag,**var_id; // for keyword values with variable inputs int status; int *groupbits; @@ -114,7 +116,7 @@ class FixBondReact : public Fix { int *ibonding,*jbonding; int *closeneigh; // indicates if bonding atoms of a rxn are 1-2, 1-3, or 1-4 neighbors - int nedge,nequivalent,ndelete,nchiral,nconstr; // # edge, equivalent atoms in mapping file + int nedge,nequivalent,ndelete,nchiral; // # edge, equivalent atoms in mapping file int attempted_rxn; // there was an attempt! int *local_rxn_count; int *ghostly_rxn_count; @@ -155,7 +157,7 @@ class FixBondReact : public Fix { void DeleteAtoms(char *, int); void CustomCharges(int, int); void ChiralCenters(char *, int); - void Constraints(char *, int); + void ReadConstraints(char *, int); void readID(char *, int, int, int); void make_a_guess (); @@ -195,6 +197,14 @@ class FixBondReact : public Fix { }; Set *set; + struct Constraint { + int type; + int id[MAXCONIDS]; + int idtype[MAXCONIDS]; + double par[MAXCONPAR]; + }; + Constraint **constraints; + // DEBUG void print_bb(); diff --git a/src/USER-SMTBQ/pair_smtbq.cpp b/src/USER-SMTBQ/pair_smtbq.cpp index 94647cb552..aedf90da07 100644 --- a/src/USER-SMTBQ/pair_smtbq.cpp +++ b/src/USER-SMTBQ/pair_smtbq.cpp @@ -72,17 +72,6 @@ using namespace MathSpecial; #define PGDELTA 1 #define MAXNEIGH 24 -/* ------------------------------------------------------------------------------------ - - Calculates the factorial of an integer n via recursion. - - ------------------------------------------------------------------------------------ */ -static double factorial(int n) -{ - if (n <= 1) return 1.0; - else return static_cast(n)*factorial(n-1); -} - /* ---------------------------------------------------------------------- */ PairSMTBQ::PairSMTBQ(LAMMPS *lmp) : Pair(lmp) diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index e464d31b77..4406ac5f23 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -29,9 +29,6 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define DELTA 16384 -#define DELTA_BONUS 8192 - /* ---------------------------------------------------------------------- */ AtomVec::AtomVec(LAMMPS *lmp) : Pointers(lmp) @@ -188,6 +185,8 @@ void AtomVec::init() error->all(FLERR,"KOKKOS package requires a kokkos enabled atom_style"); } +static constexpr bigint DELTA=16384; + /* ---------------------------------------------------------------------- roundup N so it is a multiple of DELTA error if N exceeds 32-bit int, since will be used as arg to grow() @@ -211,6 +210,8 @@ void AtomVec::grow_nmax() nmax += DELTA; } +static constexpr bigint DELTA_BONUS=8192; + /* ---------------------------------------------------------------------- grow nmax_bonus so it is a multiple of DELTA_BONUS ------------------------------------------------------------------------- */ diff --git a/src/balance.cpp b/src/balance.cpp index c47412cc9e..6294e023b3 100644 --- a/src/balance.cpp +++ b/src/balance.cpp @@ -924,66 +924,66 @@ int Balance::shift() i = 0; while (i < np) { if (split[i+1] - split[i] < close) { - j = i+1; + j = i+1; - // I,J = set of consecutive splits that are collectively too close - // if can expand set and not become too close to splits I-1 or J+1, do it - // else add split I-1 or J+1 to set and try again - // delta = size of expanded split set that will satisy criterion + // I,J = set of consecutive splits that are collectively too close + // if can expand set and not become too close to splits I-1 or J+1, do it + // else add split I-1 or J+1 to set and try again + // delta = size of expanded split set that will satisy criterion - while (1) { - delta = (j-i) * close; - midpt = 0.5 * (split[i]+split[j]); - start = midpt - 0.5*delta; - stop = midpt + 0.5*delta; + while (1) { + delta = (j-i) * close; + midpt = 0.5 * (split[i]+split[j]); + start = midpt - 0.5*delta; + stop = midpt + 0.5*delta; - if (i > 0) lbound = split[i-1] + close; - else lbound = 0.0; - if (j < np) ubound = split[j+1] - close; - else ubound = 1.0; + if (i > 0) lbound = split[i-1] + close; + else lbound = 0.0; + if (j < np) ubound = split[j+1] - close; + else ubound = 1.0; - // start/stop are within bounds, reset the splits + // start/stop are within bounds, reset the splits - if (start >= lbound && stop <= ubound) break; + if (start >= lbound && stop <= ubound) break; - // try a shift to either bound, reset the splits if delta fits - // these tests change start/stop + // try a shift to either bound, reset the splits if delta fits + // these tests change start/stop - if (start < lbound) { - start = lbound; - stop = start + delta; - if (stop <= ubound) break; - } else if (stop > ubound) { - stop = ubound; - start = stop - delta; - if (start >= lbound) break; - } + if (start < lbound) { + start = lbound; + stop = start + delta; + if (stop <= ubound) break; + } else if (stop > ubound) { + stop = ubound; + start = stop - delta; + if (start >= lbound) break; + } - // delta does not fit between lbound and ubound - // exit if can't expand set, else expand set - // if can expand in either direction, - // pick new split closest to current midpt of set + // delta does not fit between lbound and ubound + // exit if can't expand set, else expand set + // if can expand in either direction, + // pick new split closest to current midpt of set - if (i == 0 && j == np) { - start = 0.0; stop = 1.0; - break; - } - if (i == 0) j++; - else if (j == np) i--; - else if (midpt-lbound < ubound-midpt) i--; - else j++; - } + if (i == 0 && j == np) { + start = 0.0; stop = 1.0; + break; + } + if (i == 0) j++; + else if (j == np) i--; + else if (midpt-lbound < ubound-midpt) i--; + else j++; + } - // reset all splits between I,J inclusive to be equi-spaced + // reset all splits between I,J inclusive to be equi-spaced - spacing = (stop-start) / (j-i); - for (m = i; m <= j; m++) - split[m] = start + (m-i)*spacing; + spacing = (stop-start) / (j-i); + for (m = i; m <= j; m++) + split[m] = start + (m-i)*spacing; if (j == np) split[np] = 1.0; - // continue testing beyond the J split + // continue testing beyond the J split - i = j+1; + i = j+1; } else i++; } diff --git a/src/compute_orientorder_atom.cpp b/src/compute_orientorder_atom.cpp index db8a2f404b..b334654e82 100644 --- a/src/compute_orientorder_atom.cpp +++ b/src/compute_orientorder_atom.cpp @@ -23,6 +23,7 @@ #include "error.h" #include "force.h" #include "math_const.h" +#include "math_special.h" #include "memory.h" #include "modify.h" #include "neigh_list.h" @@ -36,6 +37,8 @@ using namespace LAMMPS_NS; using namespace MathConst; +using namespace MathSpecial; + #ifdef DBL_EPSILON #define MY_EPSILON (10.0*DBL_EPSILON) @@ -708,191 +711,3 @@ void ComputeOrientOrderAtom::init_clebsch_gordan() } } } - -/* ---------------------------------------------------------------------- - factorial n, wrapper for precomputed table -------------------------------------------------------------------------- */ - -double ComputeOrientOrderAtom::factorial(int n) -{ - if (n < 0 || n > nmaxfactorial) - error->all(FLERR,fmt::format("Invalid argument to factorial {}", n)); - - return nfac_table[n]; -} - -/* ---------------------------------------------------------------------- - factorial n table, size SNA::nmaxfactorial+1 -------------------------------------------------------------------------- */ - -const double ComputeOrientOrderAtom::nfac_table[] = { - 1, - 1, - 2, - 6, - 24, - 120, - 720, - 5040, - 40320, - 362880, - 3628800, - 39916800, - 479001600, - 6227020800, - 87178291200, - 1307674368000, - 20922789888000, - 355687428096000, - 6.402373705728e+15, - 1.21645100408832e+17, - 2.43290200817664e+18, - 5.10909421717094e+19, - 1.12400072777761e+21, - 2.5852016738885e+22, - 6.20448401733239e+23, - 1.5511210043331e+25, - 4.03291461126606e+26, - 1.08888694504184e+28, - 3.04888344611714e+29, - 8.8417619937397e+30, - 2.65252859812191e+32, - 8.22283865417792e+33, - 2.63130836933694e+35, - 8.68331761881189e+36, - 2.95232799039604e+38, - 1.03331479663861e+40, - 3.71993326789901e+41, - 1.37637530912263e+43, - 5.23022617466601e+44, - 2.03978820811974e+46, - 8.15915283247898e+47, - 3.34525266131638e+49, - 1.40500611775288e+51, - 6.04152630633738e+52, - 2.65827157478845e+54, - 1.1962222086548e+56, - 5.50262215981209e+57, - 2.58623241511168e+59, - 1.24139155925361e+61, - 6.08281864034268e+62, - 3.04140932017134e+64, - 1.55111875328738e+66, - 8.06581751709439e+67, - 4.27488328406003e+69, - 2.30843697339241e+71, - 1.26964033536583e+73, - 7.10998587804863e+74, - 4.05269195048772e+76, - 2.35056133128288e+78, - 1.3868311854569e+80, - 8.32098711274139e+81, - 5.07580213877225e+83, - 3.14699732603879e+85, - 1.98260831540444e+87, - 1.26886932185884e+89, - 8.24765059208247e+90, - 5.44344939077443e+92, - 3.64711109181887e+94, - 2.48003554243683e+96, - 1.71122452428141e+98, - 1.19785716699699e+100, - 8.50478588567862e+101, - 6.12344583768861e+103, - 4.47011546151268e+105, - 3.30788544151939e+107, - 2.48091408113954e+109, - 1.88549470166605e+111, - 1.45183092028286e+113, - 1.13242811782063e+115, - 8.94618213078297e+116, - 7.15694570462638e+118, - 5.79712602074737e+120, - 4.75364333701284e+122, - 3.94552396972066e+124, - 3.31424013456535e+126, - 2.81710411438055e+128, - 2.42270953836727e+130, - 2.10775729837953e+132, - 1.85482642257398e+134, - 1.65079551609085e+136, - 1.48571596448176e+138, - 1.3520015276784e+140, - 1.24384140546413e+142, - 1.15677250708164e+144, - 1.08736615665674e+146, - 1.03299784882391e+148, - 9.91677934870949e+149, - 9.61927596824821e+151, - 9.42689044888324e+153, - 9.33262154439441e+155, - 9.33262154439441e+157, - 9.42594775983835e+159, - 9.61446671503512e+161, - 9.90290071648618e+163, - 1.02990167451456e+166, - 1.08139675824029e+168, - 1.14628056373471e+170, - 1.22652020319614e+172, - 1.32464181945183e+174, - 1.44385958320249e+176, - 1.58824554152274e+178, - 1.76295255109024e+180, - 1.97450685722107e+182, - 2.23119274865981e+184, - 2.54355973347219e+186, - 2.92509369349301e+188, - 3.3931086844519e+190, - 3.96993716080872e+192, - 4.68452584975429e+194, - 5.5745857612076e+196, - 6.68950291344912e+198, - 8.09429852527344e+200, - 9.8750442008336e+202, - 1.21463043670253e+205, - 1.50614174151114e+207, - 1.88267717688893e+209, - 2.37217324288005e+211, - 3.01266001845766e+213, - 3.8562048236258e+215, - 4.97450422247729e+217, - 6.46685548922047e+219, - 8.47158069087882e+221, - 1.118248651196e+224, - 1.48727070609069e+226, - 1.99294274616152e+228, - 2.69047270731805e+230, - 3.65904288195255e+232, - 5.01288874827499e+234, - 6.91778647261949e+236, - 9.61572319694109e+238, - 1.34620124757175e+241, - 1.89814375907617e+243, - 2.69536413788816e+245, - 3.85437071718007e+247, - 5.5502938327393e+249, - 8.04792605747199e+251, - 1.17499720439091e+254, - 1.72724589045464e+256, - 2.55632391787286e+258, - 3.80892263763057e+260, - 5.71338395644585e+262, - 8.62720977423323e+264, - 1.31133588568345e+267, - 2.00634390509568e+269, - 3.08976961384735e+271, - 4.78914290146339e+273, - 7.47106292628289e+275, - 1.17295687942641e+278, - 1.85327186949373e+280, - 2.94670227249504e+282, - 4.71472363599206e+284, - 7.59070505394721e+286, - 1.22969421873945e+289, - 2.0044015765453e+291, - 3.28721858553429e+293, - 5.42391066613159e+295, - 9.00369170577843e+297, - 1.503616514865e+300, // nmaxfactorial = 167 -}; - diff --git a/src/compute_orientorder_atom.h b/src/compute_orientorder_atom.h index 4e5084bfcd..4fc122c5c8 100644 --- a/src/compute_orientorder_atom.h +++ b/src/compute_orientorder_atom.h @@ -56,9 +56,6 @@ class ComputeOrientOrderAtom : public Compute { double polar_prefactor(int, int, double); double associated_legendre(int, int, double); - static const int nmaxfactorial = 167; - static const double nfac_table[]; - double factorial(int); virtual void init_clebsch_gordan(); double *cglist; // Clebsch-Gordan coeffs int idxcg_max; diff --git a/src/fix.h b/src/fix.h index 75c644e87f..ec951e3bb2 100644 --- a/src/fix.h +++ b/src/fix.h @@ -251,31 +251,32 @@ class Fix : protected Pointers { }; namespace FixConst { - static const int INITIAL_INTEGRATE = 1<<0; - static const int POST_INTEGRATE = 1<<1; - static const int PRE_EXCHANGE = 1<<2; - static const int PRE_NEIGHBOR = 1<<3; - static const int POST_NEIGHBOR = 1<<4; - static const int PRE_FORCE = 1<<5; - static const int PRE_REVERSE = 1<<6; - static const int POST_FORCE = 1<<7; - static const int FINAL_INTEGRATE = 1<<8; - static const int END_OF_STEP = 1<<9; - static const int POST_RUN = 1<<10; - static const int THERMO_ENERGY = 1<<11; - static const int INITIAL_INTEGRATE_RESPA = 1<<12; - static const int POST_INTEGRATE_RESPA = 1<<13; - static const int PRE_FORCE_RESPA = 1<<14; - static const int POST_FORCE_RESPA = 1<<15; - static const int FINAL_INTEGRATE_RESPA = 1<<16; - static const int MIN_PRE_EXCHANGE = 1<<17; - static const int MIN_PRE_NEIGHBOR = 1<<18; - static const int MIN_POST_NEIGHBOR = 1<<19; - static const int MIN_PRE_FORCE = 1<<20; - static const int MIN_PRE_REVERSE = 1<<21; - static const int MIN_POST_FORCE = 1<<22; - static const int MIN_ENERGY = 1<<23; - static const int FIX_CONST_LAST = 1<<24; + enum { + INITIAL_INTEGRATE = 1<<0, + POST_INTEGRATE = 1<<1, + PRE_EXCHANGE = 1<<2, + PRE_NEIGHBOR = 1<<3, + POST_NEIGHBOR = 1<<4, + PRE_FORCE = 1<<5, + PRE_REVERSE = 1<<6, + POST_FORCE = 1<<7, + FINAL_INTEGRATE = 1<<8, + END_OF_STEP = 1<<9, + POST_RUN = 1<<10, + THERMO_ENERGY = 1<<11, + INITIAL_INTEGRATE_RESPA = 1<<12, + POST_INTEGRATE_RESPA = 1<<13, + PRE_FORCE_RESPA = 1<<14, + POST_FORCE_RESPA = 1<<15, + FINAL_INTEGRATE_RESPA = 1<<16, + MIN_PRE_EXCHANGE = 1<<17, + MIN_PRE_NEIGHBOR = 1<<18, + MIN_POST_NEIGHBOR = 1<<19, + MIN_PRE_FORCE = 1<<20, + MIN_PRE_REVERSE = 1<<21, + MIN_POST_FORCE = 1<<22, + MIN_ENERGY = 1<<23 + }; } } diff --git a/src/fix_temp_csld.cpp b/src/fix_temp_csld.cpp index f01de7c2fa..3b522c185f 100644 --- a/src/fix_temp_csld.cpp +++ b/src/fix_temp_csld.cpp @@ -305,16 +305,17 @@ double FixTempCSLD::compute_scalar() void FixTempCSLD::write_restart(FILE *fp) { - int nsize = (98+2+3)*comm->nprocs+2; // pRNG state per proc + nprocs + energy + const int PRNGSIZE = 98+2+3; + int nsize = PRNGSIZE*comm->nprocs+2; // pRNG state per proc + nprocs + energy double *list = nullptr; if (comm->me == 0) { list = new double[nsize]; list[0] = energy; list[1] = comm->nprocs; } - double state[103]; + double state[PRNGSIZE]; random->get_state(state); - MPI_Gather(state,103,MPI_DOUBLE,list+2,103*comm->nprocs,MPI_DOUBLE,0,world); + MPI_Gather(state,PRNGSIZE,MPI_DOUBLE,list+2,PRNGSIZE,MPI_DOUBLE,0,world); if (comm->me == 0) { int size = nsize * sizeof(double); diff --git a/src/fix_temp_csvr.cpp b/src/fix_temp_csvr.cpp index 0130631172..674c436e9d 100644 --- a/src/fix_temp_csvr.cpp +++ b/src/fix_temp_csvr.cpp @@ -338,16 +338,17 @@ double FixTempCSVR::compute_scalar() void FixTempCSVR::write_restart(FILE *fp) { - int nsize = (98+2+3)*comm->nprocs+2; // pRNG state per proc + nprocs + energy + const int PRNGSIZE = 98+2+3; + int nsize = PRNGSIZE*comm->nprocs+2; // pRNG state per proc + nprocs + energy double *list = nullptr; if (comm->me == 0) { list = new double[nsize]; list[0] = energy; list[1] = comm->nprocs; } - double state[103]; + double state[PRNGSIZE]; random->get_state(state); - MPI_Gather(state,103,MPI_DOUBLE,list+2,103*comm->nprocs,MPI_DOUBLE,0,world); + MPI_Gather(state,PRNGSIZE,MPI_DOUBLE,list+2,PRNGSIZE,MPI_DOUBLE,0,world); if (comm->me == 0) { int size = nsize * sizeof(double); diff --git a/src/force.cpp b/src/force.cpp index d271d1207e..1f03206f31 100644 --- a/src/force.cpp +++ b/src/force.cpp @@ -245,13 +245,22 @@ void Force::create_pair(const std::string &style, int trysuffix) /* ---------------------------------------------------------------------- generate a pair class if trysuffix = 1, try first with suffix1/2 appended - return sflag = 0 for no suffix added, 1 or 2 for suffix1/2 added + return sflag = 0 for no suffix added, 1 or 2 or 3 for suffix1/2/p added + special case: if suffixp exists only try suffixp, not suffix ------------------------------------------------------------------------- */ Pair *Force::new_pair(const std::string &style, int trysuffix, int &sflag) { if (trysuffix && lmp->suffix_enable) { - if (lmp->suffix) { + if (lmp->suffixp) { + sflag = 3; + std::string estyle = style + "/" + lmp->suffixp; + if (pair_map->find(estyle) != pair_map->end()) { + PairCreator &pair_creator = (*pair_map)[estyle]; + return pair_creator(lmp); + } + } + if (lmp->suffix && !lmp->suffixp) { sflag = 1; std::string estyle = style + "/" + lmp->suffix; if (pair_map->find(estyle) != pair_map->end()) { @@ -727,7 +736,7 @@ KSpace *Force::kspace_match(const std::string &word, int exact) /* ---------------------------------------------------------------------- store style name in str allocated here if sflag = 0, no suffix - if sflag = 1/2, append suffix or suffix2 to style + if sflag = 1/2/3, append suffix or suffix2 or suffixp to style ------------------------------------------------------------------------- */ void Force::store_style(char *&str, const std::string &style, int sflag) @@ -736,6 +745,7 @@ void Force::store_style(char *&str, const std::string &style, int sflag) if (sflag == 1) estyle += std::string("/") + lmp->suffix; else if (sflag == 2) estyle += std::string("/") + lmp->suffix2; + else if (sflag == 3) estyle += std::string("/") + lmp->suffixp; str = new char[estyle.size()+1]; strcpy(str,estyle.c_str()); diff --git a/src/input.cpp b/src/input.cpp index abdc3775ce..457cf74b1a 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1715,7 +1715,10 @@ void Input::pair_style() int match = 0; if (style == force->pair_style) match = 1; if (!match && lmp->suffix_enable) { - if (lmp->suffix) + if (lmp->suffixp) + if (style + "/" + lmp->suffixp == force->pair_style) match = 1; + + if (lmp->suffix && !lmp->suffixp) if (style + "/" + lmp->suffix == force->pair_style) match = 1; if (lmp->suffix2) diff --git a/src/lammps.cpp b/src/lammps.cpp index 102d2f18cf..69baec5557 100644 --- a/src/lammps.cpp +++ b/src/lammps.cpp @@ -173,7 +173,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) : int citeflag = 1; int helpflag = 0; - suffix = suffix2 = nullptr; + suffix = suffix2 = suffixp = nullptr; suffix_enable = 0; if (arg) exename = arg[0]; else exename = nullptr; @@ -714,6 +714,7 @@ LAMMPS::~LAMMPS() delete kokkos; delete [] suffix; delete [] suffix2; + delete [] suffixp; // free the MPI comm created by -mpi command-line arg processed in constructor // it was passed to universe as if original universe world diff --git a/src/lammps.h b/src/lammps.h index 0d9442ffb9..49d55d4e37 100644 --- a/src/lammps.h +++ b/src/lammps.h @@ -51,7 +51,7 @@ class LAMMPS { double initclock; // wall clock at instantiation - char *suffix,*suffix2; // suffixes to add to input script style names + char *suffix,*suffix2,*suffixp;// suffixes to add to input script style names int suffix_enable; // 1 if suffixes are enabled, 0 if disabled char *exename; // pointer to argv[0] char ***packargs; // arguments for cmdline package commands diff --git a/src/math_const.h b/src/math_const.h index fefb442f68..53a485bf99 100644 --- a/src/math_const.h +++ b/src/math_const.h @@ -17,18 +17,18 @@ namespace LAMMPS_NS { namespace MathConst { - static const double THIRD = 1.0/3.0; - static const double TWOTHIRDS = 2.0/3.0; - static const double MY_PI = 3.14159265358979323846; // pi - static const double MY_2PI = 6.28318530717958647692; // 2pi - static const double MY_3PI = 9.42477796076937971538; // 3pi - static const double MY_4PI = 12.56637061435917295384; // 4pi - static const double MY_PI2 = 1.57079632679489661923; // pi/2 - static const double MY_PI4 = 0.78539816339744830962; // pi/4 - static const double MY_PIS = 1.77245385090551602729; // sqrt(pi) - static const double MY_ISPI4 = 1.12837916709551257389; // 1/sqrt(pi/4) - static const double MY_SQRT2 = 1.41421356237309504880; // sqrt(2) - static const double MY_CBRT2 = 1.25992104989487316476; // 2*(1/3) + static constexpr double THIRD = 1.0/3.0; + static constexpr double TWOTHIRDS = 2.0/3.0; + static constexpr double MY_PI = 3.14159265358979323846; // pi + static constexpr double MY_2PI = 6.28318530717958647692; // 2pi + static constexpr double MY_3PI = 9.42477796076937971538; // 3pi + static constexpr double MY_4PI = 12.56637061435917295384; // 4pi + static constexpr double MY_PI2 = 1.57079632679489661923; // pi/2 + static constexpr double MY_PI4 = 0.78539816339744830962; // pi/4 + static constexpr double MY_PIS = 1.77245385090551602729; // sqrt(pi) + static constexpr double MY_ISPI4 = 1.12837916709551257389; // 1/sqrt(pi/4) + static constexpr double MY_SQRT2 = 1.41421356237309504880; // sqrt(2) + static constexpr double MY_CBRT2 = 1.25992104989487316476; // 2*(1/3) } } diff --git a/src/math_special.cpp b/src/math_special.cpp index 5ec0fc3f61..243d5a05f3 100644 --- a/src/math_special.cpp +++ b/src/math_special.cpp @@ -1,9 +1,203 @@ #include "math_special.h" + #include #include // IWYU pragma: keep +#include + +#include "error.h" using namespace LAMMPS_NS; +static constexpr int nmaxfactorial = 167; + +/* ---------------------------------------------------------------------- + factorial n table, size nmaxfactorial+1 +------------------------------------------------------------------------- */ + +static const double nfac_table[] = { + 1, + 1, + 2, + 6, + 24, + 120, + 720, + 5040, + 40320, + 362880, + 3628800, + 39916800, + 479001600, + 6227020800, + 87178291200, + 1307674368000, + 20922789888000, + 355687428096000, + 6.402373705728e+15, + 1.21645100408832e+17, + 2.43290200817664e+18, + 5.10909421717094e+19, + 1.12400072777761e+21, + 2.5852016738885e+22, + 6.20448401733239e+23, + 1.5511210043331e+25, + 4.03291461126606e+26, + 1.08888694504184e+28, + 3.04888344611714e+29, + 8.8417619937397e+30, + 2.65252859812191e+32, + 8.22283865417792e+33, + 2.63130836933694e+35, + 8.68331761881189e+36, + 2.95232799039604e+38, + 1.03331479663861e+40, + 3.71993326789901e+41, + 1.37637530912263e+43, + 5.23022617466601e+44, + 2.03978820811974e+46, + 8.15915283247898e+47, + 3.34525266131638e+49, + 1.40500611775288e+51, + 6.04152630633738e+52, + 2.65827157478845e+54, + 1.1962222086548e+56, + 5.50262215981209e+57, + 2.58623241511168e+59, + 1.24139155925361e+61, + 6.08281864034268e+62, + 3.04140932017134e+64, + 1.55111875328738e+66, + 8.06581751709439e+67, + 4.27488328406003e+69, + 2.30843697339241e+71, + 1.26964033536583e+73, + 7.10998587804863e+74, + 4.05269195048772e+76, + 2.35056133128288e+78, + 1.3868311854569e+80, + 8.32098711274139e+81, + 5.07580213877225e+83, + 3.14699732603879e+85, + 1.98260831540444e+87, + 1.26886932185884e+89, + 8.24765059208247e+90, + 5.44344939077443e+92, + 3.64711109181887e+94, + 2.48003554243683e+96, + 1.71122452428141e+98, + 1.19785716699699e+100, + 8.50478588567862e+101, + 6.12344583768861e+103, + 4.47011546151268e+105, + 3.30788544151939e+107, + 2.48091408113954e+109, + 1.88549470166605e+111, + 1.45183092028286e+113, + 1.13242811782063e+115, + 8.94618213078297e+116, + 7.15694570462638e+118, + 5.79712602074737e+120, + 4.75364333701284e+122, + 3.94552396972066e+124, + 3.31424013456535e+126, + 2.81710411438055e+128, + 2.42270953836727e+130, + 2.10775729837953e+132, + 1.85482642257398e+134, + 1.65079551609085e+136, + 1.48571596448176e+138, + 1.3520015276784e+140, + 1.24384140546413e+142, + 1.15677250708164e+144, + 1.08736615665674e+146, + 1.03299784882391e+148, + 9.91677934870949e+149, + 9.61927596824821e+151, + 9.42689044888324e+153, + 9.33262154439441e+155, + 9.33262154439441e+157, + 9.42594775983835e+159, + 9.61446671503512e+161, + 9.90290071648618e+163, + 1.02990167451456e+166, + 1.08139675824029e+168, + 1.14628056373471e+170, + 1.22652020319614e+172, + 1.32464181945183e+174, + 1.44385958320249e+176, + 1.58824554152274e+178, + 1.76295255109024e+180, + 1.97450685722107e+182, + 2.23119274865981e+184, + 2.54355973347219e+186, + 2.92509369349301e+188, + 3.3931086844519e+190, + 3.96993716080872e+192, + 4.68452584975429e+194, + 5.5745857612076e+196, + 6.68950291344912e+198, + 8.09429852527344e+200, + 9.8750442008336e+202, + 1.21463043670253e+205, + 1.50614174151114e+207, + 1.88267717688893e+209, + 2.37217324288005e+211, + 3.01266001845766e+213, + 3.8562048236258e+215, + 4.97450422247729e+217, + 6.46685548922047e+219, + 8.47158069087882e+221, + 1.118248651196e+224, + 1.48727070609069e+226, + 1.99294274616152e+228, + 2.69047270731805e+230, + 3.65904288195255e+232, + 5.01288874827499e+234, + 6.91778647261949e+236, + 9.61572319694109e+238, + 1.34620124757175e+241, + 1.89814375907617e+243, + 2.69536413788816e+245, + 3.85437071718007e+247, + 5.5502938327393e+249, + 8.04792605747199e+251, + 1.17499720439091e+254, + 1.72724589045464e+256, + 2.55632391787286e+258, + 3.80892263763057e+260, + 5.71338395644585e+262, + 8.62720977423323e+264, + 1.31133588568345e+267, + 2.00634390509568e+269, + 3.08976961384735e+271, + 4.78914290146339e+273, + 7.47106292628289e+275, + 1.17295687942641e+278, + 1.85327186949373e+280, + 2.94670227249504e+282, + 4.71472363599206e+284, + 7.59070505394721e+286, + 1.22969421873945e+289, + 2.0044015765453e+291, + 3.28721858553429e+293, + 5.42391066613159e+295, + 9.00369170577843e+297, + 1.503616514865e+300, // nmaxfactorial = 167 +}; + +/* ---------------------------------------------------------------------- + factorial n vial lookup from precomputed table +------------------------------------------------------------------------- */ + +double MathSpecial::factorial(const int n) +{ + if (n < 0 || n > nmaxfactorial) + return std::numeric_limits::quiet_NaN(); + + return nfac_table[n]; +} + + /* Library libcerf: * Compute complex error functions, based on a new implementation of * Faddeeva's w_of_z. Also provide Dawson and Voigt functions. diff --git a/src/math_special.h b/src/math_special.h index 1e7b10d9fd..59517a2f76 100644 --- a/src/math_special.h +++ b/src/math_special.h @@ -20,6 +20,10 @@ namespace LAMMPS_NS { namespace MathSpecial { + // tabulated factorial function + + extern double factorial(const int); + // support function for scaled error function complement extern double erfcx_y100(const double y100); diff --git a/src/neighbor.h b/src/neighbor.h index ad3de851cf..b8e1189b35 100644 --- a/src/neighbor.h +++ b/src/neighbor.h @@ -243,51 +243,57 @@ class Neighbor : protected Pointers { }; namespace NeighConst { - static const int NB_INTEL = 1<<0; - static const int NB_KOKKOS_DEVICE = 1<<1; - static const int NB_KOKKOS_HOST = 1<<2; - static const int NB_SSA = 1<<3; - static const int NB_MULTI = 1<<4; - static const int NB_STANDARD = 1<<5; + enum { + NB_INTEL = 1<<0, + NB_KOKKOS_DEVICE = 1<<1, + NB_KOKKOS_HOST = 1<<2, + NB_SSA = 1<<3, + NB_STANDARD = 1<<4, + NB_MULTI = 1<<5 + }; - static const int NS_BIN = 1<<0; - static const int NS_MULTI = 1<<1; - static const int NS_HALF = 1<<2; - static const int NS_FULL = 1<<3; - static const int NS_2D = 1<<4; - static const int NS_3D = 1<<5; - static const int NS_ORTHO = 1<<6; - static const int NS_TRI = 1<<7; - static const int NS_GHOST = 1<<8; - static const int NS_SSA = 1<<9; - static const int NS_MULTI_OLD = 1<<10; + enum { + NS_BIN = 1<<0, + NS_MULTI = 1<<1, + NS_HALF = 1<<2, + NS_FULL = 1<<3, + NS_2D = 1<<4, + NS_3D = 1<<5, + NS_ORTHO = 1<<6, + NS_TRI = 1<<7, + NS_GHOST = 1<<8, + NS_SSA = 1<<9, + NS_MULTI_OLD = 1<<10 + }; - static const int NP_NSQ = 1<<0; - static const int NP_BIN = 1<<1; - static const int NP_MULTI = 1<<2; - static const int NP_HALF = 1<<3; - static const int NP_FULL = 1<<4; - static const int NP_ORTHO = 1<<5; - static const int NP_TRI = 1<<6; - static const int NP_ATOMONLY = 1<<7; - static const int NP_MOLONLY = 1<<8; - static const int NP_NEWTON = 1<<9; - static const int NP_NEWTOFF = 1<<10; - static const int NP_GHOST = 1<<11; - static const int NP_SIZE = 1<<12; - static const int NP_ONESIDE = 1<<13; - static const int NP_RESPA = 1<<14; - static const int NP_BOND = 1<<15; - static const int NP_OMP = 1<<16; - static const int NP_INTEL = 1<<17; - static const int NP_KOKKOS_DEVICE = 1<<18; - static const int NP_KOKKOS_HOST = 1<<19; - static const int NP_SSA = 1<<20; - static const int NP_COPY = 1<<21; - static const int NP_SKIP = 1<<22; - static const int NP_HALF_FULL = 1<<23; - static const int NP_OFF2ON = 1<<24; - static const int NP_MULTI_OLD = 1<<25; + enum { + NP_NSQ = 1<<0, + NP_BIN = 1<<1, + NP_MULTI = 1<<2, + NP_HALF = 1<<3, + NP_FULL = 1<<4, + NP_ORTHO = 1<<5, + NP_TRI = 1<<6, + NP_ATOMONLY = 1<<7, + NP_MOLONLY = 1<<8, + NP_NEWTON = 1<<9, + NP_NEWTOFF = 1<<10, + NP_GHOST = 1<<11, + NP_SIZE = 1<<12, + NP_ONESIDE = 1<<13, + NP_RESPA = 1<<14, + NP_BOND = 1<<15, + NP_OMP = 1<<16, + NP_INTEL = 1<<17, + NP_KOKKOS_DEVICE = 1<<18, + NP_KOKKOS_HOST = 1<<19, + NP_SSA = 1<<20, + NP_COPY = 1<<21, + NP_SKIP = 1<<22, + NP_HALF_FULL = 1<<23, + NP_OFF2ON = 1<<24, + NP_MULTI_OLD = 1<<25 + }; } } diff --git a/src/pair_coul_streitz.h b/src/pair_coul_streitz.h index d5a4a2de5c..2f62846212 100644 --- a/src/pair_coul_streitz.h +++ b/src/pair_coul_streitz.h @@ -36,7 +36,7 @@ class PairCoulStreitz : public Pair { double memory_usage(); virtual void *extract(const char *, int &); - static const int NPARAMS_PER_LINE = 6; + static constexpr int NPARAMS_PER_LINE = 6; protected: struct Param { diff --git a/src/pair_lj_cubic.cpp b/src/pair_lj_cubic.cpp index 7fe4757358..c5f1f5b257 100644 --- a/src/pair_lj_cubic.cpp +++ b/src/pair_lj_cubic.cpp @@ -26,6 +26,7 @@ #include "memory.h" #include "error.h" +#include "pair_lj_cubic_const.h" using namespace LAMMPS_NS; using namespace PairLJCubicConstants; diff --git a/src/pair_lj_cubic.h b/src/pair_lj_cubic.h index d0af06c0a0..4b5edf7e97 100644 --- a/src/pair_lj_cubic.h +++ b/src/pair_lj_cubic.h @@ -46,20 +46,6 @@ class PairLJCubic : public Pair { void allocate(); }; - -namespace PairLJCubicConstants { - - // LJ quantities scaled by epsilon and rmin = sigma*2^1/6 - - static const double RT6TWO = 1.1224621; // 2^1/6 - static const double SS = 1.1086834; // inflection point (13/7)^1/6 - static const double PHIS = -0.7869823; // energy at s - static const double DPHIDS = 2.6899009; // gradient at s - static const double A3 = 27.93357; // cubic coefficient - static const double SM = 1.5475375; // cubic cutoff = s*67/48 - -} - } #endif diff --git a/src/pair_lj_cubic_const.h b/src/pair_lj_cubic_const.h new file mode 100644 index 0000000000..5fc773ac3c --- /dev/null +++ b/src/pair_lj_cubic_const.h @@ -0,0 +1,48 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifndef LMP_PAIR_LJ_CUBIC_CONST_H +#define LMP_PAIR_LJ_CUBIC_CONST_H + +namespace LAMMPS_NS { +namespace PairLJCubicConstants { + + // LJ quantities scaled by epsilon and rmin = sigma*2^1/6 + + static constexpr double RT6TWO = 1.1224620483093730; // 2^1/6 + static constexpr double SS = 1.1086834179687215; // inflection point (13/7)^1/6 + static constexpr double PHIS = -0.7869822485207097; // energy at s + static constexpr double DPHIDS = 2.6899008972047196; // gradient at s + static constexpr double A3 = 27.9335700460986445; // cubic coefficient + static constexpr double SM = 1.5475372709146737; // cubic cutoff = s*67/48} +} +} +#endif + +// python script to compute the constants +// +// sixth = 1.0/6.0 +// rmin = pow(2.0,sixth) +// rs = pow(26.0/7.0,sixth) +// ss = rs/rmin +// pow6 = pow(1.0/rs,6.0) +// phis = 4.0*pow6*(pow6-1.0) +// dpds = -24.0*pow6*(2.0*pow6-1.0)/rs*rmin +// a3 = 8.0*pow(dpds,3)/(9.0*phis*phis) +// sm = 67.0/48.0*ss +// print("static constexpr double RT6TWO = %19.16f; // 2^1/6" % rmin) +// print("static constexpr double SS = %19.16f; // inflection point (13/7)^1/6" % ss) +// print("static constexpr double PHIS = %19.16f; // energy at s" % phis) +// print("static constexpr double DPHIDS = %19.16f; // gradient at s" % dpds) +// print("static constexpr double A3 = %19.16f; // cubic coefficient" % a3) +// print("static constexpr double SM = %19.16f; // cubic cutoff = s*67/48" % sm) diff --git a/src/pair_zbl.cpp b/src/pair_zbl.cpp index 6dff702d2c..80b623ff35 100644 --- a/src/pair_zbl.cpp +++ b/src/pair_zbl.cpp @@ -16,15 +16,18 @@ ------------------------------------------------------------------------- */ #include "pair_zbl.h" + #include + #include "atom.h" #include "comm.h" +#include "error.h" #include "force.h" +#include "memory.h" #include "neighbor.h" #include "neigh_list.h" -#include "memory.h" -#include "error.h" +#include "pair_zbl_const.h" // From J.F. Zeigler, J. P. Biersack and U. Littmark, // "The Stopping and Range of Ions in Matter" volume 1, Pergamon, 1985. diff --git a/src/pair_zbl.h b/src/pair_zbl.h index 55a5dc5fa4..6a16bc7419 100644 --- a/src/pair_zbl.h +++ b/src/pair_zbl.h @@ -54,23 +54,6 @@ class PairZBL : public Pair { double d2zbldr2(double, int, int); void set_coeff(int, int, double, double); }; - -namespace PairZBLConstants { - - // ZBL constants - - static const double pzbl = 0.23; - static const double a0 = 0.46850; - static const double c1 = 0.02817; - static const double c2 = 0.28022; - static const double c3 = 0.50986; - static const double c4 = 0.18175; - static const double d1 = 0.20162; - static const double d2 = 0.40290; - static const double d3 = 0.94229; - static const double d4 = 3.19980; -} - } #endif diff --git a/src/pair_zbl_const.h b/src/pair_zbl_const.h new file mode 100644 index 0000000000..385657693f --- /dev/null +++ b/src/pair_zbl_const.h @@ -0,0 +1,34 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifndef LMP_PAIR_ZBL_CONST_H +#define LMP_PAIR_ZBL_CONST_H + +namespace LAMMPS_NS { +namespace PairZBLConstants { + + // ZBL constants + + static constexpr double pzbl = 0.23; + static constexpr double a0 = 0.46850; + static constexpr double c1 = 0.02817; + static constexpr double c2 = 0.28022; + static constexpr double c3 = 0.50986; + static constexpr double c4 = 0.18175; + static constexpr double d1 = 0.20162; + static constexpr double d2 = 0.40290; + static constexpr double d3 = 0.94229; + static constexpr double d4 = 3.19980; +} +} +#endif diff --git a/src/text_file_reader.h b/src/text_file_reader.h index 0b90304911..0da21e4581 100644 --- a/src/text_file_reader.h +++ b/src/text_file_reader.h @@ -27,7 +27,7 @@ namespace LAMMPS_NS class TextFileReader { std::string filename; std::string filetype; - static const int MAXLINE = 1024; + static constexpr int MAXLINE = 1024; char line[MAXLINE]; FILE *fp; diff --git a/src/version.h b/src/version.h index 379d627653..f812b62821 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define LAMMPS_VERSION "30 Nov 2020" +#define LAMMPS_VERSION "24 Dec 2020" diff --git a/unittest/c-library/test_library_mpi.cpp b/unittest/c-library/test_library_mpi.cpp index cf33ed13b5..7502da767a 100644 --- a/unittest/c-library/test_library_mpi.cpp +++ b/unittest/c-library/test_library_mpi.cpp @@ -173,7 +173,7 @@ TEST(MPI, multi_partition) MPI_Comm_size(MPI_COMM_WORLD, &nprocs); MPI_Comm_rank(MPI_COMM_WORLD, &me); - const char *args[] = {"LAMMPS_test", "-log", "none", "-partition", "2x2", + const char *args[] = {"LAMMPS_test", "-log", "none", "-partition", "4x1", "-echo", "screen", "-nocite", "-in", "none"}; char **argv = (char **)args; int argc = sizeof(args) / sizeof(char *); @@ -183,19 +183,15 @@ TEST(MPI, multi_partition) lammps_command(lmp, "atom_style atomic"); lammps_command(lmp, "region box block 0 2 0 2 0 2"); lammps_command(lmp, "create_box 1 box"); - lammps_command(lmp, "variable partition universe 1 2"); + lammps_command(lmp, "variable partition universe 1 2 3 4"); EXPECT_EQ(lammps_extract_setting(lmp, "universe_size"), nprocs); EXPECT_EQ(lammps_extract_setting(lmp, "universe_rank"), me); - EXPECT_EQ(lammps_extract_setting(lmp, "world_size"), nprocs / 2); - EXPECT_EQ(lammps_extract_setting(lmp, "world_rank"), me % 2); + EXPECT_EQ(lammps_extract_setting(lmp, "world_size"), 1); + EXPECT_EQ(lammps_extract_setting(lmp, "world_rank"), 0); char *part_id = (char *)lammps_extract_variable(lmp, "partition", nullptr); - if (me < 2) { - ASSERT_THAT(part_id, StrEq("1")); - } else { - ASSERT_THAT(part_id, StrEq("2")); - } + ASSERT_THAT(part_id, StrEq(std::to_string(me+1))); lammps_close(lmp); }; diff --git a/unittest/force-styles/tests/fix-timestep-oneway.yaml b/unittest/force-styles/tests/fix-timestep-oneway.yaml index 4fcef41f5b..01131a3803 100644 --- a/unittest/force-styles/tests/fix-timestep-oneway.yaml +++ b/unittest/force-styles/tests/fix-timestep-oneway.yaml @@ -1,7 +1,7 @@ --- lammps_version: 24 Aug 2020 date_generated: Tue Sep 15 09:44:41 202 -epsilon: 2e-14 +epsilon: 4e-14 prerequisites: ! | atom full fix oneway diff --git a/unittest/force-styles/tests/mol-pair-lj_cubic.yaml b/unittest/force-styles/tests/mol-pair-lj_cubic.yaml index ad7f0666ca..6d23998ad5 100644 --- a/unittest/force-styles/tests/mol-pair-lj_cubic.yaml +++ b/unittest/force-styles/tests/mol-pair-lj_cubic.yaml @@ -1,7 +1,7 @@ --- -lammps_version: 24 Aug 2020 -date_generated: Tue Sep 15 09:44:15 202 -epsilon: 2e-13 +lammps_version: 30 Nov 2020 +date_generated: Fri Dec 18 22:30:42 202 +epsilon: 1e-13 prerequisites: ! | atom full pair lj/cubic @@ -19,72 +19,72 @@ pair_coeff: ! | 5 5 0.015 3.1 extract: ! "" natoms: 29 -init_vdwl: 166.005266308562 +init_vdwl: 166.005266338502 init_coul: 0 init_stress: ! |2- - 4.5860676757908186e+02 4.8091912919212928e+02 1.0767204080701006e+03 -2.1005546139122362e+02 -2.9491286717936713e+00 1.6145675857120941e+02 + 4.5860676760613336e+02 4.8091912923656065e+02 1.0767204080957010e+03 -2.1005546139899724e+02 -2.9491286649299440e+00 1.6145675855773089e+02 init_forces: ! |2 - 1 9.1849370411551270e+00 7.6268937957720553e+01 6.1726872441625311e+01 - 2 2.2858712118514426e+01 1.8809274242266209e+01 -2.6905829837199740e+01 - 3 -3.2016987482543328e+01 -9.4135849525427091e+01 -3.4799279593035926e+01 - 4 -5.5341015869901478e-01 1.5206999898436971e-01 -3.9418368928369890e-01 - 5 -1.8042057425348118e-01 -3.0459951056385326e-01 8.7068483241007189e-01 - 6 -2.0038994438822397e+02 2.3344446299945159e+02 2.8487343926572851e+02 - 7 8.0909912172413883e+00 -7.8410849891085633e+01 -4.3214084684451740e+02 - 8 4.7943581255133857e+01 -2.1287511456246008e+01 1.4094503445180061e+02 - 9 1.1447552368270737e+01 1.2328709806786962e+01 5.0656476982000299e+01 - 10 1.3071496571967870e+02 -1.4589264560693914e+02 -4.4748155922123622e+01 - 11 -1.6551880116149281e-01 -4.1534332040572380e-01 -6.8284765241715795e-01 - 12 1.7721533626133388e+00 6.3456329073685158e-01 -8.2372301448028962e-01 - 13 5.6789360334118277e-01 -2.2634410312439054e-01 -9.7536738055328392e-03 - 14 -2.4337021468262635e-01 4.6659433642728905e-02 -6.1110664501270184e-01 - 15 -2.1936997101927893e-02 5.9238263972968364e-01 2.1493099548264527e-01 - 16 1.1121534968449923e+02 -7.8056927924992834e+01 -2.9249212971206231e+02 - 17 -1.1020604609843586e+02 7.6481296254913858e+01 2.9430701446263464e+02 - 18 -1.6570656719723909e-02 -2.7996966177077785e-02 2.6456326954440619e-02 - 19 7.4243353115058947e-04 6.3524893127716046e-04 1.8675586277048476e-04 - 20 -7.4243353115058947e-04 -6.3524893127716046e-04 -1.8675586277048476e-04 + 1 9.1849370400954342e+00 7.6268937960282486e+01 6.1726872440953251e+01 + 2 2.2858712118557477e+01 1.8809274242339992e+01 -2.6905829837209875e+01 + 3 -3.2016987482586380e+01 -9.4135849525500873e+01 -3.4799279593025787e+01 + 4 -5.5341015917141478e-01 1.5206999930354809e-01 -3.9418368927471259e-01 + 5 -1.8042057490785210e-01 -3.0459951013385317e-01 8.7068483295449139e-01 + 6 -2.0038994438983289e+02 2.3344446299845976e+02 2.8487343926562755e+02 + 7 8.0909912152126484e+00 -7.8410849888970290e+01 -4.3214084684693944e+02 + 8 4.7943581253518161e+01 -2.1287511458762772e+01 1.4094503445043824e+02 + 9 1.1447552368334570e+01 1.2328709806695397e+01 5.0656476981938759e+01 + 10 1.3071496571895125e+02 -1.4589264560750766e+02 -4.4748155921681018e+01 + 11 -1.6551880130741767e-01 -4.1534332035668403e-01 -6.8284765271893910e-01 + 12 1.7721533633976141e+00 6.3456328808910523e-01 -8.2372301296999062e-01 + 13 5.6789360517170440e-01 -2.2634410322310763e-01 -9.7536744156455080e-03 + 14 -2.4337021462140446e-01 4.6659433737428486e-02 -6.1110664517858926e-01 + 15 -2.1936996885396808e-02 5.9238264018028652e-01 2.1493099542010694e-01 + 16 1.1121534968641315e+02 -7.8056927926703892e+01 -2.9249212971001145e+02 + 17 -1.1020604609471918e+02 7.6481296251709367e+01 2.9430701446464468e+02 + 18 -1.6570656172995385e-02 -2.7996961634495443e-02 2.6456324093123054e-02 + 19 7.4243314752471426e-04 6.3524860303507949e-04 1.8675576627109685e-04 + 20 -7.4243314752471426e-04 -6.3524860303507949e-04 -1.8675576627109685e-04 21 -1.1415041486189516e+01 -1.3016363071591645e+01 3.6007276733401099e+01 - 22 -1.7227422089792942e+01 -4.1746638094950628e+00 -2.7029162034499002e+01 - 23 2.8642463575982458e+01 1.7191026881086707e+01 -8.9781146989020968e+00 - 24 5.8150644491939154e+00 -3.3774314134628064e+01 1.7867788752379695e+01 - 25 -2.3666545027773044e+01 3.8106021846559952e+00 -1.9896269873584632e+01 - 26 1.7843812244577855e+01 2.9960339884741117e+01 2.0167430316952100e+00 - 27 8.2825859209946024e+00 -3.6194570066818969e+01 1.4492694351988913e+01 - 28 -2.8773892796642542e+01 1.2366374307374247e+01 -1.9468877181285176e+01 - 29 2.0497044211022661e+01 2.3831279505404666e+01 4.9748677441078746e+00 -run_vdwl: 164.176727313193 + 22 -1.7227422090167991e+01 -4.1746638096674396e+00 -2.7029162034658786e+01 + 23 2.8642463576357507e+01 1.7191026881259084e+01 -8.9781146987423170e+00 + 24 5.8150644495067958e+00 -3.3774314132751599e+01 1.7867788754173183e+01 + 25 -2.3666545028156815e+01 3.8106021844353424e+00 -1.9896269873795571e+01 + 26 1.7843812244961626e+01 2.9960339884961773e+01 2.0167430319061479e+00 + 27 8.2825859198612442e+00 -3.6194570067428131e+01 1.4492694352248694e+01 + 28 -2.8773892797077618e+01 1.2366374307246014e+01 -1.9468877181493664e+01 + 29 2.0497044211457737e+01 2.3831279505532898e+01 4.9748677443163629e+00 +run_vdwl: 164.176727343123 run_coul: 0 run_stress: ! |2- - 4.5696669905868288e+02 4.7904134871830234e+02 1.0582153129928076e+03 -2.0794233475912671e+02 -2.0206236780739086e+00 1.5948889983617320e+02 + 4.5696669908578690e+02 4.7904134876274537e+02 1.0582153130184231e+03 -2.0794233476691440e+02 -2.0206236712071677e+00 1.5948889982266843e+02 run_forces: ! |2 - 1 9.2483453892728740e+00 7.5945844239974676e+01 6.1367289784738311e+01 - 2 2.2732852134554197e+01 1.8737493288759875e+01 -2.6669600068587577e+01 - 3 -3.1964986246503269e+01 -9.3734416340601200e+01 -3.4671255449722295e+01 - 4 -5.5001585694065913e-01 1.5070776418957152e-01 -3.9275226164990551e-01 - 5 -1.7969915375876547e-01 -3.0362292678324765e-01 8.6793365916706400e-01 - 6 -1.9796806590003533e+02 2.2990162655369829e+02 2.7501790745035373e+02 - 7 7.9109888171861886e+00 -7.6524641847864288e+01 -4.2032627555539375e+02 - 8 4.5992175211879918e+01 -1.9873148355500923e+01 1.3922798515578887e+02 - 9 1.1403303962503362e+01 1.2231165268449960e+01 5.0409090529604853e+01 - 10 1.3047784096912977e+02 -1.4556513307073578e+02 -4.4756481385998420e+01 - 11 -1.6346238349194633e-01 -4.0922088697872150e-01 -6.7303941060221573e-01 - 12 1.7689668574627495e+00 6.3166692380469824e-01 -8.3233385524693426e-01 - 13 5.6480104331071312e-01 -2.2395151872256039e-01 -9.5790993973179691e-03 - 14 -2.4030540495346994e-01 4.5179188229734012e-02 -6.0304369153488313e-01 - 15 -2.3220111317111478e-02 5.9408611078423390e-01 2.1676726911830960e-01 - 16 1.0963039832302356e+02 -7.7096357855469549e+01 -2.8842624961188653e+02 - 17 -1.0862142117090467e+02 7.5521002117836630e+01 2.9024023117219969e+02 - 18 -1.6565212275867415e-02 -2.7990268691876326e-02 2.6458602067006932e-02 - 19 7.1473709241289744e-04 6.1248437925700357e-04 1.7889258733572757e-04 - 20 -7.1473709241289744e-04 -6.1248437925700357e-04 -1.7889258733572757e-04 - 21 -1.1536904971247665e+01 -1.3021625993962397e+01 3.6108894191673429e+01 - 22 -1.7333879764643559e+01 -4.2314763344327275e+00 -2.7103019136756011e+01 - 23 2.8870784735891224e+01 1.7253102328395126e+01 -9.0058750549174214e+00 - 24 6.1437425316795213e+00 -3.4297207023632204e+01 1.8296742414004438e+01 - 25 -2.4276461284621075e+01 3.8560435260643189e+00 -2.0415720860228767e+01 - 26 1.8125049871956215e+01 3.0437790982988908e+01 2.1072387594169975e+00 - 27 8.4078124309265192e+00 -3.6323119973255714e+01 1.4505938075037919e+01 - 28 -2.8937319168272772e+01 1.2421253477627801e+01 -1.9540501416079319e+01 - 29 2.0535244350189391e+01 2.3904950625827414e+01 5.0332497948309163e+00 + 1 9.2483453882111135e+00 7.5945844242532630e+01 6.1367289784064468e+01 + 2 2.2732852134599622e+01 1.8737493288836678e+01 -2.6669600068598680e+01 + 3 -3.1964986246546172e+01 -9.3734416340673434e+01 -3.4671255449709932e+01 + 4 -5.5001585741105219e-01 1.5070776450703974e-01 -3.9275226164162935e-01 + 5 -1.7969915441332354e-01 -3.0362292635308630e-01 8.6793365971015668e-01 + 6 -1.9796806590165264e+02 2.2990162655270728e+02 2.7501790745023669e+02 + 7 7.9109888151537930e+00 -7.6524641845739424e+01 -4.2032627555780203e+02 + 8 4.5992175210254615e+01 -1.9873148358014198e+01 1.3922798515443196e+02 + 9 1.1403303962567387e+01 1.2231165268357689e+01 5.0409090529541324e+01 + 10 1.3047784096840681e+02 -1.4556513307130629e+02 -4.4756481385556341e+01 + 11 -1.6346238363922402e-01 -4.0922088693014880e-01 -6.7303941090576869e-01 + 12 1.7689668582530251e+00 6.3166692115802814e-01 -8.3233385373913271e-01 + 13 5.6480104514758445e-01 -2.2395151881989347e-01 -9.5791000096411370e-03 + 14 -2.4030540489083232e-01 4.5179188324553629e-02 -6.0304369170302041e-01 + 15 -2.3220111102749796e-02 5.9408611123108124e-01 2.1676726905655996e-01 + 16 1.0963039832494319e+02 -7.7096357857185083e+01 -2.8842624960984045e+02 + 17 -1.0862142116718823e+02 7.5521002114629724e+01 2.9024023117422536e+02 + 18 -1.6565211729771653e-02 -2.7990264151000276e-02 2.6458599205916818e-02 + 19 7.1473670261989000e-04 6.1248404522910675e-04 1.7889248977386897e-04 + 20 -7.1473670261989000e-04 -6.1248404522910675e-04 -1.7889248977386897e-04 + 21 -1.1536904971247079e+01 -1.3021625993961788e+01 3.6108894191671638e+01 + 22 -1.7333879765020438e+01 -4.2314763346057394e+00 -2.7103019136915339e+01 + 23 2.8870784736267517e+01 1.7253102328567529e+01 -9.0058750547563005e+00 + 24 6.1437425319896413e+00 -3.4297207021755547e+01 1.8296742415795482e+01 + 25 -2.4276461285000558e+01 3.8560435258438814e+00 -2.0415720860437396e+01 + 26 1.8125049872338021e+01 3.0437790983209180e+01 2.1072387596271578e+00 + 27 8.4078124297937791e+00 -3.6323119973862774e+01 1.4505938075297303e+01 + 28 -2.8937319168706676e+01 1.2421253477499173e+01 -1.9540501416287395e+01 + 29 2.0535244350622666e+01 2.3904950625953887e+01 5.0332497950390769e+00 ...