- Use CMake to build/manage the CPP project
- Read in integrals and basis set from files generated by psi4 scripts
(
./psi4/main.py
) - Use Eigen3 for matrix operations
- Parallelize sections with OpenMP
- Clone the repository
git clone https://github.com/Awallace3/HF.git
- Create a conda environment with psi4:
conda env create -f env.yml
- Activate the environment:
conda activate p4
- Build the project and run water example:
cd ./cpp/
bash ./example.sh
- The output should be similar to:
Ensure you have activated a conda environment that has psi4 installed
#!/usr/bash
echo 'Ensure you have activated a conda environment that has psi4 installed'
cat example.sh
export numThreads=20
rm -r build
mkdir -p build
cd build && cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=$CONDA_PREFIX ..
make
cp src/hf ..
cp compile_commands.json ..
cd ..
cd ../psi4/
python3 ./main.py
cd ../cpp/
./hf ./data/t1 $numThreads
-- The CXX compiler identification is GNU 13.3.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /home/amwalla3/miniconda3/envs/p4dev311/bin/x86_64-conda-linux-gnu-c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenMP_CXX: -fopenmp (found version "4.5")
-- Found OpenMP: TRUE (found version "4.5")
-- Found OpenMP_CXX: -fopenmp (found version "4.5")
-- Configuring done (0.4s)
-- Generating done (0.0s)
-- Build files have been written to: /home/amwalla3/gits/hf/cpp/build
[ 25%] Building CXX object src/CMakeFiles/hf.dir/hf.cpp.o
[ 50%] Building CXX object src/CMakeFiles/hf.dir/input.cpp.o
[ 75%] Building CXX object src/CMakeFiles/hf.dir/helper.cpp.o
[100%] Linking CXX executable hf
[100%] Built target hf
Memory set to 55.879 GiB by Python driver.
Threads set to 20 by Python driver.
nbf = 7
enuc = 8.907707454380846
Target Energy (HF/STO-3G): -74.96599007011574
Running: ./hf
Data Path: ./data/t1
Num Threads: 20
n_basis: 7
S:
1 0.2367039 0 -0 0 0.0500137 0.0500137
0.2367039 1 -0 0 0 0.4539953 0.4539953
0 -0 1 -0 0 0.2455507 0.2455507
-0 0 -0 1 0 -0 0
0 0 0 0 1 0.2927386 -0.2927386
0.0500137 0.4539953 0.2455507 -0 0.2927386 1 0.251002
0.0500137 0.4539953 0.2455507 0 -0.2927386 0.251002 1
Number of Electrons: 10
H Matrix:
-32.6850823 -7.6043227 -0.0186797 0 0 -1.6196032 -1.6196032
-7.6043227 -9.3020627 -0.2221597 0 0 -3.5432102 -3.5432102
-0.0186797 -0.2221597 -7.5266557 0 0 -1.6587891 -1.6587891
0 0 0 -7.4308356 0 0 0
0 0 0 0 -7.5670222 -1.890856 1.890856
-1.6196032 -3.5432102 -1.6587891 0 -1.890856 -4.9564898 -1.5602633
-1.6196032 -3.5432102 -1.6587891 0 1.890856 -1.5602633 -4.9564898
S Matrix:
1 0.2367039 0 -0 0 0.0500137 0.0500137
0.2367039 1 -0 0 0 0.4539953 0.4539953
0 -0 1 -0 0 0.2455507 0.2455507
-0 0 -0 1 0 -0 0
0 0 0 0 1 0.2927386 -0.2927386
0.0500137 0.4539953 0.2455507 -0 0.2927386 1 0.251002
0.0500137 0.4539953 0.2455507 0 -0.2927386 0.251002 1
S_12 Matrix:
1.02406182683964 -0.141659275751281 -0.0100025708715733 0 0 0.0212115742810543 0.0212115742810543
-0.141659275751281 1.22191755142436 0.105911550388264 7.28188431604302e-18 -3.31314167753195e-33 -0.275657585702812 -0.275657585702812
-0.0100025708715732 0.105911550388263 1.05609002557191 1.54935498778055e-16 -3.14571479325093e-32 -0.146486294818408 -0.146486294818408
0 7.28188431604302e-18 1.54935498778055e-16 1 -1.72421439527728e-16 1.62170846338131e-17 -5.06806499560391e-17
0 -3.31314167753195e-33 -3.14571479325093e-32 -1.72421439527728e-16 1.09816105780337 -0.213037564188841 0.213037564188841
0.0212115742810542 -0.275657585702812 -0.146486294818408 1.6217084633813e-17 -0.213037564188841 1.19047900276946 -0.0903462294425033
0.0212115742810542 -0.275657585702812 -0.146486294818408 -5.0680649956039e-17 0.213037564188841 -0.0903462294425033 1.19047900276946
F Matrix:
-32.360907183015 -2.78101329627198 0.0165513937231451 -1.46118930302141e-18 0 -0.273188055667783 -0.273188055667783
-2.78101329627198 -8.32925608489884 -0.28118835929629 -5.29998398414068e-17 0 -0.48114879657511 -0.48114879657511
0.0165513937231453 -0.28118835929629 -7.57828717474523 -2.2720966150029e-15 0 -0.146807942490089 -0.146807942490089
-1.46118930302138e-18 -5.29998398414068e-17 -2.2720966150029e-15 -7.4308356 2.48460519143785e-15 -1.29884559669202e-16 3.25076462517994e-16
0 0 0 2.48460519143785e-15 -7.66432456723451 -0.134211986464029 0.134211986464029
-0.273188055667784 -0.481148796575109 -0.146807942490089 -1.29884559669202e-16 -0.13421198646403 -4.24477064062471 -0.0501425953125875
-0.273188055667784 -0.48114879657511 -0.146807942490089 3.25076462517994e-16 0.13421198646403 -0.0501425953125875 -4.24477064062471
C_0_prime Matrix:
-0.993360946348067 -0.104696772634488 -2.58762946764875e-18 -0.0476198621039882 -5.68525975487525e-16 3.2559812234295e-17 -0.00222818392236167
-0.113882894666717 0.887057679149727 2.70105107942151e-17 0.417863124698418 4.92930378860273e-15 -6.00527148166332e-16 0.159842951615343
-0.000754960463475131 0.418666446527627 6.10223316946773e-17 -0.9069256733106 -6.97928802499565e-15 3.72981413249938e-16 0.0469431536727517
-2.78884706667882e-19 1.61447542100403e-15 -1.7928860653261e-15 8.39213884216595e-15 -1 9.71445146547012e-17 6.28979340361016e-17
6.51443850817542e-20 -4.52211016762074e-17 0.998515964153206 1.44315407662622e-17 -1.8847770566488e-15 -0.0544597955485753 -1.68041118669839e-16
-0.0114923149865523 0.115943232259054 0.0385088907344304 0.0174439221591125 3.05311331771918e-16 0.706057409375757 -0.697223639278874
-0.0114923149865523 0.115943232259054 -0.0385088907344305 0.0174439221591117 4.57966997657877e-16 -0.706057409375754 -0.697223639278878
C Matrix:
-1.00161044568986 -0.232144980462296 -7.80625564189563e-18 -0.0981482561642066 -1.19448619563009e-15 1.87350135405495e-16 -0.0549730091095336
0.00781921299249121 1.07916296574477 5.03069808033274e-17 0.411669078256667 5.14686723237015e-15 -1.63757896132211e-15 0.584992343353627
0.000444276397399207 0.50317816018453 7.28583859910259e-17 -0.918172896134312 -7.10974485401501e-15 -1.66533453693773e-16 0.270795113910036
-8.2907079893062e-19 1.68180534996102e-15 -1.96247546770511e-15 8.25406551180014e-15 -1 1.5376819217719e-16 9.53638652834899e-17
-4.33680868994202e-19 -2.42861286636753e-17 1.08012366686469 -1.56992474575901e-16 -1.86484593550528e-15 -0.360639128029168 -9.43689570931383e-16
-0.00221054670175931 -0.180520908446253 -0.163398249889719 0.0358455796706924 3.58913097618597e-16 0.915938127508575 -0.818024289980275
-0.00221054670175931 -0.180520908446253 0.163398249889719 0.0358455796706913 -1.81720565459643e-16 -0.915938127508571 -0.81802428998028
D Matrix:
1.06674785705696 -0.298758673156424 -0.0271382074326784 -5.22820475387226e-18 1.30490982947372e-17 0.0406029482955852 0.0406029482955852
-0.298758673156424 1.33412527671956 0.165031319702647 6.60118753309486e-17 -3.65032684059589e-17 -0.18007224693068 -0.18007224693068
-0.0271382074326784 0.165031319702647 1.09622992546388 3.77332971608437e-16 2.10621859877963e-16 -0.123747600380403 -0.123747600380402
-5.22820475387226e-18 6.60118753309486e-17 3.77332971608437e-16 0.999999999999999 -2.54870262804354e-16 -4.59754747387399e-17 -1.46671925409554e-16
1.30490982947372e-17 -3.65032684059589e-17 2.10621859877963e-16 -2.54870262804354e-16 1.16666713572122 -0.176490316830156 0.176490316830156
0.0406029482955852 -0.18007224693068 -0.123747600380403 -4.59754747387399e-17 -0.176490316830156 0.0605765785519323 0.00717860241788593
0.0406029482955852 -0.18007224693068 -0.123747600380402 -1.46671925409554e-16 0.176490316830156 0.00717860241788593 0.0605765785519321
iter: 0 Energy: -82.1486228591141 Delta E: -82.1486228591141
iter: 1 Energy: -83.8387580294251 Delta E: -1.69013517031105
iter: 2 Energy: -83.8721528577089 Delta E: -0.0333948282838179
iter: 3 Energy: -83.8734424503977 Delta E: -0.00128959268880635
iter: 4 Energy: -83.8735797237501 Delta E: -0.000137273352308398
iter: 5 Energy: -83.8736033783244 Delta E: -2.36545743490524e-05
iter: 6 Energy: -83.8736078646384 Delta E: -4.48631398342059e-06
iter: 7 Energy: -83.8736087370738 Delta E: -8.7243537905124e-07
iter: 8 Energy: -83.8736089079222 Delta E: -1.70848409197788e-07
iter: 9 Energy: -83.8736089414476 Delta E: -3.35253815819669e-08
iter: 10 Energy: -83.8736089480301 Delta E: -6.58253895835514e-09
Final HF Energy: -74.9659014936493
Freed Memory
Time (CPU) : 0.055469
Time (USR) : 0.00543689727783203