diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 263b5a566d..7f99b04cd6 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -800,9 +800,12 @@ if(BUILD_MPI) endif() if(PKG_GPU) message(STATUS "<<< GPU package settings >>> --- GPU API: ${GPU_API}") +-- GPU API: ${GPU_API}") if(GPU_API STREQUAL "CUDA") + message(STATUS "CUDA Compiler: ${CUDA_NVCC_EXECUTABLE}") message(STATUS "GPU default architecture: ${GPU_ARCH}") + message(STATUS "GPU binning with CUDPP: ${CUDPP_OPT}") + message(STATUS "CUDA MPS support: ${CUDA_MPS_SUPPORT}") elseif(GPU_API STREQUAL "HIP") message(STATUS "HIP platform: ${HIP_PLATFORM}") message(STATUS "HIP architecture: ${HIP_ARCH}") @@ -812,7 +815,7 @@ if(PKG_GPU) message(STATUS "HIP GPU sorting: off") endif() endif() - message(STATUS "GPU precision: ${GPU_PREC}") + message(STATUS "GPU precision: ${GPU_PREC}") endif() if(PKG_KOKKOS) message(STATUS "Kokkos Arch: ${KOKKOS_ARCH}") diff --git a/doc/src/balance.rst b/doc/src/balance.rst index 07ea82eeba..5d42fabb21 100644 --- a/doc/src/balance.rst +++ b/doc/src/balance.rst @@ -257,7 +257,7 @@ factor, similar to how the :doc:`fix balance shift ` command operates. The *dimstr* argument is a string of characters, each of which must be -an "x" or "y" or "z". Eacn character can appear zero or one time, +an "x" or "y" or "z". Each character can appear zero or one time, since there is no advantage to balancing on a dimension more than once. You should normally only list dimensions where you expect there to be a density variation in the particles. @@ -285,7 +285,7 @@ plane gets closer to the target value. After the balanced plane positions are determined, if any pair of adjacent planes are closer together than the neighbor skin distance -(as specified by the :doc`neigh_modify ` command), then +(as specified by the :doc:`neigh_modify ` command), then the plane positions are shifted to separate them by at least this amount. This is to prevent particles being lost when dynamics are run with processor sub-domains that are too narrow in one or more diff --git a/doc/src/fix_balance.rst b/doc/src/fix_balance.rst index 1875ab744f..8bab8ebefc 100644 --- a/doc/src/fix_balance.rst +++ b/doc/src/fix_balance.rst @@ -216,7 +216,7 @@ above. It changes the positions of cutting planes between processors in an iterative fashion, seeking to reduce the imbalance factor. The *dimstr* argument is a string of characters, each of which must be -an "x" or "y" or "z". Eacn character can appear zero or one time, +an "x" or "y" or "z". Each character can appear zero or one time, since there is no advantage to balancing on a dimension more than once. You should normally only list dimensions where you expect there to be a density variation in the particles. diff --git a/doc/src/fix_precession_spin.rst b/doc/src/fix_precession_spin.rst index 5e818374a0..183753db5f 100644 --- a/doc/src/fix_precession_spin.rst +++ b/doc/src/fix_precession_spin.rst @@ -12,7 +12,7 @@ Syntax * ID, group are documented in :doc:`fix ` command * precession/spin = style name of this fix command -* style = *zeeman* or *anisotropy* or *cubic* +* style = *zeeman* or *anisotropy* or *cubic* or *stt* .. parsed-literal:: @@ -22,12 +22,12 @@ Syntax *anisotropy* args = K x y z K = intensity of the magnetic anisotropy (in eV) x y z = vector direction of the anisotropy - - .. parsed-literal:: - *cubic* args = K1 K2c n1x n1y n1x n2x n2y n2z n3x n3y n3z K1 and K2c = intensity of the magnetic anisotropy (in eV) n1x to n3z = three direction vectors of the cubic anisotropy + *stt* args = J x y z + J = intensity of the spin-transfer torque field + x y z = vector direction of the field Examples """""""" @@ -125,6 +125,11 @@ axis along the :math:`(1 1 1)`-type cube diagonals). :math:`K_2^c > diagonals. See chapter 2 of :ref:`(Skomski) ` for more details on cubic anisotropies. +Style *stt* is used to simulate the interaction between the spins and +a spin-transfer torque. +See equation (7) of :ref:`(Chirac) ` for more details about the +implemented spin-transfer torque term. + In all cases, the choice of :math:`(x y z)` only imposes the vector directions for the forces. Only the direction of the vector is important; its length is ignored (the entered vectors are @@ -132,6 +137,16 @@ normalized). Those styles can be combined within one single command line. +.. note:: + + The norm of all vectors defined with the precession/spin command + have to be non-zero. For example, defining + "fix 1 all precession/spin zeeman 0.1 0.0 0.0 0.0" would result + in an error message. + Since those vector components are used to compute the inverse of the + field (or anisotropy) vector norm, setting a zero-vector would result + in a division by zero. + ---------- Restart, fix_modify, output, run start/stop, minimize info @@ -162,11 +177,6 @@ is only enabled if LAMMPS was built with this package, and if the atom_style "spin" was declared. See the :doc:`Build package ` doc page for more info. -The *precession/spin* style can only be declared once. If more than -one precession type (for example combining an anisotropy and a Zeeman -interactions) has to be declared, they have to be chained in the same -command line (as shown in the examples above). - Related commands """""""""""""""" @@ -184,3 +194,9 @@ none **(Skomski)** Skomski, R. (2008). Simple models of magnetism. Oxford University Press. + +.. _Chirac1: + +**(Chirac)** Chirac, Théophile, et al. Ultrafast antiferromagnetic +switching in NiO induced by spin transfer torques. +Physical Review B 102.13 (2020): 134415. diff --git a/doc/src/pair_hybrid.rst b/doc/src/pair_hybrid.rst index e4e253caf9..868d645b83 100644 --- a/doc/src/pair_hybrid.rst +++ b/doc/src/pair_hybrid.rst @@ -452,6 +452,9 @@ the same or else LAMMPS will generate an error. Pair style *hybrid/scaled* currently only works for non-accelerated pair styles and pair styles from the OPT package. +When using pair styles from the GPU package they must not be listed +multiple times. LAMMPS will detect this and abort. + Related commands """""""""""""""" diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index 54cb6d2f3c..da0617ce91 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -764,7 +764,6 @@ Dyre Dzyaloshinskii Eaa Eaat -Eacn eam eangle earg diff --git a/examples/SPIN/test_problems/README b/examples/SPIN/test_problems/README index 0a1362ec9c..17e0935a35 100644 --- a/examples/SPIN/test_problems/README +++ b/examples/SPIN/test_problems/README @@ -45,3 +45,14 @@ directory. results (computed by the python script). Note: This example is a reworked version of a test problem provided by Martin Kroger (ETHZ). + +- validation_nve: + simulates a small assembly of magnetic atoms (54). The atoms are + coupled by an exchange interaction and a mechanical potential + (EAM here). + This example represents an NVE run: the total energy of the + system is preserved, whereas the spin and lattice energy + reservoirs are exchanging energy. + Run as: ./run-test-nve.sh + Output: res_lammps.dat contains the data. The results are displayed + by nve_spin_lattice.pdf. diff --git a/examples/SPIN/test_problems/run_all.sh b/examples/SPIN/test_problems/run_all.sh new file mode 100755 index 0000000000..fb682e3ef5 --- /dev/null +++ b/examples/SPIN/test_problems/run_all.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# test 1: damping and exchange +cd validation_damped_exchange/ +./run-test-exchange.sh +rm dump.data res_lammps.dat res_llg.dat +cd .. + +# test 2: damping and Zeeman +cd validation_damped_precession/ +./run-test-prec.sh +rm res_lammps.dat res_llg.dat +cd .. + +# test 3: langevin, damping and Zeeman +cd validation_langevin_precession/ +./run-test-prec.sh +rm average_spin test-prec-spin.in res_lammps.dat res_langevin.dat +cd .. + +# test 4: NVE run, test Etot preservation +cd validation_nve/ +./run-test-nve.sh +rm nve_spin_lattice.pdf res_lammps.dat +cd .. diff --git a/examples/SPIN/test_problems/validation_nvt/in.spin.nvt_lattice b/examples/SPIN/test_problems/validation_nvt/in.spin.nvt_lattice index cc7bcfa68d..a1f739fe54 100644 --- a/examples/SPIN/test_problems/validation_nvt/in.spin.nvt_lattice +++ b/examples/SPIN/test_problems/validation_nvt/in.spin.nvt_lattice @@ -31,8 +31,8 @@ neighbor 0.1 bin neigh_modify every 10 check yes delay 20 fix 1 all precession/spin zeeman 0.0 0.0 0.0 1.0 -fix 2 all langevin 200.0 200.0 1.0 48279 -fix 3 all langevin/spin 0.0 0.00001 321 +fix 2 all langevin 200.0 200.0 0.1 48279 +fix 3 all langevin/spin 0.0 0.0 321 fix 4 all nve/spin lattice moving timestep 0.001 diff --git a/examples/SPIN/test_problems/validation_nvt/in.spin.nvt_spin b/examples/SPIN/test_problems/validation_nvt/in.spin.nvt_spin index 7e8152f481..102f76a2a6 100644 --- a/examples/SPIN/test_problems/validation_nvt/in.spin.nvt_spin +++ b/examples/SPIN/test_problems/validation_nvt/in.spin.nvt_spin @@ -22,16 +22,19 @@ mass 1 55.845 set group all spin 2.2 0.0 0.0 1.0 velocity all create 0 4928459 rot yes dist gaussian -pair_style hybrid/overlay eam/alloy spin/exchange 3.5 +# pair_style hybrid/overlay eam/alloy spin/exchange 3.5 +pair_style hybrid/overlay eam/alloy spin/exchange 4.0 spin/neel 4.0 pair_coeff * * eam/alloy Fe_Mishin2006.eam.alloy Fe pair_coeff * * spin/exchange exchange 3.4 0.1 0.2171 1.841 +pair_coeff * * spin/neel neel 4.0 0.02 0.0 1.841 0.0 0.0 1.0 neighbor 0.1 bin neigh_modify every 10 check yes delay 20 fix 1 all precession/spin zeeman 0.0 0.0 0.0 1.0 -fix 2 all langevin/spin 200.0 0.01 321 -fix 3 all nve/spin lattice moving +fix 2 all langevin 0.0 0.0 0.0 48279 +fix 3 all langevin/spin 200.0 0.01 321 +fix 4 all nve/spin lattice moving timestep 0.001 # compute and output options diff --git a/lib/gpu/lal_charmm.cpp b/lib/gpu/lal_charmm.cpp index 811a431cc7..a78043af40 100644 --- a/lib/gpu/lal_charmm.cpp +++ b/lib/gpu/lal_charmm.cpp @@ -150,7 +150,7 @@ int CHARMMT::loop(const int eflag, const int vflag) { &_cut_coul_innersq, &this->_threads_per_atom); } else { this->k_pair.set_size(GX,BX); - this->k_pair.run(&this->atom->x, &ljd, &sp_lj, + this->k_pair.run(&this->atom->x, &lj1, &_lj_types, &sp_lj, &this->nbor->dev_nbor, this->_nbor_data, &this->ans->force, &this->ans->engv, &eflag, &vflag, &ainum, &nbor_pitch, &this->atom->q, diff --git a/lib/gpu/lal_charmm.cu b/lib/gpu/lal_charmm.cu index 304dc34e8b..589d9adc91 100644 --- a/lib/gpu/lal_charmm.cu +++ b/lib/gpu/lal_charmm.cu @@ -29,7 +29,8 @@ _texture(q_tex, int2); #endif __kernel void k_charmm(const __global numtyp4 *restrict x_, - const __global numtyp2 *restrict ljd, + const __global numtyp4 *restrict lj1, + const int lj_types, const __global numtyp *restrict sp_lj, const __global int *dev_nbor, const __global int *dev_packed, @@ -88,20 +89,14 @@ __kernel void k_charmm(const __global numtyp4 *restrict x_, numtyp delz = ix.z-jx.z; numtyp rsq = delx*delx+dely*dely+delz*delz; + int mtype=itype*lj_types+jtype; if (rsq cut_lj_innersq) { switch1 = (cut_ljsq-rsq); numtyp switch2 = (numtyp)12.0*rsq*switch1*(rsq-cut_lj_innersq)* @@ -109,7 +104,7 @@ __kernel void k_charmm(const __global numtyp4 *restrict x_, switch1 *= switch1; switch1 *= (cut_ljsq+(numtyp)2.0*rsq-(numtyp)3.0*cut_lj_innersq)* denom_lj; - switch2 *= lj3-lj4; + switch2 *= r6inv*(lj1[mtype].z*r6inv-lj1[mtype].w); force_lj = force_lj*switch1+switch2; } } else @@ -137,7 +132,7 @@ __kernel void k_charmm(const __global numtyp4 *restrict x_, if (EVFLAG && eflag) { e_coul += forcecoul; if (rsq < cut_ljsq) { - numtyp e=lj3-lj4; + numtyp e=r6inv*(lj1[mtype].z*r6inv-lj1[mtype].w); if (rsq > cut_lj_innersq) e *= switch1; energy+=factor_lj*e; diff --git a/lib/gpu/lal_tersoff.cpp b/lib/gpu/lal_tersoff.cpp index e0e87d9148..ac5e5bc600 100644 --- a/lib/gpu/lal_tersoff.cpp +++ b/lib/gpu/lal_tersoff.cpp @@ -108,10 +108,7 @@ int TersoffT::init(const int ntypes, const int nlocal, const int nall, const int _nparams = nparams; _nelements = nelements; - UCL_H_Vec host_write(ntypes*ntypes,*(this->ucl_device), - UCL_READ_WRITE); - host_write.zero(); - cutsq_pair.alloc(ntypes*ntypes,*(this->ucl_device),UCL_READ_ONLY); + _cutsq_max=0.0; for (int ii=1; iihost_write[ii*ntypes+jj]) - host_write[ii*ntypes+jj]=host_cutsq[ijkparam]; + if (host_cutsq[ijkparam]>_cutsq_max) _cutsq_max=host_cutsq[ijkparam]; } } } - ucl_copy(cutsq_pair,host_write,ntypes*ntypes); // -------------------------------------------------------------------- UCL_H_Vec dview(nparams,*(this->ucl_device), @@ -235,7 +230,6 @@ void TersoffT::clear() { ts3.clear(); ts4.clear(); ts5.clear(); - cutsq_pair.clear(); map.clear(); elem2param.clear(); _zetaij.clear(); @@ -286,7 +280,7 @@ int TersoffT::loop(const int eflag, const int vflag, const int evatom, int BX=this->block_pair(); int GX=static_cast(ceil(static_cast(ainum)/BX)); this->k_short_nbor.set_size(GX,BX); - this->k_short_nbor.run(&this->atom->x, &cutsq_pair, &_ntypes, + this->k_short_nbor.run(&this->atom->x, &_cutsq_max, &_ntypes, &this->nbor->dev_nbor, &this->nbor->dev_packed, &ainum, &nbor_pitch, &this->_threads_per_atom); diff --git a/lib/gpu/lal_tersoff.cu b/lib/gpu/lal_tersoff.cu index 03ce68be77..8baa5ce12a 100644 --- a/lib/gpu/lal_tersoff.cu +++ b/lib/gpu/lal_tersoff.cu @@ -226,17 +226,13 @@ _texture_2d( pos_tex,int4); #endif __kernel void k_tersoff_short_nbor(const __global numtyp4 *restrict x_, - const __global numtyp *restrict cutsq_pair, - const int ntypes, __global int * dev_nbor, + const numtyp cutsq, const int ntypes, + __global int * dev_nbor, const __global int * dev_packed, const int inum, const int nbor_pitch, const int t_per_atom_in) { const int ii=GLOBAL_ID_X; - #ifdef ONETYPE - const numtyp cutsq=cutsq_pair[ONETYPE]; - #endif - if (ii { /// ts5.x = beta, ts5.y = powern, ts5.z = lam2, ts5.w = bigb UCL_D_Vec ts5; - UCL_D_Vec cutsq_pair; + numtyp _cutsq_max; UCL_D_Vec elem2param; UCL_D_Vec map; diff --git a/lib/gpu/lal_tersoff_extra.h b/lib/gpu/lal_tersoff_extra.h index da2568aa1b..9fe2c63176 100644 --- a/lib/gpu/lal_tersoff_extra.h +++ b/lib/gpu/lal_tersoff_extra.h @@ -142,7 +142,10 @@ ucl_inline numtyp ters_fa_d(const numtyp r, numtyp *ans_d) { #ifndef ONETYPE - if (r > param_bigr + param_bigd) return (numtyp)0.0; + if (r > param_bigr + param_bigd) { + *ans_d = (numtyp)0.0; + return (numtyp)0.0; + } #endif numtyp dfc; const numtyp fc=ters_fc_d(r,param_bigr,param_bigd,&dfc); diff --git a/lib/gpu/lal_tersoff_mod.cpp b/lib/gpu/lal_tersoff_mod.cpp index b7b0fff1b9..347feab06f 100644 --- a/lib/gpu/lal_tersoff_mod.cpp +++ b/lib/gpu/lal_tersoff_mod.cpp @@ -105,10 +105,7 @@ int TersoffMT::init(const int ntypes, const int nlocal, const int nall, const in _nparams = nparams; _nelements = nelements; - UCL_H_Vec host_write(ntypes*ntypes,*(this->ucl_device), - UCL_READ_WRITE); - host_write.zero(); - cutsq_pair.alloc(ntypes*ntypes,*(this->ucl_device),UCL_READ_ONLY); + _cutsq_max=0.0; for (int ii=1; iihost_write[ii*ntypes+jj]) - host_write[ii*ntypes+jj]=host_cutsq[ijkparam]; + if (host_cutsq[ijkparam]>_cutsq_max) _cutsq_max=host_cutsq[ijkparam]; } } } - ucl_copy(cutsq_pair,host_write,ntypes*ntypes); UCL_H_Vec dview(nparams,*(this->ucl_device), UCL_WRITE_ONLY); @@ -229,7 +224,6 @@ void TersoffMT::clear() { ts3.clear(); ts4.clear(); ts5.clear(); - cutsq_pair.clear(); map.clear(); elem2param.clear(); _zetaij.clear(); @@ -275,7 +269,7 @@ int TersoffMT::loop(const int eflag, const int vflag, const int evatom, int BX=this->block_pair(); int GX=static_cast(ceil(static_cast(ainum)/BX)); this->k_short_nbor.set_size(GX,BX); - this->k_short_nbor.run(&this->atom->x, &cutsq_pair, &_ntypes, + this->k_short_nbor.run(&this->atom->x, &_cutsq_max, &_ntypes, &this->nbor->dev_nbor, &this->nbor->dev_packed, &ainum, &nbor_pitch, &this->_threads_per_atom); diff --git a/lib/gpu/lal_tersoff_mod.cu b/lib/gpu/lal_tersoff_mod.cu index 44b04c6933..1eb57683d5 100644 --- a/lib/gpu/lal_tersoff_mod.cu +++ b/lib/gpu/lal_tersoff_mod.cu @@ -220,17 +220,13 @@ _texture_2d( pos_tex,int4); #endif __kernel void k_tersoff_mod_short_nbor(const __global numtyp4 *restrict x_, - const __global numtyp *restrict cutsq_pair, - const int ntypes, __global int * dev_nbor, - const __global int * dev_packed, - const int inum, const int nbor_pitch, - const int t_per_atom) { + const numtyp cutsq, const int ntypes, + __global int * dev_nbor, + const __global int * dev_packed, + const int inum, const int nbor_pitch, + const int t_per_atom) { const int ii=GLOBAL_ID_X; - #ifdef ONETYPE - const numtyp cutsq=cutsq_pair[ONETYPE]; - #endif - if (ii { /// ts5.x = c5, ts5.y = h UCL_D_Vec ts5; - UCL_D_Vec cutsq_pair; + numtyp _cutsq_max; UCL_D_Vec elem2param; UCL_D_Vec map; diff --git a/lib/gpu/lal_tersoff_zbl.cpp b/lib/gpu/lal_tersoff_zbl.cpp index 4456712b0a..4fba97606c 100644 --- a/lib/gpu/lal_tersoff_zbl.cpp +++ b/lib/gpu/lal_tersoff_zbl.cpp @@ -112,10 +112,7 @@ int TersoffZT::init(const int ntypes, const int nlocal, const int nall, _nparams = nparams; _nelements = nelements; - UCL_H_Vec host_write(ntypes*ntypes,*(this->ucl_device), - UCL_READ_WRITE); - host_write.zero(); - cutsq_pair.alloc(ntypes*ntypes,*(this->ucl_device),UCL_READ_ONLY); + _cutsq_max=0.0; for (int ii=1; iihost_write[ii*ntypes+jj]) - host_write[ii*ntypes+jj]=host_cutsq[ijkparam]; + if (host_cutsq[ijkparam]>_cutsq_max) _cutsq_max=host_cutsq[ijkparam]; } } } - ucl_copy(cutsq_pair,host_write,ntypes*ntypes); UCL_H_Vec dview(nparams,*(this->ucl_device), UCL_WRITE_ONLY); @@ -253,7 +248,6 @@ void TersoffZT::clear() { ts4.clear(); ts5.clear(); ts6.clear(); - cutsq_pair.clear(); map.clear(); elem2param.clear(); _zetaij.clear(); @@ -299,7 +293,7 @@ int TersoffZT::loop(const int eflag, const int vflag, const int evatom, int BX=this->block_pair(); int GX=static_cast(ceil(static_cast(ainum)/BX)); this->k_short_nbor.set_size(GX,BX); - this->k_short_nbor.run(&this->atom->x, &cutsq_pair, &_ntypes, + this->k_short_nbor.run(&this->atom->x, &_cutsq_max, &_ntypes, &this->nbor->dev_nbor, &this->nbor->dev_packed, &ainum, &nbor_pitch, &this->_threads_per_atom); diff --git a/lib/gpu/lal_tersoff_zbl.cu b/lib/gpu/lal_tersoff_zbl.cu index fce1ccc406..6250fa55de 100644 --- a/lib/gpu/lal_tersoff_zbl.cu +++ b/lib/gpu/lal_tersoff_zbl.cu @@ -238,17 +238,13 @@ _texture( ts6_tex,int4); #endif __kernel void k_tersoff_zbl_short_nbor(const __global numtyp4 *restrict x_, - const __global numtyp *restrict cutsq_pair, - const int ntypes, __global int * dev_nbor, - const __global int * dev_packed, - const int inum, const int nbor_pitch, - const int t_per_atom) { + const numtyp cutsq, const int ntypes, + __global int * dev_nbor, + const __global int * dev_packed, + const int inum, const int nbor_pitch, + const int t_per_atom) { const int ii=GLOBAL_ID_X; - #ifdef ONETYPE - const numtyp cutsq=cutsq_pair[ONETYPE]; - #endif - if (ii { /// ts6.x = Z_i, ts6.y = Z_j, ts6.z = ZBLcut, ts6.w = ZBLexpscale UCL_D_Vec ts6; - UCL_D_Vec cutsq_pair; + numtyp _cutsq_max; UCL_D_Vec elem2param; UCL_D_Vec map; diff --git a/src/KOKKOS/kokkos_type.h b/src/KOKKOS/kokkos_type.h index af5adeee73..8eb9744a94 100644 --- a/src/KOKKOS/kokkos_type.h +++ b/src/KOKKOS/kokkos_type.h @@ -1038,6 +1038,11 @@ typedef tdual_virial_array::t_host_const_randomread t_virial_array_randomread; // Spin types //2d X_FLOAT array n*4 +#ifdef LMP_KOKKOS_NO_LEGACY +typedef Kokkos::DualView tdual_float_1d_4; +#else +typedef Kokkos::DualView tdual_float_1d_4; +#endif typedef tdual_float_1d_4::t_host t_sp_array; typedef tdual_float_1d_4::t_host_const t_sp_array_const; typedef tdual_float_1d_4::t_host_um t_sp_array_um; diff --git a/src/KSPACE/fft3d.cpp b/src/KSPACE/fft3d.cpp index 7a271326f7..6a05be4e6f 100644 --- a/src/KSPACE/fft3d.cpp +++ b/src/KSPACE/fft3d.cpp @@ -69,7 +69,6 @@ void fft_3d(FFT_DATA *in, FFT_DATA *out, int flag, struct fft_plan_3d *plan) { - int i,total,length,offset,num; FFT_SCALAR norm; #if defined(FFT_FFTW3) FFT_SCALAR *out_ptr; @@ -99,9 +98,6 @@ void fft_3d(FFT_DATA *in, FFT_DATA *out, int flag, struct fft_plan_3d *plan) // 1d FFTs along fast axis - total = plan->total1; - length = plan->length1; - #if defined(FFT_MKL) if (flag == 1) DftiComputeForward(plan->handle_fast,data); @@ -114,11 +110,14 @@ void fft_3d(FFT_DATA *in, FFT_DATA *out, int flag, struct fft_plan_3d *plan) theplan=plan->plan_fast_backward; FFTW_API(execute_dft)(theplan,data,data); #else + int total = plan->total1; + int length = plan->length1; + if (flag == 1) - for (offset = 0; offset < total; offset += length) + for (int offset = 0; offset < total; offset += length) kiss_fft(plan->cfg_fast_forward,&data[offset],&data[offset]); else - for (offset = 0; offset < total; offset += length) + for (int offset = 0; offset < total; offset += length) kiss_fft(plan->cfg_fast_backward,&data[offset],&data[offset]); #endif @@ -133,9 +132,6 @@ void fft_3d(FFT_DATA *in, FFT_DATA *out, int flag, struct fft_plan_3d *plan) // 1d FFTs along mid axis - total = plan->total2; - length = plan->length2; - #if defined(FFT_MKL) if (flag == 1) DftiComputeForward(plan->handle_mid,data); @@ -148,11 +144,14 @@ void fft_3d(FFT_DATA *in, FFT_DATA *out, int flag, struct fft_plan_3d *plan) theplan=plan->plan_mid_backward; FFTW_API(execute_dft)(theplan,data,data); #else + total = plan->total2; + length = plan->length2; + if (flag == 1) - for (offset = 0; offset < total; offset += length) + for (int offset = 0; offset < total; offset += length) kiss_fft(plan->cfg_mid_forward,&data[offset],&data[offset]); else - for (offset = 0; offset < total; offset += length) + for (int offset = 0; offset < total; offset += length) kiss_fft(plan->cfg_mid_backward,&data[offset],&data[offset]); #endif @@ -167,9 +166,6 @@ void fft_3d(FFT_DATA *in, FFT_DATA *out, int flag, struct fft_plan_3d *plan) // 1d FFTs along slow axis - total = plan->total3; - length = plan->length3; - #if defined(FFT_MKL) if (flag == 1) DftiComputeForward(plan->handle_slow,data); @@ -182,11 +178,14 @@ void fft_3d(FFT_DATA *in, FFT_DATA *out, int flag, struct fft_plan_3d *plan) theplan=plan->plan_slow_backward; FFTW_API(execute_dft)(theplan,data,data); #else + total = plan->total3; + length = plan->length3; + if (flag == 1) - for (offset = 0; offset < total; offset += length) + for (int offset = 0; offset < total; offset += length) kiss_fft(plan->cfg_slow_forward,&data[offset],&data[offset]); else - for (offset = 0; offset < total; offset += length) + for (int offset = 0; offset < total; offset += length) kiss_fft(plan->cfg_slow_backward,&data[offset],&data[offset]); #endif @@ -201,11 +200,11 @@ void fft_3d(FFT_DATA *in, FFT_DATA *out, int flag, struct fft_plan_3d *plan) if (flag == -1 && plan->scaled) { norm = plan->norm; - num = plan->normnum; + const int num = plan->normnum; #if defined(FFT_FFTW3) out_ptr = (FFT_SCALAR *)out; #endif - for (i = 0; i < num; i++) { + for (int i = 0; i < num; i++) { #if defined(FFT_FFTW3) *(out_ptr++) *= norm; *(out_ptr++) *= norm; diff --git a/src/SPIN/fix_langevin_spin.cpp b/src/SPIN/fix_langevin_spin.cpp index c9cb0fa2ec..949833caa7 100644 --- a/src/SPIN/fix_langevin_spin.cpp +++ b/src/SPIN/fix_langevin_spin.cpp @@ -24,9 +24,11 @@ #include "fix_langevin_spin.h" #include #include +#include "atom.h" #include "comm.h" #include "error.h" #include "force.h" +#include "group.h" #include "math_const.h" #include "memory.h" #include "modify.h" @@ -42,7 +44,7 @@ using namespace MathConst; /* ---------------------------------------------------------------------- */ FixLangevinSpin::FixLangevinSpin(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), id_temp(nullptr), random(nullptr) + Fix(lmp, narg, arg), random(nullptr) { if (narg != 6) error->all(FLERR,"Illegal langevin/spin command"); @@ -106,10 +108,8 @@ void FixLangevinSpin::init() double hbar = force->hplanck/MY_2PI; // eV/(rad.THz) double kb = force->boltz; // eV/K - // D = (MY_2PI*alpha_t*gil_factor*kb*temp); D = (alpha_t*gil_factor*kb*temp); - // D = (12.0/MY_2PI)*(MY_2PI*alpha_t*gil_factor*kb*temp); D /= (hbar*dts); sigma = sqrt(2.0*D); } @@ -142,7 +142,7 @@ void FixLangevinSpin::add_tdamping(double spi[3], double fmi[3]) /* ---------------------------------------------------------------------- */ -void FixLangevinSpin::add_temperature(double fmi[3]) +void FixLangevinSpin::add_temperature(int i, double spi[3], double fmi[3]) { // double rx = sigma*(2.0*random->uniform() - 1.0); // double ry = sigma*(2.0*random->uniform() - 1.0); @@ -150,6 +150,7 @@ void FixLangevinSpin::add_temperature(double fmi[3]) double rx = sigma*random->gaussian(); double ry = sigma*random->gaussian(); double rz = sigma*random->gaussian(); + double hbar = force->hplanck/MY_2PI; // adding the random field @@ -163,3 +164,14 @@ void FixLangevinSpin::add_temperature(double fmi[3]) fmi[1] *= gil_factor; fmi[2] *= gil_factor; } + +/* ---------------------------------------------------------------------- */ + +void FixLangevinSpin::compute_single_langevin(int i, double spi[3], double fmi[3]) +{ + int *mask = atom->mask; + if (mask[i] & groupbit) { + if (tdamp_flag) add_tdamping(spi,fmi); + if (temp_flag) add_temperature(i,spi,fmi); + } +} diff --git a/src/SPIN/fix_langevin_spin.h b/src/SPIN/fix_langevin_spin.h index c73b33353b..090e5b666a 100644 --- a/src/SPIN/fix_langevin_spin.h +++ b/src/SPIN/fix_langevin_spin.h @@ -26,7 +26,7 @@ namespace LAMMPS_NS { class FixLangevinSpin : public Fix { public: - int tdamp_flag,ldamp_flag,temp_flag; // damping and temperature flags + int tdamp_flag,temp_flag; // damping and temperature flags FixLangevinSpin(class LAMMPS *, int, char **); virtual ~FixLangevinSpin(); @@ -34,7 +34,8 @@ class FixLangevinSpin : public Fix { void init(); void setup(int); void add_tdamping(double *, double *); // add transverse damping - void add_temperature(double *); // add temperature + void add_temperature(int, double *, double *); + void compute_single_langevin(int, double *, double *); protected: double alpha_t; // transverse mag. damping @@ -43,9 +44,6 @@ class FixLangevinSpin : public Fix { double D,sigma; // bath intensity var. double gil_factor; // gilbert's prefactor - char *id_temp; - class Compute *temperature; - int nlevels_respa; class RanMars *random; int seed; diff --git a/src/SPIN/fix_nve_spin.cpp b/src/SPIN/fix_nve_spin.cpp index eb6d918ab0..5da7c32b6c 100644 --- a/src/SPIN/fix_nve_spin.cpp +++ b/src/SPIN/fix_nve_spin.cpp @@ -60,7 +60,8 @@ enum{NONE}; FixNVESpin::FixNVESpin(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), - pair(nullptr), spin_pairs(nullptr), + pair(nullptr), spin_pairs(nullptr), locklangevinspin(nullptr), + locksetforcespin(nullptr), lockprecessionspin(nullptr), rsec(nullptr), stack_head(nullptr), stack_foot(nullptr), backward_stacks(nullptr), forward_stacks(nullptr) { @@ -74,6 +75,9 @@ FixNVESpin::FixNVESpin(LAMMPS *lmp, int narg, char **arg) : nlocal_max = 0; npairs = 0; npairspin = 0; + + // test nprec + nprecspin = nlangspin = nsetspin = 0; // checking if map array or hash is defined @@ -125,7 +129,6 @@ FixNVESpin::FixNVESpin(LAMMPS *lmp, int narg, char **arg) : maglangevin_flag = 0; tdamp_flag = temp_flag = 0; setforce_spin_flag = 0; - } /* ---------------------------------------------------------------------- */ @@ -138,6 +141,8 @@ FixNVESpin::~FixNVESpin() memory->destroy(forward_stacks); memory->destroy(backward_stacks); delete [] spin_pairs; + delete [] locklangevinspin; + delete [] lockprecessionspin; } /* ---------------------------------------------------------------------- */ @@ -189,20 +194,20 @@ void FixNVESpin::init() // loop 2: fill vector with ptrs to Pair/Spin styles - int count = 0; + int count1 = 0; if (npairspin == 1) { - count = 1; + count1 = 1; spin_pairs[0] = (PairSpin *) force->pair_match("spin",0,0); } else if (npairspin > 1) { for (int i = 0; ipair_match("spin",0,i)) { - spin_pairs[count] = (PairSpin *) force->pair_match("spin",0,i); - count++; + spin_pairs[count1] = (PairSpin *) force->pair_match("spin",0,i); + count1++; } } } - if (count != npairspin) + if (count1 != npairspin) error->all(FLERR,"Incorrect number of spin pairs"); // set pair/spin and long/spin flags @@ -215,30 +220,71 @@ void FixNVESpin::init() } } - // ptrs FixPrecessionSpin classes - + // set ptrs for fix precession/spin styles + + // loop 1: obtain # of fix precession/spin styles + int iforce; for (iforce = 0; iforce < modify->nfix; iforce++) { if (strstr(modify->fix[iforce]->style,"precession/spin")) { - precession_spin_flag = 1; - lockprecessionspin = (FixPrecessionSpin *) modify->fix[iforce]; + nprecspin++; } } + + // init length of vector of ptrs to precession/spin styles - // ptrs on the FixLangevinSpin class + if (nprecspin > 0) { + lockprecessionspin = new FixPrecessionSpin*[nprecspin]; + } + + // loop 2: fill vector with ptrs to precession/spin styles + int count2 = 0; + if (nprecspin > 0) { + for (iforce = 0; iforce < modify->nfix; iforce++) { + if (strstr(modify->fix[iforce]->style,"precession/spin")) { + precession_spin_flag = 1; + lockprecessionspin[count2] = (FixPrecessionSpin *) modify->fix[iforce]; + count2++; + } + } + } + + if (count2 != nprecspin) + error->all(FLERR,"Incorrect number of fix precession/spin"); + + // set ptrs for fix langevin/spin styles + + // loop 1: obtain # of fix langevin/spin styles + for (iforce = 0; iforce < modify->nfix; iforce++) { if (strstr(modify->fix[iforce]->style,"langevin/spin")) { - maglangevin_flag = 1; - locklangevinspin = (FixLangevinSpin *) modify->fix[iforce]; + nlangspin++; } } + + // init length of vector of ptrs to precession/spin styles - if (maglangevin_flag) { - if (locklangevinspin->tdamp_flag == 1) tdamp_flag = 1; - if (locklangevinspin->temp_flag == 1) temp_flag = 1; + if (nlangspin > 0) { + locklangevinspin = new FixLangevinSpin*[nprecspin]; } + + // loop 2: fill vector with ptrs to precession/spin styles + count2 = 0; + if (nlangspin > 0) { + for (iforce = 0; iforce < modify->nfix; iforce++) { + if (strstr(modify->fix[iforce]->style,"langevin/spin")) { + maglangevin_flag = 1; + locklangevinspin[count2] = (FixLangevinSpin *) modify->fix[iforce]; + count2++; + } + } + } + + if (count2 != nlangspin) + error->all(FLERR,"Incorrect number of fix precession/spin"); + // ptrs FixSetForceSpin classes for (iforce = 0; iforce < modify->nfix; iforce++) { @@ -471,17 +517,16 @@ void FixNVESpin::ComputeInteractionsSpin(int i) // update magnetic precession interactions if (precession_spin_flag) { - lockprecessionspin->compute_single_precession(i,spi,fmi); + for (int k = 0; k < nprecspin; k++) { + lockprecessionspin[k]->compute_single_precession(i,spi,fmi); + } } // update langevin damping and random force if (maglangevin_flag) { // mag. langevin - if (tdamp_flag) { // transverse damping - locklangevinspin->add_tdamping(spi,fmi); - } - if (temp_flag) { // spin temperature - locklangevinspin->add_temperature(fmi); + for (int k = 0; k < nlangspin; k++) { + locklangevinspin[k]->compute_single_langevin(i,spi,fmi); } } @@ -496,7 +541,6 @@ void FixNVESpin::ComputeInteractionsSpin(int i) fm[i][0] = fmi[0]; fm[i][1] = fmi[1]; fm[i][2] = fmi[2]; - } /* ---------------------------------------------------------------------- diff --git a/src/SPIN/fix_nve_spin.h b/src/SPIN/fix_nve_spin.h index 5aa6b8e4e4..ac5bc57b25 100644 --- a/src/SPIN/fix_nve_spin.h +++ b/src/SPIN/fix_nve_spin.h @@ -61,11 +61,20 @@ friend class PairSpin; int tdamp_flag, temp_flag; int setforce_spin_flag; - // pointers to magnetic fixes + // pointers to fix langevin/spin styles - class FixPrecessionSpin *lockprecessionspin; - class FixLangevinSpin *locklangevinspin; - class FixSetForceSpin *locksetforcespin; + int nlangspin; + class FixLangevinSpin **locklangevinspin; + + // pointers to fix setforce/spin styles + + int nsetspin; + class FixSetForceSpin *locksetforcespin; // to be done + + // pointers to fix precession/spin styles + + int nprecspin; + class FixPrecessionSpin **lockprecessionspin; // pointers to magnetic pair styles diff --git a/src/SPIN/fix_precession_spin.cpp b/src/SPIN/fix_precession_spin.cpp index 17b9d3eb22..389ab1838d 100644 --- a/src/SPIN/fix_precession_spin.cpp +++ b/src/SPIN/fix_precession_spin.cpp @@ -67,6 +67,9 @@ FixPrecessionSpin::FixPrecessionSpin(LAMMPS *lmp, int narg, char **arg) : H_field = 0.0; nhx = nhy = nhz = 0.0; hx = hy = hz = 0.0; + stt_field = 0.0; + nsttx = nstty = nsttz = 0.0; + sttx = stty = sttz = 0.0; Ka = 0.0; nax = nay = naz = 0.0; Kax = Kay = Kaz = 0.0; @@ -74,8 +77,11 @@ FixPrecessionSpin::FixPrecessionSpin(LAMMPS *lmp, int narg, char **arg) : nc1x = nc1y = nc1z = 0.0; nc2x = nc2y = nc2z = 0.0; nc3x = nc3y = nc3z = 0.0; + K6 = 0.0; + n6x = n6y = n6z = 0.0; + m6x = m6y = m6z = 0.0; - zeeman_flag = aniso_flag = cubic_flag = 0; + zeeman_flag = stt_flag = aniso_flag = cubic_flag = hexaniso_flag = 0; int iarg = 3; while (iarg < narg) { @@ -87,6 +93,14 @@ FixPrecessionSpin::FixPrecessionSpin(LAMMPS *lmp, int narg, char **arg) : nhy = utils::numeric(FLERR,arg[iarg+3],false,lmp); nhz = utils::numeric(FLERR,arg[iarg+4],false,lmp); iarg += 5; + } else if (strcmp(arg[iarg],"stt") == 0) { + if (iarg+4 > narg) error->all(FLERR,"Illegal fix precession/spin command"); + stt_flag = 1; + stt_field = utils::numeric(FLERR,arg[iarg+1],false,lmp); + nsttx = utils::numeric(FLERR,arg[iarg+2],false,lmp); + nstty = utils::numeric(FLERR,arg[iarg+3],false,lmp); + nsttz = utils::numeric(FLERR,arg[iarg+4],false,lmp); + iarg += 5; } else if (strcmp(arg[iarg],"anisotropy") == 0) { if (iarg+4 > narg) error->all(FLERR,"Illegal fix precession/spin command"); aniso_flag = 1; @@ -110,40 +124,110 @@ FixPrecessionSpin::FixPrecessionSpin(LAMMPS *lmp, int narg, char **arg) : nc3y = utils::numeric(FLERR,arg[iarg+10],false,lmp); nc3z = utils::numeric(FLERR,arg[iarg+11],false,lmp); iarg += 12; + } else if (strcmp(arg[iarg],"hexaniso") == 0) { + if (iarg+7 > narg) error->all(FLERR,"Illegal fix precession/spin command"); + hexaniso_flag = 1; + K6 = utils::numeric(FLERR,arg[iarg+1],false,lmp); + n6x = utils::numeric(FLERR,arg[iarg+2],false,lmp); + n6y = utils::numeric(FLERR,arg[iarg+3],false,lmp); + n6z = utils::numeric(FLERR,arg[iarg+4],false,lmp); + m6x = utils::numeric(FLERR,arg[iarg+5],false,lmp); + m6y = utils::numeric(FLERR,arg[iarg+6],false,lmp); + m6z = utils::numeric(FLERR,arg[iarg+7],false,lmp); + iarg += 8; } else error->all(FLERR,"Illegal precession/spin command"); } // normalize vectors - double inorm; + double norm2,inorm; if (zeeman_flag) { - inorm = 1.0/sqrt(nhx*nhx + nhy*nhy + nhz*nhz); + norm2 = nhx*nhx + nhy*nhy + nhz*nhz; + if (norm2 == 0.0) + error->all(FLERR,"Illegal precession/spin command"); + inorm = 1.0/sqrt(norm2); nhx *= inorm; nhy *= inorm; nhz *= inorm; } + if (stt_flag) { + norm2 = nsttx*nsttx + nstty*nstty + nsttz*nsttz; + if (norm2 == 0.0) + error->all(FLERR,"Illegal precession/spin command"); + inorm = 1.0/sqrt(norm2); + nsttx *= inorm; + nstty *= inorm; + nsttz *= inorm; + } + if (aniso_flag) { - inorm = 1.0/sqrt(nax*nax + nay*nay + naz*naz); + norm2 = nax*nax + nay*nay + naz*naz; + if (norm2 == 0.0) + error->all(FLERR,"Illegal precession/spin command"); + inorm = 1.0/sqrt(norm2); nax *= inorm; nay *= inorm; naz *= inorm; } if (cubic_flag) { - inorm = 1.0/sqrt(nc1x*nc1x + nc1y*nc1y + nc1z*nc1z); + norm2 = nc1x*nc1x + nc1y*nc1y + nc1z*nc1z; + if (norm2 == 0.0) + error->all(FLERR,"Illegal precession/spin command"); + inorm = 1.0/sqrt(norm2); nc1x *= inorm; nc1y *= inorm; nc1z *= inorm; - inorm = 1.0/sqrt(nc2x*nc2x + nc2y*nc2y + nc2z*nc2z); + + norm2 = nc2x*nc2x + nc2y*nc2y + nc2z*nc2z; + if (norm2 == 0.0) + error->all(FLERR,"Illegal precession/spin command"); + inorm = 1.0/sqrt(norm2); nc2x *= inorm; nc2y *= inorm; nc2z *= inorm; - inorm = 1.0/sqrt(nc3x*nc3x + nc3y*nc3y + nc3z*nc3z); + + norm2 = nc3x*nc3x + nc3y*nc3y + nc3z*nc3z; + if (norm2 == 0.0) + error->all(FLERR,"Illegal precession/spin command"); + inorm = 1.0/sqrt(norm2); nc3x *= inorm; nc3y *= inorm; nc3z *= inorm; } + + if (hexaniso_flag) { + norm2 = n6x*n6x + n6y*n6y + n6z*n6z; + if (norm2 == 0.0) + error->all(FLERR,"Illegal precession/spin command"); + inorm = 1.0/sqrt(norm2); + n6x *= inorm; + n6y *= inorm; + n6z *= inorm; + + norm2 = m6x*m6x + m6y*m6y + m6z*m6z; + if (norm2 == 0.0) + error->all(FLERR,"Illegal precession/spin command"); + inorm = 1.0/sqrt(norm2); + m6x *= inorm; + m6y *= inorm; + m6z *= inorm; + l6x = (n6z*m6y-n6y*m6z); + l6y = (n6x*m6z-n6z*m6x); + l6z = (n6y*m6x-n6x*m6y); + + norm2 = l6x*l6x + l6y*l6y + l6z*l6z; + if (norm2 == 0.0) + error->all(FLERR,"Illegal precession/spin command"); + inorm = 1.0/sqrt(norm2); + l6x *= inorm; + l6y *= inorm; + l6z *= inorm; + m6x = (l6z*n6y-l6y*n6z); + m6y = (l6x*n6z-l6z*n6x); + m6z = (l6y*n6x-l6x*n6y); + } degree2rad = MY_PI/180.0; time_origin = update->ntimestep; @@ -185,6 +269,7 @@ void FixPrecessionSpin::init() Kah = Ka/hbar; k1ch = k1c/hbar; k2ch = k2c/hbar; + K6h = K6/hbar; if (utils::strmatch(update->integrate_style,"^respa")) { ilevel_respa = ((Respa *) update->integrate)->nlevels-1; @@ -199,15 +284,6 @@ void FixPrecessionSpin::init() error->all(FLERR,"Illegal precession/spin command"); } - // check that fix precession/spin is only declared once - - int iprec = 0; - for (int iforce = 0; iforce < modify->nfix; iforce++) - if (strstr(modify->fix[iforce]->style,"precession/spin")) iprec++; - if (iprec > 1) - error->all(FLERR,"precession/spin command can only be declared once"); - - varflag = CONSTANT; if (magfieldstyle != CONSTANT) varflag = EQUAL; @@ -283,16 +359,26 @@ void FixPrecessionSpin::post_force(int /* vflag */) epreci -= compute_zeeman_energy(spi); } + if (stt_flag) { // compute Spin Transfer Torque + compute_stt(spi,fmi); + epreci -= compute_stt_energy(spi); + } + if (aniso_flag) { // compute magnetic anisotropy compute_anisotropy(spi,fmi); epreci -= compute_anisotropy_energy(spi); } - if (cubic_flag) { // compute cubic anisotropy + if (cubic_flag) { // compute cubic anisotropy compute_cubic(spi,fmi); epreci -= compute_cubic_energy(spi); } + if (hexaniso_flag) { // compute hexagonal anisotropy + compute_hexaniso(spi,fmi); + epreci -= compute_hexaniso_energy(spi); + } + emag[i] += epreci; eprec += epreci; fm[i][0] += fmi[0]; @@ -309,12 +395,16 @@ void FixPrecessionSpin::compute_single_precession(int i, double spi[3], double f int *mask = atom->mask; if (mask[i] & groupbit) { if (zeeman_flag) compute_zeeman(i,fmi); + if (stt_flag) compute_stt(spi,fmi); if (aniso_flag) compute_anisotropy(spi,fmi); if (cubic_flag) compute_cubic(spi,fmi); + if (hexaniso_flag) compute_hexaniso(spi,fmi); } } -/* ---------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Zeeman +------------------------------------------------------------------------- */ void FixPrecessionSpin::compute_zeeman(int i, double fmi[3]) { @@ -334,8 +424,32 @@ double FixPrecessionSpin::compute_zeeman_energy(double spi[4]) return energy; } +/* ---------------------------------------------------------------------- + STT +------------------------------------------------------------------------- */ + +void FixPrecessionSpin::compute_stt(double spi[3], double fmi[3]) +{ + double sx = spi[0]; + double sy = spi[1]; + double sz = spi[2]; + fmi[0] += 1.0*stt_field*( sy*nsttz-sz*nstty); + fmi[1] += 1.0*stt_field*(-sx*nsttz+sz*nsttx); + fmi[2] += 1.0*stt_field*( sx*nstty-sy*nsttx); +} + /* ---------------------------------------------------------------------- */ +double FixPrecessionSpin::compute_stt_energy(double spi[3]) +{ + double energy = 0.0; // Non-conservative force + return energy; +} + +/* ---------------------------------------------------------------------- + compute uniaxial anisotropy interaction for spin i +------------------------------------------------------------------------- */ + void FixPrecessionSpin::compute_anisotropy(double spi[3], double fmi[3]) { double scalar = nax*spi[0] + nay*spi[1] + naz*spi[2]; @@ -393,9 +507,7 @@ void FixPrecessionSpin::compute_cubic(double spi[3], double fmi[3]) fmi[2] += (fourz + sixz); } -/* ---------------------------------------------------------------------- - compute cubic aniso energy of spin i -------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- */ double FixPrecessionSpin::compute_cubic_energy(double spi[3]) { @@ -412,6 +524,62 @@ double FixPrecessionSpin::compute_cubic_energy(double spi[3]) return energy; } +/* ---------------------------------------------------------------------- + compute hexagonal anisotropy interaction for spin i +------------------------------------------------------------------------- */ + +void FixPrecessionSpin::compute_hexaniso(double spi[3], double fmi[3]) +{ + double s_x,s_y,s_z; + double pf, phi, ssint2; + + // changing to the axes' frame + + s_x = l6x*spi[0]+l6y*spi[1]+l6z*spi[2]; + s_y = m6x*spi[0]+m6y*spi[1]+m6z*spi[2]; + s_z = n6x*spi[0]+n6y*spi[1]+n6z*spi[2]; + + // hexagonal anisotropy in the axes' frame + + phi = atan2(s_y,s_x); + ssint2 = s_x*s_x + s_y*s_y; // s^2sin^2(theta) + pf = 6.0 * K6h * ssint2*ssint2*sqrt(ssint2); // 6*K_6*s^5*sin^5(theta) + double fm_x = pf*cos(5*phi); + double fm_y = -pf*sin(5*phi); + double fm_z = 0; + + // back to the lab's frame + + fmi[0] += fm_x*l6x+fm_y*m6x+fm_z*n6x; + fmi[1] += fm_x*l6y+fm_y*m6y+fm_z*n6y; + fmi[2] += fm_x*l6z+fm_y*m6z+fm_z*n6z; +} + +/* ---------------------------------------------------------------------- + compute hexagonal aniso energy of spin i +------------------------------------------------------------------------- */ + +double FixPrecessionSpin::compute_hexaniso_energy(double spi[3]) +{ + double energy = 0.0; + double s_x,s_y,s_z, phi,ssint2; + + // changing to the axes' frame + + s_x = l6x*spi[0]+l6y*spi[1]+l6z*spi[2]; + s_y = m6x*spi[0]+m6y*spi[1]+m6z*spi[2]; + s_z = n6x*spi[0]+n6y*spi[1]+n6z*spi[2]; + + // hexagonal anisotropy in the axes' frame + + phi = atan2(s_y,s_z); + ssint2 = s_x*s_x + s_y*s_y; + + energy = K6 * ssint2*ssint2*ssint2*cos(6*phi); + + return 2.0*energy; +} + /* ---------------------------------------------------------------------- */ void FixPrecessionSpin::set_magneticprecession() @@ -421,6 +589,13 @@ void FixPrecessionSpin::set_magneticprecession() hy = H_field*nhy; hz = H_field*nhz; } + + if (stt_flag) { + sttx = stt_field*nsttx; + stty = stt_field*nstty; + sttz = stt_field*nsttz; + } + if (aniso_flag) { Kax = 2.0*Kah*nax; Kay = 2.0*Kah*nay; diff --git a/src/SPIN/fix_precession_spin.h b/src/SPIN/fix_precession_spin.h index 9c3c616077..d06a04f8f1 100644 --- a/src/SPIN/fix_precession_spin.h +++ b/src/SPIN/fix_precession_spin.h @@ -39,7 +39,7 @@ class FixPrecessionSpin : public Fix { void min_post_force(int); double compute_scalar(); - int zeeman_flag, aniso_flag, cubic_flag; + int zeeman_flag, stt_flag, aniso_flag, cubic_flag, hexaniso_flag; void compute_single_precession(int, double *, double *); // zeeman calculations @@ -47,6 +47,11 @@ class FixPrecessionSpin : public Fix { void compute_zeeman(int, double *); double compute_zeeman_energy(double *); + // stt calculations + + void compute_stt(double *, double *); + double compute_stt_energy(double *); + // uniaxial aniso calculations void compute_anisotropy(double *, double *); @@ -57,6 +62,11 @@ class FixPrecessionSpin : public Fix { void compute_cubic(double *, double *); double compute_cubic_energy(double *); + // hexagonal aniso calculations + + void compute_hexaniso(double *, double *); + double compute_hexaniso_energy(double *); + // storing magnetic energies int nlocal_max; // max nlocal (for list size) @@ -83,6 +93,12 @@ class FixPrecessionSpin : public Fix { double nhx, nhy, nhz; double hx, hy, hz; // temp. force variables + // STT intensity and direction + + double stt_field; + double nsttx, nstty, nsttz; + double sttx, stty, sttz; + // magnetic anisotropy intensity and direction double Ka; // aniso const. in eV @@ -98,6 +114,13 @@ class FixPrecessionSpin : public Fix { double nc2x,nc2y,nc2z; double nc3x,nc3y,nc3z; + // hexagonal anisotropy + double K6; // hexagonal aniso const. in eV + double K6h; // hexagonal aniso const. in rad.THz + double n6x,n6y,n6z; // main axis + double m6x,m6y,m6z; // secondary (perpendicular) axis + double l6x,l6y,l6z; // =(m x n) + void set_magneticprecession(); }; diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index 7d7cfa4878..eec09cf58a 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -71,21 +71,6 @@ AtomVec::AtomVec(LAMMPS *lmp) : Pointers(lmp) default_create = "id type mask image x v"; default_data_atom = ""; default_data_vel = ""; - - // initializations - - init_method(&mgrow); - init_method(&mcopy); - init_method(&mcomm); - init_method(&mcomm_vel); - init_method(&mreverse); - init_method(&mborder); - init_method(&mborder_vel); - init_method(&mexchange); - init_method(&mrestart); - init_method(&mcreate); - init_method(&mdata_atom); - init_method(&mdata_vel); } /* ---------------------------------------------------------------------- */ @@ -129,19 +114,6 @@ AtomVec::~AtomVec() } } - destroy_method(&mgrow); - destroy_method(&mcopy); - destroy_method(&mcomm); - destroy_method(&mcomm_vel); - destroy_method(&mreverse); - destroy_method(&mborder); - destroy_method(&mborder_vel); - destroy_method(&mexchange); - destroy_method(&mrestart); - destroy_method(&mcreate); - destroy_method(&mdata_atom); - destroy_method(&mdata_vel); - delete [] threads; } @@ -2395,18 +2367,18 @@ void AtomVec::setup_fields() // populate field-based data struct for each method to use - create_method(ngrow,&mgrow); - create_method(ncopy,&mcopy); - create_method(ncomm,&mcomm); - create_method(ncomm_vel,&mcomm_vel); - create_method(nreverse,&mreverse); - create_method(nborder,&mborder); - create_method(nborder_vel,&mborder_vel); - create_method(nexchange,&mexchange); - create_method(nrestart,&mrestart); - create_method(ncreate,&mcreate); - create_method(ndata_atom,&mdata_atom); - create_method(ndata_vel,&mdata_vel); + init_method(ngrow,&mgrow); + init_method(ncopy,&mcopy); + init_method(ncomm,&mcomm); + init_method(ncomm_vel,&mcomm_vel); + init_method(nreverse,&mreverse); + init_method(nborder,&mborder); + init_method(nborder_vel,&mborder_vel); + init_method(nexchange,&mexchange); + init_method(nrestart,&mrestart); + init_method(ncreate,&mcreate); + init_method(ndata_atom,&mdata_atom); + init_method(ndata_vel,&mdata_vel); // create threads data struct for grow and memory_usage to use @@ -2480,7 +2452,6 @@ void AtomVec::setup_fields() int AtomVec::process_fields(char *str, const char *default_str, Method *method) { if (str == nullptr) { - method->index = nullptr; return 0; } @@ -2496,17 +2467,19 @@ int AtomVec::process_fields(char *str, const char *default_str, Method *method) Atom::PerAtom *peratom = atom->peratom; int nperatom = atom->nperatom; - int *index; + // allocate memory in method + method->resize(nfield); + + std::vector & index = method->index; int match; - if (nfield) index = new int[nfield]; for (int i = 0; i < nfield; i++) { - const char * field = words[i].c_str(); + const std::string & field = words[i]; // find field in master Atom::peratom list for (match = 0; match < nperatom; match++) - if (strcmp(field, peratom[match].name) == 0) break; + if (field == peratom[match].name) break; if (match == nperatom) error->all(FLERR,fmt::format("Peratom field {} not recognized", field)); index[i] = match; @@ -2520,38 +2493,19 @@ int AtomVec::process_fields(char *str, const char *default_str, Method *method) // error if field is in default str for (match = 0; match < ndef; match++) - if (strcmp(field, def_words[match].c_str()) == 0) + if (field == def_words[match]) error->all(FLERR,fmt::format("Peratom field {} is a default", field)); } - if (nfield) method->index = index; - else method->index = nullptr; return nfield; } /* ---------------------------------------------------------------------- - create a method data structs for processing fields + init method data structs for processing fields ------------------------------------------------------------------------- */ -void AtomVec::create_method(int nfield, Method *method) +void AtomVec::init_method(int nfield, Method *method) { - if (nfield > 0) { - method->pdata = new void*[nfield]; - method->datatype = new int[nfield]; - method->cols = new int[nfield]; - method->maxcols = new int*[nfield]; - method->collength = new int[nfield]; - method->plength = new void*[nfield]; - } else { - method->pdata = nullptr; - method->datatype = nullptr; - method->cols = nullptr; - method->maxcols = nullptr; - method->collength = nullptr; - method->plength = nullptr; - return; - } - for (int i = 0; i < nfield; i++) { Atom::PerAtom *field = &atom->peratom[method->index[i]]; method->pdata[i] = (void *) field->address; @@ -2566,31 +2520,15 @@ void AtomVec::create_method(int nfield, Method *method) } /* ---------------------------------------------------------------------- - free memory in a method data structs + Method class members ------------------------------------------------------------------------- */ -void AtomVec::init_method(Method *method) -{ - method->pdata = nullptr; - method->datatype = nullptr; - method->cols = nullptr; - method->maxcols = nullptr; - method->collength = nullptr; - method->plength = nullptr; - method->index = nullptr; -} - -/* ---------------------------------------------------------------------- - free memory in a method data structs -------------------------------------------------------------------------- */ - -void AtomVec::destroy_method(Method *method) -{ - delete [] method->pdata; - delete [] method->datatype; - delete [] method->cols; - delete [] method->maxcols; - delete [] method->collength; - delete [] method->plength; - delete [] method->index; +void AtomVec::Method::resize(int nfield) { + pdata.resize(nfield); + datatype.resize(nfield); + cols.resize(nfield); + maxcols.resize(nfield); + collength.resize(nfield); + plength.resize(nfield); + index.resize(nfield); } diff --git a/src/atom_vec.h b/src/atom_vec.h index 8e670304ed..a8f5f5ec22 100644 --- a/src/atom_vec.h +++ b/src/atom_vec.h @@ -191,13 +191,15 @@ class AtomVec : protected Pointers { const char *default_create,*default_data_atom,*default_data_vel; struct Method { - void **pdata; - int *datatype; - int *cols; - int **maxcols; - int *collength; - void **plength; - int *index; + std::vector pdata; + std::vector datatype; + std::vector cols; + std::vector maxcols; + std::vector collength; + std::vector plength; + std::vector index; + + void resize(int nfield); }; Method mgrow,mcopy; @@ -219,9 +221,7 @@ class AtomVec : protected Pointers { int grow_nmax_bonus(int); void setup_fields(); int process_fields(char *, const char *, Method *); - void create_method(int, Method *); - void init_method(Method *); - void destroy_method(Method *); + void init_method(int, Method *); }; } diff --git a/src/compute_chunk_atom.cpp b/src/compute_chunk_atom.cpp index be1e1e1035..5960e1fc6f 100644 --- a/src/compute_chunk_atom.cpp +++ b/src/compute_chunk_atom.cpp @@ -237,15 +237,12 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) : else if (strcmp(arg[iarg+1],"y") == 0) idim = 1; else if (strcmp(arg[iarg+1],"z") == 0) idim = 2; else error->all(FLERR,"Illegal compute chunk/atom command"); + minflag[idim] = COORD; if (strcmp(arg[iarg+2],"lower") == 0) minflag[idim] = LOWER; - else minflag[idim] = COORD; - if (minflag[idim] == COORD) - minvalue[idim] = utils::numeric(FLERR,arg[iarg+2],false,lmp); + else minvalue[idim] = utils::numeric(FLERR,arg[iarg+2],false,lmp); + maxflag[idim] = COORD; if (strcmp(arg[iarg+3],"upper") == 0) maxflag[idim] = UPPER; - else maxflag[idim] = COORD; - if (maxflag[idim] == COORD) - maxvalue[idim] = utils::numeric(FLERR,arg[iarg+3],false,lmp); - else error->all(FLERR,"Illegal compute chunk/atom command"); + else maxvalue[idim] = utils::numeric(FLERR,arg[iarg+3],false,lmp); iarg += 4; } else if (strcmp(arg[iarg],"units") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal compute chunk/atom command"); diff --git a/src/force.cpp b/src/force.cpp index e56e250ffc..80f5ef22a7 100644 --- a/src/force.cpp +++ b/src/force.cpp @@ -36,8 +36,6 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 - /* ---------------------------------------------------------------------- */ Force::Force(LAMMPS *lmp) : Pointers(lmp) diff --git a/src/group.cpp b/src/group.cpp index 0143008a72..9e140779ef 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -30,11 +30,13 @@ #include "region.h" #include "tokenizer.h" #include "variable.h" +#include "exceptions.h" #include #include #include #include +#include using namespace LAMMPS_NS; @@ -151,12 +153,14 @@ void Group::assign(int narg, char **arg) // add a new group if igroup = -1 int igroup = find(arg[0]); + bool created = false; if (igroup == -1) { if (ngroup == MAX_GROUP) error->all(FLERR,"Too many groups"); igroup = find_unused(); names[igroup] = utils::strdup(arg[0]); ngroup++; + created = true; } double **x = atom->x; @@ -164,355 +168,360 @@ void Group::assign(int narg, char **arg) int nlocal = atom->nlocal; int bit = bitmask[igroup]; - // style = region - // add to group if atom is in region + try { + // style = region + // add to group if atom is in region - if (strcmp(arg[1],"region") == 0) { + if (strcmp(arg[1],"region") == 0) { - if (narg != 3) error->all(FLERR,"Illegal group command"); + if (narg != 3) error->all(FLERR,"Illegal group command"); - int iregion = domain->find_region(arg[2]); - if (iregion == -1) error->all(FLERR,"Group region ID does not exist"); - domain->regions[iregion]->init(); - domain->regions[iregion]->prematch(); + int iregion = domain->find_region(arg[2]); + if (iregion == -1) error->all(FLERR,"Group region ID does not exist"); + domain->regions[iregion]->init(); + domain->regions[iregion]->prematch(); - for (i = 0; i < nlocal; i++) - if (domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2])) - mask[i] |= bit; + for (i = 0; i < nlocal; i++) + if (domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2])) + mask[i] |= bit; - // create an empty group + // create an empty group - } else if (strcmp(arg[1],"empty") == 0) { + } else if (strcmp(arg[1],"empty") == 0) { - if (narg != 2) error->all(FLERR,"Illegal group command"); - // nothing else to do here + if (narg != 2) error->all(FLERR,"Illegal group command"); + // nothing else to do here - // style = type, molecule, id - // add to group if atom matches type/molecule/id or condition + // style = type, molecule, id + // add to group if atom matches type/molecule/id or condition - } else if (strcmp(arg[1],"type") == 0 || strcmp(arg[1],"molecule") == 0 || - strcmp(arg[1],"id") == 0) { + } else if (strcmp(arg[1],"type") == 0 || strcmp(arg[1],"molecule") == 0 || + strcmp(arg[1],"id") == 0) { - if (narg < 3) error->all(FLERR,"Illegal group command"); + if (narg < 3) error->all(FLERR,"Illegal group command"); - int category=NONE; - if (strcmp(arg[1],"type") == 0) category = TYPE; - else if (strcmp(arg[1],"molecule") == 0) category = MOLECULE; - else if (strcmp(arg[1],"id") == 0) category = ID; + int category=NONE; + if (strcmp(arg[1],"type") == 0) category = TYPE; + else if (strcmp(arg[1],"molecule") == 0) category = MOLECULE; + else if (strcmp(arg[1],"id") == 0) category = ID; - if ((category == MOLECULE) && (!atom->molecule_flag)) - error->all(FLERR,"Group command requires atom attribute molecule"); - - if ((category == ID) && (!atom->tag_enable)) - error->all(FLERR,"Group command requires atom IDs"); - - // args = logical condition - - if (narg > 3 && - (strcmp(arg[2],"<") == 0 || strcmp(arg[2],">") == 0 || - strcmp(arg[2],"<=") == 0 || strcmp(arg[2],">=") == 0 || - strcmp(arg[2],"==") == 0 || strcmp(arg[2],"!=") == 0 || - strcmp(arg[2],"<>") == 0)) { - - int condition = -1; - if (strcmp(arg[2],"<") == 0) condition = LT; - else if (strcmp(arg[2],"<=") == 0) condition = LE; - else if (strcmp(arg[2],">") == 0) condition = GT; - else if (strcmp(arg[2],">=") == 0) condition = GE; - else if (strcmp(arg[2],"==") == 0) condition = EQ; - else if (strcmp(arg[2],"!=") == 0) condition = NEQ; - else if (strcmp(arg[2],"<>") == 0) condition = BETWEEN; - else error->all(FLERR,"Illegal group command"); - - tagint bound1,bound2; - bound1 = utils::tnumeric(FLERR,arg[3],false,lmp); - bound2 = -1; - - if (condition == BETWEEN) { - if (narg != 5) error->all(FLERR,"Illegal group command"); - bound2 = utils::tnumeric(FLERR,arg[4],false,lmp); - } else if (narg != 4) error->all(FLERR,"Illegal group command"); - - int *attribute = nullptr; - tagint *tattribute = nullptr; - if (category == TYPE) attribute = atom->type; - else if (category == MOLECULE) tattribute = atom->molecule; - else if (category == ID) tattribute = atom->tag; - - // add to group if meets condition - - if (attribute) { - if (condition == LT) { - for (i = 0; i < nlocal; i++) - if (attribute[i] < bound1) mask[i] |= bit; - } else if (condition == LE) { - for (i = 0; i < nlocal; i++) - if (attribute[i] <= bound1) mask[i] |= bit; - } else if (condition == GT) { - for (i = 0; i < nlocal; i++) - if (attribute[i] > bound1) mask[i] |= bit; - } else if (condition == GE) { - for (i = 0; i < nlocal; i++) - if (attribute[i] >= bound1) mask[i] |= bit; - } else if (condition == EQ) { - for (i = 0; i < nlocal; i++) - if (attribute[i] == bound1) mask[i] |= bit; - } else if (condition == NEQ) { - for (i = 0; i < nlocal; i++) - if (attribute[i] != bound1) mask[i] |= bit; - } else if (condition == BETWEEN) { - for (i = 0; i < nlocal; i++) - if (attribute[i] >= bound1 && attribute[i] <= bound2) - mask[i] |= bit; - } - } else { - if (condition == LT) { - for (i = 0; i < nlocal; i++) - if (tattribute[i] < bound1) mask[i] |= bit; - } else if (condition == LE) { - for (i = 0; i < nlocal; i++) - if (tattribute[i] <= bound1) mask[i] |= bit; - } else if (condition == GT) { - for (i = 0; i < nlocal; i++) - if (tattribute[i] > bound1) mask[i] |= bit; - } else if (condition == GE) { - for (i = 0; i < nlocal; i++) - if (tattribute[i] >= bound1) mask[i] |= bit; - } else if (condition == EQ) { - for (i = 0; i < nlocal; i++) - if (tattribute[i] == bound1) mask[i] |= bit; - } else if (condition == NEQ) { - for (i = 0; i < nlocal; i++) - if (tattribute[i] != bound1) mask[i] |= bit; - } else if (condition == BETWEEN) { - for (i = 0; i < nlocal; i++) - if (tattribute[i] >= bound1 && tattribute[i] <= bound2) - mask[i] |= bit; - } - } - - // args = list of values - - } else { - int *attribute = nullptr; - tagint *tattribute = nullptr; - if (category == TYPE) attribute = atom->type; - else if (category == MOLECULE) tattribute = atom->molecule; - else if (category == ID) tattribute = atom->tag; - - tagint start,stop,delta; - - for (int iarg = 2; iarg < narg; iarg++) { - delta = 1; - try { - ValueTokenizer values(arg[iarg],":"); - start = values.next_tagint(); - if (utils::strmatch(arg[iarg],"^-?\\d+$")) { - stop = start; - } else if (utils::strmatch(arg[iarg],"^-?\\d+:-?\\d+$")) { - stop = values.next_tagint(); - } else if (utils::strmatch(arg[iarg],"^-?\\d+:-?\\d+:\\d+$")) { - stop = values.next_tagint(); - delta = values.next_tagint(); - } else throw TokenizerException("Syntax error",""); - } catch (TokenizerException &e) { - error->all(FLERR,fmt::format("Incorrect range string " - "'{}': {}",arg[iarg],e.what())); - } - if (delta < 1) - error->all(FLERR,"Illegal range increment value"); - - // add to group if attribute matches value or sequence - - if (attribute) { - for (i = 0; i < nlocal; i++) - if (attribute[i] >= start && attribute[i] <= stop && - (attribute[i]-start) % delta == 0) mask[i] |= bit; - } else { - for (i = 0; i < nlocal; i++) - if (tattribute[i] >= start && tattribute[i] <= stop && - (tattribute[i]-start) % delta == 0) mask[i] |= bit; - } - } - } - - // style = variable - // add to group if atom-atyle variable is non-zero - - } else if (strcmp(arg[1],"variable") == 0) { - - int ivar = input->variable->find(arg[2]); - if (ivar < 0) error->all(FLERR,"Variable name for group does not exist"); - if (!input->variable->atomstyle(ivar)) - error->all(FLERR,"Variable for group is invalid style"); - - double *aflag; - - // aflag = evaluation of per-atom variable - - memory->create(aflag,nlocal,"group:aflag"); - input->variable->compute_atom(ivar,0,aflag,1,0); - - // add to group if per-atom variable evaluated to non-zero - - for (i = 0; i < nlocal; i++) - if (aflag[i] != 0.0) mask[i] |= bit; - - memory->destroy(aflag); - - // style = include - - } else if (strcmp(arg[1],"include") == 0) { - - if (narg != 3) error->all(FLERR,"Illegal group command"); - if (strcmp(arg[2],"molecule") == 0) { - if (!atom->molecule_flag) + if ((category == MOLECULE) && (!atom->molecule_flag)) error->all(FLERR,"Group command requires atom attribute molecule"); - add_molecules(igroup,bit); + if ((category == ID) && (!atom->tag_enable)) + error->all(FLERR,"Group command requires atom IDs"); + + // args = logical condition + + if (narg > 3 && + (strcmp(arg[2],"<") == 0 || strcmp(arg[2],">") == 0 || + strcmp(arg[2],"<=") == 0 || strcmp(arg[2],">=") == 0 || + strcmp(arg[2],"==") == 0 || strcmp(arg[2],"!=") == 0 || + strcmp(arg[2],"<>") == 0)) { + + int condition = -1; + if (strcmp(arg[2],"<") == 0) condition = LT; + else if (strcmp(arg[2],"<=") == 0) condition = LE; + else if (strcmp(arg[2],">") == 0) condition = GT; + else if (strcmp(arg[2],">=") == 0) condition = GE; + else if (strcmp(arg[2],"==") == 0) condition = EQ; + else if (strcmp(arg[2],"!=") == 0) condition = NEQ; + else if (strcmp(arg[2],"<>") == 0) condition = BETWEEN; + else error->all(FLERR,"Illegal group command"); + + tagint bound1,bound2; + bound1 = utils::tnumeric(FLERR,arg[3],false,lmp); + bound2 = -1; + + if (condition == BETWEEN) { + if (narg != 5) error->all(FLERR,"Illegal group command"); + bound2 = utils::tnumeric(FLERR,arg[4],false,lmp); + } else if (narg != 4) error->all(FLERR,"Illegal group command"); + + int *attribute = nullptr; + tagint *tattribute = nullptr; + if (category == TYPE) attribute = atom->type; + else if (category == MOLECULE) tattribute = atom->molecule; + else if (category == ID) tattribute = atom->tag; + + // add to group if meets condition + + if (attribute) { + if (condition == LT) { + for (i = 0; i < nlocal; i++) + if (attribute[i] < bound1) mask[i] |= bit; + } else if (condition == LE) { + for (i = 0; i < nlocal; i++) + if (attribute[i] <= bound1) mask[i] |= bit; + } else if (condition == GT) { + for (i = 0; i < nlocal; i++) + if (attribute[i] > bound1) mask[i] |= bit; + } else if (condition == GE) { + for (i = 0; i < nlocal; i++) + if (attribute[i] >= bound1) mask[i] |= bit; + } else if (condition == EQ) { + for (i = 0; i < nlocal; i++) + if (attribute[i] == bound1) mask[i] |= bit; + } else if (condition == NEQ) { + for (i = 0; i < nlocal; i++) + if (attribute[i] != bound1) mask[i] |= bit; + } else if (condition == BETWEEN) { + for (i = 0; i < nlocal; i++) + if (attribute[i] >= bound1 && attribute[i] <= bound2) + mask[i] |= bit; + } + } else { + if (condition == LT) { + for (i = 0; i < nlocal; i++) + if (tattribute[i] < bound1) mask[i] |= bit; + } else if (condition == LE) { + for (i = 0; i < nlocal; i++) + if (tattribute[i] <= bound1) mask[i] |= bit; + } else if (condition == GT) { + for (i = 0; i < nlocal; i++) + if (tattribute[i] > bound1) mask[i] |= bit; + } else if (condition == GE) { + for (i = 0; i < nlocal; i++) + if (tattribute[i] >= bound1) mask[i] |= bit; + } else if (condition == EQ) { + for (i = 0; i < nlocal; i++) + if (tattribute[i] == bound1) mask[i] |= bit; + } else if (condition == NEQ) { + for (i = 0; i < nlocal; i++) + if (tattribute[i] != bound1) mask[i] |= bit; + } else if (condition == BETWEEN) { + for (i = 0; i < nlocal; i++) + if (tattribute[i] >= bound1 && tattribute[i] <= bound2) + mask[i] |= bit; + } + } + + // args = list of values + + } else { + int *attribute = nullptr; + tagint *tattribute = nullptr; + if (category == TYPE) attribute = atom->type; + else if (category == MOLECULE) tattribute = atom->molecule; + else if (category == ID) tattribute = atom->tag; + + tagint start,stop,delta; + + for (int iarg = 2; iarg < narg; iarg++) { + delta = 1; + try { + ValueTokenizer values(arg[iarg],":"); + start = values.next_tagint(); + if (utils::strmatch(arg[iarg],"^-?\\d+$")) { + stop = start; + } else if (utils::strmatch(arg[iarg],"^-?\\d+:-?\\d+$")) { + stop = values.next_tagint(); + } else if (utils::strmatch(arg[iarg],"^-?\\d+:-?\\d+:\\d+$")) { + stop = values.next_tagint(); + delta = values.next_tagint(); + } else throw TokenizerException("Syntax error",""); + } catch (TokenizerException &e) { + error->all(FLERR,fmt::format("Incorrect range string " + "'{}': {}",arg[iarg],e.what())); + } + if (delta < 1) + error->all(FLERR,"Illegal range increment value"); + + // add to group if attribute matches value or sequence + + if (attribute) { + for (i = 0; i < nlocal; i++) + if (attribute[i] >= start && attribute[i] <= stop && + (attribute[i]-start) % delta == 0) mask[i] |= bit; + } else { + for (i = 0; i < nlocal; i++) + if (tattribute[i] >= start && tattribute[i] <= stop && + (tattribute[i]-start) % delta == 0) mask[i] |= bit; + } + } + } + + // style = variable + // add to group if atom-atyle variable is non-zero + + } else if (strcmp(arg[1],"variable") == 0) { + + int ivar = input->variable->find(arg[2]); + if (ivar < 0) error->all(FLERR,"Variable name for group does not exist"); + if (!input->variable->atomstyle(ivar)) + error->all(FLERR,"Variable for group is invalid style"); + + double *aflag; + + // aflag = evaluation of per-atom variable + + memory->create(aflag,nlocal,"group:aflag"); + input->variable->compute_atom(ivar,0,aflag,1,0); + + // add to group if per-atom variable evaluated to non-zero + + for (i = 0; i < nlocal; i++) + if (aflag[i] != 0.0) mask[i] |= bit; + + memory->destroy(aflag); + + // style = include + + } else if (strcmp(arg[1],"include") == 0) { + + if (narg != 3) error->all(FLERR,"Illegal group command"); + if (strcmp(arg[2],"molecule") == 0) { + if (!atom->molecule_flag) + error->all(FLERR,"Group command requires atom attribute molecule"); + + add_molecules(igroup,bit); + + } else error->all(FLERR,"Illegal group command"); + + // style = subtract + + } else if (strcmp(arg[1],"subtract") == 0) { + + if (narg < 4) error->all(FLERR,"Illegal group command"); + + int length = narg-2; + std::vector list(length); + + int jgroup; + for (int iarg = 2; iarg < narg; iarg++) { + jgroup = find(arg[iarg]); + if (jgroup == -1) error->all(FLERR,"Group ID does not exist"); + if (dynamic[jgroup]) + error->all(FLERR,"Cannot subtract groups using a dynamic group"); + list[iarg-2] = jgroup; + } + + // add to group if in 1st group in list + + int otherbit = bitmask[list[0]]; + + for (i = 0; i < nlocal; i++) + if (mask[i] & otherbit) mask[i] |= bit; + + // remove atoms if they are in any of the other groups + // AND with inverse mask removes the atom from group + + int inverse = inversemask[igroup]; + + for (int ilist = 1; ilist < length; ilist++) { + otherbit = bitmask[list[ilist]]; + for (i = 0; i < nlocal; i++) + if (mask[i] & otherbit) mask[i] &= inverse; + } + + // style = union + + } else if (strcmp(arg[1],"union") == 0) { + + if (narg < 3) error->all(FLERR,"Illegal group command"); + + int length = narg-2; + std::vector list(length); + + int jgroup; + for (int iarg = 2; iarg < narg; iarg++) { + jgroup = find(arg[iarg]); + if (jgroup == -1) error->all(FLERR,"Group ID does not exist"); + if (dynamic[jgroup]) + error->all(FLERR,"Cannot union groups using a dynamic group"); + list[iarg-2] = jgroup; + } + + // add to group if in any other group in list + + int otherbit; + + for (int ilist = 0; ilist < length; ilist++) { + otherbit = bitmask[list[ilist]]; + for (i = 0; i < nlocal; i++) + if (mask[i] & otherbit) mask[i] |= bit; + } + + // style = intersect + + } else if (strcmp(arg[1],"intersect") == 0) { + + if (narg < 4) error->all(FLERR,"Illegal group command"); + + int length = narg-2; + std::vector list(length); + + int jgroup; + for (int iarg = 2; iarg < narg; iarg++) { + jgroup = find(arg[iarg]); + if (jgroup == -1) error->all(FLERR,"Group ID does not exist"); + if (dynamic[jgroup]) + error->all(FLERR,"Cannot intersect groups using a dynamic group"); + list[iarg-2] = jgroup; + } + + // add to group if in all groups in list + + int otherbit,ok,ilist; + + for (i = 0; i < nlocal; i++) { + ok = 1; + for (ilist = 0; ilist < length; ilist++) { + otherbit = bitmask[list[ilist]]; + if ((mask[i] & otherbit) == 0) ok = 0; + } + if (ok) mask[i] |= bit; + } + + // style = dynamic + // create a new FixGroup to dynamically determine atoms in group + + } else if (strcmp(arg[1],"dynamic") == 0) { + + if (narg < 4) error->all(FLERR,"Illegal group command"); + if (strcmp(arg[0],arg[2]) == 0) + error->all(FLERR,"Group dynamic cannot reference itself"); + if (find(arg[2]) < 0) + error->all(FLERR,"Group dynamic parent group does not exist"); + if (igroup == 0) error->all(FLERR,"Group all cannot be made dynamic"); + + // if group is already dynamic, delete existing FixGroup + + if (dynamic[igroup]) + modify->delete_fix(std::string("GROUP_") + names[igroup]); + + dynamic[igroup] = 1; + + std::string fixcmd = "GROUP_"; + fixcmd += fmt::format("{} {} GROUP",names[igroup],arg[2]); + for (int i = 3; i < narg; i++) fixcmd += std::string(" ") + arg[i]; + modify->add_fix(fixcmd); + + // style = static + // remove dynamic FixGroup if necessary + + } else if (strcmp(arg[1],"static") == 0) { + + if (narg != 2) error->all(FLERR,"Illegal group command"); + + if (dynamic[igroup]) + modify->delete_fix(std::string("GROUP_") + names[igroup]); + + dynamic[igroup] = 0; + + // not a valid group style } else error->all(FLERR,"Illegal group command"); - // style = subtract - - } else if (strcmp(arg[1],"subtract") == 0) { - - if (narg < 4) error->all(FLERR,"Illegal group command"); - - int length = narg-2; - int *list = new int[length]; - - int jgroup; - for (int iarg = 2; iarg < narg; iarg++) { - jgroup = find(arg[iarg]); - if (jgroup == -1) error->all(FLERR,"Group ID does not exist"); - if (dynamic[jgroup]) - error->all(FLERR,"Cannot subtract groups using a dynamic group"); - list[iarg-2] = jgroup; + } catch (LAMMPSException & e) { + // undo created group in case of an error + if (created) { + delete [] names[igroup]; + names[igroup] = nullptr; + ngroup--; } - - // add to group if in 1st group in list - - int otherbit = bitmask[list[0]]; - - for (i = 0; i < nlocal; i++) - if (mask[i] & otherbit) mask[i] |= bit; - - // remove atoms if they are in any of the other groups - // AND with inverse mask removes the atom from group - - int inverse = inversemask[igroup]; - - for (int ilist = 1; ilist < length; ilist++) { - otherbit = bitmask[list[ilist]]; - for (i = 0; i < nlocal; i++) - if (mask[i] & otherbit) mask[i] &= inverse; - } - - delete [] list; - - // style = union - - } else if (strcmp(arg[1],"union") == 0) { - - if (narg < 3) error->all(FLERR,"Illegal group command"); - - int length = narg-2; - int *list = new int[length]; - - int jgroup; - for (int iarg = 2; iarg < narg; iarg++) { - jgroup = find(arg[iarg]); - if (jgroup == -1) error->all(FLERR,"Group ID does not exist"); - if (dynamic[jgroup]) - error->all(FLERR,"Cannot union groups using a dynamic group"); - list[iarg-2] = jgroup; - } - - // add to group if in any other group in list - - int otherbit; - - for (int ilist = 0; ilist < length; ilist++) { - otherbit = bitmask[list[ilist]]; - for (i = 0; i < nlocal; i++) - if (mask[i] & otherbit) mask[i] |= bit; - } - - delete [] list; - - // style = intersect - - } else if (strcmp(arg[1],"intersect") == 0) { - - if (narg < 4) error->all(FLERR,"Illegal group command"); - - int length = narg-2; - int *list = new int[length]; - - int jgroup; - for (int iarg = 2; iarg < narg; iarg++) { - jgroup = find(arg[iarg]); - if (jgroup == -1) error->all(FLERR,"Group ID does not exist"); - if (dynamic[jgroup]) - error->all(FLERR,"Cannot intersect groups using a dynamic group"); - list[iarg-2] = jgroup; - } - - // add to group if in all groups in list - - int otherbit,ok,ilist; - - for (i = 0; i < nlocal; i++) { - ok = 1; - for (ilist = 0; ilist < length; ilist++) { - otherbit = bitmask[list[ilist]]; - if ((mask[i] & otherbit) == 0) ok = 0; - } - if (ok) mask[i] |= bit; - } - - delete [] list; - - // style = dynamic - // create a new FixGroup to dynamically determine atoms in group - - } else if (strcmp(arg[1],"dynamic") == 0) { - - if (narg < 4) error->all(FLERR,"Illegal group command"); - if (strcmp(arg[0],arg[2]) == 0) - error->all(FLERR,"Group dynamic cannot reference itself"); - if (find(arg[2]) < 0) - error->all(FLERR,"Group dynamic parent group does not exist"); - if (igroup == 0) error->all(FLERR,"Group all cannot be made dynamic"); - - // if group is already dynamic, delete existing FixGroup - - if (dynamic[igroup]) - modify->delete_fix(std::string("GROUP_") + names[igroup]); - - dynamic[igroup] = 1; - - std::string fixcmd = "GROUP_"; - fixcmd += fmt::format("{} {} GROUP",names[igroup],arg[2]); - for (int i = 3; i < narg; i++) fixcmd += std::string(" ") + arg[i]; - modify->add_fix(fixcmd); - - // style = static - // remove dynamic FixGroup if necessary - - } else if (strcmp(arg[1],"static") == 0) { - - if (narg != 2) error->all(FLERR,"Illegal group command"); - - if (dynamic[igroup]) - modify->delete_fix(std::string("GROUP_") + names[igroup]); - - dynamic[igroup] = 0; - - // not a valid group style - - } else error->all(FLERR,"Illegal group command"); + throw e; + } // print stats for changed group @@ -539,13 +548,12 @@ void Group::assign(int narg, char **arg) void Group::assign(const std::string &groupcmd) { auto args = utils::split_words(groupcmd); - char **newarg = new char*[args.size()]; + std::vector newarg(args.size()); int i=0; for (const auto &arg : args) { newarg[i++] = (char *)arg.c_str(); } - assign(args.size(),newarg); - delete[] newarg; + assign(args.size(),newarg.data()); } /* ---------------------------------------------------------------------- diff --git a/src/modify.cpp b/src/modify.cpp index 79a0ecd41f..246b855913 100644 --- a/src/modify.cpp +++ b/src/modify.cpp @@ -964,13 +964,12 @@ void Modify::add_fix(int narg, char **arg, int trysuffix) void Modify::add_fix(const std::string &fixcmd, int trysuffix) { auto args = utils::split_words(fixcmd); - char **newarg = new char*[args.size()]; - int i=0; + std::vector newarg(args.size()); + int i = 0; for (const auto &arg : args) { newarg[i++] = (char *)arg.c_str(); } - add_fix(args.size(),newarg,trysuffix); - delete[] newarg; + add_fix(args.size(),newarg.data(),trysuffix); } diff --git a/src/pair_coul_streitz.cpp b/src/pair_coul_streitz.cpp index 55529f9eae..87bcd45736 100644 --- a/src/pair_coul_streitz.cpp +++ b/src/pair_coul_streitz.cpp @@ -36,7 +36,6 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define MAXLINE 1024 #define DELTA 4 #define PGDELTA 1 #define MAXNEIGH 24 diff --git a/src/pair_hybrid.cpp b/src/pair_hybrid.cpp index 48ba1ccff7..002429e7b3 100644 --- a/src/pair_hybrid.cpp +++ b/src/pair_hybrid.cpp @@ -547,6 +547,15 @@ void PairHybrid::init_style() if (used == 0) error->all(FLERR,"Pair hybrid sub-style is not used"); } + // The GPU library uses global data for each pair style, so the + // same style must not be used multiple times + + for (istyle = 0; istyle < nstyles; istyle++) { + bool is_gpu = (((PairHybrid *)styles[istyle])->suffix_flag & Suffix::GPU); + if (multiple[istyle] && is_gpu) + error->all(FLERR,"GPU package styles must not be used multiple times"); + } + // check if special_lj/special_coul overrides are compatible for (istyle = 0; istyle < nstyles; istyle++) { diff --git a/src/run.cpp b/src/run.cpp index 379cf8015a..1534d506d6 100644 --- a/src/run.cpp +++ b/src/run.cpp @@ -27,8 +27,6 @@ using namespace LAMMPS_NS; -#define MAXLINE 2048 - /* ---------------------------------------------------------------------- */ Run::Run(LAMMPS *lmp) : Command(lmp) {} diff --git a/src/variable.cpp b/src/variable.cpp index f66b99d6e5..3e93a33797 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -412,7 +412,7 @@ void Variable::set(int narg, char **arg) if (style[ivar] != EQUAL) error->all(FLERR,"Cannot redefine variable as a different style"); delete [] data[ivar][0]; - copy(1,&arg[2],data[ivar]); + data[ivar][0] = utils::strdup(arg[2]); replaceflag = 1; } else { if (nvar == maxvar) grow(); @@ -421,7 +421,7 @@ void Variable::set(int narg, char **arg) which[nvar] = 0; pad[nvar] = 0; data[nvar] = new char*[num[nvar]]; - copy(1,&arg[2],data[nvar]); + data[nvar][0] = utils::strdup(arg[2]); data[nvar][1] = new char[VALUELENGTH]; strcpy(data[nvar][1],"(undefined)"); } @@ -438,7 +438,7 @@ void Variable::set(int narg, char **arg) if (style[ivar] != ATOM) error->all(FLERR,"Cannot redefine variable as a different style"); delete [] data[ivar][0]; - copy(1,&arg[2],data[ivar]); + data[ivar][0] = utils::strdup(arg[2]); replaceflag = 1; } else { if (nvar == maxvar) grow(); @@ -447,7 +447,7 @@ void Variable::set(int narg, char **arg) which[nvar] = 0; pad[nvar] = 0; data[nvar] = new char*[num[nvar]]; - copy(1,&arg[2],data[nvar]); + data[nvar][0] = utils::strdup(arg[2]); } // VECTOR @@ -462,7 +462,7 @@ void Variable::set(int narg, char **arg) if (style[ivar] != VECTOR) error->all(FLERR,"Cannot redefine variable as a different style"); delete [] data[ivar][0]; - copy(1,&arg[2],data[ivar]); + data[ivar][0] = utils::strdup(arg[2]); replaceflag = 1; } else { if (nvar == maxvar) grow(); @@ -471,7 +471,7 @@ void Variable::set(int narg, char **arg) which[nvar] = 0; pad[nvar] = 0; data[nvar] = new char*[num[nvar]]; - copy(1,&arg[2],data[nvar]); + data[nvar][0] = utils::strdup(arg[2]); } // PYTHON @@ -488,7 +488,7 @@ void Variable::set(int narg, char **arg) if (style[ivar] != PYTHON) error->all(FLERR,"Cannot redefine variable as a different style"); delete [] data[ivar][0]; - copy(1,&arg[2],data[ivar]); + data[ivar][0] = utils::strdup(arg[2]); replaceflag = 1; } else { if (nvar == maxvar) grow(); @@ -497,7 +497,7 @@ void Variable::set(int narg, char **arg) which[nvar] = 1; pad[nvar] = 0; data[nvar] = new char*[num[nvar]]; - copy(1,&arg[2],data[nvar]); + data[nvar][0] = utils::strdup(arg[2]); data[nvar][1] = new char[VALUELENGTH]; strcpy(data[nvar][1],"(undefined)"); } diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index 4e27f4be45..412cf8d3d6 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -7,6 +7,7 @@ add_test(NAME RunLammps COMMAND $ -log none -echo none -in in.empty WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) set_tests_properties(RunLammps PROPERTIES + ENVIRONMENT "TSAN_OPTIONS='ignore_noninstrumented_modules=1'" PASS_REGULAR_EXPRESSION "^LAMMPS \\([0-9]+ [A-Za-z]+ 2[0-9][0-9][0-9]\\)") if(BUILD_MPI) diff --git a/unittest/commands/CMakeLists.txt b/unittest/commands/CMakeLists.txt index a970cdc838..9987fdb071 100644 --- a/unittest/commands/CMakeLists.txt +++ b/unittest/commands/CMakeLists.txt @@ -56,3 +56,10 @@ add_executable(test_reset_ids test_reset_ids.cpp) target_compile_definitions(test_reset_ids PRIVATE -DTEST_INPUT_FOLDER=${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries(test_reset_ids PRIVATE lammps GTest::GMock GTest::GTest) add_test(NAME ResetIDs COMMAND test_reset_ids WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + +if(BUILD_MPI) + add_executable(test_mpi_load_balancing test_mpi_load_balancing.cpp) + target_link_libraries(test_mpi_load_balancing PRIVATE lammps GTest::GTest GTest::GMock) + target_compile_definitions(test_mpi_load_balancing PRIVATE ${TEST_CONFIG_DEFS}) + add_mpi_test(NAME MPILoadBalancing NUM_PROCS 4 COMMAND $) +endif() diff --git a/unittest/commands/test_groups.cpp b/unittest/commands/test_groups.cpp index 181f000a7c..7feddcc685 100644 --- a/unittest/commands/test_groups.cpp +++ b/unittest/commands/test_groups.cpp @@ -297,7 +297,7 @@ TEST_F(GroupTest, Dynamic) command("group grow delete"); command("variable ramp equal step"); END_HIDE_OUTPUT(); - ASSERT_EQ(group->ngroup, 4); + ASSERT_EQ(group->ngroup, 3); TEST_FAILURE(".*ERROR: Group dynamic cannot reference itself.*", command("group half dynamic half region top");); diff --git a/unittest/commands/test_mpi_load_balancing.cpp b/unittest/commands/test_mpi_load_balancing.cpp new file mode 100644 index 0000000000..39e39e5da8 --- /dev/null +++ b/unittest/commands/test_mpi_load_balancing.cpp @@ -0,0 +1,257 @@ +// unit tests for checking LAMMPS MPI load balancing + +#define LAMMPS_LIB_MPI 1 +#include "lammps.h" +#include "atom.h" +#include "comm.h" +#include "domain.h" +#include "neighbor.h" +#include "input.h" +#include "timer.h" +#include "info.h" +#include + +#include "gmock/gmock.h" +#include "gtest/gtest.h" + +#include "../testing/test_mpi_main.h" + +using ::testing::ExitedWithCode; +using ::testing::HasSubstr; +using ::testing::StartsWith; +using ::testing::StrEq; + +namespace LAMMPS_NS +{ + +class MPILoadBalanceTest : public ::testing::Test { +public: + void command(const std::string &line) { lmp->input->one(line); } + +protected: + const char *testbinary = "LAMMPSTest"; + LAMMPS *lmp; + + void SetUp() override + { + const char *args[] = {testbinary, "-log", "none", "-echo", "screen", "-nocite"}; + char **argv = (char **)args; + int argc = sizeof(args) / sizeof(char *); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD); + InitSystem(); + if (!verbose) ::testing::internal::GetCapturedStdout(); + } + + virtual void InitSystem() + { + command("boundary f f f"); + command("units lj"); + command("atom_style atomic"); + command("atom_modify map yes"); + + command("region box block 0 20 0 20 0 20"); + command("create_box 1 box"); + command("mass 1 1.0"); + + + command("pair_style lj/cut 2.5"); + command("pair_coeff 1 1 1.0 1.0 2.5"); + + command("neighbor 0.3 bin"); + command("neigh_modify every 20 delay 0 check no"); + } + + void TearDown() override + { + if (!verbose) ::testing::internal::CaptureStdout(); + delete lmp; + lmp = nullptr; + if (!verbose) ::testing::internal::GetCapturedStdout(); + } +}; + +TEST_F(MPILoadBalanceTest, grid_yz) +{ + command("create_atoms 1 single 0 0 0"); + command("create_atoms 1 single 0 0 5"); + command("create_atoms 1 single 0 5 0"); + command("create_atoms 1 single 0 5 5"); + command("create_atoms 1 single 5 0 0"); + command("create_atoms 1 single 5 0 5"); + command("create_atoms 1 single 5 5 0"); + command("create_atoms 1 single 5 5 5"); + ASSERT_EQ(lmp->atom->natoms, 8); + ASSERT_EQ(lmp->comm->nprocs, 4); + + // initial state + switch(lmp->comm->me) { + case 0: + ASSERT_EQ(lmp->atom->nlocal, 8); + break; + case 1: + ASSERT_EQ(lmp->atom->nlocal, 0); + break; + case 2: + ASSERT_EQ(lmp->atom->nlocal, 0); + break; + case 3: + ASSERT_EQ(lmp->atom->nlocal, 0); + break; + } + + command("balance 1 x uniform y 0.125 z uniform"); + + // state after balance command + switch(lmp->comm->me) { + case 0: + ASSERT_EQ(lmp->atom->nlocal, 4); + break; + case 1: + ASSERT_EQ(lmp->atom->nlocal, 0); + break; + case 2: + ASSERT_EQ(lmp->atom->nlocal, 4); + break; + case 3: + ASSERT_EQ(lmp->atom->nlocal, 0); + break; + } + + command("balance 1 x uniform y 0.125 z 0.125"); + + // state after second balance command + switch(lmp->comm->me) { + case 0: + ASSERT_EQ(lmp->atom->nlocal, 2); + break; + case 1: + ASSERT_EQ(lmp->atom->nlocal, 2); + break; + case 2: + ASSERT_EQ(lmp->atom->nlocal, 2); + break; + case 3: + ASSERT_EQ(lmp->atom->nlocal, 2); + break; + } +} + +TEST_F(MPILoadBalanceTest, rcb) +{ + command("comm_style tiled"); + command("create_atoms 1 single 0 0 0"); + command("create_atoms 1 single 0 0 5"); + command("create_atoms 1 single 0 5 0"); + command("create_atoms 1 single 0 5 5"); + command("create_atoms 1 single 5 0 0"); + command("create_atoms 1 single 5 0 5"); + command("create_atoms 1 single 5 5 0"); + command("create_atoms 1 single 5 5 5"); + + // initial state + switch(lmp->comm->me) { + case 0: + ASSERT_EQ(lmp->atom->nlocal, 8); + break; + case 1: + ASSERT_EQ(lmp->atom->nlocal, 0); + break; + case 2: + ASSERT_EQ(lmp->atom->nlocal, 0); + break; + case 3: + ASSERT_EQ(lmp->atom->nlocal, 0); + break; + } + + command("balance 1 rcb"); + + // state after balance command + switch(lmp->comm->me) { + case 0: + ASSERT_EQ(lmp->atom->nlocal, 2); + break; + case 1: + ASSERT_EQ(lmp->atom->nlocal, 2); + break; + case 2: + ASSERT_EQ(lmp->atom->nlocal, 2); + break; + case 3: + ASSERT_EQ(lmp->atom->nlocal, 2); + break; + } + + // box dimensions should have minimal size + double dx = lmp->domain->subhi[0] - lmp->domain->sublo[0]; + double dy = lmp->domain->subhi[1] - lmp->domain->sublo[1]; + double dz = lmp->domain->subhi[2] - lmp->domain->sublo[2]; + + ASSERT_GT(dx, lmp->neighbor->skin); + ASSERT_GT(dy, lmp->neighbor->skin); + ASSERT_GT(dz, lmp->neighbor->skin); +} + +TEST_F(MPILoadBalanceTest, rcb_min_size) +{ + GTEST_SKIP(); + // TODO minimum domain size is not enforced right now + // skipping for now to allow other MPI tests to get merged + command("comm_style tiled"); + command("create_atoms 1 single 0 0 0"); + command("create_atoms 1 single 0 0 0.25"); + command("create_atoms 1 single 0 0.25 0"); + command("create_atoms 1 single 0 0.25 0.25"); + command("create_atoms 1 single 0.25 0 0"); + command("create_atoms 1 single 0.25 0 0.25"); + command("create_atoms 1 single 0.25 0.25 0"); + command("create_atoms 1 single 0.25 0.25 0.25"); + + // initial state + switch(lmp->comm->me) { + case 0: + ASSERT_EQ(lmp->atom->nlocal, 8); + break; + case 1: + ASSERT_EQ(lmp->atom->nlocal, 0); + break; + case 2: + ASSERT_EQ(lmp->atom->nlocal, 0); + break; + case 3: + ASSERT_EQ(lmp->atom->nlocal, 0); + break; + } + + // this should fail and not change the boxes + // or keep them at a minimum size + command("balance 1 rcb"); + + // state after balance command + switch(lmp->comm->me) { + case 0: + ASSERT_EQ(lmp->atom->nlocal, 8); + break; + case 1: + ASSERT_EQ(lmp->atom->nlocal, 0); + break; + case 2: + ASSERT_EQ(lmp->atom->nlocal, 0); + break; + case 3: + ASSERT_EQ(lmp->atom->nlocal, 0); + break; + } + + // box dimensions should have minimal size + double dx = lmp->domain->subhi[0] - lmp->domain->sublo[0]; + double dy = lmp->domain->subhi[1] - lmp->domain->sublo[1]; + double dz = lmp->domain->subhi[2] - lmp->domain->sublo[2]; + + ASSERT_GT(dx, lmp->neighbor->skin); + ASSERT_GT(dy, lmp->neighbor->skin); + ASSERT_GT(dz, lmp->neighbor->skin); +} + +} diff --git a/unittest/force-styles/tests/atomic-pair-hybrid-eam.yaml b/unittest/force-styles/tests/atomic-pair-hybrid-eam.yaml index a681657b65..4c8e040200 100644 --- a/unittest/force-styles/tests/atomic-pair-hybrid-eam.yaml +++ b/unittest/force-styles/tests/atomic-pair-hybrid-eam.yaml @@ -1,6 +1,6 @@ --- -lammps_version: 10 Feb 2021 -date_generated: Fri Feb 26 23:09:02 2021 +lammps_version: 8 Apr 2021 +date_generated: Mon Apr 19 08:49:08 2021 epsilon: 1e-11 prerequisites: ! | pair eam/fs @@ -13,7 +13,7 @@ pair_coeff: ! | 2 2 eam Ni_u3.eam extract: ! "" natoms: 32 -init_vdwl: 0.713225916338978 +init_vdwl: 0.7132259163389776 init_coul: 0 init_stress: ! |2- 2.6556151567263032e+02 2.6660724159085703e+02 2.4812081237895359e+02 6.0264893464561915e+00 -6.6027371615114303e+00 -1.4187579099120772e+01 @@ -50,7 +50,7 @@ init_forces: ! |2 30 -8.7442364632334701e-01 -8.5922993943854902e+00 -3.1671240722317777e+00 31 3.1880080741982892e+00 -5.0021160844369490e+00 -2.7083467494366831e-01 32 -1.5986786450380142e+01 -5.5759911113046883e+00 -1.5504124024744577e+00 -run_vdwl: 0.669352105052575 +run_vdwl: 0.6693521050525746 run_coul: 0 run_stress: ! |2- 2.6541041873586806e+02 2.6644256162479292e+02 2.4793398704069506e+02 5.9903981717659827e+00 -6.6045526000630410e+00 -1.4160943794248436e+01 diff --git a/unittest/force-styles/tests/atomic-pair-hybrid-eam_fs.yaml b/unittest/force-styles/tests/atomic-pair-hybrid-eam_fs.yaml index d2f511b3ea..be3889de90 100644 --- a/unittest/force-styles/tests/atomic-pair-hybrid-eam_fs.yaml +++ b/unittest/force-styles/tests/atomic-pair-hybrid-eam_fs.yaml @@ -1,6 +1,6 @@ --- -lammps_version: 10 Feb 2021 -date_generated: Fri Feb 26 23:09:03 2021 +lammps_version: 8 Apr 2021 +date_generated: Mon Apr 19 08:49:08 2021 epsilon: 5e-12 prerequisites: ! | pair eam/fs @@ -13,7 +13,7 @@ pair_coeff: ! | * * eam/fs AlFe_mm.eam.fs NULL Al extract: ! "" natoms: 32 -init_vdwl: 15.6583494469006 +init_vdwl: 15.658349446900637 init_coul: 0 init_stress: ! |2- 3.1757662346015599e+02 3.1488042003987044e+02 2.9518192213010605e+02 8.0970202601485379e+00 -4.6038792816319125e+00 -1.1521259274290610e+01 @@ -50,7 +50,7 @@ init_forces: ! |2 30 -2.0584055270338175e+00 -5.2207163606526530e+00 -4.6304543222177532e+00 31 1.2014109675977875e+00 -6.5554529419137078e+00 2.1453874832093329e+00 32 -1.5986786450380142e+01 -5.5759911113046883e+00 -1.5504124024744577e+00 -run_vdwl: 15.6055369596825 +run_vdwl: 15.605536959682482 run_coul: 0 run_stress: ! |2- 3.1739734448741643e+02 3.1467775824072135e+02 2.9494960877836593e+02 8.0575431550134713e+00 -4.6069278562709943e+00 -1.1484582135772436e+01 diff --git a/unittest/force-styles/tests/manybody-pair-tersoff.yaml b/unittest/force-styles/tests/manybody-pair-tersoff.yaml index 7626e4e5de..366810b84e 100644 --- a/unittest/force-styles/tests/manybody-pair-tersoff.yaml +++ b/unittest/force-styles/tests/manybody-pair-tersoff.yaml @@ -2,7 +2,6 @@ lammps_version: 10 Feb 2021 date_generated: Fri Feb 26 23:09:20 2021 epsilon: 5e-13 -skip_tests: gpu prerequisites: ! | pair tersoff pre_commands: ! | diff --git a/unittest/force-styles/tests/manybody-pair-tersoff_zbl.yaml b/unittest/force-styles/tests/manybody-pair-tersoff_zbl.yaml index a8d668ac3b..c1da0c1543 100644 --- a/unittest/force-styles/tests/manybody-pair-tersoff_zbl.yaml +++ b/unittest/force-styles/tests/manybody-pair-tersoff_zbl.yaml @@ -1,8 +1,7 @@ --- lammps_version: 10 Feb 2021 date_generated: Fri Feb 26 23:09:20 2021 -epsilon: 5e-11 -skip_tests: gpu +epsilon: 5e-9 prerequisites: ! | pair tersoff/zbl pre_commands: ! | diff --git a/unittest/force-styles/tests/mol-pair-hybrid-overlay.yaml b/unittest/force-styles/tests/mol-pair-hybrid-overlay.yaml index 0967d5727b..4aeae6cd1b 100644 --- a/unittest/force-styles/tests/mol-pair-hybrid-overlay.yaml +++ b/unittest/force-styles/tests/mol-pair-hybrid-overlay.yaml @@ -1,8 +1,7 @@ --- -lammps_version: 10 Feb 2021 -date_generated: Fri Feb 26 23:08:45 2021 -epsilon: 5e-14 -skip_tests: gpu +lammps_version: 8 Apr 2021 +date_generated: Mon Apr 19 08:49:07 2021 +epsilon: 7.5e-14 prerequisites: ! | atom full pair lj/cut @@ -17,86 +16,85 @@ pair_coeff: ! | 1 2 lj/cut 0.01 1.75 8 1 3 lj/cut 0.02 2.85 8 1 4 lj/cut 0.0173205 2.8 8 - 1 5 lj/cut 0.0173205 2.8 8 2 2 lj/cut 0.005 1 8 2 3 lj/cut 0.01 2.1 8 2 4 lj/cut 0.005 0.5 8 2 5 lj/cut 0.00866025 2.05 8 3 3 lj/cut 0.02 3.2 8 - 3 4 lj/cut 0.0173205 3.15 8 3 5 lj/cut 0.0173205 3.15 8 4 4 lj/cut 0.015 3.1 8 4 5 lj/cut 0.015 3.1 8 5 5 lj/cut 0.015 3.1 8 * * coul/cut + 3 3 none extract: ! "" natoms: 29 -init_vdwl: 749.237031537357 -init_coul: -127.494586297384 +init_vdwl: 745.8729165577952 +init_coul: -138.51281549901438 init_stress: ! |2- - 2.1525607963688685e+03 2.1557327421151899e+03 4.6078904881742919e+03 -7.6038602729615206e+02 1.6844266627640316e+01 6.6957549356541904e+02 + 2.1433945387773583e+03 2.1438418525427405e+03 4.5749493230631624e+03 -7.5161300805564053e+02 2.2812993218099149e+00 6.7751226426357493e+02 init_forces: ! |2 - 1 -2.1092656751925425e+01 2.6988675971196511e+02 3.3315496490210148e+02 + 1 -1.9649291084632637e+01 2.6691357149380127e+02 3.3265232188338541e+02 2 1.5859534558925552e+02 1.2807631885753918e+02 -1.8817306436807144e+02 - 3 -1.3530454720678361e+02 -3.8712939850050407e+02 -1.4565941679363837e+02 + 3 -1.3530567831970495e+02 -3.8712983044177196e+02 -1.4566129338928388e+02 4 -7.8195539840070643e+00 2.1451967639963558e+00 -5.9041143405612999e+00 5 -2.9163954623584245e+00 -3.3469203159528891e+00 1.2074681739853981e+01 - 6 -8.2989063447195736e+02 9.6019318342576571e+02 1.1479359629470548e+03 - 7 5.7874538635311936e+01 -3.3533985555183068e+02 -1.7140659049826711e+03 - 8 1.4280513303191131e+02 -1.0509295075299345e+02 4.0233495763755388e+02 + 6 -8.2989098462283039e+02 9.6019325436904921e+02 1.1479348548947717e+03 + 7 6.6019203897045301e+01 -3.4002739206175022e+02 -1.6963964881803979e+03 + 8 1.3359110241269076e+02 -9.8018932606492385e+01 3.8583797257557939e+02 9 8.0984846358566287e+01 7.9600519879262990e+01 3.5197302607961126e+02 - 10 5.3089511229361369e+02 -6.0998478582862322e+02 -1.8376190026890427e+02 + 10 5.3089359350918085e+02 -6.0998285656765029e+02 -1.8376081267141316e+02 11 -3.3416993160125812e+00 -4.7792759715873308e+00 -1.0199030124309976e+01 - 12 2.0837574127335213e+01 9.8678992274266921e+00 -6.6547856883058829e+00 + 12 2.0835873540321462e+01 9.8712254444709888e+00 -6.6533607886298407e+00 13 7.7163253261199216e+00 -3.2213746930547997e+00 -1.5767800864580894e-01 14 -4.6138299494911639e+00 1.1336312962250332e+00 -8.7660603717255832e+00 15 1.6301594996052212e-02 8.3212544078493291e+00 2.0473863128880430e+00 - 16 4.6221152690976908e+02 -3.3124444344467344e+02 -1.1865036959698600e+03 - 17 -4.5568726200724092e+02 3.2159231068141992e+02 1.1980747895060381e+03 - 18 1.2559081069243214e+00 6.6417071126352401e+00 -9.8829024661057083e+00 + 16 4.6221076301291345e+02 -3.3124285139751140e+02 -1.1865012258764175e+03 + 17 -4.5606960458862824e+02 3.2217194951510470e+02 1.1974188947377352e+03 + 18 1.2642503785059469e+00 6.6487748605328285e+00 -9.8967964193854954e+00 19 1.6184514948299680e+00 -1.6594104323923884e+00 5.6561121961572223e+00 20 -3.4526823962510336e+00 -3.1794201827804485e+00 4.2593058942069533e+00 - 21 -6.9075184494915916e+01 -8.0130885501011278e+01 2.1539206802020570e+02 + 21 -6.9068952751967188e+01 -8.0138116375988346e+01 2.1538477896980064e+02 22 -1.0659100672969126e+02 -2.5122518903211912e+01 -1.6283765584018167e+02 23 1.7515797811309091e+02 1.0400246780074602e+02 -5.2024018223038112e+01 - 24 3.4171625917777114e+01 -2.0194713552213176e+02 1.0982444762500101e+02 + 24 3.4173068949839667e+01 -2.0194449586908348e+02 1.0982812303394964e+02 25 -1.4493448920889654e+02 2.0799041369281703e+01 -1.2091050237305346e+02 26 1.0983611557367320e+02 1.8026252731144598e+02 1.2199612526237862e+01 - 27 4.8962849172262665e+01 -2.1594262411895852e+02 8.6423873663236122e+01 + 27 4.8960638929347951e+01 -2.1594451942422438e+02 8.6425489362011916e+01 28 -1.7556665080686602e+02 7.2243004627719102e+01 -1.1798867746650107e+02 29 1.2734696054095977e+02 1.4335517724642804e+02 3.2138218235426962e+01 -run_vdwl: 719.583657033589 -run_coul: -127.40544584254 +run_vdwl: 716.3802195867241 +run_coul: -138.41949137400766 run_stress: ! |2- - 2.1066855251881925e+03 2.1118463017620702e+03 4.3411898896739367e+03 -7.3939094916433964e+02 3.4004309224046892e+01 6.3091802194682043e+02 + 2.0979303990927456e+03 2.1001765345686881e+03 4.3095704231054315e+03 -7.3090278796437826e+02 1.9971774954468970e+01 6.3854079301261561e+02 run_forces: ! |2 - 1 -1.8063372896871861e+01 2.6678105157873705e+02 3.2402996659149238e+02 - 2 1.5330358878115447e+02 1.2380492572678898e+02 -1.8151333240574237e+02 - 3 -1.3354888440944052e+02 -3.7931758440809585e+02 -1.4288689214683646e+02 - 4 -7.7881294728555828e+00 2.1395223669670709e+00 -5.8946911982403414e+00 - 5 -2.9015406841040750e+00 -3.3190775902304690e+00 1.2028378254388521e+01 - 6 -8.0488833369818803e+02 9.1802981835006187e+02 1.0244099127408372e+03 - 7 5.5465440662485150e+01 -3.1049131627300432e+02 -1.5711945284966396e+03 - 8 1.3295629283853211e+02 -9.6566834572636509e+01 3.9097872808487460e+02 - 9 7.8594917874857543e+01 7.6787239820699739e+01 3.4114513928465578e+02 - 10 5.2093084326233679e+02 -5.9871672888830824e+02 -1.8144904320802175e+02 - 11 -3.3489474910616370e+00 -4.7299066233626039e+00 -1.0148722292306179e+01 - 12 2.0817110693939330e+01 9.8621648346024777e+00 -6.7801624810903709e+00 - 13 7.6705047254095406e+00 -3.1868508087899996e+00 -1.5820764985177732e-01 - 14 -4.5784791310044675e+00 1.1138053855319887e+00 -8.6502065778611730e+00 - 15 -2.0858645012343142e-03 8.3343285345071436e+00 2.0653788728248101e+00 - 16 4.3381526742384807e+02 -3.1216388880293573e+02 -1.1109931745334770e+03 - 17 -4.2715774864577224e+02 3.0231264864237801e+02 1.1227484174344033e+03 - 18 1.2031503133104606e+00 6.6109154581424221e+00 -9.8172457746610178e+00 - 19 1.6542029696015907e+00 -1.6435312394752812e+00 5.6634735276627497e+00 - 20 -3.4397850729417945e+00 -3.1640002526012512e+00 4.1983600861482540e+00 - 21 -6.8065111490654829e+01 -7.8373161130023504e+01 2.1145341222255522e+02 - 22 -1.0497862711706458e+02 -2.4878742273401844e+01 -1.5988817620288421e+02 - 23 1.7253257365878264e+02 1.0200250230245655e+02 -5.1030905034776815e+01 - 24 3.5759299481226734e+01 -2.0057859782619599e+02 1.1032111627497152e+02 - 25 -1.4570195714964908e+02 2.0679748005808605e+01 -1.2162175868970056e+02 - 26 1.0901403460528100e+02 1.7901644500696690e+02 1.2412674623332103e+01 - 27 4.8035883250870448e+01 -2.1205445789284894e+02 8.4315888267103702e+01 - 28 -1.7229323056476886e+02 7.0823266235363889e+01 -1.1557273097021344e+02 - 29 1.2500312314724302e+02 1.4088629633289813e+02 3.1828931397054006e+01 + 1 -1.6610877533029917e+01 2.6383021332799052e+02 3.2353483319348879e+02 + 2 1.5330154436698174e+02 1.2380568506592064e+02 -1.8151165007810525e+02 + 3 -1.3355888938990938e+02 -3.7933844699879148e+02 -1.4289670293816388e+02 + 4 -7.7881120826204668e+00 2.1395098313701606e+00 -5.8946811108039316e+00 + 5 -2.9015331574965137e+00 -3.3190957550906650e+00 1.2028358182322860e+01 + 6 -8.0526764288323773e+02 9.1843645125221315e+02 1.0247463799396066e+03 + 7 6.3415313059583099e+01 -3.1516725367592539e+02 -1.5545584841600896e+03 + 8 1.2443895440675962e+02 -8.9966546620018491e+01 3.7528288654519253e+02 + 9 7.8562021792928846e+01 7.6737772485099740e+01 3.4097956793351517e+02 + 10 5.2084083656240523e+02 -5.9861234059469723e+02 -1.8138805681750645e+02 + 11 -3.3489824667518393e+00 -4.7298446901938807e+00 -1.0148711690275450e+01 + 12 2.0815589888478105e+01 9.8654168641522730e+00 -6.7785848461804141e+00 + 13 7.6704892224392722e+00 -3.1868449584865046e+00 -1.5821377982473980e-01 + 14 -4.5785422362324342e+00 1.1138107530543817e+00 -8.6501509346025998e+00 + 15 -2.1389037192471316e-03 8.3343251445103643e+00 2.0653551218031234e+00 + 16 4.3381854759590340e+02 -3.1216576452973555e+02 -1.1109981398263690e+03 + 17 -4.2754398440828430e+02 3.0289566960675381e+02 1.1220989215843697e+03 + 18 1.2114513551044401e+00 6.6180216089215458e+00 -9.8312525087926925e+00 + 19 1.6542558848822984e+00 -1.6435031778340830e+00 5.6635143081937196e+00 + 20 -3.4397798875877807e+00 -3.1640142907323199e+00 4.1983853511543821e+00 + 21 -6.8058847895033125e+01 -7.8380439852912886e+01 2.1144611822725810e+02 + 22 -1.0497864675042641e+02 -2.4878735013483009e+01 -1.5988818740798348e+02 + 23 1.7253258234009186e+02 1.0200252121753527e+02 -5.1030908277968685e+01 + 24 3.5760727178399790e+01 -2.0057598226072813e+02 1.1032480117076591e+02 + 25 -1.4570194437506802e+02 2.0679739580300286e+01 -1.2162176434722556e+02 + 26 1.0901404321356092e+02 1.7901646282634897e+02 1.2412667553028452e+01 + 27 4.8033700837518651e+01 -2.1205635024551196e+02 8.4317526475629421e+01 + 28 -1.7229323238986416e+02 7.0823275743089638e+01 -1.1557274387241809e+02 + 29 1.2500309665422407e+02 1.4088628735688107e+02 3.1828917009980870e+01 ... diff --git a/unittest/force-styles/tests/mol-pair-hybrid-scaled.yaml b/unittest/force-styles/tests/mol-pair-hybrid-scaled.yaml index cc3acb50f0..e9a036b545 100644 --- a/unittest/force-styles/tests/mol-pair-hybrid-scaled.yaml +++ b/unittest/force-styles/tests/mol-pair-hybrid-scaled.yaml @@ -1,6 +1,6 @@ --- -lammps_version: 10 Feb 2021 -date_generated: Fri Feb 26 23:08:45 2021 +lammps_version: 8 Apr 2021 +date_generated: Mon Apr 19 08:49:07 2021 epsilon: 5e-14 skip_tests: gpu intel omp prerequisites: ! | @@ -31,74 +31,75 @@ pair_coeff: ! | 5 5 lj/cut 0.015 3.1 8 * * coul/cut 1 * * coul/cut 2 + 2 3 none extract: ! "" natoms: 29 -init_vdwl: 749.237031537357 -init_coul: -127.494586297384 +init_vdwl: 695.3728483503972 +init_coul: 118.95803822933868 init_stress: ! |2- - 2.1525607963688685e+03 2.1557327421151899e+03 4.6078904881742919e+03 -7.6038602729615206e+02 1.6844266627640316e+01 6.6957549356541904e+02 + 2.1020038760662910e+03 2.1696900014167491e+03 4.2400143530641753e+03 -8.4820804228720078e+02 3.1662186032408862e+01 6.7609982605789560e+02 init_forces: ! |2 - 1 -2.1092656751925425e+01 2.6988675971196511e+02 3.3315496490210148e+02 - 2 1.5859534558925552e+02 1.2807631885753918e+02 -1.8817306436807144e+02 + 1 1.2395744433084418e+02 4.0360040310773837e+02 1.4710329775938777e+02 + 2 2.0403866219573294e+00 3.7427015227202860e+00 -5.2095053499948687e+00 3 -1.3530454720678361e+02 -3.8712939850050407e+02 -1.4565941679363837e+02 - 4 -7.8195539840070643e+00 2.1451967639963558e+00 -5.9041143405612999e+00 - 5 -2.9163954623584245e+00 -3.3469203159528891e+00 1.2074681739853981e+01 - 6 -8.2989063447195736e+02 9.6019318342576571e+02 1.1479359629470548e+03 - 7 5.7874538635311936e+01 -3.3533985555183068e+02 -1.7140659049826711e+03 - 8 1.4280513303191131e+02 -1.0509295075299345e+02 4.0233495763755388e+02 - 9 8.0984846358566287e+01 7.9600519879262990e+01 3.5197302607961126e+02 - 10 5.3089511229361369e+02 -6.0998478582862322e+02 -1.8376190026890427e+02 - 11 -3.3416993160125812e+00 -4.7792759715873308e+00 -1.0199030124309976e+01 - 12 2.0837574127335213e+01 9.8678992274266921e+00 -6.6547856883058829e+00 - 13 7.7163253261199216e+00 -3.2213746930547997e+00 -1.5767800864580894e-01 - 14 -4.6138299494911639e+00 1.1336312962250332e+00 -8.7660603717255832e+00 - 15 1.6301594996052212e-02 8.3212544078493291e+00 2.0473863128880430e+00 - 16 4.6221152690976908e+02 -3.3124444344467344e+02 -1.1865036959698600e+03 - 17 -4.5568726200724092e+02 3.2159231068141992e+02 1.1980747895060381e+03 - 18 1.2559081069243214e+00 6.6417071126352401e+00 -9.8829024661057083e+00 - 19 1.6184514948299680e+00 -1.6594104323923884e+00 5.6561121961572223e+00 - 20 -3.4526823962510336e+00 -3.1794201827804485e+00 4.2593058942069533e+00 + 4 -8.8457203481064290e+00 2.0775655304814062e+00 -6.4577920902830810e+00 + 5 -3.8621595793596168e+00 -3.4155992315339034e+00 1.2662823025931699e+01 + 6 -8.2989063447195713e+02 9.6019318342576582e+02 1.1479359629470543e+03 + 7 5.7874538635311936e+01 -3.3533985555183062e+02 -1.7140659049826709e+03 + 8 2.1951760889665016e+02 -2.7745841022748479e+01 7.5004437999744698e+02 + 9 5.2714873038389127e+00 -8.4861250407806690e+00 6.9224510478542918e+00 + 10 5.3089511229361347e+02 -6.0998478582862344e+02 -1.8376190026890421e+02 + 11 -2.8872927401613704e+00 -5.8162507264509147e+00 -1.0845838127234256e+01 + 12 2.0837574127335216e+01 9.8678992274266957e+00 -6.6547856883058802e+00 + 13 8.7535743331999196e+00 -3.5826004829028451e+00 -5.0574000969376898e-01 + 14 -3.5497769084795245e+00 7.9766504428704821e-01 -1.0037637362299094e+01 + 15 1.9984402152167433e+00 8.5838951595651096e+00 1.4145761197403108e+00 + 16 4.6221152690976896e+02 -3.3124444344467344e+02 -1.1865036959698600e+03 + 17 -4.5568726200724080e+02 3.2159231068141997e+02 1.1980747895060381e+03 + 18 1.2559081069243216e+00 6.6417071126352401e+00 -9.8829024661057083e+00 + 19 3.1958200177362119e+00 3.7689524813885311e-01 4.2824321381874042e-01 + 20 -1.2082334569560751e+00 -9.0511517312734613e-01 9.8083091385568755e-01 21 -6.9075184494915916e+01 -8.0130885501011278e+01 2.1539206802020570e+02 - 22 -1.0659100672969126e+02 -2.5122518903211912e+01 -1.6283765584018167e+02 - 23 1.7515797811309091e+02 1.0400246780074602e+02 -5.2024018223038112e+01 - 24 3.4171625917777114e+01 -2.0194713552213176e+02 1.0982444762500101e+02 - 25 -1.4493448920889654e+02 2.0799041369281703e+01 -1.2091050237305346e+02 - 26 1.0983611557367320e+02 1.8026252731144598e+02 1.2199612526237862e+01 - 27 4.8962849172262665e+01 -2.1594262411895852e+02 8.6423873663236122e+01 - 28 -1.7556665080686602e+02 7.2243004627719102e+01 -1.1798867746650107e+02 - 29 1.2734696054095977e+02 1.4335517724642804e+02 3.2138218235426962e+01 -run_vdwl: 719.583657033589 -run_coul: -127.40544584254 + 22 -1.0570319068625072e+02 -2.6153578761410891e+01 -1.6388724340449593e+02 + 23 1.7632012115728725e+02 1.0321660965756321e+02 -5.2838552485947986e+01 + 24 3.4171625917777135e+01 -2.0194713552213176e+02 1.0982444762500104e+02 + 25 -1.4171132869700503e+02 2.4473995934890809e+01 -1.1380863842227539e+02 + 26 1.1207773375764390e+02 1.8255009969585140e+02 1.5493459542368809e+01 + 27 4.8962849172262672e+01 -2.1594262411895849e+02 8.6423873663236122e+01 + 28 -1.7737980202409483e+02 6.9833302792655687e+01 -1.1687995083239473e+02 + 29 1.2576338082394257e+02 1.4027600476554844e+02 3.4298300872164091e+01 +run_vdwl: 666.6114372300175 +run_coul: 119.0349803664172 run_stress: ! |2- - 2.1066855251881925e+03 2.1118463017620702e+03 4.3411898896739367e+03 -7.3939094916433964e+02 3.4004309224046892e+01 6.3091802194682043e+02 + 2.0554653461439952e+03 2.1240816159348624e+03 3.9864296321079441e+03 -8.2113807711720642e+02 4.5860921368817714e+01 6.3795624388863928e+02 run_forces: ! |2 - 1 -1.8063372896871861e+01 2.6678105157873705e+02 3.2402996659149238e+02 - 2 1.5330358878115447e+02 1.2380492572678898e+02 -1.8151333240574237e+02 - 3 -1.3354888440944052e+02 -3.7931758440809585e+02 -1.4288689214683646e+02 - 4 -7.7881294728555828e+00 2.1395223669670709e+00 -5.8946911982403414e+00 - 5 -2.9015406841040750e+00 -3.3190775902304690e+00 1.2028378254388521e+01 - 6 -8.0488833369818803e+02 9.1802981835006187e+02 1.0244099127408372e+03 - 7 5.5465440662485150e+01 -3.1049131627300432e+02 -1.5711945284966396e+03 - 8 1.3295629283853211e+02 -9.6566834572636509e+01 3.9097872808487460e+02 - 9 7.8594917874857543e+01 7.6787239820699739e+01 3.4114513928465578e+02 - 10 5.2093084326233679e+02 -5.9871672888830824e+02 -1.8144904320802175e+02 - 11 -3.3489474910616370e+00 -4.7299066233626039e+00 -1.0148722292306179e+01 - 12 2.0817110693939330e+01 9.8621648346024777e+00 -6.7801624810903709e+00 - 13 7.6705047254095406e+00 -3.1868508087899996e+00 -1.5820764985177732e-01 - 14 -4.5784791310044675e+00 1.1138053855319887e+00 -8.6502065778611730e+00 - 15 -2.0858645012343142e-03 8.3343285345071436e+00 2.0653788728248101e+00 - 16 4.3381526742384807e+02 -3.1216388880293573e+02 -1.1109931745334770e+03 - 17 -4.2715774864577224e+02 3.0231264864237801e+02 1.1227484174344033e+03 - 18 1.2031503133104606e+00 6.6109154581424221e+00 -9.8172457746610178e+00 - 19 1.6542029696015907e+00 -1.6435312394752812e+00 5.6634735276627497e+00 - 20 -3.4397850729417945e+00 -3.1640002526012512e+00 4.1983600861482540e+00 - 21 -6.8065111490654829e+01 -7.8373161130023504e+01 2.1145341222255522e+02 - 22 -1.0497862711706458e+02 -2.4878742273401844e+01 -1.5988817620288421e+02 - 23 1.7253257365878264e+02 1.0200250230245655e+02 -5.1030905034776815e+01 - 24 3.5759299481226734e+01 -2.0057859782619599e+02 1.1032111627497152e+02 - 25 -1.4570195714964908e+02 2.0679748005808605e+01 -1.2162175868970056e+02 - 26 1.0901403460528100e+02 1.7901644500696690e+02 1.2412674623332103e+01 - 27 4.8035883250870448e+01 -2.1205445789284894e+02 8.4315888267103702e+01 - 28 -1.7229323056476886e+02 7.0823266235363889e+01 -1.1557273097021344e+02 - 29 1.2500312314724302e+02 1.4088629633289813e+02 3.1828931397054006e+01 + 1 1.2147752778287347e+02 3.9534374510798301e+02 1.4413605468707195e+02 + 2 2.0399930128993224e+00 3.7557805682682748e+00 -5.2058063128492336e+00 + 3 -1.3333096721751764e+02 -3.7844737951764535e+02 -1.4238961467845959e+02 + 4 -8.8134959904656007e+00 2.0713309772867512e+00 -6.4488585600230390e+00 + 5 -3.8477726201647444e+00 -3.3895758075040905e+00 1.2617145909886416e+01 + 6 -8.0167356407303771e+02 9.1511139207343115e+02 1.0260272560535318e+03 + 7 5.5505611657656395e+01 -3.1051895449278589e+02 -1.5710947343097826e+03 + 8 2.0529374503578478e+02 -2.0214215494247814e+01 7.2625230302681450e+02 + 9 5.2759827822743706e+00 -8.5029606929125237e+00 6.9437749095564918e+00 + 10 5.1965622207475565e+02 -5.9755369618722887e+02 -1.8157960265809501e+02 + 11 -2.8945778423069450e+00 -5.7662137070620867e+00 -1.0795655996511190e+01 + 12 2.0805414458419623e+01 9.8601745071951186e+00 -6.7782082590913761e+00 + 13 8.7071353977142216e+00 -3.5468381013374746e+00 -5.0622413568933977e-01 + 14 -3.5154376369702902e+00 7.7780954572734984e-01 -9.9213826027447922e+00 + 15 1.9841048852047882e+00 8.5994997942103542e+00 1.4318674533257378e+00 + 16 4.3381844145946962e+02 -3.1216471119732176e+02 -1.1109885080754987e+03 + 17 -4.2715530816964593e+02 3.0229606646197493e+02 1.1227416717947804e+03 + 18 1.2084471423281700e+00 6.6044276302722391e+00 -9.8277754487894136e+00 + 19 3.2313284340457584e+00 3.9423765207539685e-01 4.3538203547548804e-01 + 20 -1.1969830459758257e+00 -8.8960771143457151e-01 9.2526061301410900e-01 + 21 -6.8060732684000939e+01 -7.8361174093266939e+01 2.1144116321844479e+02 + 22 -1.0408301224632098e+02 -2.5910595170511762e+01 -1.6092979318531198e+02 + 23 1.7368084263289987e+02 1.0120586644080414e+02 -5.1841492516928824e+01 + 24 3.5901478353702402e+01 -2.0053113579605662e+02 1.1040539818330446e+02 + 25 -1.4257916099779564e+02 2.4374225442971877e+01 -1.1459703108843671e+02 + 26 1.1121725716987784e+02 1.8123540984908496e+02 1.5706480723289609e+01 + 27 4.7997433858479745e+01 -2.1209575374436324e+02 8.4297950741699410e+01 + 28 -1.7410976565710496e+02 6.8409754929264125e+01 -1.1446187451410728e+02 + 29 1.2345981204292134e+02 1.3785309073312925e+02 3.4004852992123624e+01 ... diff --git a/unittest/force-styles/tests/mol-pair-hybrid.yaml b/unittest/force-styles/tests/mol-pair-hybrid.yaml index 95bec97279..ab25a334c6 100644 --- a/unittest/force-styles/tests/mol-pair-hybrid.yaml +++ b/unittest/force-styles/tests/mol-pair-hybrid.yaml @@ -1,99 +1,99 @@ --- -lammps_version: 10 Feb 2021 -date_generated: Fri Feb 26 23:08:45 2021 +lammps_version: 8 Apr 2021 +date_generated: Mon Apr 19 08:49:07 2021 epsilon: 5e-14 -skip_tests: gpu prerequisites: ! | atom full pair lj/cut + pair lj96/cut pre_commands: ! "" post_commands: ! "" input_file: in.fourmol -pair_style: hybrid lj/cut 8.0 lj/cut 8.0 +pair_style: hybrid lj/cut 8.0 lj96/cut 8.0 pair_coeff: ! | - 1 1 lj/cut 1 0.02 2.5 8 - 1 2 lj/cut 1 0.01 1.75 8 - 1 3 lj/cut 1 0.02 2.85 8 - 1 4 lj/cut 1 0.0173205 2.8 8 - 1 5 lj/cut 1 0.0173205 2.8 8 - 2 2 lj/cut 1 0.005 1 8 - 2 3 lj/cut 1 0.01 2.1 8 - 2 4 lj/cut 2 0.005 0.5 8 - 2 5 lj/cut 2 0.00866025 2.05 8 - 3 3 lj/cut 2 0.02 3.2 8 - 3 4 lj/cut 2 0.0173205 3.15 8 - 3 5 lj/cut 2 0.0173205 3.15 8 - 4 4 lj/cut 2 0.015 3.1 8 - 4 5 lj/cut 2 0.015 3.1 8 - 5 5 lj/cut 2 0.015 3.1 8 + 1 1 lj/cut 0.02 2.5 8 + 1 2 lj/cut 0.01 1.75 8 + 1 3 lj/cut 0.02 2.85 8 + 1 4 lj/cut 0.0173205 2.8 8 + 1 5 none + 2 2 lj/cut 0.005 1 8 + 2 3 lj/cut 0.01 2.1 8 + 2 4 lj96/cut 0.005 0.5 8 + 2 5 lj96/cut 0.00866025 2.05 8 + 3 3 lj96/cut 0.02 3.2 8 + 3 4 lj96/cut 0.0173205 3.15 8 + 3 5 lj96/cut 0.0173205 3.15 8 + 4 4 lj96/cut 0.015 3.1 8 + 4 5 none + 5 5 lj96/cut 0.015 3.1 8 extract: ! "" natoms: 29 -init_vdwl: 749.237031537357 +init_vdwl: 652.4450882982227 init_coul: 0 init_stress: ! |2- - 2.1793853434038251e+03 2.1988955172192786e+03 4.6653977523326275e+03 -7.5956547636050641e+02 2.4751536734034119e+01 6.6652028436400667e+02 + 1.6199549089538609e+03 1.8652222871458566e+03 4.3555170935393007e+03 -9.5632547516887212e+02 -2.2845869578774162e+02 6.9982627975055175e+02 init_forces: ! |2 - 1 -2.3333390280895383e+01 2.6994567613322732e+02 3.3272827850356794e+02 - 2 1.5828554630414868e+02 1.3025008843535846e+02 -1.8629682358935690e+02 - 3 -1.3528903738169089e+02 -3.8704313358320059e+02 -1.4568978437133126e+02 - 4 -7.8711096705893420e+00 2.1350518625373542e+00 -5.5954532185548151e+00 - 5 -2.5176757268228527e+00 -4.0521510681020221e+00 1.2152704057877008e+01 - 6 -8.3190662465252262e+02 9.6394149462625705e+02 1.1509093566509250e+03 - 7 5.8203388932513640e+01 -3.3608997951626816e+02 -1.7179617996573054e+03 - 8 1.4451392284291583e+02 -1.0927475861089046e+02 3.9990593492420493e+02 - 9 7.9156945283097571e+01 8.5273009783986680e+01 3.5032175698445252e+02 - 10 5.3118875219105416e+02 -6.1040990859419469e+02 -1.8355872642619312e+02 - 11 -2.3530157267965532e+00 -5.9077640073819744e+00 -9.6590723955414326e+00 - 12 1.7527155146800411e+01 1.0633119523437488e+01 -7.9254398064483143e+00 - 13 8.0986409579532861e+00 -3.2098088264781510e+00 -1.4896399843793828e-01 - 14 -3.3852721292265100e+00 6.8636181241903504e-01 -8.7507190862499726e+00 - 15 -2.0454999188605286e-01 8.4846165523049883e+00 3.0131615419406708e+00 - 16 4.6326310311812085e+02 -3.3087715736498177e+02 -1.1893024561782547e+03 - 17 -4.5334300923766710e+02 3.1554283255882558e+02 1.2058417793481196e+03 - 18 -1.8862623280672657e-02 -3.3402010907951640e-02 3.1000479299095243e-02 - 19 3.1843079640570080e-04 -2.3918627818763423e-04 1.7427252638513441e-03 - 20 -9.9760831209706009e-04 -1.0209184826753088e-03 3.6910972636601454e-04 - 21 -7.1566125273265527e+01 -8.1615678329920812e+01 2.2589561408339878e+02 - 22 -1.0808835729977487e+02 -2.6193787235943859e+01 -1.6957904943161384e+02 - 23 1.7964455474779510e+02 1.0782097695276961e+02 -5.6305786479140700e+01 - 24 3.6591406576585001e+01 -2.1181587621785556e+02 1.1218301872572404e+02 - 25 -1.4851489147738829e+02 2.3907118122949107e+01 -1.2485634873166315e+02 - 26 1.1191129453598201e+02 1.8789774664223359e+02 1.2650137204319886e+01 - 27 5.1810388677546058e+01 -2.2705458321213791e+02 9.0849111082069683e+01 - 28 -1.8041307121444072e+02 7.7534042932772934e+01 -1.2206956760706599e+02 - 29 1.2861057254925004e+02 1.4952711274394565e+02 3.1216025556267869e+01 -run_vdwl: 719.443281677466 + 1 -2.3333467289742931e+01 2.6993142283476851e+02 3.3272495963292283e+02 + 2 1.5828552013445056e+02 1.3025008546972211e+02 -1.8629688302475225e+02 + 3 -1.3529016849461223e+02 -3.8704356552446848e+02 -1.4569166096697677e+02 + 4 -7.8711116846129050e+00 2.1350517679284451e+00 -5.5954561911890046e+00 + 5 -2.5177006460693390e+00 -4.0521653208614632e+00 1.2152678277353530e+01 + 6 -8.3190697480339566e+02 9.6394156556954056e+02 1.1509082485986419e+03 + 7 6.4961865086373535e+01 -3.3998877273576284e+02 -1.7032949977108992e+03 + 8 1.3800067755917669e+02 -1.0575764259058835e+02 3.8568183849544192e+02 + 9 7.9156940582018805e+01 8.5272978047670051e+01 3.5032172427046436e+02 + 10 5.3118723340662132e+02 -6.1040797933322176e+02 -1.8355763882870201e+02 + 11 -2.3531003777844695e+00 -5.9077049537176469e+00 -9.6590265504356907e+00 + 12 1.7525454559786660e+01 1.0636445740481784e+01 -7.9240149067722738e+00 + 13 8.0985903919880737e+00 -3.2096212808671210e+00 -1.4884740337815178e-01 + 14 -3.3853022166233191e+00 6.8640988271648729e-01 -8.7507072432538457e+00 + 15 -2.0454983537269980e-01 8.4846157143527687e+00 3.0131531921339136e+00 + 16 4.6326233922126522e+02 -3.3087556531781973e+02 -1.1892999860848122e+03 + 17 -4.5359533332836713e+02 3.1593155242296575e+02 1.2054040116538242e+03 + 18 -1.2313292578060062e-02 -2.5378393942268991e-02 2.2968315649798128e-02 + 19 3.0439100375925543e-04 -2.4779478988349023e-04 1.7258398467618651e-03 + 20 -9.8045055969651082e-04 -1.0028949153285463e-03 3.5715001758946177e-04 + 21 -5.7186294103147572e+00 -6.6344147796080684e+00 1.8654007864095536e+01 + 22 -8.9567671655515344e+00 -2.1701845330290590e+00 -1.4052631842883260e+01 + 23 1.4673371058172327e+01 8.8071981142288021e+00 -4.5994772330864269e+00 + 24 3.2769508891728725e+00 -1.7316771489185900e+01 9.3887574366841235e+00 + 25 -1.2406052232816045e+01 1.9955673026898786e+00 -1.0432202322872895e+01 + 26 9.1216838958879958e+00 1.5316110435596807e+01 1.0304939537049307e+00 + 27 3.8455233865293490e+00 -1.8678583225803411e+01 7.2399697763695485e+00 + 28 -1.4536949587460585e+01 6.2480560831561052e+00 -9.8361741655762192e+00 + 29 1.0692946253413785e+01 1.2432540782763471e+01 2.5948100184389560e+00 +run_vdwl: 624.1198434527859 run_coul: 0 run_stress: ! |2- - 2.1330153957371017e+03 2.1547728168285512e+03 4.3976497417710170e+03 -7.3873328448298525e+02 4.1743821105367225e+01 6.2788012209191243e+02 + 1.5811055300513408e+03 1.8260026652593124e+03 4.0928122296059910e+03 -9.3274940961565028e+02 -2.0869586127604293e+02 6.5975565836651401e+02 run_forces: ! |2 - 1 -2.0299419751359796e+01 2.6686193378822901e+02 3.2358785870694004e+02 - 2 1.5298617928491248e+02 1.2596516341409225e+02 -1.7961292655338647e+02 - 3 -1.3353630652439793e+02 -3.7923748696131213e+02 -1.4291839793625775e+02 - 4 -7.8374717836161771e+00 2.1276610789823414e+00 -5.5845014473820624e+00 - 5 -2.5014258630866699e+00 -4.0250131424704385e+00 1.2103512372025625e+01 - 6 -8.0681462887292412e+02 9.2165637136761688e+02 1.0270795806932804e+03 - 7 5.5780279349903594e+01 -3.1117530951561696e+02 -1.5746991292869038e+03 - 8 1.3452983055534955e+02 -1.0064659350255846e+02 3.8851791558207583e+02 - 9 7.6746213883426122e+01 8.2501469877402286e+01 3.3944351200617950e+02 - 10 5.2128033527695618e+02 -5.9920098848285909e+02 -1.8126029815043356e+02 - 11 -2.3573118090915246e+00 -5.8616944550888350e+00 -9.6049808811326240e+00 - 12 1.7503975847822890e+01 1.0626930310560827e+01 -8.0603160272054950e+00 - 13 8.0530313322973104e+00 -3.1756495170399104e+00 -1.4618315664740525e-01 - 14 -3.3416065168069760e+00 6.6492606336082127e-01 -8.6345131440469647e+00 - 15 -2.2253843262374870e-01 8.5025661635348619e+00 3.0369735873081569e+00 - 16 4.3476311264989528e+02 -3.1171086735551455e+02 -1.1135217194927461e+03 - 17 -4.2469846140777202e+02 2.9615411776780638e+02 1.1302573488400678e+03 - 18 -1.8849981672825901e-02 -3.3371636477421286e-02 3.0986293443778724e-02 - 19 3.0940277774413972e-04 -2.4634536455373055e-04 1.7433360008861018e-03 - 20 -9.8648131277150768e-04 -1.0112587134526944e-03 3.6932948773965422e-04 - 21 -7.0490745283106705e+01 -7.9749153581142281e+01 2.2171003384646417e+02 - 22 -1.0638717908920059e+02 -2.5949502163177943e+01 -1.6645589526812256e+02 - 23 1.7686797710735050e+02 1.0571018898885526e+02 -5.5243337084099444e+01 - 24 3.8206017656281247e+01 -2.1022820141992992e+02 1.1260711266189016e+02 - 25 -1.4918881473530885e+02 2.3762151395876515e+01 -1.2549188139143089e+02 - 26 1.1097059498808326e+02 1.8645503634228552e+02 1.2861559677865269e+01 - 27 5.0800844984832011e+01 -2.2296588090685447e+02 8.8607367716323097e+01 - 28 -1.7694190504288861e+02 7.6029945485181912e+01 -1.1950518150242056e+02 - 29 1.2614894925528131e+02 1.4694250820033537e+02 3.0893386672863009e+01 + 1 -2.0299545735132892e+01 2.6684807204226053e+02 3.2358468359237850e+02 + 2 1.5298613010577799e+02 1.2596515036763115e+02 -1.7961295708782035e+02 + 3 -1.3353752998744326e+02 -3.7923796991710333e+02 -1.4292028045209116e+02 + 4 -7.8374742335759366e+00 2.1276610876297597e+00 -5.5845047399918775e+00 + 5 -2.5014507165598512e+00 -4.0250273077928105e+00 1.2103486006755219e+01 + 6 -8.0709614974024726e+02 9.2196952917801661e+02 1.0273844835710092e+03 + 7 6.2368964790102126e+01 -3.1505972760991460e+02 -1.5609074758304780e+03 + 8 1.2853739032019485e+02 -9.7465044500250556e+01 3.7497119240743029e+02 + 9 7.6715909814250395e+01 8.2459997325499288e+01 3.3929722449258207e+02 + 10 5.2123917690492942e+02 -5.9914969452129674e+02 -1.8122078898785443e+02 + 11 -2.3573941156945706e+00 -5.8616368783617920e+00 -9.6049336125719105e+00 + 12 1.7502383808896312e+01 1.0630235744520755e+01 -8.0588289450962680e+00 + 13 8.0529802801748964e+00 -3.1754616291151323e+00 -1.4606677296755816e-01 + 14 -3.3416363973176253e+00 6.6497430894639287e-01 -8.6345016037082427e+00 + 15 -2.2253805990966902e-01 8.5025662406844038e+00 3.0369660480415672e+00 + 16 4.3476506269170443e+02 -3.1171159958023998e+02 -1.1135242200065077e+03 + 17 -4.2495337371832613e+02 2.9654505216420324e+02 1.1298239214745126e+03 + 18 -1.2304275579819248e-02 -2.5351950229154721e-02 2.2962838569349546e-02 + 19 2.9523284665120854e-04 -2.5507040924857842e-04 1.7263527188201720e-03 + 20 -9.6972071754998339e-04 -9.9365617456234753e-04 3.5770286471788313e-04 + 21 -5.7779283683910396e+00 -6.6373783567402054e+00 1.8717023177597437e+01 + 22 -9.0188479017520962e+00 -2.2015411814231656e+00 -1.4100630927846634e+01 + 23 1.4794749299535622e+01 8.8415202426425061e+00 -4.6144921197234865e+00 + 24 3.4171983592341331e+00 -1.7549081284618467e+01 9.5729670271818517e+00 + 25 -1.2674530181010821e+01 2.0106979870159911e+00 -1.0661184439552951e+01 + 26 9.2499114441813344e+00 1.5533293107821931e+01 1.0752648395769842e+00 + 27 3.9098603108147572e+00 -1.8759688298395208e+01 7.2506773670471274e+00 + 28 -1.4631015477945336e+01 6.2801033491768763e+00 -9.8799560206646078e+00 + 29 1.0722675266961424e+01 1.2481598596015642e+01 2.6278846486097209e+00 ... diff --git a/unittest/force-styles/tests/mol-pair-hybrid_multiple.yaml b/unittest/force-styles/tests/mol-pair-hybrid_multiple.yaml new file mode 100644 index 0000000000..59a5098238 --- /dev/null +++ b/unittest/force-styles/tests/mol-pair-hybrid_multiple.yaml @@ -0,0 +1,99 @@ +--- +lammps_version: 8 Apr 2021 +date_generated: Mon Apr 19 08:49:08 2021 +epsilon: 5e-14 +skip_tests: gpu +prerequisites: ! | + atom full + pair lj/cut +pre_commands: ! "" +post_commands: ! "" +input_file: in.fourmol +pair_style: hybrid lj/cut 8.0 lj/cut 8.0 +pair_coeff: ! | + 1 1 lj/cut 1 0.02 2.5 8 + 1 2 lj/cut 1 0.01 1.75 8 + 1 3 lj/cut 1 0.02 2.85 8 + 1 4 lj/cut 1 0.0173205 2.8 8 + 1 5 lj/cut 1 0.0173205 2.8 8 + 2 2 lj/cut 1 0.005 1 8 + 2 3 none + 2 4 lj/cut 2 0.005 0.5 8 + 2 5 lj/cut 2 0.00866025 2.05 8 + 3 3 lj/cut 2 0.02 3.2 8 + 3 4 lj/cut 2 0.0173205 3.15 8 + 3 5 lj/cut 2 0.0173205 3.15 8 + 4 4 none + 4 5 lj/cut 2 0.015 3.1 8 + 5 5 lj/cut 2 0.015 3.1 8 +extract: ! "" +natoms: 29 +init_vdwl: 695.3923515458562 +init_coul: 0 +init_stress: ! |2- + 2.0701694962880379e+03 2.1161697936676396e+03 4.2064778387649758e+03 -8.5392301766114281e+02 5.8381311611070338e+01 6.7526909503583579e+02 +init_forces: ! |2 + 1 1.3470193899351008e+02 3.9971667505559770e+02 1.4653534158640173e+02 + 2 -2.5920146506056333e-04 -3.7955921659898438e-03 1.6073626919112927e-04 + 3 -1.3528903738169089e+02 -3.8704313358320059e+02 -1.4568978437133126e+02 + 4 -7.8050743980642938e+00 2.1869547823331810e+00 -5.5398195700937443e+00 + 5 -2.3463115265684147e+00 -3.6110080311379984e+00 1.1991043207479338e+01 + 6 -8.3190662465252262e+02 9.6394149462625705e+02 1.1509093566509250e+03 + 7 5.8196056725569250e+01 -3.3609532232737348e+02 -1.7179637678770343e+03 + 8 2.2371752997318714e+02 -2.4044581303870338e+01 7.5018536133648945e+02 + 9 -1.9409760262620549e-03 7.2485476558358224e-03 5.8859368216628563e-03 + 10 5.3118875219105416e+02 -6.1040990859419469e+02 -1.8355872642619312e+02 + 11 -2.3694888595131456e+00 -5.8683646131501845e+00 -9.6273569602169200e+00 + 12 1.7527155146800411e+01 1.0633119523437488e+01 -7.9254398064483143e+00 + 13 8.1017386753150031e+00 -3.2103099553624541e+00 -1.4999876338278073e-01 + 14 -3.3827233651141047e+00 6.8626763970182614e-01 -8.7541119515926020e+00 + 15 -2.2835033173800551e-01 8.4695347876005833e+00 3.0205948609978988e+00 + 16 4.6326310311812085e+02 -3.3087715736498177e+02 -1.1893024561782547e+03 + 17 -4.5334049545249684e+02 3.1553975228548006e+02 1.2058468481979494e+03 + 18 -1.4044201506550015e-02 -2.4978926457057571e-02 2.7899849198216014e-02 + 19 5.7908066872909211e-04 2.3580122518177659e-05 9.4432839946607169e-04 + 20 -7.9929144000317922e-04 -8.5923998915859100e-04 9.3688470857894682e-05 + 21 -7.1566125273265527e+01 -8.1615678329920812e+01 2.2589561408339878e+02 + 22 -1.0808832728447032e+02 -2.6193822094038484e+01 -1.6957908491609356e+02 + 23 1.7964458878508086e+02 1.0782095393625858e+02 -5.6305810335528790e+01 + 24 3.6591406576585001e+01 -2.1181587621785556e+02 1.1218301872572404e+02 + 25 -1.4851247198601720e+02 2.3908563011127814e+01 -1.2485206982576771e+02 + 26 1.1191155617819715e+02 1.8789792679177191e+02 1.2650470167620387e+01 + 27 5.1810388677546058e+01 -2.2705458321213791e+02 9.0849111082069683e+01 + 28 -1.8041314710135907e+02 7.7533961534478649e+01 -1.2206952271304674e+02 + 29 1.2861042716162333e+02 1.4952690328401346e+02 3.1216205256769118e+01 +run_vdwl: 666.4782147617275 +run_coul: 0 +run_stress: ! |2- + 2.0230459789503245e+03 2.0702509496053467e+03 3.9518738620330496e+03 -8.2693736200387241e+02 7.2394119974104541e+01 6.3708810010786885e+02 +run_forces: ! |2 + 1 1.3222884765649096e+02 3.9147464530754542e+02 1.4358022294156322e+02 + 2 -3.0864727869908275e-04 -3.8828117503160744e-03 1.7172318042670622e-04 + 3 -1.3332620470087795e+02 -3.7836092101534376e+02 -1.4242041283928734e+02 + 4 -7.7728646036501301e+00 2.1785693730418103e+00 -5.5299592481691731e+00 + 5 -2.3308414297947593e+00 -3.5861079994724223e+00 1.1943272718268586e+01 + 6 -8.0362787449170855e+02 9.1873908852320062e+02 1.0286784127827473e+03 + 7 5.5811219820327509e+01 -3.1120381969697877e+02 -1.5746114945931058e+03 + 8 2.0944769168608951e+02 -1.6467844308363212e+01 7.2633940157846291e+02 + 9 -1.8576332682468917e-03 7.0788521064532543e-03 5.6952330037911550e-03 + 10 5.1993646731938259e+02 -5.9797705136296099e+02 -1.8137145374090557e+02 + 11 -2.3735947029864999e+00 -5.8227345663909000e+00 -9.5735721932593005e+00 + 12 1.7496750082385656e+01 1.0626428651973894e+01 -8.0588816332352362e+00 + 13 8.0561193459222018e+00 -3.1761461937053199e+00 -1.4721657561379659e-01 + 14 -3.3390327331317540e+00 6.6483212295920502e-01 -8.6379436016166640e+00 + 15 -2.4691219203353357e-01 8.4871512091352503e+00 3.0445957174405320e+00 + 16 4.3476322109548175e+02 -3.1171106479661643e+02 -1.1135217352066604e+03 + 17 -4.2469483753690730e+02 2.9614920041309318e+02 1.1302640053436066e+03 + 18 -1.4041685725000265e-02 -2.4956350669900162e-02 2.7904010910612693e-02 + 19 5.7049372682756931e-04 1.6554736417528457e-05 9.4341990684141492e-04 + 20 -7.8849148841722897e-04 -8.4994368910122327e-04 9.4566031895818034e-05 + 21 -7.0490744649332854e+01 -7.9749153638697052e+01 2.2171003329264727e+02 + 22 -1.0638714881331208e+02 -2.5949537046722948e+01 -1.6645593048575904e+02 + 23 1.7686801069212282e+02 1.0571016567965997e+02 -5.5243360803916154e+01 + 24 3.8206094080913594e+01 -2.1022820935692107e+02 1.1260716750436217e+02 + 25 -1.4918646093941553e+02 2.3763610305920544e+01 -1.2548765023777884e+02 + 26 1.1097085296101896e+02 1.8645520999549970e+02 1.2861892631557549e+01 + 27 5.0800842221321886e+01 -2.2296588391583720e+02 8.8607366497542188e+01 + 28 -1.7694198089845398e+02 7.6029863930484495e+01 -1.1950513646089449e+02 + 29 1.2614880669418112e+02 1.4694230208476219e+02 3.0893567658970003e+01 +... diff --git a/unittest/force-styles/tests/mol-pair-lj_charmm_coul_charmm.yaml b/unittest/force-styles/tests/mol-pair-lj_charmm_coul_charmm.yaml index db8265a6b2..452a1b58d6 100644 --- a/unittest/force-styles/tests/mol-pair-lj_charmm_coul_charmm.yaml +++ b/unittest/force-styles/tests/mol-pair-lj_charmm_coul_charmm.yaml @@ -2,7 +2,6 @@ lammps_version: 10 Feb 2021 date_generated: Fri Feb 26 23:08:45 2021 epsilon: 7e-14 -skip_tests: gpu prerequisites: ! | atom full pair lj/charmm/coul/charmm diff --git a/unittest/force-styles/tests/mol-pair-python_hybrid.yaml b/unittest/force-styles/tests/mol-pair-python_hybrid.yaml index 663e3efa2d..5383ee113f 100644 --- a/unittest/force-styles/tests/mol-pair-python_hybrid.yaml +++ b/unittest/force-styles/tests/mol-pair-python_hybrid.yaml @@ -1,6 +1,6 @@ --- -lammps_version: 10 Feb 2021 -date_generated: Fri Feb 26 23:08:56 2021 +lammps_version: 8 Apr 2021 +date_generated: Mon Apr 19 08:49:08 2021 epsilon: 5e-14 prerequisites: ! | atom full @@ -15,8 +15,8 @@ pair_coeff: ! | * * python py_pot.LJCutFourMol 1 2 3 4 5 extract: ! "" natoms: 29 -init_vdwl: 769.435514792906 -init_coul: -127.494586297384 +init_vdwl: 769.4355147929056 +init_coul: -127.49458629738443 init_stress: ! |2- 2.2678521911648518e+03 2.2247029630324569e+03 4.6668446509523028e+03 -7.1863043563709800e+02 6.6980305204573611e+01 6.6425623166019000e+02 init_forces: ! |2 @@ -49,8 +49,8 @@ init_forces: ! |2 27 5.8858131514524516e+01 -2.5934658519982310e+02 1.0378659589349859e+02 28 -2.1004851662389484e+02 8.7061736878465183e+01 -1.4131944246679177e+02 29 1.5193395589309270e+02 1.7194075642255194e+02 3.8106025733269696e+01 -run_vdwl: 738.975921529802 -run_coul: -127.388878149465 +run_vdwl: 738.9759215298017 +run_coul: -127.38887814946516 run_stress: ! |2- 2.2173727908784563e+03 2.1780484935540412e+03 4.3978310588967724e+03 -6.9936430337437957e+02 8.2321786589523725e+01 6.2596079360064653e+02 run_forces: ! |2 diff --git a/unittest/formats/test_atom_styles.cpp b/unittest/formats/test_atom_styles.cpp index 8a031fe308..980afc3182 100644 --- a/unittest/formats/test_atom_styles.cpp +++ b/unittest/formats/test_atom_styles.cpp @@ -48,7 +48,7 @@ using LAMMPS_NS::utils::split_words; -static void create_molecule_files() +static void create_molecule_files(const std::string & h2o_filename, const std::string & co2_filename) { // create molecule files const char h2o_file[] = "# Water molecule. SPC/E model.\n\n3 atoms\n2 bonds\n1 angles\n\n" @@ -73,18 +73,16 @@ static void create_molecule_files() "Special Bond Counts\n\n1 2 0 0\n2 1 1 0\n3 1 1 0\n\n" "Special Bonds\n\n1 2 3\n2 1 3\n3 1 2\n\n"; - FILE *fp = fopen("tmp.h2o.mol", "w"); + FILE *fp = fopen(h2o_filename.c_str(), "w"); if (fp) { fputs(h2o_file, fp); fclose(fp); } - rename("tmp.h2o.mol", "h2o.mol"); - fp = fopen("tmp.co2.mol", "w"); + fp = fopen(co2_filename.c_str(), "w"); if (fp) { fputs(co2_file, fp); fclose(fp); } - rename("tmp.co2.mol", "co2.mol"); } // whether to print verbose output (i.e. not capturing LAMMPS screen output). @@ -97,6 +95,15 @@ using ::testing::Eq; class AtomStyleTest : public LAMMPSTest { protected: + static void SetUpTestSuite() { + create_molecule_files("h2o.mol", "co2.mol"); + } + + static void TearDownTestSuite() { + remove("h2o.mol"); + remove("co2.mol"); + } + void SetUp() override { testbinary = "AtomStyleTest"; @@ -2618,7 +2625,6 @@ TEST_F(AtomStyleTest, body_nparticle) TEST_F(AtomStyleTest, template) { if (!LAMMPS::is_installed_pkg("MOLECULE")) GTEST_SKIP(); - create_molecule_files(); BEGIN_HIDE_OUTPUT(); command("molecule twomols h2o.mol co2.mol offset 2 1 1 0 0"); command("atom_style template twomols"); @@ -3014,7 +3020,6 @@ TEST_F(AtomStyleTest, template) TEST_F(AtomStyleTest, template_charge) { if (!LAMMPS::is_installed_pkg("MOLECULE")) GTEST_SKIP(); - create_molecule_files(); BEGIN_HIDE_OUTPUT(); command("molecule twomols h2o.mol co2.mol offset 2 1 1 0 0"); command("atom_style hybrid template twomols charge"); diff --git a/unittest/formats/test_molecule_file.cpp b/unittest/formats/test_molecule_file.cpp index 9928ec4b7c..5712e31a30 100644 --- a/unittest/formats/test_molecule_file.cpp +++ b/unittest/formats/test_molecule_file.cpp @@ -35,7 +35,7 @@ using utils::split_words; #define test_name test_info_->name() -static void create_molecule_files() +static void create_molecule_files(const std::string & h2o_filename, const std::string & co2_filename) { // create molecule files const char h2o_file[] = "# Water molecule. SPC/E model.\n\n3 atoms\n2 bonds\n1 angles\n\n" @@ -60,18 +60,16 @@ static void create_molecule_files() "Special Bond Counts\n\n1 2 0 0\n2 1 1 0\n3 1 1 0\n\n" "Special Bonds\n\n1 2 3\n2 1 3\n3 1 2\n\n"; - FILE *fp = fopen("tmp.h2o.mol", "w"); + FILE *fp = fopen(h2o_filename.c_str(), "w"); if (fp) { fputs(h2o_file, fp); fclose(fp); } - rename("tmp.h2o.mol", "h2o.mol"); - fp = fopen("tmp.co2.mol", "w"); + fp = fopen(co2_filename.c_str(), "w"); if (fp) { fputs(co2_file, fp); fclose(fp); } - rename("tmp.co2.mol", "co2.mol"); } // whether to print verbose output (i.e. not capturing LAMMPS screen output). @@ -79,26 +77,30 @@ bool verbose = false; class MoleculeFileTest : public LAMMPSTest { protected: + static void SetUpTestSuite() { + create_molecule_files("moltest.h2o.mol", "moltest.co2.mol"); + } + + static void TearDownTestSuite() { + remove("moltest.h2o.mol"); + remove("moltest.co2.mol"); + } + void SetUp() override { testbinary = "MoleculeFileTest"; LAMMPSTest::SetUp(); ASSERT_NE(lmp, nullptr); - BEGIN_HIDE_OUTPUT(); - create_molecule_files(); - END_HIDE_OUTPUT(); } void TearDown() override { LAMMPSTest::TearDown(); - remove("h2o.mol"); - remove("co2.mol"); } void run_mol_cmd(const std::string &name, const std::string &args, const std::string &content) { - std::string file = name + ".mol"; + std::string file = fmt::format("moltest_{}.mol", name); FILE *fp = fopen(file.c_str(), "w"); fputs(content.c_str(), fp); fclose(fp); @@ -195,7 +197,7 @@ TEST_F(MoleculeFileTest, twomols) TEST_F(MoleculeFileTest, twofiles) { BEGIN_CAPTURE_OUTPUT(); - command("molecule twomols h2o.mol co2.mol offset 2 1 1 0 0"); + command("molecule twomols moltest.h2o.mol moltest.co2.mol offset 2 1 1 0 0"); auto output = END_CAPTURE_OUTPUT(); ASSERT_THAT(output, MatchesRegex(".*Read molecule template twomols:.*1 molecules.*3 atoms " "with max type 2.*2 bonds with max type 1.*" diff --git a/unittest/testing/core.h b/unittest/testing/core.h index 75b0564d02..843d135645 100644 --- a/unittest/testing/core.h +++ b/unittest/testing/core.h @@ -42,6 +42,9 @@ using ::testing::MatchesRegex; auto mesg = ::testing::internal::GetCapturedStdout(); \ ASSERT_THAT(mesg, MatchesRegex(errmsg)); \ } \ + else { \ + std::cerr << "[ ] [ INFO ] Skipping death test (no exception support) \n"; \ + } \ } // whether to print verbose output (i.e. not capturing LAMMPS screen output).