Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add energy decomposition (with PME) #1109

Merged
merged 219 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
219 commits
Select commit Hold shift + click to select a range
9f0b7ff
Start EnergyDecomposer class
drroe Sep 13, 2024
aaeb9a7
Update dependencies
drroe Sep 13, 2024
f55d1e7
Start init routine
drroe Sep 13, 2024
60d2060
Add mask and options print
drroe Sep 13, 2024
1d66d29
Start energy decomp action
drroe Sep 13, 2024
cc5648b
Start adding the enedecomp command, start initialization
drroe Sep 13, 2024
d868e8d
Start doing setup
drroe Sep 13, 2024
edb9c8b
Bond setup
drroe Sep 13, 2024
e015e59
Setup output arrays
drroe Sep 13, 2024
8e836d0
Print atoms that energy will be saved for
drroe Sep 13, 2024
f2f48b7
Just allocate an energy for each atom, will make bookkeeping easier
drroe Sep 13, 2024
915d75d
Fix up the dataset dimension labels. Add calculation
drroe Sep 13, 2024
3289056
Add output file
drroe Sep 13, 2024
692c65d
Add angle term. Need to sum before accumulation
drroe Sep 13, 2024
05a3eab
Decompose dihedrals
drroe Sep 13, 2024
e2919b5
LJ 6-12 energy template
drroe Sep 13, 2024
9375be0
Create and use an LJ 6-12 template
drroe Sep 13, 2024
53a3c2f
Start adding the 1-4 energy
drroe Sep 13, 2024
c5df682
Add 1-4 elec
drroe Sep 13, 2024
383e73e
Add debug for the 1-4 terms
drroe Sep 16, 2024
63efd03
Start adding nonbond decomp
drroe Sep 16, 2024
bef1e31
Only do 1-4 calculation for NORMAL dihedrals
drroe Sep 16, 2024
cc50187
Start trying to template the pairlist loop
drroe Sep 17, 2024
31c3e9e
Add wrapper around Erfc
drroe Sep 17, 2024
96556d8
Add Ewald adjust kernel
drroe Sep 17, 2024
1cc44dd
Finish initial incarnation of the Ewald pairlist nonbond kernel. Make
drroe Sep 17, 2024
e2a5b52
Some cleanup
drroe Sep 18, 2024
b540bb2
Add code comments
drroe Sep 18, 2024
52b94da
Change name
drroe Sep 18, 2024
baeb484
Change class name
drroe Sep 18, 2024
a3af47e
Reorder
drroe Sep 18, 2024
e00caf1
Try as a separate class
drroe Sep 18, 2024
623f494
Remove for now
drroe Sep 18, 2024
2cb1d53
Rename
drroe Sep 18, 2024
91893e0
Finish renaming
drroe Sep 18, 2024
43eaf88
Remove unneeded depend.
drroe Sep 18, 2024
5535ef0
Rip out the new framework. Its really not at all ready for further
drroe Sep 18, 2024
85ca9d3
Start a separate class for decomposing ewald energies. Bring back
drroe Sep 18, 2024
e3e13b9
Start splitting out the Ewald parameters
drroe Sep 18, 2024
837ca73
Update build files
drroe Sep 18, 2024
b32ef0d
Just make a function template again
drroe Sep 18, 2024
0fda331
Put in energy namespace and make erfc_func available
drroe Sep 18, 2024
1534b5d
Put Erfc and switching functions through the EwaldParams class
drroe Sep 18, 2024
f2dc7b3
Init class vars
drroe Sep 18, 2024
b27e445
Add params for PME
drroe Sep 19, 2024
b01d0ea
Second try for using pairlist template/engine model
drroe Sep 19, 2024
cad4101
Do some Ewald setup
drroe Sep 19, 2024
142e806
Add routines to access Ewald parameters to the engine
drroe Sep 19, 2024
84e8add
Start PME calc wrapper
drroe Sep 19, 2024
ed8a923
Add class for calculating long range VDW
drroe Sep 19, 2024
2f2e2a8
Use long range VDW calc
drroe Sep 19, 2024
8e3b60f
PME calculation setup
drroe Sep 19, 2024
4fcdf6f
Add PME recip calc wrapper class
drroe Sep 19, 2024
a7a6951
Start using PME_Recip
drroe Sep 19, 2024
14d9006
Allow PME_Recip to be used for coulomb or LJ
drroe Sep 19, 2024
392df78
Use COULOMB recip
drroe Sep 19, 2024
d42e02d
Add self energy calc
drroe Sep 19, 2024
2e80c2c
Save recip coords in EwaldParams_PME so it can be used for multiple
drroe Sep 20, 2024
564be0e
Finish up nonbonded pme calc with template
drroe Sep 20, 2024
c3bc274
Remove separate EwaldDecomp for now
drroe Sep 20, 2024
071e732
Add timing data
drroe Sep 20, 2024
9f2b076
Report pairlist timing data
drroe Sep 20, 2024
1fded79
New test action for comparing the old and new PME methods
drroe Sep 20, 2024
7686d35
Enable the new pmetest action (hidden)
drroe Sep 20, 2024
a8ca188
Ensure previous coords are cleared
drroe Sep 20, 2024
8deddbe
Add unit cell vector check to recip part
drroe Sep 20, 2024
8a2e976
Move LJ ewald coeff into a separate class
drroe Sep 23, 2024
d77bfd2
Add C6 param and LJ self energy calcs
drroe Sep 23, 2024
eaa6928
Return the precalculated self energy
drroe Sep 23, 2024
68f2902
First pass at the LJPME engine
drroe Sep 23, 2024
7b4ad37
Use Ewald parameters
drroe Sep 23, 2024
11750ce
Remove unneeded typedef
drroe Sep 23, 2024
eb0dbbf
Start the LJPME calc class
drroe Sep 23, 2024
85eb8ee
Use the right variables
drroe Sep 23, 2024
78adfe3
Add Calc_LJPME to build
drroe Sep 23, 2024
2cd111f
Add Init routine
drroe Sep 23, 2024
13b0754
Add Setup routine
drroe Sep 23, 2024
2c43c56
Add nonbonded calc routine
drroe Sep 23, 2024
a0568b4
Add timing routine
drroe Sep 23, 2024
8a3127d
Need to pass C6 params to LJPME recip calc, not charges
drroe Sep 23, 2024
c6ff796
Test new LJPME calc
drroe Sep 23, 2024
740f35e
Report LJ PME recip timing in addition to regular recip timing
drroe Sep 23, 2024
a87b1d6
Openmp parallelize the pairlist template loop
Sep 24, 2024
64f0c08
Add timer to check that the recip calc itself is what takes the major…
Sep 24, 2024
6e59fdb
Rename
Sep 24, 2024
19c5e9f
const correctness
Sep 24, 2024
a99fc0f
Rename
drroe Sep 25, 2024
180f284
Finish renaming
drroe Sep 25, 2024
002e056
Start decomposable PME energy class
drroe Sep 25, 2024
00318ac
Placeholder for decomp ewald engine
drroe Sep 25, 2024
68d5a3c
Add engine placeholder
drroe Sep 25, 2024
503db3d
Do engine init
drroe Sep 25, 2024
4cd4df6
Add setup
drroe Sep 25, 2024
3d0617c
Add decomposed self energy
drroe Sep 25, 2024
fc2fd31
Add to build
drroe Sep 25, 2024
06295cd
Start incorporating ene decomp
drroe Sep 25, 2024
52a5a44
Self energy decomp seems to work
drroe Sep 25, 2024
d771f80
Put lattice check in a separate routine
drroe Sep 25, 2024
dc69b6a
Decomposable recip energy
drroe Sep 25, 2024
014dc2d
Decompose direct elec, vdw, and adjust energies
drroe Sep 25, 2024
104fbab
Restore arrays needed for atom decomp of LR vdw correction
drroe Sep 25, 2024
79c433f
Decompose the long range correction
drroe Sep 25, 2024
5d1e788
Actually save the energies back to EnergyDecomposer
drroe Sep 26, 2024
d0dfb01
Add timing data. Hide some debug info.
drroe Sep 26, 2024
243371a
Put LJ PME vdw calc into a template
drroe Sep 26, 2024
53ec89f
Add LJPME exclude adjust kernel
drroe Sep 26, 2024
603ae5d
Remove old code
drroe Sep 26, 2024
5d2a29f
Add Ewald LJPME decomp
drroe Sep 26, 2024
6281543
Create decomposed LJPME calc. Still need to do decomposed self6 energy.
drroe Sep 27, 2024
99c22d6
Add decomposed self6 calc
drroe Sep 27, 2024
7d83077
Use decomposed self6 energies
drroe Sep 27, 2024
498b9ce
Update depends
drroe Sep 27, 2024
1519b88
Doesnt appear like the recip term for the LJPME is working yet.
drroe Sep 27, 2024
fc8e5a2
Use cutoff from EwaldOptions instead of the engine
drroe Oct 1, 2024
c55c10b
Merge branch 'master' into ene.decomp
drroe Oct 2, 2024
289f0d1
Start Ecalc_Nonbond
drroe Oct 2, 2024
5dbc46e
Start implementation
drroe Oct 2, 2024
21479a0
Add pairlist setup
drroe Oct 2, 2024
1324362
Add pairlist setup to nonbond calc
drroe Oct 2, 2024
18506ed
Start refactoring so that pairlist and exclusion array are not part of
drroe Oct 2, 2024
34d5471
Add .cpp.o rule so that subdir compile uses the correct flags
Oct 3, 2024
debf312
Abstract base class for Ewald calcs
Oct 3, 2024
75029a1
Use abstract base class
Oct 3, 2024
c214283
Use EwaldCalc ABC
Oct 3, 2024
8d06da0
Add to build
Oct 3, 2024
25d9d85
Add a nonbond kernel
Oct 3, 2024
f5753a5
Add note about includes
Oct 3, 2024
b6e4fa1
Add calc init and setup, and simple nonbond calc
Oct 3, 2024
8798a7b
Use new nonbond calc
Oct 3, 2024
703bc6a
Report pairlist timing
Oct 3, 2024
c9e082f
Try adding a simple nonbond decomposable energy kernel
Oct 3, 2024
5cd33b8
Start ewald decomp ABC
Oct 3, 2024
04ef644
Fix includes
Oct 3, 2024
399f54f
Convert to EwaldCalc_Decomp class
Oct 3, 2024
9787d5c
Convert decomposd LJPME to Ewald_Decomp class. Update depends
Oct 3, 2024
8bda700
Add energy decomp to Ecalc_Nonbond
Oct 3, 2024
3915705
All ewald calcs need the pairlist
Oct 3, 2024
c21cdf5
Use Ecalc_Nonbond to do the decomp
Oct 3, 2024
7e335b7
Start moving nfft and order to inside PME_Recip
drroe Oct 4, 2024
10a322d
New class to hold recip coords
drroe Oct 7, 2024
9ff25b7
Add routine to access coords array, update depends
drroe Oct 7, 2024
c495811
Remove files
drroe Oct 7, 2024
9ed3b29
Move EwaldParams_PME Init, Setup, and coordsD routines to EwaldParams
drroe Oct 7, 2024
5584d11
Use new EwaldParams
drroe Oct 7, 2024
adc88a7
Use EwaldParams
drroe Oct 7, 2024
f1b0bed
Have recip print opts right after init
drroe Oct 7, 2024
2f82704
Use new EwaldParams
drroe Oct 7, 2024
9350915
Update for new EwaldParams and PME_Recip
drroe Oct 7, 2024
eb0aab3
Update depends
drroe Oct 7, 2024
7af5105
Use EwaldParams intead of EwaldParams_PME. Update depends
drroe Oct 7, 2024
71be5c6
Start Ewald_Recip class
drroe Oct 8, 2024
a36fbc3
Make 1 / sqrt(PI) constant available
drroe Oct 8, 2024
e14f404
Add init and print routines
drroe Oct 8, 2024
348b5ef
Add setup
drroe Oct 8, 2024
d6fcccf
Finish setup
drroe Oct 8, 2024
231bb28
Finish regular recip calc
drroe Oct 8, 2024
890d2e6
Add timing
drroe Oct 8, 2024
1799e40
Update docs
drroe Oct 8, 2024
5298f0d
No need to save ewald coeff, just calculate the factor in Init
drroe Oct 8, 2024
8a7f2e0
Start regular Ewald calc class
drroe Oct 8, 2024
0a48302
Add setup
drroe Oct 8, 2024
c9f7fe9
Finish regular ewald
drroe Oct 8, 2024
22d7eaf
Add EwaldCalc_Regular and Ewald_Recip to build
drroe Oct 8, 2024
966e02d
Add regular ewald to Ecalc_Nonbond
drroe Oct 8, 2024
0092a1b
Add ability to test Ewald regular
drroe Oct 8, 2024
9166109
Add missing init
drroe Oct 8, 2024
064e6f2
Need to look for method == 4. Improve error message. Fix timing message.
drroe Oct 8, 2024
1e02fbf
Fix reduction pragma
drroe Oct 9, 2024
521fdbb
Fix OpenMP compile
drroe Oct 9, 2024
8a5e4f4
Introduce new constant COULOMBFACTOR to replace all separate instances
drroe Oct 9, 2024
190f17f
Start adding ifdefs
drroe Oct 9, 2024
60770df
Start splitting off the direct sum routines
drroe Oct 9, 2024
2b102cd
Start removing old Ewald
drroe Oct 10, 2024
527d74f
These dont need to be separate yet
drroe Oct 10, 2024
ead268e
Make vars available for GIST PME
drroe Oct 10, 2024
acb9a21
Use Ecalc_Nonbond
drroe Oct 10, 2024
be9e8a3
Start converting to use EwaldParams
drroe Oct 10, 2024
693c60a
Add PME_RecipParams class
drroe Oct 15, 2024
34a47cc
Use PME_RecipParams class
drroe Oct 15, 2024
7099669
Put PME_EwaldParams inside PME_Recip
drroe Oct 15, 2024
e92f693
Dont call print inside the init
drroe Oct 15, 2024
c263b71
Expose arrays needed by GIST_PME
drroe Oct 15, 2024
7acd572
Finish converting GIST_PME, add VDW long range, recip, and adjust stuff.
drroe Oct 15, 2024
542c05a
Add missing timing function
drroe Oct 15, 2024
d861972
Fix non-openmp compile
Oct 17, 2024
3293676
Start adding LJPME OptType
Oct 17, 2024
8c11158
Use IsPmeType where appropriate. Ensure GIST PME is only used with PM…
Oct 17, 2024
9fcfa99
Energy decomp with ljpme not yet allowed
Oct 17, 2024
dd45c9d
Allow LJPME to be directly set
Oct 17, 2024
d2d5b89
Remove debug message
Oct 17, 2024
554ed9c
Make options printout more clear
Oct 17, 2024
749c08d
Make sure printed Ewald options line up
Oct 17, 2024
48782ec
Make print private
Oct 17, 2024
2e57168
Clean up printout of regular ewald recip opts
Oct 17, 2024
a80ea73
Since fftw3 is always on now by default, change -fftw3 to -pubfft in …
Oct 17, 2024
30a4275
PME recip needs LIBPME
Oct 17, 2024
5620ed2
Add include of base Ewald decomp class when no LIBPME since no decomp…
Oct 17, 2024
880975f
Add files for enedecomp test
Oct 17, 2024
f9f17d1
Enable enedecomp test
Oct 17, 2024
bc2819d
Remove all references to PairListLoop and associated files
drroe Oct 17, 2024
192276d
Update dependencies
drroe Oct 17, 2024
4e802ce
Add help text
drroe Oct 18, 2024
368313b
Dont repeat the same timing data. Should clean that up eventually
drroe Oct 18, 2024
eacabe2
Use Ecalc_Nonbond interal timer only when it is active
drroe Oct 18, 2024
b03176f
Hide some debug info
drroe Oct 18, 2024
9c802cd
Remove old code
drroe Oct 18, 2024
06a842e
Hide some debug behind ifdef
drroe Oct 18, 2024
2d062f3
Fix up info output
drroe Oct 18, 2024
bacb58d
Hide debug info behind ifdef
drroe Oct 18, 2024
cad81d2
Version 6.29.4. Revision bump for addition of the 'enedecomp' action and
drroe Oct 18, 2024
39badde
Add documentation on how to use the pairlist template
drroe Oct 18, 2024
c51cf8c
Add longer test
drroe Oct 18, 2024
f32b400
Add enedecomp to manual
drroe Oct 18, 2024
e2cff2c
Put functionality to reduce an array of Stats<T> into a separate class
drroe Oct 18, 2024
7cd003f
Use Stats_Reduce
drroe Oct 18, 2024
30bb8f2
Ensure decomposed energy results are synced
drroe Oct 18, 2024
17c8ab8
Add citation to code docs
drroe Oct 18, 2024
31b46b7
Update manual PDF and checksum
drroe Oct 18, 2024
825cd4b
Fix non-MPI compile (oops)
drroe Oct 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ UsageFull() {
echo " -debugon : Add -DDEBUG flag to activate additional internal debugging."
echo " -nolfs : Do not enable large file support."
echo " -shared : Configure for generating libcpptraj (implies -nosanderlib)."
echo " -fftw3 : Use FFTW instead of pubfft for FFT."
echo " -pubfft : Use pubfft instead of FFTW for FFT (disables PME functionality)."
echo " -windows : Set up for use with MinGW compilers for a native Windows build."
echo " LIBRARY OPTIONS"
echo " -<lib> : Enable library."
Expand Down Expand Up @@ -1038,7 +1038,7 @@ EOF
if [ "${LIB_STAT[$LFFTW3]}" = 'optional' ] ; then
WrnMsg "FFTW test failed. CPPTRAJ will use the built-in PubFFT routines."
if [ $BUILD_LIBS -eq 1 ] ; then
echo "To force CPPTRAJ to build its own FFTW, reconfigure and specify '-fftw3'."
echo "To force CPPTRAJ to build its own FFTW, reconfigure and specify '--buildlibs'."
fi
LIB_STAT[$LFFTW3]='off'
elif [ "${LIB_STAT[$LFFTW3]}" = 'enabled' ] ; then
Expand Down Expand Up @@ -2605,6 +2605,7 @@ while [ ! -z "$1" ] ; do
'-tune' ) USE_OPT=2 ;;
'-noc++11' ) C11_SUPPORT='no' ;;
'-windows' ) PLATFORM='windows' ;;
'-pubfft' ) LIB_STAT[$LFFTW3]='off' ;;
# Cpptraj options
'-nolfs' ) LFS='' ;;
'-single-ensemble' ) USE_SINGLEENSEMBLE=1 ;;
Expand Down
5 changes: 5 additions & 0 deletions devtools/CreateMake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ DEL_FILE = /bin/rm -f
# Objects
OBJECTS=\$($VARNAME:.cpp=.o)

# General rules
.cpp.o:
\$(VB)echo CXX $<
\$(VB)\$(CXX) \$(DIRECTIVES) \$(CPPTRAJ_INC) \$(CXXFLAGS) -c -o \$@ $<

# Default target: objects
all: \$(OBJECTS)

Expand Down
Binary file modified doc/CpptrajManual.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion doc/DocumentChecksums.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
b37726e7a841f6fc695ecd7fb040ffbf CpptrajDevelopmentGuide.lyx
736ee725ca9cc67d349f67d714f41c20 cpptraj.lyx
151841b1d3283890c425aaae5a923e7f cpptraj.lyx
07c4039e732fc2eb1df0c1e0863cb949 CpptrajManual.lyx
171 changes: 169 additions & 2 deletions doc/cpptraj.lyx
Original file line number Diff line number Diff line change
Expand Up @@ -20478,7 +20478,7 @@ Mod
\begin_layout Standard
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="92" columns="3">
<lyxtabular version="3" rows="93" columns="3">
<features islongtable="true" longtabularalignment="center">
<column alignment="center" valignment="top" width="25text%">
<column alignment="center" valignment="top" width="65text%">
Expand Down Expand Up @@ -21385,6 +21385,35 @@ Calculate secondary structure content using the DSSP algorithm
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
enedecomp
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Perform per-atom energy decomposition.
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout

\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
energy
\end_layout
Expand Down Expand Up @@ -27788,6 +27817,144 @@ nolink "false"
.
\end_layout

\begin_layout Subsection
enedecomp
\end_layout

\begin_layout LyX-Code
enedecomp [<name>] [<mask>] [out <filename>]
\end_layout

\begin_layout LyX-Code
[ pme [cut <cutoff>] [dsumtol <dtol>] [ewcoeff <coeff>]
\end_layout

\begin_layout LyX-Code
[erfcdx <dx>] [skinnb <skinnb>] [ljswidth <width>]
\end_layout

\begin_layout LyX-Code
[order <order>] [nfft <nfft1>,<nfft2>,<nfft3>]
\end_layout

\begin_deeper
\begin_layout Description
[<name>] Data set name.
\end_layout

\begin_layout Description
[<mask>] Mask of atoms to calculate energy for.
\end_layout

\begin_layout Description
[out
\begin_inset space ~
\end_inset

<filename>] File to write results to.
\end_layout

\begin_layout Description
[pme] Use particle mesh Ewald for electrostatics;
van der Waals energy will be calculated using a long-range correction for periodicity.
\end_layout

\begin_deeper
\begin_layout Description
cut
\begin_inset space ~
\end_inset

<cutoff> Direct space cutoff in Angstroms (default 8.0).
\end_layout

\begin_layout Description
dsumtol
\begin_inset space ~
\end_inset

<dtol> Direct sum tolerance (default 0.00001).
Used to determine Ewald coefficient.
\end_layout

\begin_layout Description
ewcoeff
\begin_inset space ~
\end_inset

<coeff> Ewald coefficient in 1/Ang.
\end_layout

\begin_layout Description
erfcdx
\begin_inset space ~
\end_inset

<dx> Spacing to use for the ERFC splines (default 0.0002 Ang.).
\end_layout

\begin_layout Description
skinnb Used to determine pairlist atoms (added to cut,
so pairlist cutoff is
\series bold
cut
\series default
+
\series bold
skinnb
\series default
);
included in order to maintain consistency with results from sander.
\end_layout

\begin_layout Description
ljswidth
\begin_inset space ~
\end_inset

<width> If specified,
use a force-switching form for the Lennard-Jones calculation from <cutoff>-<width> to <cutoff>.
\end_layout

\begin_layout Description
order
\begin_inset space ~
\end_inset

<order> Spline order for charges.
\end_layout

\begin_layout Description
nfft
\begin_inset space ~
\end_inset

<nfft1>,<nfft2>,<nfft3> Explicitly set the number of FFT grid points in each dimension.
Will be determined automatically from unit cell dimensions if not specified.
\end_layout

\end_deeper
\begin_layout Standard
DataSets created:
\end_layout

\begin_layout Description
<name> Set containing atom index and the corresponding average energy over frames.
\end_layout

\end_deeper
\begin_layout Standard
Perform per-atom energy decomposition for selected atoms.
The energy is calculated for the entire system but only the energies for selected atoms will be reported.
The energy is composed of the regular bond,
angle,
torsion,
1-4 nonbonded,
and nonbonded terms.
If 'pme' is specified the non-bonded terms will us PME for electrostatics and a long-range periodic correction for van der Waals,
otherwise a simple model with no cutoff will be used.
\end_layout

\begin_layout Subsection
energy
\end_layout
Expand Down Expand Up @@ -28154,7 +28321,7 @@ nfft
\end_inset

<nfft1>,<nfft2>,<nfft3> Explicitly set the number of FFT grid points in each dimension.
Will be determined automatically if not specified.
Will be determined automatically from unit cell dimensions if not specified.
\end_layout

\begin_layout Description
Expand Down
51 changes: 51 additions & 0 deletions src/Action_EneDecomp.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include "Action_EneDecomp.h"
#include "CpptrajStdio.h"

// Action_EneDecomp::Help()
void Action_EneDecomp::Help() const {
Cpptraj::Energy::EnergyDecomposer::HelpText();
}

// Action_EneDecomp::Init()
Action::RetType Action_EneDecomp::Init(ArgList& actionArgs, ActionInit& init, int debugIn)
{
# ifdef MPI
trajComm_ = init.TrajComm();
# endif
if (eneDecomp_.InitDecomposer( actionArgs, init.DSL(), init.DFL(), debugIn ))
return Action::ERR;
mprintf(" ENEDECOMP: Decomposing energy for selected atoms.\n");
eneDecomp_.PrintOpts();

return Action::OK;
}

// Action_EneDecomp::Setup()
Action::RetType Action_EneDecomp::Setup(ActionSetup& setup)
{
int ret = eneDecomp_.SetupDecomposer( setup.Top(), setup.CoordInfo().TrajBox() );
if (ret == -1)
return Action::SKIP;
else if (ret == 1)
return Action::ERR;
return Action::OK;
}

// Action_EneDecomp::DoAction()
Action::RetType Action_EneDecomp::DoAction(int frameNum, ActionFrame& frm)
{
if (eneDecomp_.CalcEne( frm.Frm() ))
return Action::ERR;
return Action::OK;
}

#ifdef MPI
int Action_EneDecomp::SyncAction() {
return eneDecomp_.ReduceToMaster(trajComm_);
}
#endif

// Action_EneDecomp::Print()
void Action_EneDecomp::Print() {
eneDecomp_.FinishCalc();
}
32 changes: 32 additions & 0 deletions src/Action_EneDecomp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#ifndef INC_ACTION_ENEDECOMP_H
#define INC_ACTION_ENEDECOMP_H
#include "Action.h"
#include "Energy/EnergyDecomposer.h"
/// Used to decompose the pairwise additive energy of a system
class Action_EneDecomp : public Action {
public:
/// CONSTRUCTOR
Action_EneDecomp() {}
/// Allocator
DispatchObject* Alloc() const { return (DispatchObject*)new Action_EneDecomp(); }
/// Help text
void Help() const;
private:
/// Initialization
Action::RetType Init(ArgList&, ActionInit&, int);
/// Topology-based setup
Action::RetType Setup(ActionSetup&);
/// Do the action
Action::RetType DoAction(int, ActionFrame&);
/// Print results/finish calculations
void Print();
# ifdef MPI
int SyncAction();
# endif

Cpptraj::Energy::EnergyDecomposer eneDecomp_; ///< Do the actual decomposition
# ifdef MPI
Parallel::Comm trajComm_; ///< Across-trajectory communicator
# endif
};
#endif
Loading
Loading