kupdatemd.br 2.7 KB
Newer Older
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.               *
 *                                                                            *
10
11
 * Portions copyright (c) 2009 Stanford University and the Authors.           *
 * Authors: Mark Friedrichs, Mike Houston                                     *
12
13
 * Contributors:                                                              *
 *                                                                            *
14
15
16
17
 * 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.                                        *
18
 *                                                                            *
19
20
21
22
 * 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.                        *
23
 *                                                                            *
24
25
 * 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/>.      *
26
 * -------------------------------------------------------------------------- */
Mark Friedrichs's avatar
Mark Friedrichs committed
27

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
28
kernel void kupdate_md1( 
Mark Friedrichs's avatar
Mark Friedrichs committed
29
30
31
32
33
34
35
		float dt,
		float3 posq<>, 
		float3 v<>, 
		float3 f<>,
		float invmass<>,
		out float3 posqp<> ){

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
36
37
   posqp  = v + dt*invmass*f;
	posqp *= dt;
Mark Friedrichs's avatar
Mark Friedrichs committed
38
39
}

Mark Friedrichs's avatar
Mark Friedrichs committed
40
41
kernel void kupdate_md2(
		float dtinv, //1/dt
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
42
43
		float3 posqp<>, //positions after constraints
		float3 posq<>,  //positions before update
Mark Friedrichs's avatar
Mark Friedrichs committed
44
		out float3 vnew<>, //Corrected velocities
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
45
46
47
		out float3 posqnew<> //equal to posqp, avoids an extra call to copy
		){
   vnew        = posqp * dtinv;
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
48
   posqnew     = posq  + posqp;
Mark Friedrichs's avatar
Mark Friedrichs committed
49
50
}

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
51
52
53
54
55
56
57
58
59
60
61
62
kernel void kupdateMdNoShake(
      float dt,
      float3 posq<>,
      float3 v<>, 
      float3 f<>,
      float invmass<>,
      out float3 outv<>,
      out float3 posqp<> ){
   posqp     = posq;
   outv      = v + dt*invmass*f;
   posqp    += dt*outv;
}