BrookCalcKineticEnergyKernel.cpp 5.1 KB
Newer Older
Mark Friedrichs's avatar
Mark Friedrichs committed
1
2
3
4
5
6
7
8
9
/* -------------------------------------------------------------------------- *
 *                                   OpenMM                                   *
 * -------------------------------------------------------------------------- *
 * This is part of the OpenMM molecular simulation toolkit originating from   *
 * Simbios, the NIH National Center for Physics-Based Simulation of           *
 * Biological Structures at Stanford, funded under the NIH Roadmap for        *
 * Medical Research, grant U54 GM072970. See https://simtk.org.               *
 *                                                                            *
 * Portions copyright (c) 2008 Stanford University and the Authors.           *
Mark Friedrichs's avatar
Mark Friedrichs committed
10
 * Authors: Peter Eastman                                                     *
Mark Friedrichs's avatar
Mark Friedrichs committed
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 * Contributors:                                                              *
 *                                                                            *
 * Permission is hereby granted, free of charge, to any person obtaining a    *
 * copy of this software and associated documentation files (the "Software"), *
 * to deal in the Software without restriction, including without limitation  *
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,   *
 * and/or sell copies of the Software, and to permit persons to whom the      *
 * Software is furnished to do so, subject to the following conditions:       *
 *                                                                            *
 * The above copyright notice and this permission notice shall be included in *
 * all copies or substantial portions of the Software.                        *
 *                                                                            *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   *
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    *
 * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,    *
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR      *
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE  *
 * USE OR OTHER DEALINGS IN THE SOFTWARE.                                     *
 * -------------------------------------------------------------------------- */

Mark Friedrichs's avatar
Mark Friedrichs committed
32
33
#include "BrookCalcKineticEnergyKernel.h"
#include "BrookStreamInternal.h"
Mark Friedrichs's avatar
Mark Friedrichs committed
34
35

using namespace OpenMM;
Mark Friedrichs's avatar
Mark Friedrichs committed
36
using namespace std;
Mark Friedrichs's avatar
Mark Friedrichs committed
37

38
/** 
Mark Friedrichs's avatar
Mark Friedrichs committed
39
 * BrookCalcKineticEnergyKernel constructor
40
 * 
Mark Friedrichs's avatar
Mark Friedrichs committed
41
42
 * @param name        name of the stream to create
 * @param platform    platform
43
44
45
 *
 */

Mark Friedrichs's avatar
Mark Friedrichs committed
46
47
BrookCalcKineticEnergyKernel::BrookCalcKineticEnergyKernel( std::string name, const Platform& platform ) :
                              CalcKineticEnergyKernel( name, platform ){
48
49
50

// ---------------------------------------------------------------------------------------

Mark Friedrichs's avatar
Mark Friedrichs committed
51
   // static const std::string methodName      = "BrookCalcKineticEnergyKernel::BrookCalcKineticEnergyKernel";
52
53
54

// ---------------------------------------------------------------------------------------

Mark Friedrichs's avatar
Mark Friedrichs committed
55
56
}

57
/** 
Mark Friedrichs's avatar
Mark Friedrichs committed
58
 * BrookCalcKineticEnergyKernel destructor
59
60
 * 
 */
Mark Friedrichs's avatar
Mark Friedrichs committed
61
62
  
BrookCalcKineticEnergyKernel::~BrookCalcKineticEnergyKernel( ){
63
64
65

// ---------------------------------------------------------------------------------------

Mark Friedrichs's avatar
Mark Friedrichs committed
66
   // static const std::string methodName      = "BrookCalcKineticEnergyKernel::~BrookCalcKineticEnergyKernel";
67
68
69

// ---------------------------------------------------------------------------------------

Mark Friedrichs's avatar
Mark Friedrichs committed
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
    if (dynamics)
        delete dynamics;
    if (shake)
        delete shake;
    if (masses)
        delete[] masses;
    if (constraintIndices)
        disposeIntArray(constraintIndices, numConstraints);
    if (shakeParameters)
        disposeRealArray(shakeParameters, numConstraints);
*/

Mark Friedrichs's avatar
Mark Friedrichs committed
83
84
}

85
/** 
Mark Friedrichs's avatar
Mark Friedrichs committed
86
 * Initialize the kernel
87
 * 
Mark Friedrichs's avatar
Mark Friedrichs committed
88
 * @param masses   mass of each atom
89
90
91
 *
 */

Mark Friedrichs's avatar
Mark Friedrichs committed
92
void BrookCalcKineticEnergyKernel::initialize( const vector<double>& masses ){
93
94
95

// ---------------------------------------------------------------------------------------

Mark Friedrichs's avatar
Mark Friedrichs committed
96
   // static const std::string methodName      = "BrookCalcKineticEnergyKernel::initialize";
97
98
99

// ---------------------------------------------------------------------------------------

Mark Friedrichs's avatar
Mark Friedrichs committed
100
101
102
    // this->masses = masses;

   return;
Mark Friedrichs's avatar
Mark Friedrichs committed
103
104
}

105
/** 
Mark Friedrichs's avatar
Mark Friedrichs committed
106
 * Execute kernel
107
 * 
Mark Friedrichs's avatar
Mark Friedrichs committed
108
109
110
 * @param velocities  stream of atom velocities
 *
 * @return kinetic energy of the system
111
112
113
 *
 */

Mark Friedrichs's avatar
Mark Friedrichs committed
114
double BrookCalcKineticEnergyKernel::execute( const Stream& velocities ){
115
116
117

// ---------------------------------------------------------------------------------------

Mark Friedrichs's avatar
Mark Friedrichs committed
118
   // static const std::string methodName      = "BrookCalcKineticEnergyKernel::execute";
119
120
121

// ---------------------------------------------------------------------------------------

Mark Friedrichs's avatar
Mark Friedrichs committed
122
123
124
125
126
127
128
/*
    RealOpenMM** velData = const_cast<RealOpenMM**>(((BrookFloatStreamImpl&) velocities.getImpl()).getData()); // Brook code needs to be made const correct
    double energy = 0.0;
    for (size_t i = 0; i < masses.size(); ++i)
        energy += masses[i]*(velData[i][0]*velData[i][0]+velData[i][1]*velData[i][1]+velData[i][2]*velData[i][2]);
    return 0.5*energy;
*/
129

Mark Friedrichs's avatar
Mark Friedrichs committed
130
   return 0.0;
Mark Friedrichs's avatar
Mark Friedrichs committed
131
}