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 periodic hamiltonian learning example #75

Merged
merged 23 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 docs/src/software/cp2k.sec
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ material, crystal, and biological systems. Learn more about it on its `homepage
<https://cp2k.org>`_.

- examples/batch-cp2k/reference-trajectory
- examples/periodic-hamiltonian/periodic-hamiltonian
1 change: 1 addition & 0 deletions docs/src/software/rascaline.sec
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ version from the `github repository <https://github.com/Luthaf/rascaline>`_
- examples/lode-linear/lode-linear
- examples/roy-gch/roy-gch
- examples/sample-selection/sample-selection
- examples/periodic-hamiltonian/periodic-hamiltonian
1 change: 1 addition & 0 deletions docs/src/topics/ml-models.sec
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ data.
- examples/dos-align/dos-align
- examples/lode-linear/lode-linear
- examples/sample-selection/sample-selection
- examples/periodic-hamiltonian/periodic-hamiltonian
3 changes: 3 additions & 0 deletions examples/periodic-hamiltonian/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Periodic Hamiltonian Learning
=============================

28 changes: 28 additions & 0 deletions examples/periodic-hamiltonian/data/BASIS_STO3G
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@


#----------------------------------------------------------------------
# Basis Set Exchange
# Version v0.9.1
# https://www.basissetexchange.org
#----------------------------------------------------------------------
# Basis set: STO-3G
# Description: STO-3G Minimal Basis (3 functions/AO)
# Role: orbital
# Version: 1 (Data from Gaussian09)
#----------------------------------------------------------------------


# Carbon STO-3G (6s,3p) -> [2s,1p]
C STO-3G
2
1 0 0 3 1
0.7161683735E+02 0.1543289673E+00
0.1304509632E+02 0.5353281423E+00
0.3530512160E+01 0.4446345422E+00
1 0 1 3 1 1
0.2941249355E+01 -0.9996722919E-01 0.1559162750E+00
0.6834830964E+00 0.3995128261E+00 0.6076837186E+00
0.2222899159E+00 0.7001154689E+00 0.3919573931E+00



140 changes: 140 additions & 0 deletions examples/periodic-hamiltonian/data/C2.xyz
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
2
Lattice="2.321189 0.0 0.0 -1.155982 1.986034 0.0 -0.37381 -0.001243 106.457295" Properties=species:S:1:pos:R:3 pbc="T T F"
C -0.08351854 -0.00307582 1.62727708
C -0.05879422 1.33906047 1.60493484
2
Lattice="2.292099 0.0 0.0 -1.223659 2.063605 0.0 0.021344 0.646819 106.294756" Properties=species:S:1:pos:R:3 pbc="T T F"
C 0.01526967 0.15893965 1.58664361
C -0.01481984 1.55278985 1.56429722
2
Lattice="2.236061 0.0 0.0 -1.153526 1.997966 0.0 0.0 0.0 106.227097" Properties=species:S:1:pos:R:3 pbc="T T F"
C 0.00000000 0.00000000 1.55677425
C -0.02366480 1.33197800 1.55677425
2
Lattice="2.297961 0.0 0.0 -1.14898 1.990093 0.0 0.0 0.0 106.227097" Properties=species:S:1:pos:R:3 pbc="T T F"
C 0.00000000 0.00000000 1.55677425
C -0.00000082 1.32672933 1.55677425
2
Lattice="2.395273 0.0 0.0 -1.14898 1.990093 0.0 0.0 0.0 105.967224" Properties=species:S:1:pos:R:3 pbc="T T F"
C 0.00993388 -0.00276424 1.50476084
C 0.06402213 1.34207693 1.48241956
2
Lattice="2.297961 0.0 0.0 -1.14898 1.990093 0.0 0.263751 0.152277 106.318023" Properties=species:S:1:pos:R:3 pbc="T T F"
C 0.07587250 0.03530473 1.59245770
C 0.09752113 1.38014676 1.57011717
2
Lattice="2.297961 0.0 0.0 -1.176539 2.037827 0.0 0.0 0.0 106.227097" Properties=species:S:1:pos:R:3 pbc="T T F"
C 0.00000000 0.00000000 1.55677425
C -0.01837349 1.35855201 1.55677425
2
Lattice="2.312702 0.0 0.0 -1.119515 2.006816 0.0 0.0 0.0 106.409587" Properties=species:S:1:pos:R:3 pbc="T T F"
C 0.00071308 -0.00008429 1.60239675
C 0.02384542 1.33796229 1.60239675
2
Lattice="2.336932 0.0 0.0 -0.998849 2.069523 0.0 0.0 0.0 105.947627" Properties=species:S:1:pos:R:3 pbc="T T F"
C 0.00993437 -0.00276488 1.49986068
C 0.14466347 1.39503027 1.47751545
2
Lattice="2.3713 0.0 0.0 -1.220678 2.114278 0.0 0.0 0.412583 106.473131" Properties=species:S:1:pos:R:3 pbc="T T F"
C 0.00000000 0.10314575 1.61828275
C -0.02335320 1.51266512 1.61828275
2
Lattice="2.3713 0.0 0.0 -1.165341 2.018432 0.0 0.453069 0.261579 106.225241" Properties=species:S:1:pos:R:3 pbc="T T F"
C 0.11375064 0.06618396 1.55631025
C 0.12632202 1.41022755 1.55631025
2
Lattice="2.3713 0.0 0.0 -1.330946 1.962561 0.0 -0.083921 0.133479 106.405776" Properties=species:S:1:pos:R:3 pbc="T T F"
C -0.02294377 0.03441187 1.60144400
C -0.11587959 1.34070228 1.60144400
2
Lattice="2.311962 0.0 0.0 -1.18565 2.053606 0.0 0.0 0.0 106.425834" Properties=species:S:1:pos:R:3 pbc="T T F"
C -0.00059072 -0.00111922 1.60645850
C -0.01918978 1.37019057 1.60645850
2
Lattice="2.480636 0.0 0.0 -1.208047 2.092399 0.0 0.0 0.279671 106.419745" Properties=species:S:1:pos:R:3 pbc="T T F"
C 0.00993567 0.06715103 1.61789130
C 0.05309740 1.48019981 1.59554416
2
Lattice="2.3713 0.0 0.0 -1.18565 2.053606 0.0 -0.231464 -0.133636 106.351346" Properties=species:S:1:pos:R:3 pbc="T T F"
C -0.04793269 -0.03617456 1.60078689
C -0.02628320 1.35101137 1.57844921
2
Lattice="2.415222 0.0 0.0 -1.18565 2.053606 0.0 0.0 -0.479047 106.307035" Properties=species:S:1:pos:R:3 pbc="T T F"
C 0.00000000 -0.11976175 1.57675875
C 0.01463947 1.24930960 1.57675875
2
Lattice="2.3713 0.0 0.0 -1.189577 2.051334 0.0 -0.246145 0.454992 106.404978" Properties=species:S:1:pos:R:3 pbc="T T F"
C -0.06163595 0.11380544 1.60124450
C -0.06405573 1.48124725 1.60124450
2
Lattice="2.398523 0.0 0.0 -1.180965 2.045492 0.0 0.0 -0.128692 106.730214" Properties=species:S:1:pos:R:3 pbc="T T F"
C 0.00993495 -0.03493873 1.69550916
C 0.04378159 1.34683791 1.67316485
2
Lattice="2.444639 0.0 0.0 -1.253686 2.171449 0.0 0.0 0.373074 106.614058" Properties=species:S:1:pos:R:3 pbc="T T F"
C 0.00993418 0.09050295 1.66646483
C 0.01067295 1.55624976 1.64412254
2
Lattice="2.444639 0.0 0.0 -1.389228 1.992181 0.0 0.0 0.0 106.624571" Properties=species:S:1:pos:R:3 pbc="T T F"
C 0.00993444 -0.00276515 1.66909379
C -0.07968886 1.34346909 1.64675573
2
Lattice="2.451565 0.0 0.0 -1.222319 2.11712 0.0 0.0 0.454355 106.608972" Properties=species:S:1:pos:R:3 pbc="T T F"
C 0.00993389 0.11082302 1.66519659
C 0.03389293 1.54034988 1.64285165
2
Lattice="2.54493 0.0 0.0 -1.108732 2.178576 0.0 0.0179 0.345442 106.728616" Properties=species:S:1:pos:R:3 pbc="T T F"
C 0.01440967 0.08359422 1.69510659
C 0.14521338 1.55409287 1.67276758
2
Lattice="2.343757 0.0 0.0 -1.064869 2.103133 0.0 -0.220008 -0.603298 106.555214" Properties=species:S:1:pos:R:3 pbc="T T F"
C -0.05300592 -0.15247546 1.63880350
C 0.01434045 1.25291583 1.63880350
2
Lattice="2.444639 0.0 0.0 -1.242413 2.151923 0.0 0.0 0.0 106.624571" Properties=species:S:1:pos:R:3 pbc="T T F"
C 0.00000000 0.00000000 1.65614275
C -0.01339690 1.43461605 1.65614275
2
Lattice="2.41426 0.0 0.0 -1.35096 2.037442 0.0 -0.548096 0.112718 106.496947" Properties=species:S:1:pos:R:3 pbc="T T F"
C -0.14037392 0.02936122 1.62423675
C -0.22956066 1.38529109 1.62423675
2
Lattice="2.444639 0.0 0.0 -1.351634 2.0373 0.0 0.0 0.0 106.624571" Properties=species:S:1:pos:R:3 pbc="T T F"
C 0.00993326 -0.00276462 1.66909379
C -0.05462749 1.37354970 1.64675573
2
Lattice="2.517979 0.0 0.0 -1.236616 2.141882 0.0 0.283452 0.163651 106.77526" Properties=species:S:1:pos:R:3 pbc="T T F"
C 0.07181119 0.04237566 1.69381500
C 0.08483174 1.46737189 1.69381500
2
Lattice="2.517979 0.0 0.0 -1.389247 2.10005 0.0 0.0 0.0 106.823308" Properties=species:S:1:pos:R:3 pbc="T T F"
C 0.00000000 0.00000000 1.70582700
C -0.08683964 1.40003403 1.70582700
2
Lattice="2.527906 0.0 0.0 -1.287031 2.229204 0.0 0.0 0.0 106.823308" Properties=species:S:1:pos:R:3 pbc="T T F"
C 0.00000000 0.00000000 1.70582700
C -0.01538660 1.48613674 1.70582700
2
Lattice="2.517979 0.0 0.0 -1.258989 2.180634 0.0 0.0 -0.228791 106.819472" Properties=species:S:1:pos:R:3 pbc="T T F"
C 0.00000000 -0.05719775 1.70486800
C -0.00000093 1.39655898 1.70486800
2
Lattice="2.517979 0.0 0.0 -1.297692 2.259268 0.0 -0.090565 -0.121788 106.82162" Properties=species:S:1:pos:R:3 pbc="T T F"
C -0.02264125 -0.03044700 1.70540500
C -0.04844419 1.47573242 1.70540500
2
Lattice="2.505494 0.0 0.0 -1.301622 2.155457 0.0 0.229407 0.81562 106.7705" Properties=species:S:1:pos:R:3 pbc="T T F"
C 0.05735175 0.20390500 1.69262500
C 0.02476715 1.64087705 1.69262500
2
Lattice="2.517979 0.0 0.0 -1.41732 2.081206 0.0 -0.545915 -0.130377 106.800185" Properties=species:S:1:pos:R:3 pbc="T T F"
C -0.14216919 -0.02958483 1.70004625
C -0.23634329 1.35186769 1.70004625
2
Lattice="2.460394 0.0 0.0 -1.26336 2.044166 0.0 -0.139209 -0.407369 106.809714" Properties=species:S:1:pos:R:3 pbc="T T F"
C -0.03480225 -0.10184225 1.70242850
C -0.05691216 1.26093576 1.70242850
2
Lattice="2.517979 0.0 0.0 -1.317654 2.282245 0.0 0.0 0.0 106.55201" Properties=species:S:1:pos:R:3 pbc="T T F"
C 0.00993403 -0.00276608 1.65095582
C -0.00752587 1.53684553 1.62861347
109 changes: 109 additions & 0 deletions examples/periodic-hamiltonian/data/reftraj_hamiltonian.cp2k
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
&GLOBAL
PROJECT //PROJECT//
RUN_TYPE MD
PRINT_LEVEL MEDIUM
FFTW_PLAN_TYPE MEASURE
&END GLOBAL

&MOTION
&PRINT
&CELL
&EACH
MD 1
&END EACH
&END CELL
&FORCES
&EACH
MD 1
&END EACH
&END FORCES
&END PRINT
&MD
ENSEMBLE REFTRAJ
&REFTRAJ ! Loads an external trajectory file and performs analysis on the loaded snapshots.
EVAL ENERGY_FORCES
CELL_FILE_NAME reftraj.cell
TRAJ_FILE_NAME reftraj.xyz
FIRST_SNAPSHOT 1
VARIABLE_VOLUME TRUE
LAST_SNAPSHOT //LAST_SNAPSHOT//
&END REFTRAJ
&END MD
&END MOTION

&FORCE_EVAL
METHOD Quickstep
&DFT
&MGRID
NGRIDS 5
CUTOFF 200
REL_CUTOFF 70
&END MGRID
UKS F
BASIS_SET_FILE_NAME ../BASIS_STO3G
POTENTIAL_FILE_NAME ../POTENTIAL

&QS
METHOD GAPW
EXTRAPOLATION USE_GUESS
EPS_DEFAULT 1.0E-12
&END QS
&SCF
SCF_GUESS ATOMIC
EPS_SCF 1.0E-8
MAX_SCF 300
ADDED_MOS -1
&DIAGONALIZATION
ALGORITHM STANDARD
&END DIAGONALIZATION
&SMEAR ON
METHOD FERMI_DIRAC
ELECTRONIC_TEMPERATURE [K] 300
&END SMEAR

&MIXING
METHOD BROYDEN_MIXING
ALPHA 0.4
BETA 0.5
NBROYDEN 8
&END MIXING

&END SCF
&XC
&XC_FUNCTIONAL PBE
&END XC_FUNCTIONAL
&END XC
&KPOINTS
SCHEME MONKHORST-PACK 15 15 1
WAVEFUNCTIONS COMPLEX
&END KPOINTS
&PRINT
&KS_CSR_WRITE
REAL_SPACE
FILENAME ./FOCK/
&END KS_CSR_WRITE
&S_CSR_WRITE
REAL_SPACE
FILENAME ./OVER/
&END S_CSR_WRITE
&END PRINT
&END DFT

&SUBSYS
&CELL
A //CELL_A//
B //CELL_B//
C //CELL_C//
PERIODIC XYZ
&END CELL
&TOPOLOGY
COORD_FILE_NAME init.xyz
COORD_FILE_FORMAT XYZ
&END TOPOLOGY
&KIND C
ELEMENT C
BASIS_SET ORB STO-3G
POTENTIAL ALL
&END KIND
&END SUBSYS
&END FORCE_EVAL
26 changes: 26 additions & 0 deletions examples/periodic-hamiltonian/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
channels:
- conda-forge
dependencies:
- python>=3.11
- pip
- graphviz
- pyscf=2.3.0
- rust>=1.65
- pip:
- pyscfad @ git+https://github.com/fishjojo/pyscfad.git@ml#egg=pyscfad
- ase==3.22.1
- seekpath
- requests
- metatensor
- metatensor-core
- metatensor-learn
- metatensor-operations
- metatensor-torch
- --extra-index-url https://download.pytorch.org/whl/cpu
- rascaline-torch @ git+https://github.com/luthaf/rascaline#subdirectory=python/rascaline-torch
- lightning
- xitorch
- keras_core
- tensorboard
- torchviz
- mlelec @ git+https://github.com/curiosity54/mlelec.git@tutorial_periodic#egg=mlelec
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading