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(poems,FixPOEMS);
17 // clang-format on
18 #else
19 
20 #ifndef LMP_FIX_POEMS_H
21 #define LMP_FIX_POEMS_H
22 
23 #include "fix.h"
24 
25 class Workspace;
26 
27 namespace LAMMPS_NS {
28 
29 class FixPOEMS : public Fix {
30  public:
31   FixPOEMS(class LAMMPS *, int narg, char **arg);
32   ~FixPOEMS();
33   int setmask();
34   void init();
35   void setup(int);
36   void initial_integrate(int);
37   void post_force(int);
38   void final_integrate();
39   void initial_integrate_respa(int, int, int);
40   void post_force_respa(int, int, int);
41   void final_integrate_respa(int, int);
42 
43   void grow_arrays(int);
44   void copy_arrays(int, int, int);
45   int pack_exchange(int, double *);
46   int unpack_exchange(int, double *);
47   double memory_usage();
48 
49   void pre_neighbor();
50   int dof(int);
51   void deform(int);
52   int modify_param(int, char **);
53   void reset_dt();
54 
55  private:
56   int me;
57   double dtv, dtf, dthalf;
58   double *step_respa;
59   int nlevels_respa;
60   double total_ke;
61   int earlyflag;    // 1 if forces and torques are computed at post_force()
62 
63   // atom assignment to rigid bodies
64   // double count joint atoms as being in multiple bodies
65 
66   int *natom2body;      // # of bodies each atom is part of
67   int **atom2body;      // list of bodies each atom is part of
68   double **displace;    // atom displace in body coords for 1st body it's in
69 
70   // rigid body properties
71   // only nrigid double counts joint atoms as being in multiple bodies
72   // other quantities only count a joint atom as being in 1st body
73 
74   int nbody;            // # of rigid bodies
75   int *nrigid;          // # of atoms in each rigid body
76   double *masstotal;    // total mass of each rigid body
77   double **xcm;         // coords of center-of-mass of each rigid body
78   double **vcm;         // velocity of center-of-mass of each
79   double **fcm;         // force on center-of-mass of each
80   double **inertia;     // 6 inertia components of each (xx,yy,zz,xy,yz,xz)
81   double **ex_space, **ey_space, **ez_space;
82   // orientation of each body in space coords
83   double **angmom;        // angular momentum of each in space coords
84   double **omega;         // angular velocity of each in space coords
85   double **torque;        // torque on each rigid body in space coords
86   double **sum, **all;    // work vectors
87 
88   // joint attributes between pairs of rigid bodies
89 
90   int ncluster;       // # of independent clusters of coupled bodies
91   int njoint;         // # of interbody joints
92   int **jointbody;    // indices of 2 rigid bodies in each joint (1-N)
93   double **xjoint;    // coords of each joint point
94   int nfree;          // # of isolated unconnected bodies
95   int *freelist;      // indices of isolated bodies (1-N)
96 
97   // POEMS object
98 
99   Workspace *poems;
100 
101   // internal class functions
102 
103   void compute_forces_and_torques();
104   void readfile(char *);
105   int readline(FILE *, char **, int *);
106   void jointbuild();
107   void sortlist(int, tagint **);
108   int loopcheck(int, int, tagint **);
109   void omega_from_mq(double *, double *, double *, double *, double *, double *);
110   void set_v();
111   void set_xv();
112 };
113 
114 }    // namespace LAMMPS_NS
115 
116 #endif
117 #endif
118 
119 /* ERROR/WARNING messages:
120 
121 E: Illegal ... command
122 
123 Self-explanatory.  Check the input script syntax and compare to the
124 documentation for the command.  You can use -echo screen as a
125 command-line option when running LAMMPS to see the offending line.
126 
127 E: Could not find fix poems group ID
128 
129 A group ID used in the fix poems command does not exist.
130 
131 E: Must use a molecular atom style with fix poems molecule
132 
133 Self-explanatory.
134 
135 E: Too many molecules for fix poems
136 
137 The limit is 2^31 = ~2 billion molecules.
138 
139 E: No rigid bodies defined
140 
141 The fix specification did not end up defining any rigid bodies.
142 
143 E: Atom in too many rigid bodies - boost MAXBODY
144 
145 Fix poems has a parameter MAXBODY (in fix_poems.cpp) which determines
146 the maximum number of rigid bodies a single atom can belong to (i.e. a
147 multibody joint).  The bodies you have defined exceed this limit.
148 
149 E: One or zero atoms in rigid body
150 
151 Any rigid body defined by the fix rigid command must contain 2 or more
152 atoms.
153 
154 W: More than one fix poems
155 
156 It is not efficient to use fix poems more than once.
157 
158 E: POEMS fix must come before NPT/NPH fix
159 
160 NPT/NPH fix must be defined in input script after all poems fixes,
161 else the fix contribution to the pressure virial is incorrect.
162 
163 E: Insufficient Jacobi rotations for POEMS body
164 
165 Eigensolve for rigid body was not sufficiently accurate.
166 
167 E: Rigid body has degenerate moment of inertia
168 
169 Fix poems will only work with bodies (collections of atoms) that have
170 non-zero principal moments of inertia.  This means they must be 3 or
171 more non-collinear atoms, even with joint atoms removed.
172 
173 E: Bad principal moments
174 
175 Fix rigid did not compute the principal moments of inertia of a rigid
176 group of atoms correctly.
177 
178 E: Cannot open fix poems file %s
179 
180 The specified file cannot be opened.  Check that the path and name are
181 correct.
182 
183 W: No joints between rigid bodies, use fix rigid instead
184 
185 The bodies defined by fix poems are not connected by joints.  POEMS
186 will integrate the body motion, but it would be more efficient to use
187 fix rigid.
188 
189 E: Cyclic loop in joint connections
190 
191 Fix poems cannot (yet) work with coupled bodies whose joints connect
192 the bodies in a ring (or cycle).
193 
194 E: Tree structure in joint connections
195 
196 Fix poems cannot (yet) work with coupled bodies whose joints connect
197 the bodies in a tree structure.
198 
199 */
200