"platforms/cuda/src/kernels/customGBValueN2.cu" did not exist on "d65992eaa97e1279a8646d606771006482ca5119"
CudaFreeEnergyKernels.h 7.74 KB
Newer Older
Mark Friedrichs's avatar
Mark Friedrichs committed
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
#ifndef OPENMM_FREE_ENERGY_CUDA_KERNELS_H_
#define OPENMM_FREE_ENERGY_CUDA_KERNELS_H_

/* -------------------------------------------------------------------------- *
 *                                   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.           *
 * Authors: Peter Eastman                                                     *
 * Contributors:                                                              *
 *                                                                            *
 * This program is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU Lesser General Public License as published   *
 * by the Free Software Foundation, either version 3 of the License, or       *
 * (at your option) any later version.                                        *
 *                                                                            *
 * This program is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
 * GNU Lesser General Public License for more details.                        *
 *                                                                            *
 * You should have received a copy of the GNU Lesser General Public License   *
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.      *
 * -------------------------------------------------------------------------- */

#include "CudaPlatform.h"
#include "openmm/kernels.h"
#include "kernels/gputypes.h"
#include "openmm/System.h"
#include "OpenMMFreeEnergy.h"
#include "openmm/freeEnergyKernels.h"
36
#include "FreeEnergyCudaData.h"
Mark Friedrichs's avatar
Mark Friedrichs committed
37
38
39
40
41
42
43

namespace OpenMM {

/**
 * This kernel is invoked by NonbondedSoftcoreForce to calculate the forces acting on the system.
 */
class CudaFreeEnergyCalcNonbondedSoftcoreForceKernel : public CalcNonbondedSoftcoreForceKernel {
44

Mark Friedrichs's avatar
Mark Friedrichs committed
45
public:
46
    CudaFreeEnergyCalcNonbondedSoftcoreForceKernel(std::string name, const Platform& platform, FreeEnergyCudaData& data, System& system) :
Mark Friedrichs's avatar
Mark Friedrichs committed
47
             CalcNonbondedSoftcoreForceKernel(name, platform), data(data), system(system) {
48

Mark Friedrichs's avatar
Mark Friedrichs committed
49
50
51
52
        numExceptions        = 0;
        numParticles         = 0;
        bIncludeGBSA         = false;
        bIncludeGBVI         = false;
53
        includeSoftcore      = false;
54
55
        log                  = NULL;
        data.incrementKernelCount();
Mark Friedrichs's avatar
Mark Friedrichs committed
56
57
58
    }

    ~CudaFreeEnergyCalcNonbondedSoftcoreForceKernel();
59

Mark Friedrichs's avatar
Mark Friedrichs committed
60
61
62
63
64
65
66
67
    /**
     * Initialize the kernel.
     * 
     * @param system     the System this kernel will be applied to
     * @param force      the NonbondedForce this kernel will be used for
     */
    void initialize(const System& system, const NonbondedSoftcoreForce& force);
    /**
68
69
70
71
72
73
     * Execute the kernel to calculate the forces and/or energy.
     *
     * @param context        the context in which to execute this kernel
     * @param includeForces  true if forces should be calculated
     * @param includeEnergy  true if the energy should be calculated
     * @return the potential energy due to the force
Mark Friedrichs's avatar
Mark Friedrichs committed
74
     */
75
    double execute(ContextImpl& context, bool includeForces, bool includeEnergy);
Mark Friedrichs's avatar
Mark Friedrichs committed
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
    /**
     * Get flag signalling whether GBSA/OBC force is included
     *
     * @return flag
     */
    bool getIncludeGBSA( void ) const;
    /**
     * Set flag signalling whether GBSA/OBC force is included
     *
     * @param inputIncludeGBSA input flag value
     */
    void setIncludeGBSA( bool inputIncludeGBSA );
    /**
     * Get flag signalling whether GB/VI force is included
     *
     * @return flag
     */
    bool getIncludeGBVI( void ) const;
    /**
     * Set flag signalling whether GB/VI force is included
     *
     * @param inputIncludeGBVI input flag value
     */
    void setIncludeGBVI( bool inputIncludeGBVI );
    /**
     * Get flag signalling whether softcore force is included
     *
     * @return flag
     */
105
    int getIncludeSoftcore( void ) const;
Mark Friedrichs's avatar
Mark Friedrichs committed
106
107
108
109
110
    /**
     * Set flag signalling whether GB/VI force is included
     *
     * @param inputIncludeGBVI input flag value
     */
111
    void setIncludeSoftcore( int inputSoftcore);
Mark Friedrichs's avatar
Mark Friedrichs committed
112
113
114
115
116
117
118
    /**
     * Get number of exceptions
     *
     * @return number of exceptions
     */
    int getNumExceptions( void ) const;
private:
119
120
    FreeEnergyCudaData& data;
    class ForceInfo;
Mark Friedrichs's avatar
Mark Friedrichs committed
121
122
123
124
    int numParticles;
    System& system;
    bool bIncludeGBSA;
    bool bIncludeGBVI;
125
    int includeSoftcore;
Mark Friedrichs's avatar
Mark Friedrichs committed
126
127
128
129
130
131
132
133
134
    int numExceptions;
    FILE* log;
};

/**
 * This kernel is invoked by GBSAOBCForce to calculate the forces acting on the system.
 */
class CudaFreeEnergyCalcGBSAOBCSoftcoreForceKernel : public CalcGBSAOBCSoftcoreForceKernel {
public:
135
    CudaFreeEnergyCalcGBSAOBCSoftcoreForceKernel(std::string name, const Platform& platform, FreeEnergyCudaData& data) :
Mark Friedrichs's avatar
Mark Friedrichs committed
136
137
       CalcGBSAOBCSoftcoreForceKernel(name, platform), data(data) {
        log                  = NULL;
138
        data.incrementKernelCount();
Mark Friedrichs's avatar
Mark Friedrichs committed
139
140
141
142
143
144
145
146
147
148
    }
    ~CudaFreeEnergyCalcGBSAOBCSoftcoreForceKernel();
    /**
     * Initialize the kernel.
     * 
     * @param system     the System this kernel will be applied to
     * @param force      the GBSAOBCForce this kernel will be used for
     */
    void initialize(const System& system, const GBSAOBCSoftcoreForce& force);
    /**
149
150
151
152
153
154
     * Execute the kernel to calculate the forces and/or energy.
     *
     * @param context        the context in which to execute this kernel
     * @param includeForces  true if forces should be calculated
     * @param includeEnergy  true if the energy should be calculated
     * @return the potential energy due to the force
Mark Friedrichs's avatar
Mark Friedrichs committed
155
     */
156
    double execute(ContextImpl& context, bool includeForces, bool includeEnergy);
Mark Friedrichs's avatar
Mark Friedrichs committed
157
private:
158
159
    FreeEnergyCudaData& data;
    class ForceInfo;
Mark Friedrichs's avatar
Mark Friedrichs committed
160
161
162
163
164
165
166
167
    FILE* log;
};

/**
 * This kernel is invoked by GBVIForce to calculate the forces acting on the system.
 */
class CudaFreeEnergyCalcGBVISoftcoreForceKernel : public CalcGBVISoftcoreForceKernel {
public:
168
    CudaFreeEnergyCalcGBVISoftcoreForceKernel(std::string name, const Platform& platform, FreeEnergyCudaData& data) :
Mark Friedrichs's avatar
Mark Friedrichs committed
169
         CalcGBVISoftcoreForceKernel(name, platform), data(data) {
170

Mark Friedrichs's avatar
Mark Friedrichs committed
171
172
        log                  = NULL;
        quinticScaling       = 0;
173
        data.incrementKernelCount();
Mark Friedrichs's avatar
Mark Friedrichs committed
174
175
176
177
178
179
180
181
182
183
184
185
    }

    ~CudaFreeEnergyCalcGBVISoftcoreForceKernel();
    /**
     * Initialize the kernel.
     * 
     * @param system      the System this kernel will be applied to
     * @param force       the GBVIForce this kernel will be used for
     * @param scaledRadii the scaled radii (Eq. 5 of Labute paper)
     */
    void initialize(const System& system, const GBVISoftcoreForce& force, const std::vector<double> & scaledRadii);
    /**
186
187
188
189
190
191
     * Execute the kernel to calculate the forces and/or energy.
     *
     * @param context        the context in which to execute this kernel
     * @param includeForces  true if forces should be calculated
     * @param includeEnergy  true if the energy should be calculated
     * @return the potential energy due to the force
Mark Friedrichs's avatar
Mark Friedrichs committed
192
     */
193
    double execute(ContextImpl& context, bool includeForces, bool includeEnergy);
Mark Friedrichs's avatar
Mark Friedrichs committed
194
195

private:
196
197
    FreeEnergyCudaData& data;
    class ForceInfo;
Mark Friedrichs's avatar
Mark Friedrichs committed
198
199
200
201
202
203
204
    FILE* log;
    int quinticScaling;
};

} // namespace OpenMM

#endif /*OPENMM_FREE_ENERGY_CUDA_KERNELS_H_*/