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
41fa177a
Commit
41fa177a
authored
Jun 16, 2010
by
Peter Eastman
Browse files
Modified the algorithm for adjusting the step size of MonteCarloBarostat (see bug 1213)
parent
edafaced
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
6 deletions
+21
-6
openmmapi/include/openmm/internal/MonteCarloBarostatImpl.h
openmmapi/include/openmm/internal/MonteCarloBarostatImpl.h
+1
-1
openmmapi/src/MonteCarloBarostatImpl.cpp
openmmapi/src/MonteCarloBarostatImpl.cpp
+17
-2
platforms/cuda/tests/TestCudaMonteCarloBarostat.cpp
platforms/cuda/tests/TestCudaMonteCarloBarostat.cpp
+1
-1
platforms/opencl/tests/TestOpenCLMonteCarloBarostat.cpp
platforms/opencl/tests/TestOpenCLMonteCarloBarostat.cpp
+1
-1
platforms/reference/tests/TestReferenceMonteCarloBarostat.cpp
...forms/reference/tests/TestReferenceMonteCarloBarostat.cpp
+1
-1
No files found.
openmmapi/include/openmm/internal/MonteCarloBarostatImpl.h
View file @
41fa177a
...
@@ -62,7 +62,7 @@ public:
...
@@ -62,7 +62,7 @@ public:
std
::
vector
<
std
::
string
>
getKernelNames
();
std
::
vector
<
std
::
string
>
getKernelNames
();
private:
private:
MonteCarloBarostat
&
owner
;
MonteCarloBarostat
&
owner
;
int
step
;
int
step
,
numAttempted
,
numAccepted
;
double
volumeScale
;
double
volumeScale
;
OpenMM_SFMT
::
SFMT
random
;
OpenMM_SFMT
::
SFMT
random
;
Kernel
kernel
;
Kernel
kernel
;
...
...
openmmapi/src/MonteCarloBarostatImpl.cpp
View file @
41fa177a
...
@@ -55,6 +55,8 @@ void MonteCarloBarostatImpl::initialize(ContextImpl& context) {
...
@@ -55,6 +55,8 @@ void MonteCarloBarostatImpl::initialize(ContextImpl& context) {
context
.
getPeriodicBoxVectors
(
box
[
0
],
box
[
1
],
box
[
2
]);
context
.
getPeriodicBoxVectors
(
box
[
0
],
box
[
1
],
box
[
2
]);
double
volume
=
box
[
0
][
0
]
*
box
[
1
][
1
]
*
box
[
2
][
2
];
double
volume
=
box
[
0
][
0
]
*
box
[
1
][
1
]
*
box
[
2
][
2
];
volumeScale
=
0.01
*
volume
;
volumeScale
=
0.01
*
volume
;
numAttempted
=
0
;
numAccepted
=
0
;
init_gen_rand
(
owner
.
getRandomNumberSeed
(),
random
);
init_gen_rand
(
owner
.
getRandomNumberSeed
(),
random
);
}
}
...
@@ -89,10 +91,23 @@ void MonteCarloBarostatImpl::updateContextState(ContextImpl& context) {
...
@@ -89,10 +91,23 @@ void MonteCarloBarostatImpl::updateContextState(ContextImpl& context) {
dynamic_cast
<
ApplyMonteCarloBarostatKernel
&>
(
kernel
.
getImpl
()).
restoreCoordinates
(
context
);
dynamic_cast
<
ApplyMonteCarloBarostatKernel
&>
(
kernel
.
getImpl
()).
restoreCoordinates
(
context
);
context
.
getOwner
().
setPeriodicBoxVectors
(
box
[
0
],
box
[
1
],
box
[
2
]);
context
.
getOwner
().
setPeriodicBoxVectors
(
box
[
0
],
box
[
1
],
box
[
2
]);
volume
Scale
/=
1.1
;
volume
=
newVolume
;
}
}
else
else
volumeScale
=
std
::
min
(
volumeScale
*
1.1
,
newVolume
*
0.1
);
numAccepted
++
;
numAttempted
++
;
if
(
numAttempted
>=
10
)
{
if
(
numAccepted
<
0.25
*
numAttempted
)
{
volumeScale
/=
1.1
;
numAttempted
=
0
;
numAccepted
=
0
;
}
else
if
(
numAccepted
>
0.75
*
numAttempted
)
{
volumeScale
=
std
::
min
(
volumeScale
*
1.1
,
volume
*
0.3
);
numAttempted
=
0
;
numAccepted
=
0
;
}
}
}
}
std
::
map
<
std
::
string
,
double
>
MonteCarloBarostatImpl
::
getDefaultParameters
()
{
std
::
map
<
std
::
string
,
double
>
MonteCarloBarostatImpl
::
getDefaultParameters
()
{
...
...
platforms/cuda/tests/TestCudaMonteCarloBarostat.cpp
View file @
41fa177a
...
@@ -117,7 +117,7 @@ void testIdealGas() {
...
@@ -117,7 +117,7 @@ void testIdealGas() {
integrator
.
step
(
frequency
);
integrator
.
step
(
frequency
);
}
}
volume
/=
steps
;
volume
/=
steps
;
double
expected
=
numParticles
*
BOLTZ
*
temp
[
i
]
/
pressureInMD
;
//+numParticles*(4*M_PI/3)*sigma*sigma*sigma;
double
expected
=
(
numParticles
+
1
)
*
BOLTZ
*
temp
[
i
]
/
pressureInMD
;
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
volume
,
3
/
std
::
sqrt
((
double
)
steps
));
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
volume
,
3
/
std
::
sqrt
((
double
)
steps
));
}
}
}
}
...
...
platforms/opencl/tests/TestOpenCLMonteCarloBarostat.cpp
View file @
41fa177a
...
@@ -117,7 +117,7 @@ void testIdealGas() {
...
@@ -117,7 +117,7 @@ void testIdealGas() {
integrator
.
step
(
frequency
);
integrator
.
step
(
frequency
);
}
}
volume
/=
steps
;
volume
/=
steps
;
double
expected
=
numParticles
*
BOLTZ
*
temp
[
i
]
/
pressureInMD
;
//+numParticles*(4*M_PI/3)*sigma*sigma*sigma;
double
expected
=
(
numParticles
+
1
)
*
BOLTZ
*
temp
[
i
]
/
pressureInMD
;
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
volume
,
3
/
std
::
sqrt
((
double
)
steps
));
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
volume
,
3
/
std
::
sqrt
((
double
)
steps
));
}
}
}
}
...
...
platforms/reference/tests/TestReferenceMonteCarloBarostat.cpp
View file @
41fa177a
...
@@ -116,7 +116,7 @@ void testIdealGas() {
...
@@ -116,7 +116,7 @@ void testIdealGas() {
integrator
.
step
(
frequency
);
integrator
.
step
(
frequency
);
}
}
volume
/=
steps
;
volume
/=
steps
;
double
expected
=
numParticles
*
BOLTZ
*
temp
[
i
]
/
pressureInMD
;
//+numParticles*(4*M_PI/3)*sigma*sigma*sigma;
double
expected
=
(
numParticles
+
1
)
*
BOLTZ
*
temp
[
i
]
/
pressureInMD
;
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
volume
,
3
/
std
::
sqrt
((
double
)
steps
));
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
volume
,
3
/
std
::
sqrt
((
double
)
steps
));
}
}
}
}
...
...
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