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
02432980
Commit
02432980
authored
Nov 16, 2008
by
Mark Friedrichs
Browse files
Obc forces were overwriting input forces instead of being added to input values
parent
248522cb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
37 deletions
+49
-37
platforms/reference/src/gbsa/CpuImplicitSolvent.cpp
platforms/reference/src/gbsa/CpuImplicitSolvent.cpp
+1
-0
platforms/reference/src/gbsa/CpuObc.cpp
platforms/reference/src/gbsa/CpuObc.cpp
+48
-37
No files found.
platforms/reference/src/gbsa/CpuImplicitSolvent.cpp
View file @
02432980
...
@@ -806,6 +806,7 @@ int CpuImplicitSolvent::computeAceNonPolarForce( const ImplicitSolventParameters
...
@@ -806,6 +806,7 @@ int CpuImplicitSolvent::computeAceNonPolarForce( const ImplicitSolventParameters
const
RealOpenMM
probeRadius
=
implicitSolventParameters
->
getProbeRadius
();
const
RealOpenMM
probeRadius
=
implicitSolventParameters
->
getProbeRadius
();
const
RealOpenMM
surfaceAreaFactor
=
implicitSolventParameters
->
getPi4Asolv
();
const
RealOpenMM
surfaceAreaFactor
=
implicitSolventParameters
->
getPi4Asolv
();
const
RealOpenMM
*
atomicRadii
=
implicitSolventParameters
->
getAtomicRadii
();
const
RealOpenMM
*
atomicRadii
=
implicitSolventParameters
->
getAtomicRadii
();
int
numberOfAtoms
=
implicitSolventParameters
->
getNumberOfAtoms
();
int
numberOfAtoms
=
implicitSolventParameters
->
getNumberOfAtoms
();
...
...
platforms/reference/src/gbsa/CpuObc.cpp
View file @
02432980
...
@@ -316,19 +316,17 @@ if( logFile && atomI == 0 ){
...
@@ -316,19 +316,17 @@ if( logFile && atomI == 0 ){
obcChain
[
atomI
]
=
offsetRadiusI
*
(
alphaObc
-
two
*
betaObc
*
sum
+
three
*
gammaObc
*
sum2
);
obcChain
[
atomI
]
=
offsetRadiusI
*
(
alphaObc
-
two
*
betaObc
*
sum
+
three
*
gammaObc
*
sum2
);
obcChain
[
atomI
]
=
(
one
-
tanhSum
*
tanhSum
)
*
obcChain
[
atomI
]
/
radiusI
;
obcChain
[
atomI
]
=
(
one
-
tanhSum
*
tanhSum
)
*
obcChain
[
atomI
]
/
radiusI
;
/*
/* if( logFile && atomI >= 0 ){
if( logFile && atomI >= 0 ){
(void) fprintf( logFile, "\nRRQ %d sum %12.6e tanhS %12.6e radI %.5f %.5f born %18.10e obc %12.6e",
(void) fprintf( logFile, "\nRRQ %d sum=%12.6e tanhS=%12.6e radI=%.5f %.5f born=%12.6e obc=%12.6e",
atomI, sum, tanhSum, radiusI, offsetRadiusI, bornRadii[atomI], obcChain[atomI] );
atomI, sum, tanhSum, radiusI, offsetRadiusI, bornRadii[atomI], obcChain[atomI] );
} */
} */
}
}
/*
/*
if( logFile ){
if( logFile ){
(void) fclose( logFile );
(void) fclose( logFile );
}
}
*/
*/
return
SimTKOpenMMCommon
::
DefaultReturn
;
return
SimTKOpenMMCommon
::
DefaultReturn
;
...
@@ -351,7 +349,7 @@ if( logFile && atomI >= 0 ){
...
@@ -351,7 +349,7 @@ if( logFile && atomI >= 0 ){
--------------------------------------------------------------------------------------- */
--------------------------------------------------------------------------------------- */
int
CpuObc
::
computeBornEnergyForces
(
RealOpenMM
*
bornRadii
,
RealOpenMM
**
atomCoordinates
,
int
CpuObc
::
computeBornEnergyForces
(
RealOpenMM
*
bornRadii
,
RealOpenMM
**
atomCoordinates
,
const
RealOpenMM
*
partialCharges
,
RealOpenMM
**
f
orces
){
const
RealOpenMM
*
partialCharges
,
RealOpenMM
**
inputF
orces
){
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -389,8 +387,13 @@ int CpuObc::computeBornEnergyForces( RealOpenMM* bornRadii, RealOpenMM** atomCoo
...
@@ -389,8 +387,13 @@ int CpuObc::computeBornEnergyForces( RealOpenMM* bornRadii, RealOpenMM** atomCoo
RealOpenMM
obcEnergy
=
zero
;
RealOpenMM
obcEnergy
=
zero
;
const
unsigned
int
arraySzInBytes
=
sizeof
(
RealOpenMM
)
*
numberOfAtoms
;
const
unsigned
int
arraySzInBytes
=
sizeof
(
RealOpenMM
)
*
numberOfAtoms
;
RealOpenMM
**
forces
=
(
RealOpenMM
**
)
malloc
(
sizeof
(
RealOpenMM
*
)
*
numberOfAtoms
);
RealOpenMM
*
block
=
(
RealOpenMM
*
)
malloc
(
sizeof
(
RealOpenMM
)
*
numberOfAtoms
*
3
);
memset
(
block
,
0
,
sizeof
(
RealOpenMM
)
*
numberOfAtoms
*
3
);
RealOpenMM
*
blockPtr
=
block
;
for
(
int
ii
=
0
;
ii
<
numberOfAtoms
;
ii
++
){
for
(
int
ii
=
0
;
ii
<
numberOfAtoms
;
ii
++
){
memset
(
forces
[
ii
],
0
,
3
*
sizeof
(
RealOpenMM
)
);
forces
[
ii
]
=
blockPtr
;
blockPtr
+=
3
;
}
}
RealOpenMM
*
bornForces
=
getBornForce
();
RealOpenMM
*
bornForces
=
getBornForce
();
...
@@ -474,6 +477,7 @@ int CpuObc::computeBornEnergyForces( RealOpenMM* bornRadii, RealOpenMM** atomCoo
...
@@ -474,6 +477,7 @@ int CpuObc::computeBornEnergyForces( RealOpenMM* bornRadii, RealOpenMM** atomCoo
}
}
}
}
//obcEnergy *= getEnergyConversionFactor();
//obcEnergy *= getEnergyConversionFactor();
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -596,9 +600,9 @@ int CpuObc::computeBornEnergyForces( RealOpenMM* bornRadii, RealOpenMM** atomCoo
...
@@ -596,9 +600,9 @@ int CpuObc::computeBornEnergyForces( RealOpenMM* bornRadii, RealOpenMM** atomCoo
RealOpenMM
conversion
=
0.4184
;
RealOpenMM
conversion
=
0.4184
;
for
(
int
atomI
=
0
;
atomI
<
numberOfAtoms
;
atomI
++
){
for
(
int
atomI
=
0
;
atomI
<
numberOfAtoms
;
atomI
++
){
f
orces
[
atomI
][
0
]
*
=
conversion
;
inputF
orces
[
atomI
][
0
]
+
=
conversion
*
forces
[
atomI
][
0
]
;
f
orces
[
atomI
][
1
]
*
=
conversion
;
inputF
orces
[
atomI
][
1
]
+
=
conversion
*
forces
[
atomI
][
1
]
;
f
orces
[
atomI
][
2
]
*
=
conversion
;
inputF
orces
[
atomI
][
2
]
+
=
conversion
*
forces
[
atomI
][
2
]
;
}
}
setEnergy
(
obcEnergy
*
conversion
);
setEnergy
(
obcEnergy
*
conversion
);
...
@@ -607,6 +611,9 @@ int CpuObc::computeBornEnergyForces( RealOpenMM* bornRadii, RealOpenMM** atomCoo
...
@@ -607,6 +611,9 @@ int CpuObc::computeBornEnergyForces( RealOpenMM* bornRadii, RealOpenMM** atomCoo
memcpy
(
bornRadii
,
bornRadiiTemp
,
arraySzInBytes
);
memcpy
(
bornRadii
,
bornRadiiTemp
,
arraySzInBytes
);
memcpy
(
obcChain
,
obcChainTemp
,
arraySzInBytes
);
memcpy
(
obcChain
,
obcChainTemp
,
arraySzInBytes
);
free
(
(
char
*
)
block
);
free
(
(
char
*
)
forces
);
return
SimTKOpenMMCommon
::
DefaultReturn
;
return
SimTKOpenMMCommon
::
DefaultReturn
;
}
}
...
@@ -821,18 +828,24 @@ int CpuObc::writeForceLoop( int numberOfAtoms, const IntVector& chunkSizes,
...
@@ -821,18 +828,24 @@ int CpuObc::writeForceLoop( int numberOfAtoms, const IntVector& chunkSizes,
for
(
int
atomI
=
0
;
atomI
<
numberOfAtoms
;
atomI
++
){
for
(
int
atomI
=
0
;
atomI
<
numberOfAtoms
;
atomI
++
){
std
::
stringstream
line
;
std
::
stringstream
line
;
line
<<
(
atomI
+
1
)
<<
" "
;
char
buffer
[
128
];
(
void
)
sprintf
(
buffer
,
"%4d "
,
atomI
);
line
<<
buffer
;
int
index
=
0
;
int
index
=
0
;
for
(
RealOpenMMPtrPtrVectorCI
ii
=
realRealOpenMMVector
.
begin
();
ii
!=
realRealOpenMMVector
.
end
();
ii
++
){
for
(
RealOpenMMPtrPtrVectorCI
ii
=
realRealOpenMMVector
.
begin
();
ii
!=
realRealOpenMMVector
.
end
();
ii
++
){
RealOpenMM
**
forces
=
*
ii
;
RealOpenMM
**
forces
=
*
ii
;
SimTKOpenMMUtilities
::
formatRealStringStream
(
line
,
forces
[
atomI
],
chunks
[
index
++
]
);
(
void
)
sprintf
(
buffer
,
"%11.5f %11.5f %11.5f "
,
forces
[
atomI
][
0
],
forces
[
atomI
][
1
],
forces
[
atomI
][
2
]
);
line
<<
" "
;
line
<<
buffer
;
// SimTKOpenMMUtilities::formatRealStringStream( line, forces[atomI], chunks[index++] );
// line << " ";
}
}
for
(
RealOpenMMPtrVectorCI
ii
=
realVector
.
begin
();
ii
!=
realVector
.
end
();
ii
++
){
for
(
RealOpenMMPtrVectorCI
ii
=
realVector
.
begin
();
ii
!=
realVector
.
end
();
ii
++
){
RealOpenMM
*
array
=
*
ii
;
RealOpenMM
*
array
=
*
ii
;
line
<<
array
[
atomI
]
<<
" "
;
(
void
)
sprintf
(
buffer
,
"%11.5f "
,
array
[
atomI
]
);
line
<<
buffer
;
}
}
lineVector
.
push_back
(
line
.
str
()
);
lineVector
.
push_back
(
line
.
str
()
);
...
@@ -914,6 +927,7 @@ FILE* logFile = NULL;
...
@@ -914,6 +927,7 @@ FILE* logFile = NULL;
memset
(
forces
[
ii
],
0
,
3
*
sizeof
(
RealOpenMM
)
);
memset
(
forces
[
ii
],
0
,
3
*
sizeof
(
RealOpenMM
)
);
}
}
RealOpenMM
*
bornForces
=
getBornForce
();
RealOpenMM
*
bornForces
=
getBornForce
();
memset
(
bornForces
,
0
,
arraySzInBytes
);
memset
(
bornForces
,
0
,
arraySzInBytes
);
...
@@ -1002,8 +1016,6 @@ FILE* logFile = NULL;
...
@@ -1002,8 +1016,6 @@ FILE* logFile = NULL;
obcEnergy
+=
Gpol
;
obcEnergy
+=
Gpol
;
bornForces
[
atomI
]
+=
dGpol_dalpha2_ij
*
bornRadii
[
atomJ
];
bornForces
[
atomI
]
+=
dGpol_dalpha2_ij
*
bornRadii
[
atomJ
];
/*
if( logFile ){
//if( logFile && (atomI == -1 || atomJ == -1) ){
//if( logFile && (atomI == -1 || atomJ == -1) ){
// (void) fprintf( logFile, "\nWWX %d %d F[%.6e %.6e %.6e] bF=[%.6e %.6e] Gpl[%.6e %.6e %.6e] rb[%6.4f %7.4f] rs[%6.4f %7.4f] ",
// (void) fprintf( logFile, "\nWWX %d %d F[%.6e %.6e %.6e] bF=[%.6e %.6e] Gpl[%.6e %.6e %.6e] rb[%6.4f %7.4f] rs[%6.4f %7.4f] ",
// atomI, atomJ,
// atomI, atomJ,
...
@@ -1012,17 +1024,15 @@ if( logFile ){
...
@@ -1012,17 +1024,15 @@ if( logFile ){
// Gpol,dGpol_dr,dGpol_dalpha2_ij,
// Gpol,dGpol_dr,dGpol_dalpha2_ij,
// bornRadii[atomI],bornRadii[atomJ],atomicRadii[atomI],atomicRadii[atomJ] );
// bornRadii[atomI],bornRadii[atomJ],atomicRadii[atomI],atomicRadii[atomJ] );
//
//
(void) fprintf( logFile, "\nWWX %d %d %.1f r2=%.4f q=%.2f bF=[%.6e %.6e] Gpl[%.6e %.6e %.6e] rb[%.5f %.5f] add[%.6e %.6e] ",
// (void) fprintf( logFile, "\nWWX %d %d %.1f r2=%.4f q=%.2f bF=[%.6e %.6e] Gpl[%.6e %.6e %.6e] rb[%.5f %.5f] add[%.6e %.6e] ",
atomI, atomJ, preFactor, r2, partialCharges[atomJ],
// atomI, atomJ, preFactor, r2, partialCharges[atomJ],
bornForces[atomI], bornForces[atomJ],
// bornForces[atomI], bornForces[atomJ],
Gpol,dGpol_dr,dGpol_dalpha2_ij,
// Gpol,dGpol_dr,dGpol_dalpha2_ij,
bornRadii[atomI], bornRadii[atomJ],
// bornRadii[atomI], bornRadii[atomJ],
dGpol_dalpha2_ij*bornRadii[atomJ], dGpol_dalpha2_ij*bornRadii[atomI] );
// dGpol_dalpha2_ij*bornRadii[atomJ], dGpol_dalpha2_ij*bornRadii[atomI] );
}
//}
*/
}
}
}
}
if
(
logFile
){
if
(
logFile
){
...
@@ -1033,7 +1043,8 @@ if( logFile ){
...
@@ -1033,7 +1043,8 @@ if( logFile ){
}
}
}
}
if
(
0
){
if
(
1
){
std
::
string
outputFileName
=
"Loop1Cpu.txt"
;
std
::
string
outputFileName
=
"Loop1Cpu.txt"
;
CpuObc
::
writeForceLoop1
(
numberOfAtoms
,
forces
,
bornForces
,
outputFileName
);
CpuObc
::
writeForceLoop1
(
numberOfAtoms
,
forces
,
bornForces
,
outputFileName
);
/*
/*
...
@@ -1070,7 +1081,7 @@ if( logFile ){
...
@@ -1070,7 +1081,7 @@ if( logFile ){
bornForces
[
atomI
]
*=
bornRadii
[
atomI
]
*
bornRadii
[
atomI
]
*
obcChain
[
atomI
];
bornForces
[
atomI
]
*=
bornRadii
[
atomI
]
*
bornRadii
[
atomI
]
*
obcChain
[
atomI
];
}
}
if
(
0
){
if
(
1
){
std
::
string
outputFileName
=
"PostLoop1Cpu.txt"
;
std
::
string
outputFileName
=
"PostLoop1Cpu.txt"
;
...
@@ -1081,9 +1092,9 @@ if( logFile ){
...
@@ -1081,9 +1092,9 @@ if( logFile ){
realPtrPtrVector
.
push_back
(
forces
);
realPtrPtrVector
.
push_back
(
forces
);
RealOpenMMPtrVector
realPtrVector
;
RealOpenMMPtrVector
realPtrVector
;
realPtrVector
.
push_back
(
obcChain
);
realPtrVector
.
push_back
(
bornRadii
);
realPtrVector
.
push_back
(
bornRadii
);
realPtrVector
.
push_back
(
bornForces
);
realPtrVector
.
push_back
(
bornForces
);
realPtrVector
.
push_back
(
obcChain
);
CpuObc
::
writeForceLoop
(
numberOfAtoms
,
chunkVector
,
realPtrPtrVector
,
realPtrVector
,
outputFileName
);
CpuObc
::
writeForceLoop
(
numberOfAtoms
,
chunkVector
,
realPtrPtrVector
,
realPtrVector
,
outputFileName
);
}
}
...
@@ -1211,7 +1222,7 @@ if( logFile && atomI >= 0 ){
...
@@ -1211,7 +1222,7 @@ if( logFile && atomI >= 0 ){
}
}
setEnergy
(
obcEnergy
*
conversion
);
setEnergy
(
obcEnergy
*
conversion
);
if
(
0
){
if
(
1
){
std
::
string
outputFileName
=
"Loop2Cpu.txt"
;
std
::
string
outputFileName
=
"Loop2Cpu.txt"
;
...
...
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