Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
schwede
openstructure
Commits
330ec03a
Commit
330ec03a
authored
10 years ago
by
Studer Gabriel
Browse files
Options
Downloads
Patches
Plain Diff
speedups in state extractor
parent
f1e6408b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/mol/mm/src/state_extractor.cc
+24
-17
24 additions, 17 deletions
modules/mol/mm/src/state_extractor.cc
with
24 additions
and
17 deletions
modules/mol/mm/src/state_extractor.cc
+
24
−
17
View file @
330ec03a
...
@@ -4,34 +4,37 @@
...
@@ -4,34 +4,37 @@
namespace
ost
{
namespace
mol
{
namespace
mm
{
namespace
ost
{
namespace
mol
{
namespace
mm
{
void
StateExtractor
::
ExtractPotentialEnergy
(
boost
::
shared_ptr
<
OpenMM
::
Context
>
context
,
void
StateExtractor
::
ExtractPotentialEnergy
(
boost
::
shared_ptr
<
OpenMM
::
Context
>
context
,
Real
&
energy
){
Real
&
energy
){
OpenMM
::
State
s
=
context
->
getState
(
OpenMM
::
State
::
Energy
);
OpenMM
::
State
s
=
context
->
getState
(
OpenMM
::
State
::
Energy
);
energy
=
s
.
getPotentialEnergy
();
energy
=
s
.
getPotentialEnergy
();
}
}
void
StateExtractor
::
ExtractKineticEnergy
(
boost
::
shared_ptr
<
OpenMM
::
Context
>
context
,
void
StateExtractor
::
ExtractKineticEnergy
(
boost
::
shared_ptr
<
OpenMM
::
Context
>
context
,
Real
&
energy
){
Real
&
energy
){
OpenMM
::
State
s
=
context
->
getState
(
OpenMM
::
State
::
Energy
);
OpenMM
::
State
s
=
context
->
getState
(
OpenMM
::
State
::
Energy
);
energy
=
s
.
getKineticEnergy
();
energy
=
s
.
getKineticEnergy
();
}
}
void
StateExtractor
::
ExtractEnergy
(
boost
::
shared_ptr
<
OpenMM
::
Context
>
context
,
void
StateExtractor
::
ExtractEnergy
(
boost
::
shared_ptr
<
OpenMM
::
Context
>
context
,
Real
&
energy
){
Real
&
energy
){
OpenMM
::
State
s
=
context
->
getState
(
OpenMM
::
State
::
Energy
);
OpenMM
::
State
s
=
context
->
getState
(
OpenMM
::
State
::
Energy
);
energy
=
s
.
getKineticEnergy
()
+
s
.
getPotentialEnergy
();
energy
=
s
.
getKineticEnergy
()
+
s
.
getPotentialEnergy
();
}
}
void
StateExtractor
::
ExtractPositions
(
boost
::
shared_ptr
<
OpenMM
::
Context
>
context
,
void
StateExtractor
::
ExtractPositions
(
boost
::
shared_ptr
<
OpenMM
::
Context
>
context
,
geom
::
Vec3List
&
positions
,
bool
enforce_periodic_box
,
bool
in_angstrom
){
geom
::
Vec3List
&
positions
,
bool
enforce_periodic_box
,
bool
in_angstrom
){
positions
.
clear
(
);
positions
.
resize
(
context
->
getSystem
().
getNumParticles
()
);
OpenMM
::
State
s
=
context
->
getState
(
OpenMM
::
State
::
Positions
,
enforce_periodic_box
);
OpenMM
::
State
s
=
context
->
getState
(
OpenMM
::
State
::
Positions
,
enforce_periodic_box
);
std
::
vector
<
OpenMM
::
Vec3
>
p
=
s
.
getPositions
();
const
std
::
vector
<
OpenMM
::
Vec3
>&
p
=
s
.
getPositions
();
for
(
std
::
vector
<
OpenMM
::
Vec3
>::
iterator
i
=
p
.
begin
();
i
!=
p
.
end
();
++
i
){
int
actual_index
=
0
;
positions
.
push_back
(
geom
::
Vec3
((
*
i
)[
0
],(
*
i
)[
1
],(
*
i
)[
2
]));
for
(
std
::
vector
<
OpenMM
::
Vec3
>::
const_iterator
i
=
p
.
begin
();
i
!=
p
.
end
();
++
i
){
positions
[
actual_index
]
=
geom
::
Vec3
((
*
i
)[
0
],(
*
i
)[
1
],(
*
i
)[
2
]);
++
actual_index
;
}
}
if
(
in_angstrom
)
positions
*=
10.0
;
if
(
in_angstrom
)
positions
*=
10.0
;
}
}
...
@@ -39,22 +42,26 @@ void StateExtractor::ExtractPositions(boost::shared_ptr<OpenMM::Context> context
...
@@ -39,22 +42,26 @@ void StateExtractor::ExtractPositions(boost::shared_ptr<OpenMM::Context> context
void
StateExtractor
::
ExtractVelocities
(
boost
::
shared_ptr
<
OpenMM
::
Context
>
context
,
void
StateExtractor
::
ExtractVelocities
(
boost
::
shared_ptr
<
OpenMM
::
Context
>
context
,
geom
::
Vec3List
&
velocities
){
geom
::
Vec3List
&
velocities
){
velocities
.
clear
(
);
velocities
.
resize
(
context
->
getSystem
().
getNumParticles
()
);
OpenMM
::
State
s
=
context
->
getState
(
OpenMM
::
State
::
Velocities
);
OpenMM
::
State
s
=
context
->
getState
(
OpenMM
::
State
::
Velocities
);
std
::
vector
<
OpenMM
::
Vec3
>
v
=
s
.
getVelocities
();
const
std
::
vector
<
OpenMM
::
Vec3
>&
v
=
s
.
getVelocities
();
for
(
std
::
vector
<
OpenMM
::
Vec3
>::
iterator
i
=
v
.
begin
();
i
!=
v
.
end
();
++
i
){
int
actual_index
=
0
;
velocities
.
push_back
(
geom
::
Vec3
((
*
i
)[
0
],(
*
i
)[
1
],(
*
i
)[
2
]));
for
(
std
::
vector
<
OpenMM
::
Vec3
>::
const_iterator
i
=
v
.
begin
();
i
!=
v
.
end
();
++
i
){
velocities
[
actual_index
]
=
geom
::
Vec3
((
*
i
)[
0
],(
*
i
)[
1
],(
*
i
)[
2
]);
++
actual_index
;
}
}
}
}
void
StateExtractor
::
ExtractForces
(
boost
::
shared_ptr
<
OpenMM
::
Context
>
context
,
void
StateExtractor
::
ExtractForces
(
boost
::
shared_ptr
<
OpenMM
::
Context
>
context
,
geom
::
Vec3List
&
forces
){
geom
::
Vec3List
&
forces
){
forces
.
clear
(
);
forces
.
resize
(
context
->
getSystem
().
getNumParticles
()
);
OpenMM
::
State
s
=
context
->
getState
(
OpenMM
::
State
::
Forces
);
OpenMM
::
State
s
=
context
->
getState
(
OpenMM
::
State
::
Forces
);
std
::
vector
<
OpenMM
::
Vec3
>
f
=
s
.
getForces
();
const
std
::
vector
<
OpenMM
::
Vec3
>&
f
=
s
.
getForces
();
for
(
std
::
vector
<
OpenMM
::
Vec3
>::
iterator
i
=
f
.
begin
();
i
!=
f
.
end
();
++
i
){
int
actual_index
=
0
;
forces
.
push_back
(
geom
::
Vec3
((
*
i
)[
0
],(
*
i
)[
1
],(
*
i
)[
2
]));
for
(
std
::
vector
<
OpenMM
::
Vec3
>::
const_iterator
i
=
f
.
begin
();
i
!=
f
.
end
();
++
i
){
forces
[
actual_index
]
=
geom
::
Vec3
((
*
i
)[
0
],(
*
i
)[
1
],(
*
i
)[
2
]);
++
actual_index
;
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment