File: FundamentalAtomicQuantity.h

package info (click to toggle)
lammps 20220106.git7586adbb6a%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 348,064 kB
  • sloc: cpp: 831,421; python: 24,896; xml: 14,949; f90: 10,845; ansic: 7,967; sh: 4,226; perl: 4,064; fortran: 2,424; makefile: 1,501; objc: 238; lisp: 163; csh: 16; awk: 14; tcl: 6
file content (254 lines) | stat: -rw-r--r-- 9,904 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
// A class for defining an alternate atomic mass, needed for templating

#ifndef FUNDAMENTAL_ATOM_QUANTITY_H
#define FUNDAMENTAL_ATOM_QUANTITY_H

#include <string>

#include "PerAtomQuantity.h"

namespace ATC {

  // forward declarations
  class ATC_Method;

  //--------------------------------------------------------
  //--------------------------------------------------------
  //  Class FundamentalAtomQuantity
  //    A base class for defining objects that manage
  //    quantities defined at atoms based on lammps data
  //--------------------------------------------------------
  //--------------------------------------------------------

  class FundamentalAtomQuantity : public ShallowAtomQuantity<double> {

  public:

    // constructor
    FundamentalAtomQuantity(ATC_Method * atc,
                            LammpsInterface::FundamentalAtomQuantity atomQuantity,
                            AtomType atomType=INTERNAL);

    // destructor
    virtual ~FundamentalAtomQuantity() {};

    /** specialized reset to account for quantities which lammps can change */
    virtual void lammps_force_reset() {this->force_reset();};

  protected:

    /** enumerates the type of atom quantity being considered */
    LammpsInterface::FundamentalAtomQuantity atomQuantity_;

    /** converts from Lammps units to ATC units */
    double unitsConversion_;

    /** sets lammps data based on the quantity */
    virtual void set_lammps_to_quantity() const;

    /** sets the quantity based on a lammps pointer */
    virtual void set_quantity_to_lammps() const
      {ShallowAtomQuantity<double>::set_quantity_to_lammps(); if (unitsConversion_!=1.) quantity_ *= unitsConversion_;};

    /** gets appropriate pointer for lammps data */
    virtual double * lammps_scalar() const
      {return lammpsInterface_->atom_scalar(atomQuantity_);};

    /** gets appropriate pointer for lammps data */
    virtual double ** lammps_vector() const
      {return lammpsInterface_->atom_vector(atomQuantity_);};

  private:

    // do not define
    FundamentalAtomQuantity();

  };

  //--------------------------------------------------------
  //--------------------------------------------------------
  //  Class AtomMass
  //--------------------------------------------------------
  //--------------------------------------------------------

  class AtomMass : public FundamentalAtomQuantity {

  public:

    // constructor
    AtomMass(ATC_Method * atc,AtomType atomType = INTERNAL);

    // destructor
    virtual ~AtomMass() {};

    /** sets the quantity to a given value */
    virtual void operator=(const DENS_MAT & /* target */)
      {throw ATC_Error("Cannot modify type-based atom mass");};

    /** sets the quantity to a given constant value */
    virtual void operator=(const double & /* target */)
      {throw ATC_Error("Cannot modify type-based atom mass");};

    /** adds the given data to the Lammps quantity */
    virtual void operator+=(const DENS_MAT & /* addition */)
      {throw ATC_Error("Cannot modify type-based atom mass");};

    /** adds the scalar data to the Lammps quantity for AtC atoms */
    virtual void operator+=(double /* addition */)
      {throw ATC_Error("Cannot modify type-based atom mass");};

    /** subtracts the given data from the Lammps quantity */
    virtual void operator-=(const DENS_MAT & /* subtraction */)
      {throw ATC_Error("Cannot modify type-based atom mass");};

    /** subtracts the scalar data from the Lammps quantity for AtC atoms */
    virtual void operator-=(double /* subtracts */)
      {throw ATC_Error("Cannot modify type-based atom mass");};

    /** multiples the Lammps quantity by the given data, input is indexed in AtC atom counts */
    virtual void operator*=(const DENS_MAT & /* multiplier */)
      {throw ATC_Error("Cannot modify type-based atom mass");};

    /** multiples the Lammps quantity by the given data, input is indexed in AtC atom counts */
    virtual void operator*=(double /* multiplier */)
      {throw ATC_Error("Cannot modify type-based atom mass");};

    /** multiples the Lammps quantity by the given data, input is indexed in AtC atom counts */
    virtual void operator/=(const DENS_MAT & /* divisor */)
      {throw ATC_Error("Cannot modify type-based atom mass");};

    /** multiples the Lammps quantity by the given data, input is indexed in AtC atom counts */
    virtual void operator/=(double /* divisor */)
      {throw ATC_Error("Cannot modify type-based atom mass");};

  protected:

    /** sets lammps data based on the quantity */
    virtual void set_lammps_to_quantity() const {};

    /** sets the quantity based on a lammps pointer */
    virtual void set_quantity_to_lammps() const;

    /** gets appropriate pointer for lammps data */
    virtual double * lammps_scalar() const
      {return nullptr;};

    /** gets appropriate pointer for lammps data */
    virtual double ** lammps_vector() const
      {return nullptr;};

  private:

    // do not define
    AtomMass();

  };

  //--------------------------------------------------------
  //--------------------------------------------------------
  //  Class ComputedAtomQuantity
  //    A base class for defining objects that manage
  //    quantities defined at atoms by Lammps computes
  //    The compute associated with the tag must already
  //    be initialized.
  //--------------------------------------------------------
  //--------------------------------------------------------

  class ComputedAtomQuantity : public ShallowAtomQuantity<double> {

  public:

    // constructor
    ComputedAtomQuantity(ATC_Method * atc,
                         const std::string & tag,
                         double unitsConversion = 1.,
                         AtomType atomType=INTERNAL);

    // destructor
    virtual ~ComputedAtomQuantity() {};

    /** resets compute, must be this way to accommodate atom sorting between runs */
    virtual void post_exchange() {this->needReset_ = true;};

    /** specialized reset to account for forcing lammps to perform the compute */
    virtual void force_reset();

    /** specialized reset to account for quantities which lammps can change */
    virtual void lammps_force_reset() {this->force_reset();};

    // remove operations that change the lammps data
    /** returns a non-const version for manipulations and changes, resets dependent quantities */
    virtual DENS_MAT & set_quantity()
      {throw ATC_Error("ComputedAtomQuantity::set_quantity - Cannot modify computed per atom quantities"); return quantity_;};

    /** sets the quantity to a given constant value */
    virtual void operator=(const DENS_MAT & /* target */)
      {throw ATC_Error("ComputedAtomQuantity::operator= - Cannot modify computed per atom quantities");};

    /** adds the given data to the Lammps quantity */
    virtual void operator+=(const DENS_MAT & /* addition */)
      {throw ATC_Error("ComputedAtomQuantity::operator+= - Cannot modify computed per atom quantities");};

    /** adds the scalar data to the Lammps quantity for AtC atoms */
    virtual void operator+=(double /* addition */)
      {throw ATC_Error("ComputedAtomQuantity::operator+= - Cannot modify computed per atom quantities");};

    /** subtracts the given data from the Lammps quantity */
    virtual void operator-=(const DENS_MAT & /* subtraction */)
      {throw ATC_Error("ComputedAtomQuantity::operator-= - Cannot modify computed per atom quantities");};

    /** subtracts the scalar data from the Lammps quantity for AtC atoms */
    virtual void operator-=(double /* subtraction */)
      {throw ATC_Error("ComputedAtomQuantity::operator-= - Cannot modify computed per atom quantities");};

    /** multiples the Lammps quantity by the given data, input is indexed in AtC atom counts */
    virtual void operator*=(const DENS_MAT & /* multiplier */)
      {throw ATC_Error("ComputedAtomQuantity::operator*= - Cannot modify computed per atom quantities");};

    /** multiples the Lammps quantity by the given data, input is indexed in AtC atom counts */
    virtual void operator*=(double /* multiplier */)
      {throw ATC_Error("ComputedAtomQuantity::operator*= - Cannot modify computed per atom quantities");};

    /** multiples the Lammps quantity by the given data, input is indexed in AtC atom counts */
    virtual void operator/=(const DENS_MAT & /* divisor */)
      {throw ATC_Error("ComputedAtomQuantity::operator/= - Cannot modify computed per atom quantities");};

    /** multiples the Lammps quantity by the given data, input is indexed in AtC atom counts */
    virtual void operator/=(double /* divisor */)
      {throw ATC_Error("ComputedAtomQuantity::operator/= - Cannot modify computed per atom quantities");};

  protected:

    /** pointer to Lammps compute, meant as rapid indexing only (do not use!) */
    COMPUTE_POINTER computePointer_;

    /** tag for Lammps compute */
    std::string computeTag_;

    /** units conversion from LAMMPS to ATC units */
    double unitsConversion_;

    /** sets the quantity based on a lammps pointer */
    virtual void set_quantity_to_lammps() const
    {ShallowAtomQuantity<double>::set_quantity_to_lammps(); if (unitsConversion_!=1.) quantity_ *= unitsConversion_;};

    /** gets appropriate data for lammps pointer */
    virtual double * lammps_scalar() const {return lammpsInterface_->compute_vector_peratom(computePointer_);};

    /** gets appropriate data for lammps pointer */
    virtual double ** lammps_vector() const {return lammpsInterface_->compute_array_peratom(computePointer_);};

    // not needed if no MPI
    /** sets lammps data based on the quantity */
    virtual void set_lammps_to_quantity() const
      {throw ATC_Error("ComputedAtomQuantity::set_lammps_to_quantity - Cannot modify a compute's LAMMPS data");};

  private:

    // do not define
    ComputedAtomQuantity();

  };

}
#endif