BrookKernelFactory.cpp 6 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
/* -------------------------------------------------------------------------- *
 *                                   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, Mark Friedrichs                                    *
 * 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.                                     *
 * -------------------------------------------------------------------------- */

#include "BrookKernelFactory.h"
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
33
34
#include "BrookInitializeForcesKernel.h"
#include "BrookCalcHarmonicBondForceKernel.h"
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
35
#include "BrookCalcHarmonicAngleForceKernel.h"
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
36
37
#include "BrookCalcPeriodicTorsionForceKernel.h"
#include "BrookCalcRBTorsionForceKernel.h"
38
#include "BrookCalcNonbondedForceKernel.h"
Mark Friedrichs's avatar
Mark Friedrichs committed
39
#include "BrookIntegrateLangevinStepKernel.h"
Mark Friedrichs's avatar
Mark Friedrichs committed
40
#include "BrookIntegrateVerletStepKernel.h"
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
41
//#include "BrookIntegrateBrownianStepKernel.h"
Mark Friedrichs's avatar
Mark Friedrichs committed
42
#include "BrookCalcKineticEnergyKernel.h"
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
43
#include "BrookCalcGBSAOBCForceKernel.h"
44
#include "BrookRemoveCMMotionKernel.h"
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
45
#include "internal/OpenMMContextImpl.h"
Mark Friedrichs's avatar
Mark Friedrichs committed
46
47
48

using namespace OpenMM;

Mark Friedrichs's avatar
Mark Friedrichs committed
49
50
51
52
53
54
55
56
KernelImpl* BrookKernelFactory::createKernelImpl( std::string name, const Platform& platform, OpenMMContextImpl& context ) const {

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

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

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

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

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
59
60
61
62
63
64
   // initialize forces

	if( name == InitializeForcesKernel::Name() ){

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

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
65
   // harmonic bonds 
Mark Friedrichs's avatar
Mark Friedrichs committed
66

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

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

   // 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
81
      return new BrookCalcPeriodicTorsionForceKernel( name, platform, openMMBrookInterface, context.getSystem() );
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
82
83
84
85
86

   // RB torsion bonds

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

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

   // nonbonded 

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

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

   // GBSA OBC

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

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

   // Verlet integrator

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

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

   // Brownian integrator

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

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

113
   // Andersen thermostat
Mark Friedrichs's avatar
Mark Friedrichs committed
114
115
116

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

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

   // Langevin integrator

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

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

125
126
127
128
   // Remove com

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

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

Mark Friedrichs's avatar
Mark Friedrichs committed
131
132
133
   // KE calculator

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

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

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