Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
fcd7b0c7
Commit
fcd7b0c7
authored
Jun 10, 2009
by
Michael Sherman
Browse files
update fortran NaCl example
parent
9187b702
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
422 additions
and
248 deletions
+422
-248
examples/HelloSodiumChlorideInFortran.f90
examples/HelloSodiumChlorideInFortran.f90
+222
-122
examples/wrappers/openmm.f90
examples/wrappers/openmm.f90
+200
-126
No files found.
examples/HelloSodiumChlorideInFortran.f90
View file @
fcd7b0c7
! OpenMM HelloSodiumChloride example in Fortran 95
! -----------------------------------------------------------------------------
program
HelloSodiumChloride
! OpenMM(tm) HelloSodiumChloride example in Fortran 95 (June 2009)
use
OpenMM
! ------------------------------------------------------------------------------
implicit
none
! This is a complete, self-contained "hello world" example demonstrating
! GPU-accelerated constant temperature simulation of a very simple system with
! just nonbonded forces, consisting of several sodium (Na+) and chloride (Cl-)
! ions in implicit solvent. A multi-frame PDB file is written to stdout which
! can be read by VMD or other visualization tool to produce an animation of the
! resulting trajectory.
!
! Pay particular attention to the handling of units in this example. Incorrect
! handling of units is a very common error; this example shows how you can
! continue to work with Amber-style units like Angstroms, kCals, and van der
! Waals radii while correctly communicating with OpenMM in nm, kJ, and sigma.
!
! This example is written entirely in Fortran 95, using a Fortran interface
! module which is NOT official parts of the OpenMM distribution.
! ------------------------------------------------------------------------------
!-------------------------------------------------------------------------------
!-------------------------------------------------------------------------------
!
MODELING
AND SIMULATION PARAMETERS
!
ATOM, FORCE FIELD,
AND SIMULATION PARAMETERS
!-------------------------------------------------------------------------------
!-------------------------------------------------------------------------------
real
*
8
StepSizeInFs
,
ReportIntervalInFs
,
SimulationTimeInPs
! We'll define this module as a simplified example of the kinds of data
parameter
(
StepSizeInFs
=
2
)
! structures that may already be in an MD program that is to be converted
parameter
(
ReportIntervalInFs
=
50
)
! to use OpenMM.
parameter
(
SimulationTimeInPs
=
100
)
MODULE
MyAtomInfo
integer
NumSilentSteps
! Simulation parameters:
parameter
(
NumSilentSteps
=
(
ReportIntervalInFs
/
StepSizeInFs
+
0.5
))
real
*
8
Temperature
,
FrictionInPerPs
,
SolventDielectric
,
SoluteDielectric
parameter
(
Temperature
=
300
)
!Kelvins
parameter
(
FrictionInPerPs
=
91
)
!collisions per picosecond
parameter
(
SolventDielectric
=
80
)
!typical for water
parameter
(
SoluteDielectric
=
2
)
!typical for protein
real
*
8
StepSizeInFs
,
ReportIntervalInFs
,
SimulationTimeInPs
parameter
(
StepSizeInFs
=
2
)
!integration step size (fs)
parameter
(
ReportIntervalInFs
=
50
)
!how often for PDB frame (fs)
parameter
(
SimulationTimeInPs
=
100
)
!total simulation time (ps)
! Currently energy calculation is not available in the GPU kernels so
! asking for it requires slow Reference Platform computation at
! reporting intervals.
logical
,
parameter
::
WantEnergy
=
.true.
type
Atom
! Atom and force field information:
character
*
4
pdb
type
Atom
real
*
8
mass
character
*
4
pdb
real
*
8
charge
real
*
8
mass
,
charge
,
vdwRadiusInAng
,
vdwEnergyInKcal
real
*
8
vdwRadiusInAng
real
*
8
gbsaRadiusInAng
,
gbsaScaleFactor
real
*
8
vdwEnergyInKcal
real
*
8
initPosInAng
(
3
)
real
*
8
initPosInAng
(
3
)
real
*
8
posInAng
(
3
)
! leave room for runtime state info
end
type
end
type
integer
,
parameter
::
NumAtoms
=
6
integer
NAtom
type
(
Atom
)
::
atoms
(
NumAtoms
)
=
(/
&
parameter
(
NAtom
=
6
)
! pdb mass charge vdwRad vdwEnergy gbRad gbScale initPos pos
type
(
Atom
)
atoms
(
NAtom
)
Atom
(
' NA '
,
22.99
,
1
,
1.8680
,
0.00277
,
1.992
,
0.8
,
(/
8
,
0
,
0
/),
(/
0
,
0
,
0
/)),&
character
*
50
name
Atom
(
' CL '
,
35.45
,
-1
,
2.4700
,
0.1000
,
1.735
,
0.8
,
(/
-8
,
0
,
0
/),
(/
0
,
0
,
0
/)),&
type
(
OpenMM_String
)
dir
Atom
(
' NA '
,
22.99
,
1
,
1.8680
,
0.00277
,
1.992
,
0.8
,
(/
0
,
9
,
0
/),
(/
0
,
0
,
0
/)),&
Atom
(
' CL '
,
35.45
,
-1
,
2.4700
,
0.1000
,
1.735
,
0.8
,
(/
0
,
-9
,
0
/),
(/
0
,
0
,
0
/)),&
atoms
(
1
)
=
Atom
(
' NA '
,
22.99
,
1
,
1.8680
,
0.00277
,
(/
8
,
0
,
0
/))
Atom
(
' NA '
,
22.99
,
1
,
1.8680
,
0.00277
,
1.992
,
0.8
,
(/
0
,
0
,
-10
/),
(/
0
,
0
,
0
/)),&
atoms
(
2
)
=
Atom
(
' CL '
,
35.45
,
-1
,
2.4700
,
0.1000
,
(/
-8
,
0
,
0
/))
Atom
(
' CL '
,
35.45
,
-1
,
2.4700
,
0.1000
,
1.735
,
0.8
,
(/
0
,
0
,
10
/),
(/
0
,
0
,
0
/))
&
atoms
(
3
)
=
Atom
(
' NA '
,
22.99
,
1
,
1.8680
,
0.00277
,
(/
0
,
9
,
0
/))
/)
atoms
(
4
)
=
Atom
(
' CL '
,
35.45
,
-1
,
2.4700
,
0.1000
,
(/
0
,
-9
,
0
/))
END
MODULE
atoms
(
5
)
=
Atom
(
' NA '
,
22.99
,
1
,
1.8680
,
0.00277
,
(/
0
,
0
,
-10
/))
atoms
(
6
)
=
Atom
(
' CL '
,
35.45
,
-1
,
2.4700
,
0.1000
,
(/
0
,
0
,
10
/))
call
OpenMM_String_create
(
dir
,
''
)
call
OpenMM_Platform_getDefaultPluginsDirectory
(
dir
)
call
OpenMM_String_get
(
dir
,
name
)
print
*
,
'dir="'
,
name
,
'"'
call
OpenMM_Platform_loadPluginsFromDirectory
(
dir
)
call
simulateNaCl
(
atoms
)
! Allow subroutines to inherit type definitions from program level
CONTAINS
!-------------------------------------------------------------------------------
!-------------------------------------------------------------------------------
!
NaCl SIMULATION
!
MAIN PROGRAM
!-------------------------------------------------------------------------------
!-------------------------------------------------------------------------------
subroutine
simulateNaCl
(
atoms
)
PROGRAM
HelloSodiumChloride
use
OpenMM
use
MyAtomInfo
implicit
none
implicit
none
type
(
Atom
)
atoms
(
NAtom
)
type
(
OpenMM_System
)
system
type
(
OpenMM_NonbondedForce
)
nonbond
type
(
OpenMM_Force
)
nonbondAsForce
type
(
OpenMM_Context
)
context
type
(
OpenMM_VerletIntegrator
)
verlet
type
(
OpenMM_Integrator
)
integrator
type
(
OpenMM_Vec3Array
)
initialPositionsInNm
character
*
10
platformName
real
*
8
posInNm
(
3
),
a
(
3
),
b
(
3
),
c
(
3
),
cutoff
! Periodic box size and cutoff in nm
parameter
(
a
=
(/
5
,
0
,
0
/),
b
=
(/
0
,
5
,
0
/),
c
=
(/
0
,
0
,
5
/),
cutoff
=
2
)
integer
i
call
OpenMM_System_create
(
system
)
call
OpenMM_NonbondedForce_create
(
nonbond
)
call
OpenMM_NonbondedForce_asForce
(
nonbond
,
nonbondAsForce
)
call
OpenMM_System_addForce
(
system
,
nonbondAsForce
)
call
OpenMM_NonbondedForce_setNonbondedMethod
(
nonbond
,
&
OpenMM_NonbondedForce_CutoffPeriodic
)
! cutoff distance here is
call
OpenMM_NonbondedForce_setCutoffDistance
(
nonbond
,
cutoff
)
call
OpenMM_NonbondedForce_setPeriodicBoxVectors
(
nonbond
,
a
,
b
,
c
)
call
OpenMM_Vec3Array_create
(
initialPositionsInNm
,
0
)
do
i
=
1
,
NAtom
call
OpenMM_System_addParticle
(
system
,
atoms
(
i
)
%
mass
)
call
OpenMM_NonbondedForce_addParticle
(
nonbond
,
&
atoms
(
i
)
%
charge
,
&
atoms
(
i
)
%
vdwRadiusInAng
*
OpenMM_NmPerAngstrom
&
*
OpenMM_SigmaPerVdwRadius
,
&
atoms
(
i
)
%
vdwEnergyInKcal
*
OpenMM_KJPerKcal
)
! Convert this atom's initial position from Angstroms to nm
call
OpenMM_Vec3_scale
(
atoms
(
i
)
%
initPosInAng
,
OpenMM_NmPerAngstrom
,
posInNm
)
call
OpenMM_Vec3Array_append
(
initialPositionsInNm
,
posInNm
)
end
do
call
OpenMM_VerletIntegrator_create
(
verlet
,
StepSizeInFs
*
OpenMM_PsPerFs
)
!-------------------------------------------------------------------------------
call
OpenMM_VerletIntegrator_asIntegrator
(
verlet
,
integrator
)
! MODELING AND SIMULATION PARAMETERS
call
OpenMM_Context_create
(
context
,
system
,
integrator
)
!-------------------------------------------------------------------------------
call
OpenMM_Context_setPositions
(
context
,
initialPositionsInNm
)
call
OpenMM_Context_getPlatformName
(
context
,
platformName
)
integer
NumReports
,
NumSilentSteps
parameter
(
NumReports
=
(
SimulationTimeInPs
*
1000
/
ReportIntervalInFs
+
0.5
))
parameter
(
NumSilentSteps
=
(
ReportIntervalInFs
/
StepSizeInFs
+
0.5
))
type
(
OpenMM_Objects
)
omm
character
*
10
platformName
real
*
8
timeInPs
,
energyInKcal
integer
frame
call
myInitializeOpenMM
(
omm
,
platformName
)
print
"('REMARK Using OpenMM platform ', A)"
,
platformName
print
"('REMARK Using OpenMM platform ', A)"
,
platformName
call
writePDB
(
atoms
,
context
)
call
myGetOpenMMState
(
omm
,
timeInPs
,
energyInKcal
)
call
myWritePDBFrame
(
0
,
timeInPs
,
energyInKcal
)
do
do
frame
=
1
,
NumReports
call
OpenMM_Integrator_step
(
integrator
,
NumSilentSteps
)
call
myStepWithOpenMM
(
omm
,
NumSilentSteps
)
call
writePDB
(
atoms
,
context
)
call
myGetOpenMMState
(
omm
,
timeInPs
,
energyInKcal
)
if
(
OpenMM_Context_getTime
(
context
)
>=
SimulationT
imeInPs
)
e
xit
call
myWritePDBFrame
(
frame
,
t
imeInPs
,
e
nergyInKcal
)
end
do
end
do
! Clean up top-level heap allocated objects that we're done with now.
! Clean up top-level heap allocated objects that we're done with now.
call
myTerminateOpenMM
(
omm
)
call
OpenMM_Vec3Array_destroy
(
initialPositionsInNm
)
END
PROGRAM
call
OpenMM_Context_destroy
(
context
)
call
OpenMM_Integrator_destroy
(
integrator
)
end
subroutine
!-------------------------------------------------------------------------------
!-------------------------------------------------------------------------------
! PDB FILE WRITER
! PDB FILE WRITER
!-------------------------------------------------------------------------------
!-------------------------------------------------------------------------------
subroutine
writePDB
(
atoms
,
context
)
! Given state data, output a single frame (pdb "model") of the trajectory
SUBROUTINE
myWritePDBFrame
(
frameNum
,
timeInPs
,
energyInKcal
)
use
MyAtomInfo
implicit
none
integer
frameNum
real
*
8
timeInPs
,
energyInKcal
integer
n
print
"('MODEL',5X,I0)"
,
frameNum
print
"('REMARK 250 time=', F0.3, ' picoseconds; Energy=', F0.3, ' kcal/mole')"
,
&
timeInPs
,
energyInKcal
do
n
=
1
,
NumAtoms
print
"('ATOM ', I5, ' ', A4, ' SLT 1 ', 3F8.3, ' 1.00 0.00')"
,
&
n
,
atoms
(
n
)
%
pdb
,
atoms
(
n
)
%
posInAng
end
do
print
"('ENDMDL')"
END
SUBROUTINE
!-------------------------------------------------------------------------------
! OpenMM-USING CODE
!-------------------------------------------------------------------------------
SUBROUTINE
myInitializeOpenMM
(
omm
,
platformName
)
use
OpenMM
;
use
MyAtomInfo
implicit
none
type
(
OpenMM_Objects
)
omm
character
*
10
platformName
! These are temporary OpenMM objects used and discarded here.
type
(
OpenMM_Vec3Array
)
initialPosInNm
type
(
OpenMM_NonbondedForce
)
nonbond
type
(
OpenMM_Force
)
nonbondAsForce
type
(
OpenMM_GBSAOBCForce
)
gbsa
type
(
OpenMM_Force
)
gbsaAsForce
type
(
OpenMM_LangevinIntegrator
)
langevin
real
*
8
posInNm
(
3
)
integer
n
character
*
50
name
type
(
OpenMM_String
)
dir
call
OpenMM_String_create
(
dir
,
''
)
call
OpenMM_Platform_getDefaultPluginsDirectory
(
dir
)
call
OpenMM_String_get
(
dir
,
name
)
print
*
,
'dir="'
,
name
,
'"'
call
OpenMM_Platform_loadPluginsFromDirectory
(
dir
)
call
OpenMM_System_create
(
omm
%
system
)
call
OpenMM_NonbondedForce_create
(
nonbond
)
call
OpenMM_GBSAOBCForce_create
(
gbsa
)
! Convert specific force types to generic OpenMM_Force so that we can
! add them to the OpenMM_System.
call
OpenMM_NonbondedForce_asForce
(
nonbond
,
nonbondAsForce
)
call
OpenMM_GBSAOBCForce_asForce
(
gbsa
,
gbsaAsForce
)
call
OpenMM_System_addForce
(
omm
%
system
,
nonbondAsForce
)
call
OpenMM_System_addForce
(
omm
%
system
,
gbsaAsForce
)
! Specify dielectrics for GBSA implicit solvation.
call
OpenMM_GBSAOBCForce_setSolventDielectric
(
gbsa
,
SolventDielectric
)
call
OpenMM_GBSAOBCForce_setSoluteDielectric
(
gbsa
,
SoluteDielectric
)
call
OpenMM_Vec3Array_create
(
initialPosInNm
,
0
)
do
n
=
1
,
NumAtoms
print
*
,
'atom '
,
n
,
atoms
(
n
)
call
OpenMM_System_addParticle
(
omm
%
system
,
atoms
(
n
)
%
mass
)
call
OpenMM_NonbondedForce_addParticle
(
nonbond
,
&
atoms
(
n
)
%
charge
,
&
atoms
(
n
)
%
vdwRadiusInAng
*
OpenMM_NmPerAngstrom
&
*
OpenMM_SigmaPerVdwRadius
,
&
atoms
(
n
)
%
vdwEnergyInKcal
*
OpenMM_KJPerKcal
)
call
OpenMM_GBSAOBCForce_addParticle
(
gbsa
,
&
atoms
(
n
)
%
charge
,
&
atoms
(
n
)
%
gbsaRadiusInAng
*
OpenMM_NmPerAngstrom
,
&
atoms
(
n
)
%
gbsaScaleFactor
)
! Convert this atom's initial position from Angstroms to nm
call
OpenMM_Vec3_scale
(
atoms
(
n
)
%
initPosInAng
,
OpenMM_NmPerAngstrom
,
posInNm
)
call
OpenMM_Vec3Array_append
(
initialPosInNm
,
posInNm
)
end
do
call
OpenMM_LangevinIntegrator_create
(
langevin
,
&
Temperature
,
FrictionInPerPs
,
&
StepSizeInFs
*
OpenMM_PsPerFs
)
call
OpenMM_LangevinIntegrator_asIntegrator
(
langevin
,
omm
%
integrator
)
call
OpenMM_Context_create
(
omm
%
context
,
omm
%
system
,
omm
%
integrator
)
call
OpenMM_Context_setPositions
(
omm
%
context
,
initialPosInNm
)
call
OpenMM_Context_getPlatformName
(
omm
%
context
,
platformName
)
END
SUBROUTINE
!-------------------------------------------------------------------------------
! COPY STATE BACK TO CPU FROM OpenMM
!-------------------------------------------------------------------------------
SUBROUTINE
myGetOpenMMState
(
omm
,
timeInPs
,
energyInKcal
)
use
OpenMM
;
use
MyAtomInfo
implicit
none
implicit
none
type
(
Atom
)
atoms
(
NAtom
)
type
(
OpenMM_Objects
)
omm
type
(
OpenMM_Context
)
context
real
*
8
timeInPs
,
energyInKcal
integer
,
save
::
modelFrameNumber
=
0
type
(
OpenMM_State
)
state
type
(
OpenMM_State
)
state
type
(
OpenMM_Vec3Array
)
posArray
type
(
OpenMM_Vec3Array
)
posArray
integer
infoMask
integer
n
integer
npos
,
i
,
j
integer
npos
,
i
,
j
real
*
8
energy
real
*
8
energy
real
*
8
posInAng
(
3
),
posInNm
(
3
)
real
*
8
posInAng
(
3
),
posInNm
(
3
)
! Caution: at the moment asking for energy requires use of slow Reference
infoMask
=
OpenMM_State_Positions
! platform calculation.
if
(
WantEnergy
)
then
infoMask
=
infoMask
+
OpenMM_State_Velocities
! for KE (cheap)
infoMask
=
infoMask
+
OpenMM_State_Energy
! for PE (very expensive)
end
if
! Forces are also available (and cheap).
! Don't forget to destroy this State when you're done with it.
! Don't forget to destroy this State when you're done with it.
call
OpenMM_Context_createState
(
context
,
&
call
OpenMM_Context_createState
(
omm
%
context
,
infoMask
,
state
)
OpenMM_State_Positions
+
OpenMM_State_Velocities
+
OpenMM_State_Energy
,
&
timeInPs
=
OpenMM_State_getTime
(
state
)
! OpenMM time is in ps already.
state
)
energy
=
OpenMM_State_getPotentialEnergy
(
state
)
&
+
OpenMM_State_getKineticEnergy
(
state
)
! Positions are maintained as a Vec3Array inside the State. This will give
! Positions are maintained as a Vec3Array inside the State. This will give
! us access, but don't destroy it yourself -- it will go away with the State.
! us access, but don't destroy it yourself -- it will go away with the State.
call
OpenMM_State_getPositions
(
state
,
posArray
)
call
OpenMM_State_getPositions
(
state
,
posArray
)
npos
=
OpenMM_Vec3Array_size
(
posArray
)
do
n
=
1
,
NumAtoms
modelFrameNumber
=
modelFrameNumber
+
1
call
OpenMM_Vec3Array_get
(
posArray
,
n
,
posInNm
)
print
"('MODEL',5X,I0)"
,
modelFrameNumber
call
OpenMM_Vec3_scale
(
posInNm
,
OpenMM_AngstromsPerNm
,
atoms
(
n
)
%
posInAng
)
print
"('REMARK 250 time=', F0.3, ' picoseconds; Energy=', F0.3, ' kilojoules/mole')"
,
&
OpenMM_State_getTime
(
state
),
energy
do
i
=
1
,
npos
call
OpenMM_Vec3Array_get
(
posArray
,
i
,
posInNm
)
call
OpenMM_Vec3_scale
(
posInNm
,
OpenMM_AngstromsPerNm
,
posInAng
)
print
"('ATOM ', I5, ' ', A4, ' SLT 1 ', 3F8.3, ' 1.00 0.00 ')"
,
&
i
,
atoms
(
i
)
%
pdb
,
posInAng
end
do
end
do
print
"('ENDMDL')"
energyInKcal
=
0
if
(
WantEnergy
)
then
energyInKcal
=
(
OpenMM_State_getPotentialEnergy
(
state
)
&
+
OpenMM_State_getKineticEnergy
(
state
))
&
*
OpenMM_KcalPerKJ
end
if
! Clean up the State memory
! Clean up the State memory
call
OpenMM_State_destroy
(
state
)
call
OpenMM_State_destroy
(
state
)
end
subroutine
END
SUBROUTINE
SUBROUTINE
myStepWithOpenMM
(
omm
,
numSteps
)
use
OpenMM
implicit
none
type
(
OpenMM_Objects
)
omm
integer
numSteps
call
OpenMM_Integrator_step
(
omm
%
integrator
,
numSteps
)
END
SUBROUTINE
END
PROGRAM
SUBROUTINE
myTerminateOpenMM
(
omm
)
use
OpenMM
implicit
none
type
(
OpenMM_Objects
)
omm
call
OpenMM_Objects_destroy
(
omm
)
END
SUBROUTINE
examples/wrappers/openmm.f90
View file @
fcd7b0c7
...
@@ -29,6 +29,9 @@ module OpenMM_Types
...
@@ -29,6 +29,9 @@ module OpenMM_Types
type
OpenMM_NonbondedForce
type
OpenMM_NonbondedForce
character
,
pointer
::
handle
=>
NULL
()
character
,
pointer
::
handle
=>
NULL
()
end
type
end
type
type
OpenMM_GBSAOBCForce
character
,
pointer
::
handle
=>
NULL
()
end
type
! This is the generic Integrator type. Each concrete Integrator type should
! This is the generic Integrator type. Each concrete Integrator type should
! be able to convert itself to this type.
! be able to convert itself to this type.
type
OpenMM_Integrator
type
OpenMM_Integrator
...
@@ -42,16 +45,16 @@ module OpenMM_Types
...
@@ -42,16 +45,16 @@ module OpenMM_Types
end
type
end
type
! OpenMM::State enumerations
! OpenMM::State enumerations
integer
OpenMM_State_Positions
,
OpenMM_State_Velocities
integer
*
4
OpenMM_State_Positions
,
OpenMM_State_Velocities
integer
OpenMM_State_Forces
,
OpenMM_State_Energy
integer
*
4
OpenMM_State_Forces
,
OpenMM_State_Energy
integer
OpenMM_State_Parameters
integer
*
4
OpenMM_State_Parameters
parameter
(
OpenMM_State_Positions
=
1
,
OpenMM_State_Velocities
=
2
)
parameter
(
OpenMM_State_Positions
=
1
,
OpenMM_State_Velocities
=
2
)
parameter
(
OpenMM_State_Forces
=
4
,
OpenMM_State_Energy
=
8
)
parameter
(
OpenMM_State_Forces
=
4
,
OpenMM_State_Energy
=
8
)
parameter
(
OpenMM_State_Parameters
=
16
)
parameter
(
OpenMM_State_Parameters
=
16
)
!OpenMM::NonbondedForce enumerations
!OpenMM::NonbondedForce enumerations
integer
OpenMM_NonbondedForce_NoCutoff
,
OpenMM_NonbondedForce_CutoffNonPeriodic
integer
*
4
OpenMM_NonbondedForce_NoCutoff
,
OpenMM_NonbondedForce_CutoffNonPeriodic
integer
OpenMM_NonbondedForce_CutoffPeriodic
,
OpenMM_NonbondedForce_Ewald
integer
*
4
OpenMM_NonbondedForce_CutoffPeriodic
,
OpenMM_NonbondedForce_Ewald
parameter
(
OpenMM_NonbondedForce_NoCutoff
=
0
,
OpenMM_NonbondedForce_CutoffNonPeriodic
=
1
)
parameter
(
OpenMM_NonbondedForce_NoCutoff
=
0
,
OpenMM_NonbondedForce_CutoffNonPeriodic
=
1
)
parameter
(
OpenMM_NonbondedForce_CutoffPeriodic
=
2
,
OpenMM_NonbondedForce_Ewald
=
3
)
parameter
(
OpenMM_NonbondedForce_CutoffPeriodic
=
2
,
OpenMM_NonbondedForce_Ewald
=
3
)
...
@@ -66,6 +69,14 @@ module OpenMM_Types
...
@@ -66,6 +69,14 @@ module OpenMM_Types
parameter
(
OpenMM_DegreesPerRadian
=
180.0
/
3.1415926535897932385
)
parameter
(
OpenMM_DegreesPerRadian
=
180.0
/
3.1415926535897932385
)
parameter
(
OpenMM_SigmaPerVdwRadius
=
1.78179743628068
)
parameter
(
OpenMM_SigmaPerVdwRadius
=
1.78179743628068
)
! This data structure can be used to hold the set of OpenMM objects
! that must persist from call to call while running a simulation.
type
OpenMM_Objects
type
(
OpenMM_System
)
system
type
(
OpenMM_Integrator
)
integrator
type
(
OpenMM_Context
)
context
end
type
end
module
OpenMM_Types
end
module
OpenMM_Types
module
OpenMM
module
OpenMM
...
@@ -75,234 +86,297 @@ module OpenMM
...
@@ -75,234 +86,297 @@ module OpenMM
! arrays used in various contexts by OpenMM. It is not the
! arrays used in various contexts by OpenMM. It is not the
! same as a Fortran array of Vec3s would be.
! same as a Fortran array of Vec3s would be.
subroutine
OpenMM_Vec3Array_create
(
array
,
n
)
subroutine
OpenMM_Vec3Array_create
(
array
,
n
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_Vec3Array
)
array
type
(
OpenMM_Vec3Array
)
array
integer
n
integer
*
4
n
end
end
function
OpenMM_Vec3Array_size
(
array
)
function
OpenMM_Vec3Array_size
(
array
)
use
OpenMM_Types
use
OpenMM_Types
integer
OpenMM_Vec3Array_size
integer
*
4
OpenMM_Vec3Array_size
type
(
OpenMM_Vec3Array
)
array
type
(
OpenMM_Vec3Array
)
array
end
end
subroutine
OpenMM_Vec3Array_resize
(
array
,
n
)
subroutine
OpenMM_Vec3Array_resize
(
array
,
n
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_Vec3Array
)
array
type
(
OpenMM_Vec3Array
)
array
integer
n
integer
*
4
n
end
end
subroutine
OpenMM_Vec3Array_destroy
(
array
)
subroutine
OpenMM_Vec3Array_destroy
(
array
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_Vec3Array
)
array
type
(
OpenMM_Vec3Array
)
array
end
end
subroutine
OpenMM_Vec3Array_append
(
array
,
v3
)
subroutine
OpenMM_Vec3Array_append
(
array
,
v3
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_Vec3Array
)
array
type
(
OpenMM_Vec3Array
)
array
real
*
8
v3
(
3
)
real
*
8
v3
(
3
)
end
end
subroutine
OpenMM_Vec3Array_get
(
array
,
i
,
v3
)
subroutine
OpenMM_Vec3Array_get
(
array
,
i
,
v3
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_Vec3Array
)
array
type
(
OpenMM_Vec3Array
)
array
integer
*
4
i
integer
*
4
i
real
*
8
v3
(
3
)
real
*
8
v3
(
3
)
end
end
! OpenMM_String is an interface to std::string, with some
! OpenMM_String is an interface to std::string, with some
! crude ability to copy from and out to fixed-size Fortran
! crude ability to copy from and out to fixed-size Fortran
! character arrays (with blank padding).
! character arrays (with blank padding).
subroutine
OpenMM_String_create
(
string
,
initVal
)
subroutine
OpenMM_String_create
(
string
,
initVal
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_String
)
string
type
(
OpenMM_String
)
string
character
(
*
)
initVal
character
(
*
)
initVal
end
end
subroutine
OpenMM_String_destroy
(
string
)
subroutine
OpenMM_String_destroy
(
string
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_String
)
string
type
(
OpenMM_String
)
string
end
end
function
OpenMM_String_length
(
string
)
function
OpenMM_String_length
(
string
)
use
OpenMM_Types
use
OpenMM_Types
integer
OpenMM_String_length
integer
*
4
OpenMM_String_length
type
(
OpenMM_String
)
string
type
(
OpenMM_String
)
string
end
end
subroutine
OpenMM_String_get
(
string
,
fstring
)
subroutine
OpenMM_String_get
(
string
,
fstring
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_String
)
string
type
(
OpenMM_String
)
string
character
(
*
)
fstring
character
(
*
)
fstring
end
end
subroutine
OpenMM_String_set
(
string
,
fstring
)
subroutine
OpenMM_String_set
(
string
,
fstring
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_String
)
string
type
(
OpenMM_String
)
string
character
(
*
)
fstring
character
(
*
)
fstring
end
end
! OpenMM::Platform
! OpenMM::Platform
subroutine
OpenMM_Platform_loadPluginsFromDirectory
(
dirName
)
subroutine
OpenMM_Platform_loadPluginsFromDirectory
(
dirName
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_String
)
dirName
type
(
OpenMM_String
)
dirName
end
end
subroutine
OpenMM_Platform_getDefaultPluginsDirectory
(
dirName
)
subroutine
OpenMM_Platform_getDefaultPluginsDirectory
(
dirName
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_String
)
dirName
type
(
OpenMM_String
)
dirName
end
end
! OpenMM::System
! OpenMM::System
subroutine
OpenMM_System_create
(
system
)
subroutine
OpenMM_System_create
(
system
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_System
)
system
type
(
OpenMM_System
)
system
end
end
subroutine
OpenMM_System_destroy
(
system
)
subroutine
OpenMM_System_destroy
(
system
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_System
)
system
type
(
OpenMM_System
)
system
end
end
subroutine
OpenMM_System_addForce
(
system
,
force
)
subroutine
OpenMM_System_addForce
(
system
,
force
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_System
)
system
type
(
OpenMM_System
)
system
type
(
OpenMM_Force
)
force
type
(
OpenMM_Force
)
force
end
end
subroutine
OpenMM_System_addParticle
(
system
,
mass
)
subroutine
OpenMM_System_addParticle
(
system
,
mass
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_System
)
system
type
(
OpenMM_System
)
system
real
*
8
mass
real
*
8
mass
end
end
! OpenMM::NonbondedForce
! OpenMM::NonbondedForce
subroutine
OpenMM_NonbondedForce_create
(
nonbond
)
subroutine
OpenMM_NonbondedForce_create
(
nonbond
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_NonbondedForce
)
nonbond
type
(
OpenMM_NonbondedForce
)
nonbond
end
end
subroutine
OpenMM_NonbondedForce_destroy
(
nonbond
)
subroutine
OpenMM_NonbondedForce_destroy
(
nonbond
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_NonbondedForce
)
nonbond
type
(
OpenMM_NonbondedForce
)
nonbond
end
end
subroutine
OpenMM_NonbondedForce_asForce
(
nonbond
,
force
)
subroutine
OpenMM_NonbondedForce_asForce
(
nonbond
,
force
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_NonbondedForce
)
nonbond
type
(
OpenMM_NonbondedForce
)
nonbond
type
(
OpenMM_Force
)
force
type
(
OpenMM_Force
)
force
end
end
subroutine
OpenMM_NonbondedForce_setNonbondedMethod
(
nonbond
,
method
)
subroutine
OpenMM_NonbondedForce_setNonbondedMethod
(
nonbond
,
method
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_NonbondedForce
)
nonbond
type
(
OpenMM_NonbondedForce
)
nonbond
integer
method
integer
*
4
method
end
end
subroutine
OpenMM_NonbondedForce_setCutoffDistance
(
nonbond
,
distanceInNm
)
subroutine
OpenMM_NonbondedForce_setCutoffDistance
(
nonbond
,
distanceInNm
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_NonbondedForce
)
nonbond
type
(
OpenMM_NonbondedForce
)
nonbond
real
*
8
distanceInNm
real
*
8
distanceInNm
end
end
subroutine
OpenMM_NonbondedForce_setPeriodicBoxVectors
(
nonbond
,
a
,
b
,
c
)
subroutine
OpenMM_NonbondedForce_setPeriodicBoxVectors
(
nonbond
,
a
,
b
,
c
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_NonbondedForce
)
nonbond
type
(
OpenMM_NonbondedForce
)
nonbond
real
*
8
a
(
3
),
b
(
3
),
c
(
3
)
real
*
8
a
(
3
),
b
(
3
),
c
(
3
)
end
end
subroutine
OpenMM_NonbondedForce_addParticle
(
nonbond
,
charge
,
sigmaInNm
,
vdwEnergyInKJ
)
subroutine
OpenMM_NonbondedForce_addParticle
&
use
OpenMM_Types
(
nonbond
,
charge
,
sigmaInNm
,
vdwEnergyInKJ
)
type
(
OpenMM_NonbondedForce
)
nonbond
use
OpenMM_Types
real
*
8
charge
,
sigmaInNm
,
vdwEnergyInKJ
type
(
OpenMM_NonbondedForce
)
nonbond
real
*
8
charge
,
sigmaInNm
,
vdwEnergyInKJ
end
! OpenMM::GBSAOBCForce
subroutine
OpenMM_GBSAOBCForce_create
(
gbsa
)
use
OpenMM_Types
type
(
OpenMM_GBSAOBCForce
)
gbsa
end
subroutine
OpenMM_GBSAOBCForce_destroy
(
gbsa
)
use
OpenMM_Types
type
(
OpenMM_GBSAOBCForce
)
gbsa
end
subroutine
OpenMM_GBSAOBCForce_asForce
(
gbsa
,
force
)
use
OpenMM_Types
type
(
OpenMM_GBSAOBCForce
)
gbsa
type
(
OpenMM_Force
)
force
end
subroutine
OpenMM_GBSAOBCForce_setSolventDielectric
(
gbsa
,
d
)
use
OpenMM_Types
type
(
OpenMM_GBSAOBCForce
)
gbsa
real
*
8
d
end
subroutine
OpenMM_GBSAOBCForce_setSoluteDielectric
(
gbsa
,
d
)
use
OpenMM_Types
type
(
OpenMM_GBSAOBCForce
)
gbsa
real
*
8
d
end
subroutine
OpenMM_GBSAOBCForce_addParticle
&
(
gbsa
,
charge
,
radiusInNm
,
scalingFactor
)
use
OpenMM_Types
type
(
OpenMM_GBSAOBCForce
)
gbsa
real
*
8
charge
,
radiusInNm
,
scalingFactor
end
end
! OpenMM::Integrator
! OpenMM::Integrator
subroutine
OpenMM_Integrator_step
(
integrator
,
numSteps
)
subroutine
OpenMM_Integrator_step
(
integrator
,
numSteps
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_Integrator
)
integrator
type
(
OpenMM_Integrator
)
integrator
integer
*
4
numSteps
integer
*
4
numSteps
end
end
subroutine
OpenMM_Integrator_destroy
(
integrator
)
subroutine
OpenMM_Integrator_destroy
(
integrator
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_Integrator
)
integrator
type
(
OpenMM_Integrator
)
integrator
end
end
! OpenMM::VerletIntegrator
! OpenMM::VerletIntegrator
subroutine
OpenMM_VerletIntegrator_create
(
verlet
,
stepSzInPs
)
subroutine
OpenMM_VerletIntegrator_create
(
verlet
,
stepSzInPs
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_VerletIntegrator
)
verlet
type
(
OpenMM_VerletIntegrator
)
verlet
real
*
8
stepSzInPs
real
*
8
stepSzInPs
end
end
subroutine
OpenMM_VerletIntegrator_destroy
(
verlet
)
subroutine
OpenMM_VerletIntegrator_destroy
(
verlet
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_VerletIntegrator
)
verlet
type
(
OpenMM_VerletIntegrator
)
verlet
end
end
subroutine
OpenMM_VerletIntegrator_asIntegrator
(
verlet
,
integ
)
subroutine
OpenMM_VerletIntegrator_asIntegrator
(
verlet
,
integ
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_VerletIntegrator
)
verlet
type
(
OpenMM_VerletIntegrator
)
verlet
type
(
OpenMM_Integrator
)
integ
type
(
OpenMM_Integrator
)
integ
end
end
subroutine
OpenMM_VerletIntegrator_step
(
verlet
,
numSteps
)
subroutine
OpenMM_VerletIntegrator_step
(
verlet
,
numSteps
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_VerletIntegrator
)
verlet
type
(
OpenMM_VerletIntegrator
)
verlet
integer
*
4
numSteps
integer
*
4
numSteps
end
! OpenMM::LangevinIntegrator
subroutine
OpenMM_LangevinIntegrator_create
&
(
langevin
,
temperature
,
frictionInPerPs
,
stepSzInPs
)
use
OpenMM_Types
type
(
OpenMM_LangevinIntegrator
)
langevin
real
*
8
temperature
,
frictionInPerPs
,
stepSzInPs
end
subroutine
OpenMM_LangevinIntegrator_destroy
(
langevin
)
use
OpenMM_Types
type
(
OpenMM_LangevinIntegrator
)
langevin
end
subroutine
OpenMM_LangevinIntegrator_asIntegrator
(
langevin
,
integ
)
use
OpenMM_Types
type
(
OpenMM_LangevinIntegrator
)
langevin
type
(
OpenMM_Integrator
)
integ
end
subroutine
OpenMM_LangevinIntegrator_step
(
langevin
,
numSteps
)
use
OpenMM_Types
type
(
OpenMM_LangevinIntegrator
)
langevin
integer
*
4
numSteps
end
end
! OpenMM::Context
! OpenMM::Context
subroutine
OpenMM_Context_create
(
context
,
system
,
integrator
)
subroutine
OpenMM_Context_create
(
context
,
system
,
integrator
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_Context
)
context
type
(
OpenMM_Context
)
context
type
(
OpenMM_System
)
system
type
(
OpenMM_System
)
system
type
(
OpenMM_Integrator
)
integrator
type
(
OpenMM_Integrator
)
integrator
end
end
subroutine
OpenMM_Context_destroy
(
context
)
subroutine
OpenMM_Context_destroy
(
context
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_Context
)
context
type
(
OpenMM_Context
)
context
end
end
subroutine
OpenMM_Context_setPositions
(
context
,
positions
)
subroutine
OpenMM_Context_setPositions
(
context
,
positions
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_Context
)
context
type
(
OpenMM_Context
)
context
type
(
OpenMM_Vec3Array
)
positions
type
(
OpenMM_Vec3Array
)
positions
end
end
subroutine
OpenMM_Context_setVelocities
(
context
,
velocities
)
subroutine
OpenMM_Context_setVelocities
(
context
,
velocities
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_Context
)
context
type
(
OpenMM_Context
)
context
type
(
OpenMM_Vec3Array
)
velocities
type
(
OpenMM_Vec3Array
)
velocities
end
end
subroutine
OpenMM_Context_createState
(
context
,
types
,
state
)
subroutine
OpenMM_Context_createState
(
context
,
types
,
state
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_Context
)
context
type
(
OpenMM_Context
)
context
integer
*
4
types
integer
*
4
types
type
(
OpenMM_State
)
state
type
(
OpenMM_State
)
state
end
end
subroutine
OpenMM_Context_getPlatformName
(
context
,
platformName
)
subroutine
OpenMM_Context_getPlatformName
(
context
,
platformName
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_Context
)
context
type
(
OpenMM_Context
)
context
character
(
*
)
platformName
character
(
*
)
platformName
end
end
function
OpenMM_Context_getTime
(
context
)
function
OpenMM_Context_getTime
(
context
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_Context
)
context
type
(
OpenMM_Context
)
context
real
*
8
OpenMM_Context_getTime
real
*
8
OpenMM_Context_getTime
end
end
! OpenMM::State
! OpenMM::State
subroutine
OpenMM_State_destroy
(
state
)
subroutine
OpenMM_State_destroy
(
state
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_State
)
state
type
(
OpenMM_State
)
state
end
end
function
OpenMM_State_getTime
(
state
)
function
OpenMM_State_getTime
(
state
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_State
)
state
type
(
OpenMM_State
)
state
real
*
8
OpenMM_State_getTime
real
*
8
OpenMM_State_getTime
end
end
function
OpenMM_State_getPotentialEnergy
(
state
)
function
OpenMM_State_getPotentialEnergy
(
state
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_State
)
state
type
(
OpenMM_State
)
state
real
*
8
OpenMM_State_getPotentialEnergy
real
*
8
OpenMM_State_getPotentialEnergy
end
end
function
OpenMM_State_getKineticEnergy
(
state
)
function
OpenMM_State_getKineticEnergy
(
state
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_State
)
state
type
(
OpenMM_State
)
state
real
*
8
OpenMM_State_getKineticEnergy
real
*
8
OpenMM_State_getKineticEnergy
end
end
subroutine
OpenMM_State_getPositions
(
state
,
positions
)
subroutine
OpenMM_State_getPositions
(
state
,
positions
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_State
)
state
type
(
OpenMM_State
)
state
type
(
OpenMM_Vec3Array
)
positions
type
(
OpenMM_Vec3Array
)
positions
end
end
subroutine
OpenMM_State_getVelocities
(
state
,
velocities
)
subroutine
OpenMM_State_getVelocities
(
state
,
velocities
)
use
OpenMM_Types
use
OpenMM_Types
type
(
OpenMM_State
)
state
type
(
OpenMM_State
)
state
type
(
OpenMM_Vec3Array
)
velocities
type
(
OpenMM_Vec3Array
)
velocities
end
end
end
interface
end
interface
CONTAINS
CONTAINS
subroutine
OpenMM_Objects_destroy
(
omm
)
use
OpenMM_Types
type
(
OpenMM_Objects
)
omm
call
OpenMM_Context_destroy
(
omm
%
context
)
call
OpenMM_Integrator_destroy
(
omm
%
integrator
)
call
OpenMM_System_destroy
(
omm
%
system
)
end
subroutine
subroutine
OpenMM_Vec3_scale
(
in
,
s
,
out
)
subroutine
OpenMM_Vec3_scale
(
in
,
s
,
out
)
real
*
8
,
intent
(
in
)
::
in
(
3
)
real
*
8
,
intent
(
in
)
::
in
(
3
)
real
*
8
,
intent
(
out
)
::
out
(
3
)
real
*
8
,
intent
(
out
)
::
out
(
3
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment