1 /* -*- c++ -*- ---------------------------------------------------------- 2 LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator 3 https://www.lammps.org/, Sandia National Laboratories 4 Steve Plimpton, sjplimp@sandia.gov 5 6 Copyright (2003) Sandia Corporation. Under the terms of Contract 7 DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains 8 certain rights in this software. This software is distributed under 9 the GNU General Public License. 10 11 See the README file in the top-level LAMMPS directory. 12 ------------------------------------------------------------------------- */ 13 14 #ifdef FIX_CLASS 15 // clang-format off 16 FixStyle(rattle,FixRattle); 17 // clang-format on 18 #else 19 20 #ifndef LMP_FIX_RATTLE_H 21 #define LMP_FIX_RATTLE_H 22 23 #include "fix_shake.h" 24 25 namespace LAMMPS_NS { 26 27 class FixRattle : public FixShake { 28 public: 29 double **vp; // array for unconstrained velocities 30 int comm_mode; // mode for communication pack/unpack 31 double derr_max; // distance error 32 double verr_max; // velocity error 33 34 FixRattle(class LAMMPS *, int, char **); 35 ~FixRattle(); 36 int setmask(); 37 virtual void init(); 38 virtual void post_force(int); 39 virtual void post_force_respa(int, int, int); 40 virtual void final_integrate(); 41 virtual void final_integrate_respa(int, int); 42 43 virtual void correct_coordinates(int vflag); 44 virtual void correct_velocities(); 45 virtual void shake_end_of_step(int vflag); 46 47 virtual double memory_usage(); 48 virtual void grow_arrays(int); 49 virtual int pack_forward_comm(int, int *, double *, int, int *); 50 virtual void unpack_forward_comm(int, int, double *); 51 virtual void reset_dt(); 52 53 private: 54 void update_v_half_nocons(); 55 void update_v_half_nocons_respa(int); 56 57 void vrattle2(int m); 58 void vrattle3(int m); 59 void vrattle4(int m); 60 void vrattle3angle(int m); 61 void solve3x3exactly(const double a[][3], const double c[], double l[]); 62 void solve2x2exactly(const double a[][2], const double c[], double l[]); 63 64 // debugging methods 65 66 bool check3angle(double **v, int m, bool checkr, bool checkv); 67 bool check2(double **v, int m, bool checkr, bool checkv); 68 bool check3(double **v, int m, bool checkr, bool checkv); 69 bool check4(double **v, int m, bool checkr, bool checkv); 70 bool check_constraints(double **v, bool checkr, bool checkv); 71 void end_of_step(); 72 }; 73 74 } // namespace LAMMPS_NS 75 76 #endif 77 #endif 78 79 /* ERROR/WARNING messages: 80 81 W: Fix rattle should come after all other integration fixes 82 83 UNDOCUMENTED 84 85 E: Rattle determinant = 0.0 86 87 The determinant of the matrix being solved for a single cluster 88 specified by the fix rattle command is numerically invalid. 89 90 E: Rattle failed 91 92 UNDOCUMENTED 93 94 E: Coordinate constraints are not satisfied up to desired tolerance 95 96 UNDOCUMENTED 97 98 E: Velocity constraints are not satisfied up to desired tolerance 99 100 UNDOCUMENTED 101 102 E: Velocity constraints are not satisfied up to desired tolerance! 103 104 UNDOCUMENTED 105 106 U: Fix rattle should come after all other integration fixes 107 108 This fix is designed to work after all other integration fixes change 109 atom positions. Thus it should be the last integration fix specified. 110 If not, it will not satisfy the desired constraints as well as it 111 otherwise would. 112 113 U: Rattle failed 114 115 Certain constraints were not satisfied. 116 117 U: Coordinate constraints are not satisfied up to desired tolerance 118 119 Self-explanatory. 120 121 U: Rattle velocity constraints are not satisfied up to desired tolerance 122 123 Self-explanatory. 124 125 */ 126