Commit 09b67946 authored by charlie sievers's avatar charlie sievers
Browse files

Updated fix langevin errors and warnings as well as associated doc files....

Updated fix langevin errors and warnings as well as associated doc files. Updated fix langevin kokkos errors and warnings as well as associated doc files
parent c26b1d18
Loading
Loading
Loading
Loading
+16 −0
Original line number Original line Diff line number Diff line
@@ -4791,6 +4791,22 @@ Self-explanatory. :dd


This fix option cannot be used with point particles. :dd
This fix option cannot be used with point particles. :dd


{Fix langevin gjf and respa are not compatible} :dt

Self-explanatory. :dd

{Fix langevin gjf cannot have period equal to dt/2} :dt

If the period is equal to dt/2 then division by zero will happen. :dd

{Fix langevin gjf should come before fix nve} :dt

Self-explanatory. :dd

{Fix langevin gjf with tbias is not yet implemented with kokkos} :dt

This option is not yet available. :dd

{Fix langevin omega is not yet implemented with kokkos} :dt
{Fix langevin omega is not yet implemented with kokkos} :dt


This option is not yet available. :dd
This option is not yet available. :dd
+4 −0
Original line number Original line Diff line number Diff line
@@ -248,6 +248,10 @@ included one or more of the following: kspace, triclinic, a hybrid
pair style, an eam pair style, or no "single" function for the pair
pair style, an eam pair style, or no "single" function for the pair
style. :dd
style. :dd


{Fix langevin gjf using random gaussians is not implemented with kokkos} :dt

This will most likely cause errors in kinetic fluctuations.

{Fix property/atom mol or charge w/out ghost communication} :dt
{Fix property/atom mol or charge w/out ghost communication} :dt


A model typically needs these properties defined for ghost atoms. :dd
A model typically needs these properties defined for ghost atoms. :dd
+3 −6
Original line number Original line Diff line number Diff line
@@ -351,13 +351,10 @@ types, tally = no, zero = no, gjf = no.


:link(Gronbech-Jensen)
:link(Gronbech-Jensen)
[(Gronbech-Jensen)] Gronbech-Jensen and Farago, Mol Phys, 111, 983
[(Gronbech-Jensen)] Gronbech-Jensen and Farago, Mol Phys, 111, 983
(2013); Gronbech-Jensen, Hayre, and Farago, Comp Phys Comm,
(2013); Gronbech-Jensen, Hayre, and Farago, Comp Phys Comm, 185, 524 (2014)
185, 524 (2014)


:link(2Gronbech-Jensen)
:link(2Gronbech-Jensen)
[(Gronbech-Jensen)] Gronbech Jensen and Gronbech-Jensen, Mol Phys, 117, 2511
[(Gronbech-Jensen)] Gronbech Jensen and Gronbech-Jensen, Mol Phys, 117, 2511 (2019)
(2019)


:link(1Gronbech-Jensen)
:link(1Gronbech-Jensen)
[(Gronbech-Jensen)] Gronbech-Jensen, Mol Phys (2019);
[(Gronbech-Jensen)] Gronbech-Jensen, Mol Phys (2019); https://doi.org/10.1080/00268976.2019.1662506
https://doi.org/10.1080/00268976.2019.1662506
+916 −0

File added.

Preview size limit exceeded, changes collapsed.

fix_langevin_kokkos.h

0 → 100644
+293 −0
Original line number Original line Diff line number Diff line
/* -*- c++ -*- ----------------------------------------------------------
   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
   http://lammps.sandia.gov, Sandia National Laboratories
   Steve Plimpton, sjplimp@sandia.gov

   Copyright (2003) Sandia Corporation.  Under the terms of Contract
   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
   certain rights in this software.  This software is distributed under
   the GNU General Public License.

   See the README file in the top-level LAMMPS directory.
   ------------------------------------------------------------------------- */

#ifdef FIX_CLASS

FixStyle(langevin/kk,FixLangevinKokkos<LMPDeviceType>)
FixStyle(langevin/kk/device,FixLangevinKokkos<LMPDeviceType>)
FixStyle(langevin/kk/host,FixLangevinKokkos<LMPHostType>)

#else

#ifndef LMP_FIX_LANGEVIN_KOKKOS_H
#define LMP_FIX_LANGEVIN_KOKKOS_H

#include "fix_langevin.h"
#include "kokkos_type.h"
#include "Kokkos_Random.hpp"
#include "comm_kokkos.h"

namespace LAMMPS_NS {

  struct s_FSUM {
    double fx, fy, fz;
    KOKKOS_INLINE_FUNCTION
    s_FSUM() {
      fx = fy = fz = 0.0;
    }
    KOKKOS_INLINE_FUNCTION
    s_FSUM& operator+=(const s_FSUM &rhs){
      fx += rhs.fx;
      fy += rhs.fy;
      fz += rhs.fz;
      return *this;
    }

    KOKKOS_INLINE_FUNCTION
    volatile s_FSUM& operator+=(const volatile s_FSUM &rhs) volatile {
      fx += rhs.fx;
      fy += rhs.fy;
      fz += rhs.fz;
      return *this;
    }
  };
  typedef s_FSUM FSUM;

  template<class DeviceType>
    class FixLangevinKokkos;

  template <class DeviceType>
  class FixLangevinKokkosInitialIntegrateFunctor;

  template<class DeviceType,int Tp_TSTYLEATOM, int Tp_GJF, int Tp_TALLY,
    int Tp_BIAS, int Tp_RMASS, int Tp_ZERO>
    class FixLangevinKokkosPostForceFunctor;

  template<class DeviceType> class FixLangevinKokkosZeroForceFunctor;

  template<class DeviceType> class FixLangevinKokkosTallyEnergyFunctor;

  template<class DeviceType>
    class FixLangevinKokkos : public FixLangevin {
  public:
    FixLangevinKokkos(class LAMMPS *, int, char **);
    ~FixLangevinKokkos();

    void cleanup_copy();
    void init();
    void initial_integrate(int);
    void post_force(int);
    void reset_dt();
    void grow_arrays(int);
    void copy_arrays(int i, int j, int delflag);
    double compute_scalar();
    void end_of_step();

    KOKKOS_INLINE_FUNCTION
      void initial_integrate_item(int) const;

    KOKKOS_INLINE_FUNCTION
      void initial_integrate_rmass_item(int) const;

    template<int Tp_TSTYLEATOM, int Tp_GJF, int Tp_TALLY,
      int Tp_BIAS, int Tp_RMASS, int Tp_ZERO>
      KOKKOS_INLINE_FUNCTION
      FSUM post_force_item(int) const;

    KOKKOS_INLINE_FUNCTION
      void zero_force_item(int) const;

    KOKKOS_INLINE_FUNCTION
      double compute_energy_item(int) const;

    KOKKOS_INLINE_FUNCTION
      void end_of_step_item(int) const;

    KOKKOS_INLINE_FUNCTION
      void end_of_step_rmass_item(int) const;

  private:
    class CommKokkos *commKK;

    typename ArrayTypes<DeviceType>::t_float_1d rmass;
    typename ArrayTypes<DeviceType>::t_float_1d mass;
    typename ArrayTypes<DeviceType>::tdual_double_2d k_franprev;
    typename ArrayTypes<DeviceType>::t_double_2d d_franprev;
    HAT::t_double_2d h_franprev;

    typename ArrayTypes<DeviceType>::tdual_double_2d k_lv;
    typename ArrayTypes<DeviceType>::t_double_2d d_lv;
    HAT::t_double_2d h_lv;

    typename ArrayTypes<DeviceType>::tdual_double_2d k_flangevin;
    typename ArrayTypes<DeviceType>::t_double_2d d_flangevin;
    HAT::t_double_2d h_flangevin;

    typename ArrayTypes<DeviceType>::tdual_double_1d k_tforce;
    typename ArrayTypes<DeviceType>::t_double_1d d_tforce;
    HAT::t_double_1d h_tforce;

    typename ArrayTypes<DeviceType>::t_v_array v;
    typename ArrayTypes<DeviceType>::t_f_array f;
    typename ArrayTypes<DeviceType>::t_int_1d type;
    typename ArrayTypes<DeviceType>::t_int_1d mask;

    typename ArrayTypes<DeviceType>::tdual_double_1d k_gfactor1, k_gfactor2, k_ratio;
    typename ArrayTypes<DeviceType>::t_double_1d d_gfactor1, d_gfactor2, d_ratio;
    HAT::t_double_1d h_gfactor1, h_gfactor2, h_ratio;

    typedef Kokkos::DualView<double[3], DeviceType>
      tdual_double_1d_3n;
    tdual_double_1d_3n k_fsumall;
    typename tdual_double_1d_3n::t_dev d_fsumall;
    typename tdual_double_1d_3n::t_host h_fsumall;

    double boltz,dt,mvv2e,ftm2v,fran_prop_const;

    void compute_target();

    Kokkos::Random_XorShift64_Pool<DeviceType> rand_pool;
    typedef typename Kokkos::Random_XorShift64_Pool<DeviceType>::generator_type rand_type;

  };

  template <class DeviceType>
  struct FixLangevinKokkosInitialIntegrateFunctor  {
    typedef DeviceType  device_type ;
    FixLangevinKokkos<DeviceType> c;

  FixLangevinKokkosInitialIntegrateFunctor(FixLangevinKokkos<DeviceType>* c_ptr):
    c(*c_ptr) {c.cleanup_copy();};

    KOKKOS_INLINE_FUNCTION
    void operator()(const int i) const {
      c.initial_integrate_item(i);
    }
  };


  template <class DeviceType,int Tp_TSTYLEATOM, int Tp_GJF, int Tp_TALLY,
    int Tp_BIAS, int Tp_RMASS, int Tp_ZERO>
    struct FixLangevinKokkosPostForceFunctor {

      typedef DeviceType  device_type;
      typedef FSUM value_type;
      FixLangevinKokkos<DeviceType> c;

    FixLangevinKokkosPostForceFunctor(FixLangevinKokkos<DeviceType>* c_ptr):
      c(*c_ptr) {}
      ~FixLangevinKokkosPostForceFunctor(){c.cleanup_copy();}

      KOKKOS_INLINE_FUNCTION
      void operator()(const int i) const {
        c.template post_force_item<Tp_TSTYLEATOM,Tp_GJF, Tp_TALLY,
          Tp_BIAS,Tp_RMASS,Tp_ZERO>(i);
      }

      KOKKOS_INLINE_FUNCTION
      void operator()(const int i, value_type &fsum) const {

        fsum += c.template post_force_item<Tp_TSTYLEATOM,Tp_GJF, Tp_TALLY,
          Tp_BIAS,Tp_RMASS,Tp_ZERO>(i);
      }

      KOKKOS_INLINE_FUNCTION
      static void init(volatile value_type &update) {
        update.fx = 0.0;
        update.fy = 0.0;
        update.fz = 0.0;
      }
      KOKKOS_INLINE_FUNCTION
      static void join(volatile value_type &update,
                       const volatile value_type &source) {
        update.fx += source.fx;
        update.fy += source.fy;
        update.fz += source.fz;
      }

    };

  template <class DeviceType>
    struct FixLangevinKokkosZeroForceFunctor {
      typedef DeviceType  device_type ;
      FixLangevinKokkos<DeviceType> c;

    FixLangevinKokkosZeroForceFunctor(FixLangevinKokkos<DeviceType>* c_ptr):
      c(*c_ptr) {c.cleanup_copy();}

      KOKKOS_INLINE_FUNCTION
      void operator()(const int i) const {
        c.zero_force_item(i);
      }
    };

  template<class DeviceType>
    struct FixLangevinKokkosTallyEnergyFunctor {
      typedef DeviceType  device_type ;
      FixLangevinKokkos<DeviceType> c;
      typedef double value_type;
    FixLangevinKokkosTallyEnergyFunctor(FixLangevinKokkos<DeviceType>* c_ptr):
      c(*c_ptr) {c.cleanup_copy();}

      KOKKOS_INLINE_FUNCTION
      void operator()(const int i, value_type &energy) const {
        energy += c.compute_energy_item(i);
      }
      KOKKOS_INLINE_FUNCTION
      static void init(volatile value_type &update) {
        update = 0.0;
      }
      KOKKOS_INLINE_FUNCTION
      static void join(volatile value_type &update,
                       const volatile value_type &source) {
        update += source;
      }
    };

  template <class DeviceType, int RMass>
  struct FixLangevinKokkosEndOfStepFunctor {
    typedef DeviceType  device_type ;
    FixLangevinKokkos<DeviceType> c;

    FixLangevinKokkosEndOfStepFunctor(FixLangevinKokkos<DeviceType>* c_ptr):
      c(*c_ptr) {c.cleanup_copy();}

    KOKKOS_INLINE_FUNCTION
    void operator()(const int i) const {
      if (RMass) c.end_of_step_rmass_item(i);
      else c.end_of_step_item(i);
    }
  };
}

#endif
#endif

/* ERROR/WARNING messages:

E: Fix langevin omega is not yet implemented with kokkos

This option is not yet available.

E: Fix langevin angmom is not yet implemented with kokkos

This option is not yet available.

E: Cannot zero Langevin force of 0 atoms

The group has zero atoms, so you cannot request its force
be zeroed.

E: Fix langevin variable returned negative temperature

Self-explanatory.

E: Fix langevin gjf with tbias is not yet implemented with kokkos

This option is not yet available.

W: Fix langevin gjf using random gaussians is not implemented with kokkos

This will most likely cause errors in kinetic fluctuations.

*/
Loading