BrookKernelFactory.cpp 5.79 KB
Newer Older
Mark Friedrichs's avatar
Mark Friedrichs committed
1
2
3
4
5
6
7
8
/* -------------------------------------------------------------------------- *
 *                                   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.               *
 *                                                                            *
9
10
 * Portions copyright (c) 2009 Stanford University and the Authors.           *
 * Authors: Mark Friedrichs, Mike Houston                                     *
Mark Friedrichs's avatar
Mark Friedrichs committed
11
12
 * Contributors:                                                              *
 *                                                                            *
13
14
15
16
 * 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.                                        *
Mark Friedrichs's avatar
Mark Friedrichs committed
17
 *                                                                            *
18
19
20
21
 * 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.                        *
Mark Friedrichs's avatar
Mark Friedrichs committed
22
 *                                                                            *
23
24
 * 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/>.      *
Mark Friedrichs's avatar
Mark Friedrichs committed
25
26
27
 * -------------------------------------------------------------------------- */

#include "BrookKernelFactory.h"
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
28
#include "BrookInitializeForcesKernel.h"
29
#include "BrookUpdateTimeKernel.h"
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
30
#include "BrookCalcHarmonicBondForceKernel.h"
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
31
#include "BrookCalcHarmonicAngleForceKernel.h"
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
32
33
#include "BrookCalcPeriodicTorsionForceKernel.h"
#include "BrookCalcRBTorsionForceKernel.h"
34
#include "BrookCalcNonbondedForceKernel.h"
Mark Friedrichs's avatar
Mark Friedrichs committed
35
#include "BrookIntegrateLangevinStepKernel.h"
Mark Friedrichs's avatar
Mark Friedrichs committed
36
#include "BrookIntegrateVerletStepKernel.h"
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
37
//#include "BrookIntegrateBrownianStepKernel.h"
Mark Friedrichs's avatar
Mark Friedrichs committed
38
#include "BrookCalcKineticEnergyKernel.h"
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
39
#include "BrookCalcGBSAOBCForceKernel.h"
40
#include "BrookRemoveCMMotionKernel.h"
41
#include "openmm/internal/ContextImpl.h"
Mark Friedrichs's avatar
Mark Friedrichs committed
42
43
44

using namespace OpenMM;

45
KernelImpl* BrookKernelFactory::createKernelImpl( std::string name, const Platform& platform, ContextImpl& context ) const {
Mark Friedrichs's avatar
Mark Friedrichs committed
46
47
48
49
50
51
52

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

   static const std::string methodName      = "BrookKernelFactory::createKernelImpl";

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

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
53
   OpenMMBrookInterface& openMMBrookInterface = *static_cast<OpenMMBrookInterface*>(context.getPlatformData());
Mark Friedrichs's avatar
Mark Friedrichs committed
54

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
55
56
   // initialize forces

57
	if( name == CalcForcesAndEnergyKernel::Name() ){
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
58
59
60

      return new BrookInitializeForcesKernel( name, platform, openMMBrookInterface, context.getSystem() );

61
62
63
64
65
66
67
   // update time

	} else if( name == UpdateTimeKernel::Name() ){

      return new BrookUpdateTimeKernel( name, platform, openMMBrookInterface );

   // harmonic bonds
Mark Friedrichs's avatar
Mark Friedrichs committed
68

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
69
	} else if( name == CalcHarmonicBondForceKernel::Name() ){
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
70

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
71
      return new BrookCalcHarmonicBondForceKernel( name, platform, openMMBrookInterface, context.getSystem() );
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
72
73
74
75
76
77
78
79
80
81
82

   // angle bonds

	} else if( name == CalcHarmonicAngleForceKernel::Name() ){

      return new BrookCalcHarmonicAngleForceKernel( name, platform, openMMBrookInterface, context.getSystem() );

   // periodic torsion bonds

	} else if( name == CalcPeriodicTorsionForceKernel::Name() ){

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
83
      return new BrookCalcPeriodicTorsionForceKernel( name, platform, openMMBrookInterface, context.getSystem() );
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
84
85
86
87
88

   // RB torsion bonds

	} else if( name == CalcRBTorsionForceKernel::Name() ){

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
89
      return new BrookCalcRBTorsionForceKernel( name, platform, openMMBrookInterface, context.getSystem() );
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
90
91
92
93
94

   // nonbonded 

	} else if( name == CalcNonbondedForceKernel::Name() ){

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
95
      return new BrookCalcNonbondedForceKernel( name, platform, openMMBrookInterface, context.getSystem() );
Mark Friedrichs's avatar
Mark Friedrichs committed
96
97
98

   // GBSA OBC

99
	} else if( name == CalcGBSAOBCForceKernel::Name() ){
Mark Friedrichs's avatar
Mark Friedrichs committed
100

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
101
      return new BrookCalcGBSAOBCForceKernel( name, platform, openMMBrookInterface, context.getSystem() );
Mark Friedrichs's avatar
Mark Friedrichs committed
102
103
104
105
106

   // Verlet integrator

	} else if( name == IntegrateVerletStepKernel::Name() ){

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
107
      return new BrookIntegrateVerletStepKernel( name, platform, openMMBrookInterface, context.getSystem() );
Mark Friedrichs's avatar
Mark Friedrichs committed
108
109
110
111
112

   // Brownian integrator

	} else if( name == IntegrateBrownianStepKernel::Name() ){

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
113
//      return new BrookIntegrateBrownianStepKernel( name, platform, openMMBrookInterface );
Mark Friedrichs's avatar
Mark Friedrichs committed
114

115
   // Andersen thermostat
Mark Friedrichs's avatar
Mark Friedrichs committed
116
117
118

	} else if( name == ApplyAndersenThermostatKernel::Name() ){

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
119
      // return new BrookIntegrateAndersenThermostatKernel( name, platform, openMMBrookInterface );
Mark Friedrichs's avatar
Mark Friedrichs committed
120
121
122
123
124

   // Langevin integrator

	} else if( name == IntegrateLangevinStepKernel::Name() ){

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
125
      return new BrookIntegrateLangevinStepKernel( name, platform, openMMBrookInterface, context.getSystem() );
Mark Friedrichs's avatar
Mark Friedrichs committed
126

127
128
129
130
   // Remove com

	} else if( name == RemoveCMMotionKernel::Name() ){

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
131
      return new BrookRemoveCMMotionKernel( name, platform, openMMBrookInterface, context.getSystem() );
132

Mark Friedrichs's avatar
Mark Friedrichs committed
133
134
135
   // KE calculator

   } else if( name == CalcKineticEnergyKernel::Name() ){
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
136
      return new BrookCalcKineticEnergyKernel( name, platform, openMMBrookInterface, context.getSystem() );
Mark Friedrichs's avatar
Mark Friedrichs committed
137
138
	} 

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
139
   (void) fprintf( stderr, "%s: name=<%s> not found.", methodName.c_str(), name.c_str() );
Mark Friedrichs's avatar
Mark Friedrichs committed
140
141
142
   (void) fflush( stderr );

	return NULL;
Mark Friedrichs's avatar
Mark Friedrichs committed
143
}