├── .github └── workflows │ ├── ci_hybrid-md.yaml │ └── docs-build.yaml ├── .gitignore ├── .gitmodules ├── LICENSE.md ├── Makefile ├── README.md ├── clustering.F90 ├── descriptors.F90 ├── descriptors_noncommercial.inc ├── descriptors_noncommercial_permutations.inc ├── descriptors_noncommercial_types.inc ├── descriptors_wrapper.F90 ├── doc_src ├── Makefile ├── _static │ └── theme_overrides.css ├── _templates │ └── layout.html ├── accelerated-aimd-castep-inputs.rst ├── accelerated-aimd-input-reference.rst ├── accelerated-aimd.rst ├── accelerated-aimd_decision-making.rst ├── accelerated-aimd_example_Si16.rst ├── accelerated-aimd_installation.rst ├── benzene_frames.xyz ├── conf.py ├── data.rst ├── gap_fit.rst ├── gap_fitting_tutorial.ipynb ├── gap_si_surface.ipynb ├── gap_si_surface │ ├── __init__.py │ └── visualise.py ├── index.rst ├── installation.rst ├── quippy-descriptor-tutorial.ipynb ├── quippy-potential-tutorial.ipynb ├── reference.rst ├── requirements.txt ├── soap.png └── tutorials.rst ├── error.inc ├── find_water_triplets_noncommercial.F90 ├── gap_fit.F90 ├── gap_fit_module.F90 ├── gapversion ├── gp_fit.F90 ├── gp_predict.F90 ├── hybrid_md_package ├── .gitignore ├── README.md ├── examples │ ├── H2_in_C60 │ │ ├── build.py │ │ ├── h2c60.cell │ │ ├── h2c60.hybrid-md-input.yaml │ │ └── h2c60.param │ ├── check_installation │ │ ├── readme.md │ │ ├── sic_md.cell │ │ ├── sic_md.hybrid-md-input.yaml │ │ ├── sic_md.param │ │ └── sic_md.param-v22 │ └── walkthrough │ │ ├── 0-initial │ │ ├── si16.cell │ │ ├── si16.hybrid-md-input.yaml │ │ └── si16.param │ │ ├── 1-adaptive │ │ ├── si16.cell │ │ ├── si16.hybrid-md-input.yaml │ │ └── si16.param │ │ ├── 2-gap-parameters │ │ ├── previous_si16.hybrid-md.xyz │ │ ├── si16.cell │ │ ├── si16.hybrid-md-input.yaml │ │ └── si16.param │ │ └── readme.md ├── hybrid_md │ ├── __init__.py │ ├── cli.py │ ├── decision_making.py │ ├── refit.py │ ├── settings.py │ └── state_objects.py ├── setup.py └── tests │ ├── __init__.py │ ├── test_decision_maker.py │ └── test_settings.py ├── make_permutations_noncommercial_v2.F90 ├── meson.build ├── soap_turbo.f90 ├── soap_turbo_angular.f90 ├── soap_turbo_compress.f90 ├── soap_turbo_functions.f90 ├── soap_turbo_radial.f90 ├── tensor_reduction_docs.md └── translation_table.png /.github/workflows/ci_hybrid-md.yaml: -------------------------------------------------------------------------------- 1 | name: HybridMD Python Package 2 | 3 | on: 4 | push: 5 | workflow_dispatch: 6 | 7 | env: 8 | root-directory: "${{github.workspace}}/hybrid_md_package" 9 | 10 | jobs: 11 | install-and-run-pytest: 12 | runs-on: ubuntu-latest 13 | strategy: 14 | matrix: 15 | python-version: [ "3.7", "3.8", "3.9", "3.10"] 16 | max-parallel: 5 17 | 18 | steps: 19 | - uses: actions/checkout@v3 20 | - name: Set up Python ${{ matrix.python-version }} 21 | uses: actions/setup-python@v4 22 | with: 23 | python-version: ${{ matrix.python-version }} 24 | 25 | - name: Install Dependencies 26 | run: pip install pytest pytest-cov numpy ase quippy-ase click pyyaml 27 | 28 | - name: Install package 29 | working-directory: ${{env.root-directory}} 30 | run: pip install . 31 | 32 | - name: Pytest + Coverage 33 | working-directory: ${{env.root-directory}} 34 | run: | 35 | pytest -v --cov=hybrid_md --cov-report term --cov-report term-missing --cov-report xml 36 | 37 | - uses: codecov/codecov-action@v3 38 | with: 39 | name: hybrid-md unittests 40 | fail_ci_if_error: true 41 | files: coverage.xml 42 | -------------------------------------------------------------------------------- /.github/workflows/docs-build.yaml: -------------------------------------------------------------------------------- 1 | name: Sphinx & deploy - commit to gh-pages 2 | 3 | on: 4 | push: 5 | # branches: 6 | # - master 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - name: Checkout 14 | uses: actions/checkout@v3 15 | with: 16 | persist-credentials: false 17 | - uses: actions/setup-python@v4 18 | with: 19 | python-version: '3.9' 20 | cache: 'pip' 21 | 22 | - name: Install dependencies 23 | run: sudo apt-get install pandoc 24 | 25 | - name: Install dependencies 26 | run: pip install -r doc_src/requirements.txt 27 | 28 | - name: Build 29 | working-directory: ${{github.workspace}}/doc_src 30 | run: | 31 | make html 32 | 33 | - name: Commit to gh-pages branch 34 | if: github.ref == 'refs/heads/main' 35 | uses: peaceiris/actions-gh-pages@v3 36 | with: 37 | github_token: ${{ secrets.GITHUB_TOKEN }} 38 | publish_dir: ./doc_src/_build/html 39 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "soap_turbo"] 2 | path = soap_turbo 3 | url = https://github.com/libAtoms/soap_turbo.git 4 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # Academic Software Licence (“ASL”) 2 | 3 | ## Preamble 4 | 5 | ASL is a software license that proposes to offer copyleft style rights to use the software in an academic non-commercial setting. The purpose of ASL is to encourage academic cooperation and collaboration free-of-charge whilst enabling academic institutions to earn revenue from the parallel licensing of valuable bodies of software code. Significant proportions of such revenue are typically reinvested in academic research. 6 | 7 | ASL is not an open-source licence because it does not allow commercial use – it is an “available source” licence, meaning that the source code is made available subject to the terms of this licence and only for academic non-commercial use. 8 | 9 | ASL is a reciprocal licence very similar to GPL and the core terms are identical to those of GNU GPLv2 (except for the limitation to non-commercial use), making it easier for those who know the GPLv2 to understand the licensing*. As a reciprocal licence, if you redistribute any derivative works you have created based on ASL licenced code, then you are required to license the new work under the ASL - including making your source code available and ensuring that licensees are aware of the terms of the ASL licence. 10 | 11 | The non-commercial limitation makes ASL incompatible with the GPL and other open-source licences with copyleft provisions because these licences require that modified versions of the original program are made available free of charge for any type of use, including commercial, and this is prevented by ASL. As the two sets of reciprocal terms are incompatible, any modified version of the original program combining ASL and copylefted open-source code can be used internally but cannot be licensed out. 12 | 13 | The non-commercial restriction is an integral part of the license and you may not remove it without the consent of the rights holder in the ASL licensed code. Please contact __Cambridge Enterprise__ for any questions and/or to enquire about commercial use rights. 14 | 15 | *The changes to the GPLv2 are: removing the Preamble, replacing the reference to the “General Public License” in clause 0 with a reference to the “ASL”, removing clause 9 and adding clause 13 with the non-commercial restriction and limited patent grant 16 | 17 | ## TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 18 | 19 | 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". 20 | 21 | Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 22 | 23 | 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. 24 | You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 25 | 26 | 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: 27 | 28 | a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. 29 | 30 | b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. 31 | 32 | c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) 33 | These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. 34 | Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. 35 | In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 36 | 37 | 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: 38 | 39 | a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, 40 | 41 | b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, 42 | 43 | c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) 44 | The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. 45 | If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 46 | 47 | 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 48 | 49 | 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 50 | 51 | 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 52 | 53 | 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. 54 | If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. 55 | It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. 56 | This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 57 | 58 | 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 59 | 60 | 9. Not used. 61 | 62 | 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. 63 | 64 | ### NO WARRANTY 65 | 66 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 67 | 68 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 69 | 70 | ### Non Commercial Use; Limited Patent Rights Grant 71 | 72 | 13. The Preamble of the GPLv2 does not apply to this License. The Program is provided to you by the Licensor subject to the following conditions, which prevail over any clause or indication to the contrary in the GPLv2: 73 | 74 | a) The grant of rights under the License is for academic non-commercial use only. Academic non-commercial use is defined as use for academic research or other not-for-profit scholarly purposes, which are undertaken at an educational, non-profit, charitable or governmental institution, and which does not involve and is not intended to lead to the production or manufacture of products for sale, or the enhancement of a product or service in or proposed for commerce, or the performance of services for a fee. 75 | 76 | b) Subject to your compliance with the License, in the event the Licensor holds patent rights on the Program or any part of it, the Licensor grants you a perpetual, worldwide, non-exclusive, royalty-free, irrevocable (except as stated in this section), limited patent licence to make, use, import and otherwise run, modify and distribute the Program. For the avoidance of doubt, this patent licence is limited to academic non-commercial use, as described above. If you institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program constitutes direct or contributory patent infringement, then any patent license granted to you under this License for the Program shall terminate as of the date such litigation is filed. 77 | 78 | Use other than academic and non-commercial use as above is deemed to be commercial use and outside the scope of this License. If you intend to use the Program for a commercial use, then you must obtain a commercial use license for the Program. In that case, please contact the original licensor to enquire about commercial use licenses. 79 | 80 | ## END OF TERMS AND CONDITIONS 81 | 82 | ## Appendix: Suggested code header and licensing information 83 | [Program name] is © 2021, [Name of copyright holder] 84 | 85 | [Program name] is published and distributed under the Academic Software License v1.0 (ASL). 86 | 87 | [Program name] is distributed in the hope that it will be useful for non-commercial academic research, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ASL for more details. 88 | 89 | You should have received a copy of the ASL along with this program; if not, write to [Contact details of copyright holder]. It is also published at [URL where licence terms are published]. 90 | 91 | You may contact the original licensor at [Contact details of original licensor]. 92 | 93 | 94 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | #! HND XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 2 | #! HND X 3 | #! HND X GAP (Gaussian Approximation Potental) 4 | #! HND X 5 | #! HND X 6 | #! HND X Portions of GAP were written by Albert Bartok-Partay, Gabor Csanyi, 7 | #! HND X Copyright 2006-2021. 8 | #! HND X 9 | #! HND X Portions of GAP were written by Noam Bernstein as part of 10 | #! HND X his employment for the U.S. Government, and are not subject 11 | #! HND X to copyright in the USA. 12 | #! HND X 13 | #! HND X GAP is published and distributed under the 14 | #! HND X Academic Software License v1.0 (ASL) 15 | #! HND X 16 | #! HND X GAP is distributed in the hope that it will be useful for non-commercial 17 | #! HND X academic research, but WITHOUT ANY WARRANTY; without even the implied 18 | #! HND X warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | #! HND X ASL for more details. 20 | #! HND X 21 | #! HND X You should have received a copy of the ASL along with this program 22 | #! HND X (e.g. in a LICENSE.md file); if not, you can write to the original licensors, 23 | #! HND X Gabor Csanyi or Albert Bartok-Partay. The ASL is also published at 24 | #! HND X http://github.com/gabor1/ASL 25 | #! HND X 26 | #! HND X When using this software, please cite the following reference: 27 | #! HND X 28 | #! HND X A. P. Bartok et al Physical Review Letters vol 104 p136403 (2010) 29 | #! HND X 30 | #! HND X When using the SOAP kernel or its variants, please additionally cite: 31 | #! HND X 32 | #! HND X A. P. Bartok et al Physical Review B vol 87 p184115 (2013) 33 | #! HND X 34 | #! HND XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 35 | 36 | CUSTOM_F90FLAGS += -frealloc-lhs 37 | 38 | ifeq (${QUIP_ARCH},) 39 | include Makefile.arch 40 | else 41 | include Makefile.${QUIP_ARCH} 42 | endif 43 | include Makefile.inc 44 | include Makefile.rules 45 | 46 | 47 | ifeq (${HAVE_DESCRIPTORS_NONCOMMERCIAL},1) 48 | DEFINES += -DDESCRIPTORS_NONCOMMERCIAL 49 | GAP1_F90_FILES = make_permutations_noncommercial_v2 50 | else 51 | GAP1_F90_FILES = 52 | endif 53 | 54 | SOAP_TURBO_F90_FILES = soap_turbo_functions soap_turbo_radial soap_turbo_angular soap_turbo_compress soap_turbo 55 | SOAP_TURBO_F90_SOURCES = ${addsuffix .f90, ${SOAP_TURBO_F90_FILES}} 56 | SOAP_TURBO_F90_OBJS = ${addsuffix .o, ${SOAP_TURBO_F90_FILES}} 57 | 58 | GAP1_F90_FILES += find_water_triplets_noncommercial descriptors gp_predict descriptors_wrapper clustering 59 | GAP1_F90_SOURCES = ${addsuffix .F90, ${GAP1_F90_FILES}} 60 | GAP1_F90_OBJS = ${addsuffix .o, ${GAP1_F90_FILES}} 61 | 62 | GAP2_F90_FILES = gp_fit gap_fit_module 63 | GAP2_F90_SOURCES = ${addsuffix .F90, ${GAP2_F90_FILES}} 64 | GAP2_F90_OBJS = ${addsuffix .o, ${GAP2_F90_FILES}} 65 | 66 | default: ${GAP_LIBFILE} 67 | 68 | 69 | 70 | ifeq (${USE_MAKEDEP},1) 71 | GAP1_F90_FPP_FILES = ${addsuffix .fpp, ${GAP1_F90_FILES}} 72 | GAP2_F90_FPP_FILES = ${addsuffix .fpp, ${GAP2_F90_FILES}} 73 | GAP1.depend: ${GAP1_F90_FPP_FILES} 74 | ${SCRIPT_PATH}/${MAKEDEP} ${MAKEDEP_ARGS} -- ${addprefix ../../src/GAP/,${GAP1_F90_SOURCES}} > GAP1.depend 75 | GAP2.depend: ${GAP2_F90_FPP_FILES} ${GAP1_F90_FPP_FILES} 76 | ${SCRIPT_PATH}/${MAKEDEP} ${MAKEDEP_ARGS} -- ${addprefix ../../src/GAP/,${GAP2_F90_SOURCES}} > GAP2.depend 77 | 78 | -include GAP1.depend 79 | -include GAP2.depend 80 | endif 81 | 82 | 83 | PROGRAMS = gap_fit 84 | 85 | LIBS = -L. -lquiputils -lquip_core -lgap -latoms 86 | ifeq (${HAVE_THIRDPARTY},1) 87 | LIBS += -lthirdparty 88 | endif 89 | LIBFILES = libatoms.a ${GAP_LIBFILE} libquip_core.a libquiputils.a 90 | 91 | .PHONY : clean allclean depend install 92 | 93 | Programs: ${PROGRAMS} 94 | #cp ${QUIP_ROOT}/src/GAP/teach_sparse . 95 | 96 | ${PROGRAMS}: % : ${LIBFILES} ${GAP2_F90_OBJS} ${GAPFIT_LIBFILE} %.o 97 | $(LINKER) $(LINKFLAGS) -o $@ ${F90OPTS} $@.o ${GAPFIT_LIBFILE} ${LIBS} ${LINKOPTS} 98 | 99 | 100 | 101 | ${GAP_LIBFILE}: ${SOAP_TURBO_F90_OBJS} ${GAP1_F90_OBJS} 102 | ifneq (${LIBTOOL},) 103 | ${LIBTOOL} -o ${GAP_LIBFILE} ${SOAP_TURBO_F90_OBJS} ${GAP1_F90_OBJS} 104 | else 105 | ${AR} ${AR_ADD} ${GAP_LIBFILE} $? 106 | endif 107 | 108 | ${GAPFIT_LIBFILE}: ${GAP2_F90_OBJS} 109 | ifneq (${LIBTOOL},) 110 | ${LIBTOOL} -o ${GAPFIT_LIBFILE} ${GAP2_F90_OBJS} 111 | else 112 | ${AR} ${AR_ADD} ${GAPFIT_LIBFILE} $? 113 | endif 114 | 115 | 116 | 117 | 118 | install: 119 | @if [ ! -d ${QUIP_INSTALLDIR} ]; then \ 120 | echo "make install: QUIP_INSTALLDIR '${QUIP_INSTALLDIR}' doesn't exist or isn't a directory"; \ 121 | exit 1; \ 122 | else \ 123 | for f in ${PROGRAMS} ; do \ 124 | echo "Copying $$f to ${QUIP_INSTALLDIR}/$${f}${QUIP_MPI_SUFFIX}" ; \ 125 | cp $$f ${QUIP_INSTALLDIR}/$${f}${QUIP_MPI_SUFFIX} ; \ 126 | done ;\ 127 | #cp ${QUIP_ROOT}/src/GAP/teach_sparse ${QUIP_INSTALLDIR}; \ 128 | fi 129 | 130 | 131 | clean: 132 | rm -f *.o *.mod *.mod.save ${GAP_LIBFILE} ${GAPFIT_LIBFILE} ${PROGRAMS} GAP1.depend GAP2.depend 133 | 134 | 135 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GAP 2 | 3 | This package is part of [QUIP](http://github.com/libatoms/QUIP) (but with a different license!). In order to use it, you should clone QUIP with the `--recursive` option. QUIP is released under a GPL license , whereas GAP uses [ASL](http://github.com/gabor1/ASL) (Academic Software License). 4 | 5 | GAP-specific documentation is [here](https://libatoms.github.io/GAP), including fitted potentials. 6 | -------------------------------------------------------------------------------- /descriptors_noncommercial_permutations.inc: -------------------------------------------------------------------------------- 1 | ! HND XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 2 | ! HND X 3 | ! HND X GAP (Gaussian Approximation Potental) 4 | ! HND X 5 | ! HND X 6 | ! HND X Portions of GAP were written by Albert Bartok-Partay, Gabor Csanyi, 7 | ! HND X Copyright 2006-2021. 8 | ! HND X 9 | ! HND X Portions of GAP were written by Noam Bernstein as part of 10 | ! HND X his employment for the U.S. Government, and are not subject 11 | ! HND X to copyright in the USA. 12 | ! HND X 13 | ! HND X GAP is published and distributed under the 14 | ! HND X Academic Software License v1.0 (ASL) 15 | ! HND X 16 | ! HND X GAP is distributed in the hope that it will be useful for non-commercial 17 | ! HND X academic research, but WITHOUT ANY WARRANTY; without even the implied 18 | ! HND X warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ! HND X ASL for more details. 20 | ! HND X 21 | ! HND X You should have received a copy of the ASL along with this program 22 | ! HND X (e.g. in a LICENSE.md file); if not, you can write to the original licensors, 23 | ! HND X Gabor Csanyi or Albert Bartok-Partay. The ASL is also published at 24 | ! HND X http://github.com/gabor1/ASL 25 | ! HND X 26 | ! HND X When using this software, please cite the following reference: 27 | ! HND X 28 | ! HND X A. P. Bartok et al Physical Review Letters vol 104 p136403 (2010) 29 | ! HND X 30 | ! HND X When using the SOAP kernel or its variants, please additionally cite: 31 | ! HND X 32 | ! HND X A. P. Bartok et al Physical Review B vol 87 p184115 (2013) 33 | ! HND X 34 | ! HND XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 35 | 36 | ! 37 | ! 38 | ! This file contains descriptors written by others, not A. P. Bartok and Gabor Csanyi 39 | ! and the code here is owned by their respective authors, as indicated below. 40 | ! 41 | 42 | ! 43 | ! Author: Alan Nichol 44 | ! 45 | 46 | case(DT_AN_MONOMER) 47 | allocate(distance_matrix(this%descriptor_AN_monomer%N,this%descriptor_AN_monomer%N), atom_permutations(this%descriptor_AN_monomer%N,np)) 48 | 49 | if(this%descriptor_AN_monomer%do_atomic) then 50 | atom_permutations(1,:) = 0 51 | call generate_AN_permutations(atom_permutations(2:this%descriptor_AN_monomer%N,:)) 52 | atom_permutations = atom_permutations + 1 53 | else 54 | call generate_AN_permutations(atom_permutations(:,:)) 55 | endif 56 | 57 | i = 0 58 | distance_matrix = 0 59 | do n = 2, this%descriptor_AN_monomer%N 60 | i = i + 1 61 | distance_matrix(1,n) = i 62 | distance_matrix(n,1) = i 63 | do m = n+1, this%descriptor_AN_monomer%N 64 | i = i + 1 65 | distance_matrix(m,n) = i 66 | distance_matrix(n,m) = i 67 | enddo 68 | enddo 69 | 70 | do ip = 1, np 71 | i = 0 72 | do n = 2, this%descriptor_AN_monomer%N 73 | i = i + 1 74 | permutations(i,ip) = distance_matrix(atom_permutations(1,ip),atom_permutations(n,ip)) 75 | do m = n+1, this%descriptor_AN_monomer%N 76 | i = i + 1 77 | permutations(i,ip) = distance_matrix(atom_permutations(m,ip),atom_permutations(n,ip)) 78 | enddo 79 | enddo 80 | enddo 81 | deallocate(distance_matrix,atom_permutations) 82 | 83 | 84 | case(DT_GENERAL_MONOMER) 85 | if (.not. this%descriptor_general_monomer%permutation_data%initialised) then 86 | RAISE_ERROR("descriptor_permutations: permutation_data not initialised "//this%descriptor_type,error) 87 | else if (this%descriptor_general_monomer%permutation_data%perm_number /= 1) then 88 | RAISE_ERROR("descriptor_permutations: permutation_data%perm_number must be initialised to one"//this%descriptor_type,error) 89 | end if 90 | 91 | call permutation_data_copy(my_permutation_data, this%descriptor_general_monomer%permutation_data) 92 | 93 | if (my_permutation_data%n_perms > 1) then 94 | call next(my_permutation_data, 1) 95 | end if 96 | 97 | permutations=my_permutation_data%dist_vec_permutations 98 | 99 | case(DT_GENERAL_DIMER) 100 | if (.not. this%descriptor_general_dimer%permutation_data%initialised)then 101 | RAISE_ERROR("descriptor_permutations: permutation_data not initialised "//this%descriptor_type,error) 102 | else if (this%descriptor_general_dimer%permutation_data%perm_number /= 1) then 103 | RAISE_ERROR("descriptor_permutations: permutation_data%perm_number must be initialised to one"//this%descriptor_type,error) 104 | end if 105 | 106 | call permutation_data_copy(my_permutation_data, this%descriptor_general_dimer%permutation_data) 107 | 108 | if (my_permutation_data%n_perms > 1) then 109 | call next(my_permutation_data, 1) 110 | end if 111 | 112 | permutations=my_permutation_data%dist_vec_permutations 113 | 114 | case(DT_GENERAL_TRIMER) 115 | if (.not. this%descriptor_general_trimer%permutation_data%initialised)then 116 | RAISE_ERROR("descriptor_permutations: permutation_data not initialised "//this%descriptor_type,error) 117 | else if (this%descriptor_general_trimer%permutation_data%perm_number /= 1) then 118 | RAISE_ERROR("descriptor_permutations: permutation_data%perm_number must be initialised to one"//this%descriptor_type,error) 119 | end if 120 | 121 | call permutation_data_copy(my_permutation_data, this%descriptor_general_trimer%permutation_data) 122 | 123 | if (my_permutation_data%n_perms > 1) then 124 | call next(my_permutation_data, 1) 125 | end if 126 | 127 | permutations=my_permutation_data%dist_vec_permutations 128 | 129 | case(DT_WATER_TRIMER) 130 | if (.not. this%descriptor_water_trimer%permutation_data%initialised)then 131 | RAISE_ERROR("descriptor_permutations: permutation_data not initialised "//this%descriptor_type,error) 132 | else if (this%descriptor_water_trimer%permutation_data%perm_number /= 1) then 133 | RAISE_ERROR("descriptor_permutations: permutation_data%perm_number must be initialised to one"//this%descriptor_type,error) 134 | end if 135 | 136 | call permutation_data_copy(my_permutation_data, this%descriptor_water_trimer%permutation_data) 137 | 138 | if (my_permutation_data%n_perms > 1) then 139 | call next(my_permutation_data, 1) 140 | end if 141 | 142 | permutations=my_permutation_data%dist_vec_permutations 143 | 144 | case(DT_MOLECULE_LO_D) 145 | if (.not. this%descriptor_molecule_lo_d%permutation_data%initialised) then 146 | RAISE_ERROR("descriptor_permutations: permutation_data not initialised "//this%descriptor_type,error) 147 | else if (this%descriptor_molecule_lo_d%permutation_data%perm_number /= 1) then 148 | RAISE_ERROR("descriptor_permutations: permutation_data%perm_number must be initialised to one"//this%descriptor_type,error) 149 | end if 150 | 151 | call permutation_data_copy(my_permutation_data, this%descriptor_molecule_lo_d%permutation_data) 152 | 153 | if (my_permutation_data%n_perms > 1) then 154 | call next(my_permutation_data, 1) 155 | end if 156 | 157 | allocate(sliced_permutations(size(this%descriptor_molecule_lo_d%included_components),my_permutation_data%n_perms)) 158 | allocate(this_perm(size(this%descriptor_molecule_lo_d%included_components))) 159 | sliced_permutations =my_permutation_data%dist_vec_permutations(this%descriptor_molecule_lo_d%included_components,:) 160 | 161 | do j=1,my_permutation_data%n_perms 162 | this_perm=sliced_permutations(:,j) 163 | do i=1,size(this%descriptor_molecule_lo_d%included_components) 164 | unit_vec=maxloc(this%descriptor_molecule_lo_d%included_components, mask=this%descriptor_molecule_lo_d%included_components .eq. this_perm(i)) 165 | if (unit_vec(1) == 0) then 166 | RAISE_ERROR("descriptor_permutations: you have specified symmetries between atoms with different connectivity",error) 167 | end if 168 | permutations(i,j) =unit_vec(1) 169 | end do 170 | end do 171 | ! begin brau 172 | if(size(this%descriptor_molecule_lo_d%included_components) > maxval(this%descriptor_molecule_lo_d%included_components)) then 173 | permutations=my_permutation_data%dist_vec_permutations 174 | end if 175 | ! end brau -------------------------------------------------------------------------------- /descriptors_noncommercial_types.inc: -------------------------------------------------------------------------------- 1 | ! HND XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 2 | ! HND X 3 | ! HND X GAP (Gaussian Approximation Potental) 4 | ! HND X 5 | ! HND X 6 | ! HND X Portions of GAP were written by Albert Bartok-Partay, Gabor Csanyi, 7 | ! HND X Copyright 2006-2021. 8 | ! HND X 9 | ! HND X Portions of GAP were written by Noam Bernstein as part of 10 | ! HND X his employment for the U.S. Government, and are not subject 11 | ! HND X to copyright in the USA. 12 | ! HND X 13 | ! HND X GAP is published and distributed under the 14 | ! HND X Academic Software License v1.0 (ASL) 15 | ! HND X 16 | ! HND X GAP is distributed in the hope that it will be useful for non-commercial 17 | ! HND X academic research, but WITHOUT ANY WARRANTY; without even the implied 18 | ! HND X warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ! HND X ASL for more details. 20 | ! HND X 21 | ! HND X You should have received a copy of the ASL along with this program 22 | ! HND X (e.g. in a LICENSE.md file); if not, you can write to the original licensors, 23 | ! HND X Gabor Csanyi or Albert Bartok-Partay. The ASL is also published at 24 | ! HND X http://github.com/gabor1/ASL 25 | ! HND X 26 | ! HND X When using this software, please cite the following reference: 27 | ! HND X 28 | ! HND X A. P. Bartok et al Physical Review Letters vol 104 p136403 (2010) 29 | ! HND X 30 | ! HND X When using the SOAP kernel or its variants, please additionally cite: 31 | ! HND X 32 | ! HND X A. P. Bartok et al Physical Review B vol 87 p184115 (2013) 33 | ! HND X 34 | ! HND XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 35 | 36 | ! 37 | ! 38 | ! This file contains descriptors written by others, not A. P. Bartok and Gabor Csanyi 39 | ! and the code here is owned by their respective authors, as indicated below. 40 | ! 41 | 42 | !!!! Author: Wojciech Slachta 43 | type bond_real_space 44 | real(dp) :: bond_cutoff 45 | real(dp) :: bond_transition_width 46 | real(dp) :: cutoff 47 | real(dp) :: transition_width 48 | real(dp) :: atom_sigma 49 | integer :: max_neighbours 50 | 51 | logical :: initialised = .false. 52 | 53 | endtype bond_real_space 54 | 55 | !!!! Authors: Alan Nichol and S. T. John 56 | 57 | type AN_monomer 58 | real(dp) :: cutoff 59 | integer :: atomic_number 60 | integer :: N 61 | 62 | logical :: initialised = .false. 63 | logical :: do_atomic = .false. 64 | 65 | endtype AN_monomer 66 | 67 | type general_monomer 68 | type(permutation_data_type) :: permutation_data 69 | integer, dimension(:), allocatable :: signature 70 | real(dp) :: cutoff, cutoff_transition_width 71 | logical :: atom_ordercheck, internal_swaps_only 72 | logical :: strict 73 | real(dp) :: power 74 | logical :: initialised = .false. 75 | endtype general_monomer 76 | 77 | type general_dimer 78 | type(permutation_data_type) :: permutation_data 79 | integer, dimension(:), allocatable :: signature_one, signature_two 80 | integer, dimension(:,:), allocatable :: component_atoms 81 | real(dp) :: cutoff, cutoff_transition_width, monomer_one_cutoff, monomer_two_cutoff 82 | logical :: atom_ordercheck, internal_swaps_only, use_smooth_cutoff, monomers_identical,double_count 83 | logical :: strict, use_com, mpifind, strict_mask 84 | type(transfer_parameters_type) :: transfer_parameters 85 | logical :: initialised = .false. 86 | logical, dimension(:), allocatable :: is_intermolecular, cutoff_contributor 87 | real(dp) :: power,dist_shift 88 | endtype general_dimer 89 | 90 | type general_trimer 91 | type(permutation_data_type) :: permutation_data 92 | integer, dimension(:), allocatable :: signature_one, signature_two, signature_three 93 | integer, dimension(:,:), allocatable :: component_atoms 94 | real(dp) :: cutoff, cutoff_transition_width, monomer_one_cutoff, monomer_two_cutoff, monomer_three_cutoff 95 | logical :: atom_ordercheck, internal_swaps_only, use_smooth_cutoff, one_two_identical, one_three_identical, two_three_identical 96 | logical :: strict, use_com, mpifind 97 | logical :: initialised = .false. 98 | logical, dimension(:), allocatable :: is_intermolecular, cutoff_contributor 99 | real(dp) :: power,dist_shift 100 | endtype general_trimer 101 | 102 | 103 | type water_trimer 104 | !!! 3-body water descriptor 105 | !!! -- Jonatan Öström, @sujona, jonatan.ostrom@gmail.com 106 | type(permutation_data_type) :: permutation_data 107 | integer, dimension(3) :: signature = [8,1,1] 108 | real(dp) :: cutoff, cutoff_transition_width, monomer_cutoff 109 | logical :: atom_ordercheck = .false., internal_swaps_only = .true., use_smooth_cutoff 110 | logical :: initialised = .false., strict 111 | real(dp) :: power,dist_shift 112 | integer, dimension(36,2):: component_atoms 113 | logical, dimension(36) :: is_intermolecular, cutoff_contributor 114 | endtype water_trimer 115 | 116 | 117 | type molecule_lo_d 118 | type(permutation_data_type) :: permutation_data 119 | type(Atoms) :: template_atoms 120 | integer :: n_atoms, max_dimension ! max_dimension is descriptor dimension if include all interatomic distances 121 | integer, dimension(:), allocatable :: signature, included_components 122 | integer, dimension(:,:), allocatable :: component_atoms 123 | real(dp) :: cutoff, cutoff_transition_width 124 | integer :: neighbour_graph_depth 125 | logical :: atom_ordercheck, use_smooth_cutoff 126 | logical :: initialised = .false. 127 | type(Table) :: bonds, atom_pairs 128 | integer :: distance_transform 129 | endtype molecule_lo_d 130 | 131 | 132 | type com_dimer 133 | integer, dimension(:), allocatable :: signature_one, signature_two 134 | real(dp) :: cutoff, cutoff_transition_width, monomer_one_cutoff, monomer_two_cutoff 135 | logical :: atom_ordercheck, use_smooth_cutoff, monomers_identical 136 | logical :: strict, mpifind 137 | type(transfer_parameters_type) :: transfer_parameters 138 | logical :: initialised = .false. 139 | logical, dimension(:), allocatable :: is_intermolecular, cutoff_contributor 140 | endtype com_dimer 141 | 142 | !!!!! Authors: A. P. Bartok and Miguel Caro 143 | type soap_express 144 | ! User controllable parameters 145 | real(dp) :: cutoff 146 | real(dp) :: cutoff_transition_width 147 | real(dp) :: cutoff_decay_rate 148 | 149 | real(dp) :: atom_sigma_radial, atom_sigma_angular, central_weight, covariance_sigma0, & 150 | atom_sigma_scaling_radial, atom_sigma_scaling_angular, amplitude_scaling 151 | 152 | integer :: l_max, n_max 153 | 154 | ! Internal pre-initialised variables 155 | real(dp), dimension(:,:), allocatable :: basis_transformation_coefficients, & 156 | overlap 157 | real(dp), dimension(:), allocatable :: semifactorial_table, Y_lm_prefactor 158 | 159 | integer :: angular_array_size 160 | 161 | logical :: initialised = .false. 162 | endtype soap_express 163 | 164 | -------------------------------------------------------------------------------- /doc_src/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /doc_src/_static/theme_overrides.css: -------------------------------------------------------------------------------- 1 | 2 | /* override table width restrictions */ 3 | .wy-table-responsive table td, .wy-table-responsive table th { 4 | /* !important prevents the common CSS stylesheets from 5 | overriding this as on RTD they are loaded after this stylesheet */ 6 | white-space: normal !important; 7 | } 8 | 9 | .wy-table-responsive { 10 | overflow: visible !important; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /doc_src/_templates/layout.html: -------------------------------------------------------------------------------- 1 | {% extends "!layout.html" %} 2 | 3 | {% block menu %} 4 | {{ super() }} 5 |

6 | 12 | {% endblock %} 13 | -------------------------------------------------------------------------------- /doc_src/accelerated-aimd-castep-inputs.rst: -------------------------------------------------------------------------------- 1 | .. 2 | Copyright (c) Tamas K. Stenczel, 2023. 3 | 4 | 5 | ******************** 6 | Castep Input File 7 | ******************** 8 | 9 | This section is about setting up castep's inputs to handle the acceleration. 10 | 11 | Depending on which version you are using, the parameter names are a little different, see the two examples below. 12 | 13 | Castep param file 14 | ================= 15 | 16 | The settings governing the acceleration interface are located in the ``.param`` file's ``DEVEL_CODE`` block at 17 | the moment, where the user needs to set a couple of things. However, this can be done once and copied over to 18 | other calculations as-is as long as you keep your ``hybrid-md`` executable in your path rather than setting it 19 | directly, and keeping the GAP model's name the same. Otherwise change these two things. 20 | 21 | The rest of the parameters listed here are recommendations, which should make your life easy or were found to 22 | be efficient. 23 | 24 | DEVEL_CODE block 25 | -------------------- 26 | 27 | Set the following: 28 | 29 | ``PP=T`` & ``MD: PP=T :ENDMD`` & ``PP_HYBRID=T`` which turn of the use of non ab-initio force calculators. 30 | 31 | Turn on the usage of QUIP, initialisation arguments of a GAP model, and the path to it. Default is ``GAP.xml`` so 32 | might just keep it as that. 33 | 34 | .. code-block:: text 35 | 36 | pp: 37 | QUIP=T 38 | QUIP_PARAM_FILE=GAP.xml 39 | quip_init_args:IP GAP:endquip_init_args 40 | :endpp 41 | 42 | 43 | Finally, set the decision maker program's path with the ``PP_HYBRID_EXEC`` block. 44 | This is an "external executable" from Castep's point of view. 45 | 46 | **Note on Castep v22:** The code's initial version was included in Castep's v22 academic release, where restarting 47 | calculations was not possible yet, and parameter names had an ``MD_`` prefix. So if you are using v22, please 48 | use ``MD_PP_HYBRID=T`` for turning on and ``MD_PP_HYBRID_EXEC`` for the executable. 49 | 50 | Useful settings in .param 51 | ------------------------- 52 | 53 | These are educated recommendations only, feel free to overwrite. 54 | 55 | ``NUM_BACKUP_ITER`` should be comparable to the number of expected MD steps between ab-initio calculations. This 56 | controls the interval between checkpoints, from where restarting is possible. Anything after the checkpoint is 57 | potentially lost if the job stops and needs restarting. 58 | 59 | Use ``continuation: default`` for continuing a calculation where checkpoints were made and the seed name is the same. 60 | Bear in mind, the MD steps is set to 0 after restart but time is incremented, so the directories with previous 61 | GAP models will have indices accordingly. 62 | 63 | ``FINITE_BASIS_CORR: 0`` is recommended. This cannot be done at each ab-initio calculation, and the initial correction 64 | value calculated at the beginning may not be applicable after a long MD run. If you know your system and your simulation 65 | goals do disregard this. 66 | 67 | Given that one is intending to use this method for longer MDs, ``md_sample_iter`` (interval of saving MD frames) should 68 | be adjusted accordingly, since there is some IO cost associated with it as well as disc usage. 69 | 70 | Use tight settings on energy and force convergence, since there provide the input data to your model. Worth starting 71 | with looser settings for initial tests and then tightening for production runs. 72 | 73 | In case of **variable cell calculations**, make sure to use very dense KPoint grid or tight spacing, otherwise the 74 | training data given to GAP may not be consistent enough between frames and will yield sub-optimal model accuracy. 75 | 76 | Example: Castep v23 77 | ====================== 78 | 79 | If you are using Castep v23 (academic release only), then then add the following to your `seed.param` file. 80 | Note, the parameter prefixes are ``MD_PP_HYBRID`` unlike in v23. 81 | 82 | .. code-block:: text 83 | 84 | %BLOCK DEVEL_CODE 85 | ! generally turns on PP, this is needed together with "PP_HYBRID=T" 86 | PP=T 87 | MD: PP=T :ENDMD 88 | 89 | ! settings of model called through QUIP 90 | pp: 91 | QUIP=T 92 | QUIP_PARAM_FILE=GAP.xml 93 | quip_init_args:IP GAP:endquip_init_args 94 | :endpp 95 | 96 | ! settings of PP Hybrid MD 97 | PP_HYBRID=T 98 | PP_HYBRID_EXEC: 99 | hybrid-md 100 | :ENDPP_HYBRID_EXEC 101 | %ENDBLOCK DEVEL_CODE 102 | 103 | 104 | 105 | Example: Castep v22 106 | ====================== 107 | 108 | If you are using Castep v22 (academic release only), then then add the following to your `seed.param` file. 109 | Note, the parameter prefixes are ``MD_PP_HYBRID`` unlike in v23. 110 | 111 | .. code-block:: text 112 | 113 | %BLOCK DEVEL_CODE 114 | ! generally turns on PP, this is needed together with "MD_PP_HYBRID=T" 115 | PP=T 116 | MD: PP=T :ENDMD 117 | 118 | ! settings of model called through QUIP 119 | pp: 120 | QUIP=T 121 | QUIP_PARAM_FILE=GAP.xml 122 | quip_init_args:IP GAP:endquip_init_args 123 | :endpp 124 | 125 | ! settings of PP Hybrid MD 126 | MD_PP_HYBRID=T 127 | MD_PP_HYBRID_EXEC: 128 | hybrid-md 129 | :ENDMD_PP_HYBRID_EXEC 130 | %ENDBLOCK DEVEL_CODE 131 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /doc_src/accelerated-aimd-input-reference.rst: -------------------------------------------------------------------------------- 1 | .. 2 | Copyright (c) Tamas K. Stenczel, 2023. 3 | 4 | .. _accelerated-aimd-input-reference: 5 | 6 | ******************** 7 | Input file reference 8 | ******************** 9 | 10 | The acceleration code has a single input file, which defines the parameters of the 11 | decision making and refitting. Everything else is handled in the ab-initio code. 12 | 13 | The file should be called as ``.hybrid-md-input.yaml`` where the ```` is 14 | the calculation's filename prefix supplied by the ab-initio code as well. 15 | 16 | See the possible contents and a couple of example below. For runnable example, see 17 | the simulation examples. 18 | 19 | Core & Mandatory parameters 20 | =========================== 21 | 22 | A minimal example: 23 | 24 | .. code-block:: yaml 25 | 26 | # this is a complete seed.hybrid-md-input.yaml files 27 | can_update: true 28 | check_interval: 5 29 | num_initial_steps: 2 30 | tolerances: 31 | ediff: 0.005 # eV 32 | 33 | This sets the following: 34 | 35 | * ``can_update: true``: the model can be updated (default false) 36 | 37 | * ``check_interval: 5``: interval between ab-initio calculations (see :ref:`Fixed interval `) 38 | 39 | * ``num_initial_steps: 2``: the first 2 steps are ab-initio and used to train the first model 40 | 41 | * ``tolerances:`` block of tolerances for accepting the result 42 | - ``ediff: 0.005``: 5 meV/atom is the maximum allowed for continuations with the same model 43 | 44 | 45 | Tolerance section 46 | ================= 47 | 48 | .. code-block:: yaml 49 | 50 | # nb. partial input only 51 | tolerances: 52 | ediff: 0.01 # eV 53 | fmax: null # eV/A 54 | frmse: 0.100 # eV/A 55 | vmax: null # eV (virial) 56 | 57 | 58 | Tolerances can be specified for the following quantitities: 59 | 60 | * ``ediff``: energy per atom difference 61 | 62 | * ``fmax``: force-component maximum absolute difference (in eV/Å) 63 | 64 | * ``frmse``: RMSE of force components (in eV/Å) 65 | 66 | * ``vmax``: maximum virial stress difference, in eV 67 | 68 | At least one of these needs to be set, specifying ``null`` and omitting the parameter 69 | are equivalent. When checking them, the ones turned on are all used and the result needs 70 | to be below all of them to pass the check. 71 | 72 | Accuracy-Adapted method section 73 | =============================== 74 | 75 | Section of parameters for the :ref:`Accuracy-adapted checking interval mode `. The existence 76 | of the block turns this decision making method on. 77 | 78 | .. code-block:: yaml 79 | 80 | # nb. partial input only 81 | check_interval: 10 82 | adaptive_method_parameters: 83 | n_min: 10 84 | n_max: 5000 85 | factor: 1.3 86 | 87 | 88 | * ``check_interval: 10``: initial checking interval to start with 89 | 90 | * ``n_min`` & ``n_max``: bounds for the number of steps between ab-initio steps 91 | 92 | * ``factor: 1.3``: the geometric factor for increasing and decreasing the checking interval 93 | 94 | Refitting-specific settings 95 | =========================== 96 | 97 | Parameters for controlling the GAP model to be trained when the model is updated. 98 | 99 | You can use the pre-set SOAP parameters, or supply your own entirely. 100 | 101 | By default, the trained model includes a 2-body and a SOAP descriptor for all species, both with 5Å cutoff. *n.b. This may fail if you only have a single atom of any element, since there will be no data to train the self-interaction 2-body part for this element.* 102 | 103 | .. code-block:: yaml 104 | 105 | # nb. partial input only 106 | refit: 107 | e0_method: "isolated" 108 | num_threads: 128 109 | 110 | * ``e0_method`` sets the method for GAP to choose the element-specific constant shift. 111 | - default is ``average`` 112 | - see :ref:`gap_fit page ` for further information 113 | 114 | * ``num_threads: 128`` tells the program to use 128 OMP threads for the fitting, this is set temporarily only and is reset to the previous value after fitting. Does not affect the parallelism of the ab-initio code. *n.b. this only single-node fitting is supported for GAP models at the moment for the acceleration program.* 115 | 116 | One can additionally set ``e0`` in this section for passing explicit values, as in the ``gap_fit`` program. 117 | 118 | .. code-block:: yaml 119 | 120 | # nb. partial input only 121 | refit: 122 | e0_method: "isolated" 123 | num_threads: 128 124 | 125 | Previous data 126 | ------------- 127 | 128 | Previous data can be included in the model training, through specifying a list of xyz filenames under the ``previous_data`` parameter. These are expected to have their energy, force, and virial results saved with the same keywords as how the ab-initio code is saving them: ``QM_energy``, ``QM_forces``, ``QM_virial``, respectively. 129 | 130 | 131 | 132 | Descriptor Parameters 133 | --------------------- 134 | 135 | You can choose the descriptor parameters in multiple ways: 136 | 137 | * using pre-set SOAP parameter values: ``preset_soap_param: "fast" | "medium" | "accurate"``, which then includes a 2-body as well 138 | 139 | * using an explicit descriptor string: ``descriptor_str: "..."`` In this case the 2-body descriptor is not added. 140 | 141 | Other parameters 142 | ---------------- 143 | 144 | The rest of the parameters, which are mostly mimicking the keywords of ``gap_fit``. See the :ref:`Defaults ` section for the for the default values of these. 145 | 146 | * ``gp_name`` name of model XML file 147 | 148 | * ``default_sigma`` default kernel regularisation 149 | 150 | * ``extra_gap_opts`` anything else to pass to ``gap_fit`` 151 | 152 | * ``function_name`` allows the user to specify any python function installed in their environment by module import path for handling the refitting of the model. If this is set, then this function is used and everything else is ignored (though that function can see these parameters). This is an advanced developer feature. 153 | 154 | 155 | Defaults 156 | -------- 157 | 158 | .. _defaults: 159 | 160 | The following input file contains the default values set explicitly. *n.b. this is not allowing refitting, due to* ``can_update: false`` 161 | 162 | .. code-block:: yaml 163 | 164 | can_update: false 165 | check_interval: 1 166 | num_initial_steps: 0 167 | tolerances: 168 | ediff: 0.03 169 | fmax: null 170 | frmse: null 171 | vmax: null 172 | refit: 173 | function_name: null 174 | previous_data: [] 175 | preset_soap_param: "fast" 176 | gp_name: "GAP.xml" 177 | default_sigma: "0.005 0.050 0.1 1.0" 178 | descriptor_str: null 179 | extra_gap_opts: "sparse_jitter=1.0e-8" 180 | e0: null 181 | e0_method: "average" 182 | num_threads: null 183 | 184 | 185 | -------------------------------------------------------------------------------- /doc_src/accelerated-aimd.rst: -------------------------------------------------------------------------------- 1 | .. 2 | Copyright (c) Tamas K. Stenczel, 2023. 3 | 4 | .. _accelerated-aimd: 5 | 6 | ******************************************************* 7 | Acceleration of Ab-initio MD with On-the-Fly GAP Models 8 | ******************************************************* 9 | 10 | This is the documentation of the ``hybrid-md`` package bundled with GAP, which provides a general framework of 11 | accelerating Ab-initio MD (AIMD) with Machine Learning models generated "On-the-Fly". 12 | 13 | The framework is intended to be agnostic of the AIMD code and the ML code as well. For the time being, an interface 14 | between the CASTEP code and GAP is available publicly, integration of other ab-initio codes and ML frameworks is in 15 | the making. If you would have any software/research ideas, or would like to contribute in any way, please feel free 16 | to reach out to with G. Csányi and T. K. Stenczel for further details. 17 | 18 | Getting started & Usage 19 | *********************** 20 | 21 | .. toctree:: 22 | :maxdepth: 2 23 | 24 | accelerated-aimd_installation.rst 25 | accelerated-aimd-input-reference.rst 26 | accelerated-aimd_decision-making.rst 27 | accelerated-aimd-castep-inputs.rst 28 | 29 | Examples 30 | ******** 31 | 32 | .. toctree:: 33 | :maxdepth: 2 34 | 35 | accelerated-aimd_example_Si16.rst 36 | 37 | 38 | Program structures and design 39 | ***************************** 40 | 41 | The program is intended to be user-accessible and extendable. CASTEP implements 42 | an interface to external force evaluation codes - including QUIP/GAP. 43 | 44 | Design Principles 45 | ################# 46 | 47 | The interface provides acceleration of an AIMD simulation, according to the following design principles: 48 | 49 | 1. MD is driven by the AIMD code (this is the main program) 50 | 51 | 2. Decision making program independent of AIMD code 52 | 53 | 3. ML code is used by the AIMD code only for force evaluation, and by decision making code for updating of models 54 | 55 | 4. The system is agnostic of programming languages used, the decision making code could be implemented in any other language as long as the API is the same 56 | 57 | Extendability & Development 58 | *************************** 59 | 60 | Users can extend the framework in multiple ways: 61 | 62 | #. Build custom decision making routines: e.g. 63 | - system specific adaptations 64 | - utilising confidence estimates of models 65 | - any external tools working out when the model is extrapolating / could use more data: e.g. sample more when connectivity changes - bond break/form 66 | #. Support other AIMD codes: There are no specific requirements apart from an internal MD loop being available. Please get in touch with G. Csányi and T. K. Stenczel for further details. 67 | #. Support for other ML tools - the framework is not depending on GAP 68 | 69 | -------------------------------------------------------------------------------- /doc_src/accelerated-aimd_decision-making.rst: -------------------------------------------------------------------------------- 1 | .. 2 | Copyright (c) Tamas K. Stenczel, 2023. 3 | 4 | .. _accelerated-aimd-decision-making: 5 | 6 | Decision making 7 | *************** 8 | 9 | Decision making methods are governing which forces are used at each step, and when to 10 | refit a model. This is a key part of any acceleration and on-the-fly model improvement 11 | cycle. 12 | 13 | We currently supply two methods, which directly compare the GAP and ab-initio energy 14 | and forces. One is using a fixed interval for performing ab-initio calculations, while 15 | the other one adapts to the accuracy of the model. Both make use of the tolerances set 16 | by the user in the input file for deciding when to retrain the model. 17 | 18 | For general calculations, particularly ones starting from scratch, **we recommend using 19 | the accuracy-adapted decision making method.** 20 | 21 | Initial steps 22 | ============= 23 | 24 | Regardless of the decision making method, the method allows for a number of initial 25 | ab-initio MD steps to be performed. This is useful for starting from scratch, where no 26 | previous model is available. 27 | 28 | In order to activate this set ``num_initial_steps > 0`` in the input file. 29 | 30 | Fixed Interval Decision Making 31 | ============================== 32 | 33 | .. _fixed interval: 34 | 35 | Ab-initio calculations are performed at fixed intervals. Set the fixed interval with the 36 | ``check_interval`` keywords in the input file. 37 | 38 | If any of the tolerance criteria are not met at this point, then the model is re-trained 39 | with the available data. 40 | 41 | Accuracy-Adapted Checking Interval 42 | ================================== 43 | 44 | .. _adaptive interval: 45 | 46 | This method adapts the interval between ab-initio steps according to a geometric factor 47 | parameter, within user-specified upper and lower bounds. You need to specify the starting 48 | interval, factor, and the bounds. 49 | 50 | Upon meeting the desired tolerances (i.e. being below the limits) at checking steps, the 51 | interval until the next one is increased, otherwise the model is re-trained with the 52 | newly available observations and the interval decreased by the factor specified. 53 | 54 | This method is turned on by supplying the ``adaptive_method_parameters: ...`` input 55 | block in the decision making input file. 56 | 57 | Further development 58 | =================== 59 | 60 | Further developments are planned and are very welcome. There are lots of open avenues that can be explored with the framework provided here. Some of these the current developers have thought of, but that is surely a small subset of what people can and want to use this for. 61 | 62 | See a few examples below. If you are interested in collaborating on any of these, or have any other idea then please feel free to reach out, we are more than happy to work together or help others get started with the code. 63 | 64 | * usage of bonding/structural information: trigger refitting when atomic connectivity is changed, or when the dynamics gets closer to potential bond breaking. Might be useful for modelling reactive systems, etc. 65 | 66 | * use similarity to a database, say through SOAP descriptor distance, trigger data acquisition when this hits a threshold of moving further from the previous data 67 | 68 | * integration of other ML and ab-initio codes (some in the making already) 69 | 70 | -------------------------------------------------------------------------------- /doc_src/accelerated-aimd_example_Si16.rst: -------------------------------------------------------------------------------- 1 | .. 2 | Copyright (c) Tamas K. Stenczel, 2023. 3 | 4 | ****************************************************** 5 | Si16 - Walkthrough of a Simple Calculation 6 | ****************************************************** 7 | 8 | This is a simple walkthrough of an experiment that one can try out, even on a laptop. 9 | 10 | We will be running MD of a small Si cell. 11 | 12 | First calculation 13 | ****************************************************** 14 | 15 | We will start out by running a short MD, starting with 3 steps of ab-initio calculations, training a model 16 | on that, and later only doing ab-initio calculations at every 10th step. We are running a total of 50 MD steps. 17 | 18 | Write the following in the input file ``si16.hybrid-md-input.yaml``. 19 | 20 | .. code-block:: yaml 21 | 22 | can_update: true 23 | check_interval: 10 24 | num_initial_steps: 3 25 | tolerances: 26 | ediff: 0.01 # eV 27 | 28 | You need ``si16.cell`` and ``si16.param`` files as well. See examples here, of 8 atom si. 29 | 30 | ``si16.cell``: 31 | 32 | .. code-block:: text 33 | 34 | %BLOCK LATTICE_CART 35 | 7.679180 0.000000 0.000000 36 | 0.000000 7.679180 0.000000 37 | 0.000000 0.000000 5.430000 38 | %ENDBLOCK LATTICE_CART 39 | 40 | %BLOCK POSITIONS_ABS 41 | Si 0.000000 0.000000 0.000000 42 | Si 1.919795 0.000000 1.357500 43 | Si 1.919795 1.919795 2.715000 44 | Si 0.000000 1.919795 4.072500 45 | Si 0.000000 3.839590 0.000000 46 | Si 1.919795 3.839590 1.357500 47 | Si 1.919795 5.759385 2.715000 48 | Si 0.000000 5.759385 4.072500 49 | Si 3.839590 0.000000 0.000000 50 | Si 5.759385 0.000000 1.357500 51 | Si 5.759385 1.919795 2.715000 52 | Si 3.839590 1.919795 4.072500 53 | Si 3.839590 3.839590 0.000000 54 | Si 5.759385 3.839590 1.357500 55 | Si 5.759385 5.759385 2.715000 56 | Si 3.839590 5.759385 4.072500 57 | %ENDBLOCK POSITIONS_ABS 58 | 59 | 60 | 61 | ``si16.param``: 62 | 63 | .. code-block:: text 64 | 65 | ############################################################### 66 | # functional & general settings 67 | ############################################################### 68 | xc_functional LDA 69 | basis_precision PRECISE ! basis set size from presets 70 | fix_occupancy true 71 | opt_strategy speed ! faster runtime with more memory use 72 | 73 | # allow continuation 74 | NUM_BACKUP_ITER = 10 ! interval between checkpoints (.check file) 75 | continuation: default ! continuation if .check file exists 76 | 77 | ############################################################### 78 | # MD settings 79 | ############################################################### 80 | task = molecular dynamics 81 | 82 | md_ensemble = NVT 83 | md_thermostat = Langevin 84 | md_num_iter = 50 ! number of MD steps we will take 85 | md_temperature = 300 K 86 | md_sample_iter = 10 ! interval between dumping MD frames 87 | md_delta_t = 1 fs 88 | 89 | ############################################################### 90 | # Devel code: contains the `PP_HYBRID` method settings 91 | ############################################################### 92 | %BLOCK DEVEL_CODE 93 | ! turn on the PP & acceleration modules 94 | PP=T 95 | MD: PP=T :ENDMD 96 | PP_HYBRID=T 97 | 98 | ! settings of model called through QUIP 99 | pp: 100 | QUIP=T 101 | QUIP_PARAM_FILE=GAP.xml 102 | quip_init_args:IP GAP:endquip_init_args 103 | :endpp 104 | 105 | ! settings of PP Hybrid MD 106 | 107 | PP_HYBRID_EXEC: 108 | hybrid-md 109 | :endPP_HYBRID_EXEC 110 | %ENDBLOCK DEVEL_CODE 111 | 112 | Let's run this! 113 | 114 | .. code-block:: bash 115 | 116 | mpirun -n 4 castep.mpi si-0 117 | 118 | The code should produce the following: 119 | 120 | * standard Castep outputs: 121 | * ``si16.castep`` main output file (worth reading) 122 | * ``si16.md`` MD trajectory 123 | * a few more castep files, including a bibliography of the parts used 124 | * ``GAP.xml`` model and associated ``GAP.xml.sparseX_