2 Highly Optimized Object-oriented Many-particle Dynamics -- Blue Edition
3 (HOOMD-blue) Open Source Software License Copyright 2009-2014 The Regents of
4 the University of Michigan All rights reserved.
6 HOOMD-blue may contain modifications ("Contributions") provided, and to which
7 copyright is held, by various Contributors who have granted The Regents of the
8 University of Michigan the right to modify and/or distribute such Contributions.
10 You may redistribute, use, and create derivate works of HOOMD-blue, in source
11 and binary forms, provided you abide by the following conditions:
13 * Redistributions of source code must retain the above copyright notice, this
14 list of conditions, and the following disclaimer both in the code and
15 prominently in any materials provided with the distribution.
17 * Redistributions in binary form must reproduce the above copyright notice, this
18 list of conditions, and the following disclaimer in the documentation and/or
19 other materials provided with the distribution.
21 * All publications and presentations based on HOOMD-blue, including any reports
22 or published results obtained, in whole or in part, with HOOMD-blue, will
23 acknowledge its use according to the terms posted at the time of submission on:
24 http://codeblue.umich.edu/hoomd-blue/citations.html
26 * Any electronic documents citing HOOMD-Blue will link to the HOOMD-Blue website:
27 http://codeblue.umich.edu/hoomd-blue/
29 * Apart from the above required attributions, neither the name of the copyright
30 holder nor the names of HOOMD-blue's contributors may be used to endorse or
31 promote products derived from this software without specific prior written
36 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS'' AND
37 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
38 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND/OR ANY
39 WARRANTIES THAT THIS SOFTWARE IS FREE OF INFRINGEMENT ARE DISCLAIMED.
41 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
42 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
43 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
44 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
45 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
46 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
47 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50 // Maintainer: joaander
52 #ifndef __EVALUATOR_CONSTRAINT_H__
53 #define __EVALUATOR_CONSTRAINT_H__
55 #include "HOOMDMath.h"
57 /*! \file EvaluatorConstraint.h
58 \brief Defines basic evaluation methods common to all constraint force implementations
61 // need to declare these class methods with __device__ qualifiers when building in nvcc
62 // DEVICE is __host__ __device__ when included in nvcc and blank when included into the host compiler
64 #define DEVICE __device__
69 //! Class for evaluating constraint forces
70 /*! <b>General Overview</b>
71 EvaluatorConstraint is a low level computation class for use on the CPU and GPU. It provides basic functionality
72 needed by all constraint forces.
74 class EvaluatorConstraint
77 //! Constructs the constraint evaluator
78 /*! \param _X Current position at the time of the constraint force calculation
79 \param V Current velocity at the time of the constraint force calculation
80 \param F Current net force at the time of the constraint force calculation
81 \param _m Mass of the particle
82 \param _deltaT Step size delta t
84 DEVICE
EvaluatorConstraint(Scalar3 _X
, Scalar3 V
, Scalar3 F
, Scalar _m
, Scalar _deltaT
)
85 : X(_X
), m(_m
), deltaT(_deltaT
)
87 // perform step 2 of this velocity verlet update and step 1 of the next to get
88 // U = X(t+2deltaT) given X = X(t+deltaT)
89 Scalar minv
= Scalar(1.0)/m
;
90 Scalar dtsqdivm
= deltaT
*deltaT
* minv
;
91 U
.x
= X
.x
+ V
.x
* deltaT
+ F
.x
* dtsqdivm
;
92 U
.y
= X
.y
+ V
.y
* deltaT
+ F
.y
* dtsqdivm
;
93 U
.z
= X
.z
+ V
.z
* deltaT
+ F
.z
* dtsqdivm
;
96 //! Evaluate the unconstrained position update U
97 /*! \returns The unconstrained position update U
99 DEVICE Scalar3
evalU()
104 //! Evaluate the additional constraint force
105 /*! \param FC output parameter where the computed force is written
106 \param virial array of six scalars the computed virial tensor is written
107 \param C constrained position particle will be moved to at the next step
108 \return Additional force \a F needed to satisfy the constraint
110 DEVICE
void evalConstraintForce(Scalar3
& FC
, Scalar
*virial
, const Scalar3
& C
)
112 // subtract a constrained update from U and get that F = (C-U)*m/dt^2
113 Scalar moverdtsq
= m
/ (deltaT
* deltaT
);
114 FC
.x
= (C
.x
- U
.x
) * moverdtsq
;
115 FC
.y
= (C
.y
- U
.y
) * moverdtsq
;
116 FC
.z
= (C
.z
- U
.z
) * moverdtsq
;
119 virial
[0] = FC
.x
* X
.x
;
120 virial
[1] = Scalar(1./2.)*(FC
.y
* X
.x
+ FC
.x
* X
.y
);
121 virial
[2] = Scalar(1./2.)*(FC
.z
* X
.x
+ FC
.x
* X
.z
);
122 virial
[3] = FC
.y
* X
.y
;
123 virial
[4] = Scalar(1./2.)*(FC
.z
* X
.y
+ FC
.y
* X
.z
);
124 virial
[5] = FC
.z
* X
.z
;
128 Scalar3 U
; //!< Unconstrained position update
129 Scalar3 X
; //!< Current particle position
130 Scalar m
; //!< Saved mass value
131 Scalar deltaT
; //!< Saved delta T value
136 #endif // __PAIR_EVALUATOR_LJ_H__