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

MPI support for SGP construction #14

Open
wants to merge 245 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
245 commits
Select commit Hold shift + click to select a range
eec1c26
add distmatrix into cmkae
YuuuXie Apr 15, 2021
6c483b8
add parallel sgp
YuuuXie Apr 16, 2021
ee139d4
create matrix
YuuuXie Apr 16, 2021
9e94754
distribute training strucs
YuuuXie Apr 16, 2021
e03ec9f
add test for ParallelSGP
YuuuXie Apr 16, 2021
55150e5
link to MPI
YuuuXie Apr 16, 2021
a0bdd55
compile successfully with distmatrix
YuuuXie Apr 17, 2021
b84fb74
add cholesky
YuuuXie Apr 19, 2021
5d685c3
done matrix operation
YuuuXie Apr 20, 2021
c0352fc
adds brackets to constrain the scope of DistMatrix
YuuuXie Apr 21, 2021
b26acf7
default blocking & distribute training set
YuuuXie Apr 24, 2021
c93b4d8
fixed u_size, solve segmentation fault
YuuuXie Apr 25, 2021
6e0efad
add write_map & unit test
YuuuXie Apr 25, 2021
22532a6
add openmp to compute_map_coef
YuuuXie Apr 25, 2021
53df035
debugging
YuuuXie Apr 27, 2021
4c97acc
Kuu & Kuu_inv match with SparseGP
YuuuXie Apr 27, 2021
25a05bc
fix: Kuf matches SparseGP
YuuuXie Apr 28, 2021
31b3276
parallel_sgp matches sparse_gp in prediction of efs and var
YuuuXie May 3, 2021
f91829e
fix mpibcast in test_parallel_sgp
YuuuXie May 4, 2021
82a4a40
match Kuu and y with mpirun
YuuuXie May 4, 2021
8edcace
fix b vector matching
YuuuXie May 4, 2021
741448d
fix Kuf match
YuuuXie May 4, 2021
bc06f2d
change kuu to be built by rank 0
YuuuXie May 5, 2021
39ddf67
efs & uncertainty match with mpirun
YuuuXie May 6, 2021
5776522
add python binding with mpi4py
YuuuXie May 6, 2021
4261583
remove debugging prints
YuuuXie May 6, 2021
e364465
add mpi timing file
YuuuXie May 7, 2021
fbdfbaa
remove pybind of ParallelSGP due to distmat sharing issue
YuuuXie May 7, 2021
2e5f998
fix timing
YuuuXie May 13, 2021
499dc0c
add timestamps
YuuuXie May 13, 2021
c4575cd
try computing a subset of descriptors in structure
YuuuXie May 13, 2021
40152db
add reader for xyz file
YuuuXie May 13, 2021
2dd01ff
Revert "try computing a subset of descriptors in structure"
YuuuXie May 13, 2021
c29925d
finish xyz reader
YuuuXie May 14, 2021
a7d9908
try using distmat for global sparse descriptors
YuuuXie May 14, 2021
a710a54
add scripts & unit test
YuuuXie May 14, 2021
7bcb5a3
add n_envs_by_type
YuuuXie May 14, 2021
157858c
distribute training set
YuuuXie May 15, 2021
9537479
distributing training data, pass unit test
YuuuXie May 17, 2021
b555728
rm debug flag & fix timing
YuuuXie May 17, 2021
b5a2b0e
add print flag
YuuuXie May 18, 2021
eb3ad8a
read extxyz format
YuuuXie May 19, 2021
cc0b79d
compilation succeed with utils
YuuuXie May 22, 2021
14e8e6a
fix utils unit test
YuuuXie May 23, 2021
65ff02c
add lock to 'get' and 'set' for multi-node
YuuuXie May 24, 2021
e9b0326
cp xyz file in cmake
YuuuXie May 25, 2021
1db0963
change to allgather
YuuuXie May 25, 2021
a0af135
add a multinode test script
YuuuXie May 25, 2021
7c3e4c1
fix par_sgp write_coef
YuuuXie May 25, 2021
d13eae3
change the input to vector of structures
YuuuXie May 26, 2021
2fffeba
change sparse ind type
YuuuXie May 28, 2021
8c570d5
fix mysterious mpi bad request issue
YuuuXie Jun 4, 2021
28a9d81
add script for mpi executable
YuuuXie Jun 4, 2021
3499df2
add docs for python api
YuuuXie Jun 9, 2021
209c223
add parallsgp doc
YuuuXie Jun 9, 2021
2ed8cbd
add docs
YuuuXie Jun 10, 2021
0bbbd51
fix map omp
YuuuXie Jun 13, 2021
9d04329
build matrix using local array
YuuuXie Jun 13, 2021
6c55fc4
Merge branch 'mpi_distmat' of github.com:mir-group/flare_pp into mpi_…
YuuuXie Jun 13, 2021
42078df
fix varmap omp
YuuuXie Jun 13, 2021
07cbda5
add docs to utils
YuuuXie Jun 14, 2021
104f2c3
add single atom energy to mpi_build
YuuuXie Jun 29, 2021
79f0fdb
Merge https://github.com/mir-group/flare_pp into mpi_distmat
YuuuXie Jul 5, 2021
c3a9f15
Merge branch 'mpi_distmat' of github.com:mir-group/flare_pp into mpi_…
YuuuXie Jul 5, 2021
62e30fe
Merge github.com:mir-group/flare_pp into mpi_distmat
YuuuXie Jul 5, 2021
ef4664f
Merge branch 'mpi_distmat' of github.com:mir-group/flare_pp into mpi_…
YuuuXie Jul 5, 2021
dcb8975
change file name b3 -> bk
YuuuXie Jul 13, 2021
12c8f40
change class name B3 -> Bk
YuuuXie Jul 13, 2021
d844f4e
add body in descriptor_settings
YuuuXie Jul 13, 2021
0e3c714
add indices module
YuuuXie Jul 13, 2021
0088bd6
add K to compute_Bk
YuuuXie Jul 13, 2021
bd3c9c1
nu replaces loops
YuuuXie Jul 13, 2021
e9e87d8
change to fwd & bwd
YuuuXie Jul 13, 2021
69514ef
add test to match bk and b3
YuuuXie Jul 13, 2021
9c1d73e
add b3 for test
YuuuXie Jul 13, 2021
e739328
add K2
YuuuXie Jul 13, 2021
8b24c50
change wigner3j to coeffs
YuuuXie Jul 14, 2021
34befc8
compiled b2
YuuuXie Jul 14, 2021
6a5f4cf
try debuggin b2
YuuuXie Jul 15, 2021
4de2ab4
add b1 & pass test
YuuuXie Jul 15, 2021
1e6fd28
fix b2
YuuuXie Jul 16, 2021
97deba5
add indices for add_training_structure
YuuuXie Jul 16, 2021
d0f7811
fix small bug
YuuuXie Jul 17, 2021
a70eaa6
add test
YuuuXie Jul 17, 2021
01e957b
add atomic indices for training structures, likelihood
YuuuXie Jul 17, 2021
66a64f6
use TYPED_TEST
YuuuXie Jul 17, 2021
ddfb3dc
inherit StructureTest
YuuuXie Jul 17, 2021
55d917f
add parametrized gtest
YuuuXie Jul 18, 2021
b22733b
Merge branch 'train_struc_indices' into Bk_desc
YuuuXie Jul 18, 2021
6e050ef
add multiplt kernel test
YuuuXie Jul 18, 2021
28bb292
add b1 for test
YuuuXie Jul 19, 2021
62b275c
fix unit tests
YuuuXie Jul 19, 2021
7cb6910
allow mapping for multiple descriptors/kernels
YuuuXie Jul 20, 2021
68bc8a7
update python interface for multiple kernels
YuuuXie Jul 20, 2021
ee8dca8
write multiple descriptors to coef file
YuuuXie Jul 20, 2021
062c8f8
add multiple cutoffs
YuuuXie Jul 21, 2021
0c2f516
add compute_likelihood_gradient_stable
YuuuXie Jul 22, 2021
b115eff
add noise_one
YuuuXie Jul 22, 2021
9c4649b
add Kuu_grad Kuf_grad
YuuuXie Jul 22, 2021
a5b870c
match datafit_grad
YuuuXie Jul 23, 2021
0836838
match complexity_grad
YuuuXie Jul 23, 2021
1b33dfa
fix multiple kernel grad
YuuuXie Jul 23, 2021
8530df8
datafit grad over noise
YuuuXie Jul 23, 2021
43de96c
complexity grad over noise
YuuuXie Jul 23, 2021
9b4862e
add pybinding to compute_grad_stable
YuuuXie Jul 23, 2021
a9247e2
add KnK
YuuuXie Jul 25, 2021
fd86f80
add KnK
YuuuXie Jul 25, 2021
81286d1
add precompute KnK
YuuuXie Jul 26, 2021
6e815b6
rm diag
YuuuXie Jul 26, 2021
84a1962
rm Kuu_grad Kuf_grad for speedup
YuuuXie Jul 27, 2021
2ffd3ca
change train() for precomputed kern matr
YuuuXie Jul 27, 2021
e0b8856
rm noise_vec loop in compute_likelihood_gradient
YuuuXie Jul 29, 2021
292ef88
call child Kuf_grad Kuu_grad
YuuuXie Jul 29, 2021
eb67338
remove comments
YuuuXie Jul 30, 2021
92a0949
change test parameters
YuuuXie Jul 31, 2021
781f2bc
fix bug: KnK
YuuuXie Jul 31, 2021
49d8a6c
change noise_vector in set_hyp
YuuuXie Jul 31, 2021
c65d329
add test match like_grad_stable & like_grad
YuuuXie Jul 31, 2021
3682ac8
fix kernels[i]->Kuu_grad & Kuf_grad
YuuuXie Jul 31, 2021
f02c1d4
preprocess training data
YuuuXie Aug 5, 2021
5bbeaf3
fix compilation
YuuuXie Aug 7, 2021
651a66a
add -lgfortran to allow compilation with downloaded scalapack
YuuuXie Aug 7, 2021
299e126
rm commented func
YuuuXie Aug 7, 2021
e7953bc
load_local loads struc of A's local part
YuuuXie Aug 7, 2021
cd71bb9
add A.set
YuuuXie Aug 7, 2021
4786c7d
get back to the old adding scheme
YuuuXie Aug 7, 2021
0942922
as_dict supports multiple kernels/descs
YuuuXie Aug 10, 2021
09d7afe
add Bk to lammps
YuuuXie Aug 10, 2021
a32f459
use original pair style
YuuuXie Aug 10, 2021
06dbd59
add coeffs and indices
YuuuXie Aug 10, 2021
1db17b7
copy b1+b2 pair_style & add body K
YuuuXie Aug 10, 2021
e8c5513
replace descriptor_code with K
YuuuXie Aug 10, 2021
ba9b7e2
done lammps file parsing
YuuuXie Aug 11, 2021
f81c4e5
write K to coeff file
YuuuXie Aug 11, 2021
907b617
fix calling desc
YuuuXie Aug 11, 2021
c29b70f
rm neighbor loop in lmp descriptor
YuuuXie Aug 11, 2021
a149ed1
add multiple kernels to local_unc
YuuuXie Aug 14, 2021
d5f412f
Merge branch 'Bk' of github.com:mir-group/flare_pp into like_grad_stable
YuuuXie Aug 14, 2021
742b294
fix local stds
YuuuXie Aug 14, 2021
353dbb3
Merge branch 'Bk' into like_grad_stable
YuuuXie Aug 14, 2021
897755c
separate kernel tests to debug
YuuuXie Aug 15, 2021
d56a9dc
separate stree-energy kernel test & change b2_norm
YuuuXie Aug 15, 2021
f62cf48
separate force stress kernels and fix unit test
YuuuXie Aug 15, 2021
cd9f542
rm B2 binding, add Bk binding
YuuuXie Aug 15, 2021
7874c4a
fix python test bugs except for lmp
YuuuXie Aug 15, 2021
e3ef23c
Merge branch 'Bk' of github.com:mir-group/flare_pp into like_grad_stable
YuuuXie Aug 15, 2021
4a41f35
pass compilation
YuuuXie Aug 16, 2021
8c05ba7
pass b2 test (no variance)
YuuuXie Aug 16, 2021
2d97b6f
add multiple kernels to python test
YuuuXie Aug 16, 2021
b3f2c69
try using scatter for set
YuuuXie Aug 17, 2021
6dc8413
update_db for multiple desc/kernels
YuuuXie Aug 19, 2021
343f666
add more scatter
YuuuXie Sep 1, 2021
377cf9a
test new scatter
YuuuXie Sep 1, 2021
5130d67
A.collect works for collecting Kfu
YuuuXie Sep 2, 2021
c18b2d7
done b.collect
YuuuXie Sep 2, 2021
ae2acab
rm A.set & b.set
YuuuXie Sep 3, 2021
d0b52e3
fix mpi_construction exec
YuuuXie Sep 5, 2021
08a885d
change param in test
YuuuXie Sep 6, 2021
ed990aa
change to partial_forces
YuuuXie Sep 6, 2021
ce5487b
fix bug dA=1 of Bk
YuuuXie Sep 7, 2021
4d17b5f
fix unit test for multiple kernels
YuuuXie Sep 7, 2021
00dc29a
compute_std passes compilation
YuuuXie Sep 8, 2021
424c0ab
change stds from vector_atom to array_atom
YuuuXie Sep 8, 2021
4fe6ef3
done lmp var unit test
YuuuXie Sep 9, 2021
3bed77c
Merge branch 'rewrite_b2lmp' of github.com:mir-group/flare_pp into Bk
YuuuXie Sep 9, 2021
37fd533
Update version to 0.1.0
YuuuXie Sep 9, 2021
62e02f9
Merge branch 'Bk' of github.com:mir-group/flare_pp into like_grad_stable
YuuuXie Sep 9, 2021
6dfc15f
pass unit test
YuuuXie Sep 9, 2021
3fefb22
change u_size_single_kernel to a list
YuuuXie Sep 12, 2021
a900ac7
change n_clusters to a list for kernels
YuuuXie Sep 12, 2021
1712667
change local_labels to vector
YuuuXie Sep 12, 2021
c621bae
debugging multiple kernels
YuuuXie Sep 12, 2021
50a57ec
pass unit test with multiple kernels
YuuuXie Sep 13, 2021
10ea653
solve conflict of merging like_grad_stable
YuuuXie Sep 14, 2021
df05e4e
fix conflict
YuuuXie Sep 14, 2021
c659be3
try adding compute_likelihood_grad
YuuuXie Sep 14, 2021
55f2e3b
rm finalize to pass unit test
YuuuXie Sep 14, 2021
1a5eb3c
add compute_KnK
YuuuXie Sep 17, 2021
b474d5d
add compute_dKnK
YuuuXie Sep 19, 2021
4761988
fix conflict: change to list input for mapping
YuuuXie Sep 21, 2021
5bbdb9e
complete likelihood & grad calculation
YuuuXie Sep 21, 2021
fb5e048
mv finalize from source to script
YuuuXie Sep 21, 2021
5be8d35
match dK_alpha
YuuuXie Sep 21, 2021
72af360
pass unit test with serial dKnK
YuuuXie Sep 23, 2021
6458838
compute_likelihood_grad pass unit test with mpirun
YuuuXie Sep 23, 2021
3f544f6
remove print flags
YuuuXie Sep 23, 2021
5e9174b
add timer
YuuuXie Sep 23, 2021
0b0f8f6
add timer
YuuuXie Sep 23, 2021
23bc528
add initial value to .h
YuuuXie Sep 23, 2021
96ef772
separate like_grad parts
YuuuXie Sep 23, 2021
3f00346
merge methods & rm distmatrix from header
YuuuXie Sep 23, 2021
10f2f32
add ParallelSGP to pybind
YuuuXie Sep 23, 2021
4699007
fix name
YuuuXie Sep 30, 2021
ecd81f2
add parallelsgp module
YuuuXie Sep 30, 2021
5c05c85
try adding cppoptlib
YuuuXie Sep 30, 2021
b476030
rm cppoptlib
YuuuXie Sep 30, 2021
ac5dd1d
add set_hyperparameters
YuuuXie Sep 30, 2021
aca3e74
Merge branch 'mpi_distmat' of https://github.com/mir-group/flare_pp i…
YuuuXie Sep 30, 2021
1c18cd6
unify sgp and parsgp interface for training
YuuuXie Sep 30, 2021
b97af76
fix small bugs
YuuuXie Sep 30, 2021
d5102b7
optimization works in python
YuuuXie Oct 3, 2021
8d3dedb
mpi training in python works
YuuuXie Oct 3, 2021
542a4d1
fix sparse_ind bug
YuuuXie Oct 10, 2021
125bf28
resolve compilation issue of '-fPIC' of scalapack static
YuuuXie Oct 12, 2021
17b4d61
add compilation instruction to README
YuuuXie Oct 12, 2021
78f2d1e
fix dK_alpha bug
YuuuXie Oct 14, 2021
1824269
add update_db to parallel_sgp
YuuuXie Oct 14, 2021
da3adaa
fix a bug in initialization
YuuuXie Oct 14, 2021
093aa1e
fix mpi_bcast of likelihood grad
YuuuXie Oct 14, 2021
b81f014
add destructor & fix a bug of like_grad with multiple kernels
YuuuXie Oct 19, 2021
dcaaf34
rm debug flags
YuuuXie Oct 19, 2021
8dad80f
rm unsupported class variables
YuuuXie Oct 19, 2021
98d8780
fix a bug of local_noise in set_hyp
YuuuXie Oct 19, 2021
48a59b7
rm print flags
YuuuXie Oct 19, 2021
7a8151f
add destructors
YuuuXie Oct 20, 2021
b587629
add deepcopy to mean_efs to prevent memory accumulation
YuuuXie Oct 23, 2021
62936c0
solve conflict with master
YuuuXie Oct 23, 2021
acf537e
change dir of parsgp test
YuuuXie Oct 23, 2021
995c27a
solve conflict with master
YuuuXie Oct 27, 2021
f745867
add back b2 to python binding
YuuuXie Oct 27, 2021
f26e9e8
add virtual to fix bugs
YuuuXie Oct 27, 2021
8896bae
fix bug in add_random_envs
YuuuXie Oct 27, 2021
10161f1
add err handler & fence & barrier
YuuuXie Oct 27, 2021
26c5ac2
able to update one frame when adding training data
YuuuXie Nov 1, 2021
920da5b
add condition for finalize
YuuuXie Nov 1, 2021
a65310a
add timing for likelihood_grad
YuuuXie Nov 1, 2021
d19e7ca
fix a bug of update training set
YuuuXie Nov 1, 2021
31e59ba
add 'update' arg to 'build' in python
YuuuXie Nov 2, 2021
55a3ef8
fix a small bug of KnK matrix size
YuuuXie Nov 2, 2021
cf6e675
add precompute_KnK to ParallelSGP
YuuuXie Nov 2, 2021
e1c5d7c
pass test of parallel prediction
YuuuXie Nov 2, 2021
6824005
merge master python tests
YuuuXie Nov 2, 2021
3d04e27
add python binding for predict functions
YuuuXie Nov 2, 2021
7cc895d
predict_on_structures now compute descriptorsw
YuuuXie Nov 3, 2021
8231365
predict_on_struc returns mean values
YuuuXie Nov 3, 2021
7640208
randomly set species
YuuuXie Nov 3, 2021
3e48c4a
change 'specific' mode of sparse_gp to allow different atoms for diff…
YuuuXie Nov 4, 2021
6ec2bc6
predict_on_structures returns structure list
YuuuXie Nov 4, 2021
530f99b
add predict_on_structures to python unit test
YuuuXie Nov 4, 2021
ce4e7c8
add sparse desc by update
YuuuXie Nov 5, 2021
2ef1203
update and pop training_structures when update one structure
YuuuXie Nov 5, 2021
0b4da78
replace computation of dKnK with the SparseGP::compute_dKnK
YuuuXie Nov 6, 2021
95a1bdd
update gather/allgather interface
YuuuXie Nov 6, 2021
dd32f22
R is gathered from QR
YuuuXie Nov 6, 2021
fd140b7
change Matrix into Eigen::Matrix
YuuuXie Nov 6, 2021
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ _C_flare*
**/xml
**/dist
**egg-info
*.DS_Store
35 changes: 33 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/)

include(ExternalProject)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

Expand Down Expand Up @@ -111,6 +111,22 @@ endif()

# Greatly reduces the code bloat
target_compile_options(pybind11 INTERFACE "-fvisibility=hidden")

# Distmatrix
###############################################################################
FetchContent_Declare(
distmatrix
GIT_REPOSITORY https://github.com/mir-group/distmatrix.git
)
FetchContent_MakeAvailable(distmatrix)

link_directories(${distmatrix_BINARY_DIR})
link_directories(${distmatrix_BINARY_DIR}/scalapack_build/lib)

include_directories(${distmatrix_SOURCE_DIR}/include)


#target_link_libraries(flare PUBLIC distmatrix)
###############################################################################

# Specify source files.
Expand All @@ -119,14 +135,19 @@ set(FLARE_SOURCES
src/flare_pp/radial.cpp
src/flare_pp/cutoffs.cpp
src/flare_pp/structure.cpp
src/flare_pp/utils.cpp
src/flare_pp/bffs/sparse_gp.cpp
src/flare_pp/bffs/parallel_sgp.cpp
src/flare_pp/bffs/gp.cpp
src/flare_pp/descriptors/descriptor.cpp
src/flare_pp/descriptors/b1.cpp
src/flare_pp/descriptors/b2.cpp
src/flare_pp/descriptors/b2_norm.cpp
src/flare_pp/descriptors/b2_simple.cpp
src/flare_pp/descriptors/b3.cpp
src/flare_pp/descriptors/wigner3j.cpp
src/flare_pp/descriptors/bk.cpp
src/flare_pp/descriptors/indices.cpp
src/flare_pp/descriptors/coeffs.cpp
src/flare_pp/descriptors/two_body.cpp
src/flare_pp/descriptors/three_body.cpp
src/flare_pp/descriptors/three_body_wide.cpp
Expand All @@ -152,6 +173,14 @@ include_directories(
add_library(flare STATIC ${FLARE_SOURCES})
set_target_properties(flare PROPERTIES POSITION_INDEPENDENT_CODE ON)
add_dependencies(flare eigen_project)
add_dependencies(flare distmatrix)

# Link to MPI
find_package(MPI REQUIRED)
target_link_libraries(flare PUBLIC MPI::MPI_CXX)

# Link to distmatrix
target_link_libraries(flare PUBLIC distmatrix -lgfortran)

# Link to json.
target_link_libraries(flare PUBLIC nlohmann_json::nlohmann_json)
Expand All @@ -175,6 +204,8 @@ if (DEFINED ENV{MKL_INCLUDE} AND DEFINED ENV{MKL_LIBS})
include_directories($ENV{MKL_INCLUDE})
target_link_libraries(flare PUBLIC $ENV{MKL_LIBS})
target_compile_definitions(flare PUBLIC EIGEN_USE_MKL_ALL=1)
target_include_directories(flare PUBLIC $ENV{MKL_MPI})
message(MKL_MPI=$ENV{MKL_MPI})
# Give the option to do a "bare-bones" build without Lapack/Lapacke.
elseif(DEFINED ENV{NO_LAPACK})
message(STATUS "Building without Lapack.")
Expand Down
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,36 @@ If you're installing on Harvard's compute cluster, load the following modules fi
```
module load cmake/3.17.3-fasrc01 python/3.6.3-fasrc01 gcc/9.3.0-fasrc01
```

### MPI compilation
To install the MPI version of sparse GP, on Harvard's compute cluster, load the following modules first:
```
module load cmake/3.17.3-fasrc01 python/3.6.3-fasrc01 gcc/9.3.0-fasrc01
module load intel-mkl/2017.2.174-fasrc01 openmpi/4.0.5-fasrc01
```

Then clone the repository
```
git clone https://github.com/mir-group/flare_pp.git
git checkout mpi_distmat
```

Create a directory for building the library
```
mkdir build
cd build
```

Compile with `cmake` and `make`. Here we need to specify the MPI compiler with
`CC=mpicc CXX=mpic++ FC=mpif90`. We also set the option `-DSCALAPACK_LIB=NOTFOUND`,
such that we download and compile our own static Scalapack library to support
python binding with MPI parallelized sparse GP
```
CC=mpicc CXX=mpic++ FC=mpif90 cmake .. -DSCALAPACK_LIB=NOTFOUND
make -j
```

Copy the python binding library to the folder of `flare_pp`
```
cp _C_flare.cpython-36m-x86_64-linux-gnu.so ../flare_pp
```
7 changes: 7 additions & 0 deletions ctests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/dft_data.xyz)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/dft_data.xyz
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
endif ()

# make executable
add_executable(
tests
Expand All @@ -6,8 +11,10 @@ add_executable(
test_structure.cpp
test_n_body.cpp
test_sparse_gp.cpp
test_parallel_sgp.cpp
test_descriptor.cpp
test_json.cpp
test_utils.cpp
)

include_directories(../src/flare_pp)
Expand Down
17 changes: 17 additions & 0 deletions ctests/dft_data.xyz
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
2
Lattice="1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0" Properties=species:S:1:pos:R:3:momenta:R:3:forces:R:3 sparse_indices= energy=0.9133510291442271 stress="0.4314439934824156 0.7292230215429331 0.38721540888657746 0.7292230215429331 0.326605318720777 0.25504993852246405 0.38721540888657746 0.25504993852246405 0.3185010782409763" pbc="T T T"
He 0.15713841 0.99710398 0.64092684 0.19861472 0.12959016 0.46411878 0.48801624 0.78256914 0.52750114
He 0.69338569 0.90346464 0.14626089 0.92338744 0.37879257 0.79694737 0.92320467 0.71863087 0.54575622
4
Lattice="1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0" Properties=species:S:1:pos:R:3:momenta:R:3:forces:R:3 sparse_indices=2 energy=0.5845339958967781 stress="0.8832643728374101 0.4736589482749042 0.6125575360846077 0.4736589482749042 0.04982809557310608 0.9519383879956919 0.6125575360846077 0.9519383879956919 0.22321884060680475" pbc="T T T"
H 0.98699548 0.27109152 0.82840818 0.39723635 0.69230317 0.71742402 0.97501125 0.69790992 0.42736135
He 0.95542741 0.62792707 0.71255717 0.20846441 0.71391509 0.56988269 0.73802987 0.55611127 0.20978028
H 0.95551793 0.79583919 0.01626457 0.50770084 0.31544704 0.09250715 0.97886919 0.15580748 0.02892780
He 0.34877543 0.15749443 0.15293379 0.64543458 0.63466428 0.15787333 0.67504974 0.30204244 0.41673029
5
Lattice="1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0" Properties=species:S:1:pos:R:3:momenta:R:3:forces:R:3 sparse_indices="0 2 4" energy=0.26796364806180983 stress="0.5706389111071576 0.3483258644776196 0.06089244456604703 0.3483258644776196 0.5296282371894802 0.21476826115341807 0.06089244456604703 0.21476826115341807 0.008875719863243536" pbc="T T T"
H 0.35071505 0.73963362 0.02696195 0.50938856 0.68674285 0.31711543 0.21822063 0.99866869 0.23949716
H 0.78288668 0.67299943 0.47254490 0.03722967 0.36556295 0.28723150 0.36477796 0.28274931 0.78633052
H 0.43430905 0.05355055 0.52035306 0.40526494 0.75298417 0.54189491 0.15815742 0.15396677 0.20679348
He 0.50335965 0.87700387 0.47565834 0.59881725 0.71577512 0.87647597 0.44898467 0.56835792 0.32339863
He 0.28826927 0.14879537 0.18758152 0.00333732 0.24138565 0.27410589 0.43239731 0.43696276 0.94641792
116 changes: 98 additions & 18 deletions ctests/test_descriptor.cpp
Original file line number Diff line number Diff line change
@@ -1,52 +1,132 @@
#include "bk.h"
#include "b1.h"
#include "b2.h"
#include "b3.h"
#include "descriptor.h"
#include "test_structure.h"
#include "gtest/gtest.h"
#include <Eigen/Dense>
#include <cmath>
#include <list>
#include <iostream>

TEST_F(StructureTest, RotationTest) {
// Test different types B1, B2, B3 to match with Bk
template <typename T>
class DescTest : public StructureTest {
public:
using List = std::list<T>;
};

using DescTypes = ::testing::Types<B1, B2, B3>;
TYPED_TEST_SUITE(DescTest, DescTypes);

TYPED_TEST(DescTest, TestBk) {
// Set up B1/2/3 descriptors
std::vector<int> descriptor_settings_1{this->n_species, this->N, this->L};
std::vector<Descriptor *> descriptors1;

TypeParam desc1(this->radial_string, this->cutoff_string, this->radial_hyps,
this->cutoff_hyps, descriptor_settings_1);
descriptors1.push_back(&desc1);

// Set up Bk descriptors
int K = desc1.K;
std::vector<int> descriptor_settings_2{this->n_species, K, this->N, this->L};
Bk desc2(this->radial_string, this->cutoff_string, this->radial_hyps,
this->cutoff_hyps, descriptor_settings_2);
std::vector<Descriptor *> descriptors2;
descriptors2.push_back(&desc2);

Structure struc1 = Structure(this->cell, this->species, this->positions, this->cutoff, descriptors1);
Structure struc2 = Structure(this->cell, this->species, this->positions, this->cutoff, descriptors2);

// Check the descriptor dimensions
std::vector<int> last_index = desc2.nu[desc2.nu.size()-1];
int n_d = last_index[last_index.size()-1] + 1; // the size of list nu
int n_d1 = struc1.descriptors[0].n_descriptors;
int n_d2 = struc2.descriptors[0].n_descriptors;
EXPECT_EQ(n_d, n_d1);
EXPECT_EQ(n_d1, n_d2);

// Check that Bk and B3 give the same descriptors.
double d1, d2;
int nu_ind;
for (int i = 0; i < struc1.descriptors.size(); i++) {
for (int j = 0; j < struc1.descriptors[i].descriptors.size(); j++) {
for (int k = 0; k < struc1.descriptors[i].descriptors[j].rows(); k++) {
for (int l = 0; l < struc1.descriptors[i].descriptors[j].cols(); l++) {
d1 = struc1.descriptors[i].descriptors[j](k, l);
d2 = struc2.descriptors[i].descriptors[j](k, l);
EXPECT_NEAR(d1, d2, 1e-8);
}
}
}
}

for (int i = 0; i < struc1.descriptors.size(); i++) {
for (int j = 0; j < struc1.descriptors[i].descriptor_force_dervs.size(); j++) {
for (int k = 0; k < struc1.descriptors[i].descriptor_force_dervs[j].rows(); k++) {
for (int l = 0; l < struc1.descriptors[i].descriptor_force_dervs[j].cols(); l++) {
d1 = struc1.descriptors[i].descriptor_force_dervs[j](k, l);
d2 = struc2.descriptors[i].descriptor_force_dervs[j](k, l);
EXPECT_NEAR(d1, d2, 1e-8);
}
}
}
}

}

// Test Bk with K=1,2,3 for rotational invariance
class DescRotTest : public StructureTest,
public testing::WithParamInterface<int> {
public:
// Choose arbitrary rotation angles.
double xrot = 1.28;
double yrot = -3.21;
double zrot = 0.42;

Eigen::MatrixXd rotated_pos;
Eigen::MatrixXd rotated_cell;

// Define rotation matrices.
Eigen::MatrixXd Rx{3, 3}, Ry{3, 3}, Rz{3, 3}, R{3, 3};
Rx << 1, 0, 0, 0, cos(xrot), -sin(xrot), 0, sin(xrot), cos(xrot);
Ry << cos(yrot), 0, sin(yrot), 0, 1, 0, -sin(yrot), 0, cos(yrot);
Rz << cos(zrot), -sin(zrot), 0, sin(zrot), cos(zrot), 0, 0, 0, 1;
R = Rx * Ry * Rz;

Eigen::MatrixXd rotated_pos = positions * R.transpose();
Eigen::MatrixXd rotated_cell = cell * R.transpose();
DescRotTest() {
Rx << 1, 0, 0, 0, cos(xrot), -sin(xrot), 0, sin(xrot), cos(xrot);
Ry << cos(yrot), 0, sin(yrot), 0, 1, 0, -sin(yrot), 0, cos(yrot);
Rz << cos(zrot), -sin(zrot), 0, sin(zrot), cos(zrot), 0, 0, 0, 1;
R = Rx * Ry * Rz;
rotated_pos = positions * R.transpose();
rotated_cell = cell * R.transpose();
}
};

// Define descriptors.
descriptor_settings[2] = 2;
B3 descriptor = B3(radial_string, cutoff_string, radial_hyps, cutoff_hyps,
descriptor_settings);
TEST_P(DescRotTest, RotationTest) {
int K = GetParam();
std::vector<int> descriptor_settings{n_species, K, N, L};
Bk desc(radial_string, cutoff_string, radial_hyps, cutoff_hyps,
descriptor_settings);

std::vector<Descriptor *> descriptors;
descriptors.push_back(&descriptor);
descriptors.push_back(&desc);

Structure struc1 = Structure(cell, species, positions, cutoff, descriptors);
Structure struc2 =
Structure(rotated_cell, species, rotated_pos, cutoff, descriptors);
Structure(this->rotated_cell, species, this->rotated_pos, cutoff, descriptors);

// Check that B1 is rotationally invariant.
double d1, d2, diff;
double tol = 1e-10;
double d1, d2;

std::cout << "n_descriptors=" << struc1.descriptors[0].n_descriptors << std::endl;
for (int n = 0; n < struc1.descriptors[0].n_descriptors; n++) {
d1 = struc1.descriptors[0].descriptors[0](0, n);
d2 = struc2.descriptors[0].descriptors[0](0, n);
diff = d1 - d2;
EXPECT_LE(abs(diff), tol);
EXPECT_NEAR(d1, d2, 1e-10);
}
}

INSTANTIATE_TEST_SUITE_P(DescBodies, DescRotTest, testing::Values(1, 2, 3));

// TEST_F(DescriptorTest, SingleBond) {
// // Check that B1 descriptors match the corresponding elements of the
// // single bond vector.
Expand Down
Loading