├── .github └── workflows │ ├── comment-docs-download.yml │ ├── docs.yml │ └── lint.yml ├── .gitignore ├── .isort.cfg ├── CONDUCT.md ├── CONTRIBUTING.rst ├── INSTALLING.rst ├── LICENSE ├── README.rst ├── docs ├── .gitignore ├── requirements.txt └── src │ ├── .gitignore │ ├── _static │ ├── cookbook-icon.png │ ├── cookbook-icon.svg │ ├── cookbook.css │ └── daily-recipe.js │ ├── conf.py │ ├── contributing.rst │ ├── downloading.rst │ ├── google4ae5e3529d19a84c.html │ ├── index.rst │ ├── robots.txt │ ├── software │ ├── .gitignore │ ├── chemiscope.sec │ ├── cp2k.sec │ ├── featomic.sec │ ├── i-pi.sec │ ├── index.rst │ ├── lammps.sec │ ├── metatensor.sec │ ├── plumed.sec │ ├── scikit-matter.sec │ └── torch-pme.sec │ └── topics │ ├── .gitignore │ ├── analysis.sec │ ├── index.rst │ ├── ml-models.sec │ ├── nqes.sec │ └── sampling.sec ├── examples ├── INSTALLING.rst ├── batch-cp2k │ ├── .gitignore │ ├── README.rst │ ├── environment.yml │ ├── example.xyz │ ├── reference-trajectory.py │ ├── reftraj_template.cp2k │ └── run_calcs.sh ├── dos-align │ ├── README.rst │ ├── dos-align.py │ └── environment.yml ├── flashmd │ ├── README.rst │ ├── data │ │ ├── al110.xyz │ │ ├── ala2.xyz │ │ ├── input-al110-base.xml │ │ └── input-ala2-base.xml │ ├── environment.yml │ ├── flashmd-demo.py │ └── flashmd-scheme.png ├── gaas-map │ ├── .gitignore │ ├── README.rst │ ├── environment.yml │ └── gaas-map.py ├── heat-capacity │ ├── README.rst │ ├── data │ │ ├── in.lmp │ │ ├── input.xml │ │ ├── water_32.pdb │ │ └── water_32_data.lmp │ ├── environment.yml │ └── heat-capacity.py ├── learn-tensors-with-mcov │ ├── README.rst │ ├── architecture.png │ ├── data │ │ └── qm7x_reduced_100_CHNO.xyz │ ├── environment.yml │ ├── eval.yaml │ ├── learn-tensors-with-mcov.py │ └── options.yaml ├── lode-linear │ ├── README.rst │ ├── charge-charge.xyz │ ├── environment.yml │ └── lode-linear.py ├── lpr │ ├── .gitignore │ ├── README.rst │ ├── environment.yml │ └── lpr.py ├── path-integrals │ ├── README.rst │ ├── data │ │ ├── in.lmp │ │ ├── input_piglet.xml │ │ ├── input_pimd.xml │ │ ├── water_32.pdb │ │ └── water_32_data.lmp │ ├── environment.yml │ ├── path-integrals.py │ └── pimd-slices-round.png ├── periodic-hamiltonian │ ├── README.rst │ ├── data │ │ ├── BASIS_STO3G │ │ ├── C2.xyz │ │ └── reftraj_hamiltonian.cp2k │ ├── environment.yml │ ├── equivariantnonlinear.png │ ├── graphene_lattice.png │ ├── periodic-hamiltonian.py │ └── simpleMLP.png ├── pet-mad-nc │ ├── README.rst │ ├── data │ │ ├── bmimcl.xyz │ │ ├── input-nc-nve-mts.xml │ │ ├── input-nc-nve.xml │ │ └── input-nve.xml │ ├── environment.yml │ └── pet-mad-nc.py ├── pet-mad │ ├── .gitignore │ ├── README.rst │ ├── data │ │ ├── al6xxx-o2.in │ │ └── al6xxx-o2.xyz │ ├── environment.yml │ └── pet-mad.py ├── pi-metad │ ├── README.rst │ ├── data │ │ ├── FES-md_hiq.bz2 │ │ ├── FES-pimd_hiq.bz2 │ │ ├── h5o2+.xyz │ │ ├── h5o2.dms4B.coeff.com.dat │ │ ├── h5o2.pes4B.coeff.dat │ │ ├── input-md.xml │ │ ├── input-md_hiq.xml │ │ ├── input-pimd.xml │ │ ├── input-pimd_hiq.xml │ │ ├── plumed-md.dat │ │ ├── plumed-md_hiq.dat │ │ ├── plumed-pimd.dat │ │ └── plumed-pimd_hiq.dat │ ├── environment.yml │ ├── metad-scheme.png │ ├── pi-metad.py │ └── plumed-tutorials.zip ├── pi-mts-rpc │ ├── README.rst │ ├── data │ │ ├── h2o_md.xml │ │ ├── h2o_mts.xml │ │ ├── h2o_pimd.xml │ │ ├── h2o_rpc-mts.xml │ │ ├── h2o_rpc.xml │ │ └── water_32.pdb │ ├── environment.yml │ ├── mts-rpc.py │ ├── pimd-mts-integrator.png │ ├── pimd-mts-pots.png │ ├── pimd-mts-rpc.png │ └── rpc-4.png ├── polarizability │ ├── README.rst │ ├── data │ │ └── qm7x_reduced_100.xyz │ ├── environment.yml │ └── polarizability.py ├── rotate-equivariants │ ├── README.rst │ ├── environment.yml │ ├── rotate-equivariants.png │ └── rotate-equivariants.py ├── roy-gch │ ├── .gitignore │ ├── README.rst │ ├── data │ │ └── beran_roy_structures.xyz.bz2 │ ├── environment.yml │ └── roy-gch.py ├── sample-selection │ ├── .gitignore │ ├── README.rst │ ├── data │ │ └── input-fps.xyz │ ├── environment.yml │ └── sample-selection.py ├── thermostats │ ├── README.rst │ ├── data │ │ ├── gle.lmp │ │ ├── in.lmp │ │ ├── input_cvv_sample.xml │ │ ├── input_cvv_traj.xml │ │ ├── input_gle.xml │ │ ├── input_higamma.xml │ │ ├── input_nve.xml │ │ ├── input_svr.xml │ │ ├── run_traj.sh │ │ ├── smart.A │ │ ├── traj-all_facf.data │ │ ├── water_32.pdb │ │ └── water_32_data.lmp │ ├── environment.yml │ └── thermostats.py ├── torchpme │ ├── README.rst │ ├── data │ │ └── point_charges_Training_set.xyz │ ├── environment.yml │ └── torchpme_learning.py └── water-model │ ├── .gitignore │ ├── README.rst │ ├── data │ ├── spcfw.in │ └── water_32.xyz │ ├── environment.yml │ └── water-model.py ├── noxfile.py ├── requirements.txt └── src ├── generate-gallery.py ├── get_examples.py ├── ipynb-to-gallery.py └── latest_docs_run.py /.github/workflows/comment-docs-download.yml: -------------------------------------------------------------------------------- 1 | name: Comment on pull request 2 | on: 3 | workflow_run: 4 | workflows: ['Documentation'] 5 | types: [completed] 6 | 7 | jobs: 8 | pr_comment: 9 | if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/github-script@v7 13 | with: 14 | script: | 15 | async function insertUpdateComment(owner, repo, issue_number, purpose, body) { 16 | const {data: comments} = await github.rest.issues.listComments( 17 | {owner, repo, issue_number} 18 | ); 19 | const marker = ``; 20 | body = marker + "\n" + body; 21 | const existing = comments.filter((c) => c.body.includes(marker)); 22 | if (existing.length > 0) { 23 | const last = existing[existing.length - 1]; 24 | core.info(`Updating comment ${last.id}`); 25 | await github.rest.issues.updateComment({ 26 | owner, repo, 27 | body, 28 | comment_id: last.id, 29 | }); 30 | } else { 31 | core.info(`Creating a comment in issue / PR #${issue_number}`); 32 | await github.rest.issues.createComment({issue_number, body, owner, repo}); 33 | } 34 | } 35 | 36 | const {owner, repo} = context.repo; 37 | const run_id = ${{github.event.workflow_run.id}}; 38 | 39 | // Find the PR with the right sha, see https://github.com/orgs/community/discussions/25220 40 | const response = await github.rest.search.issuesAndPullRequests({ 41 | q: 'repo:${{ github.repository }} is:pr sha:${{ github.event.workflow_run.head_sha }}', 42 | per_page: 1, 43 | }) 44 | const items = response.data.items 45 | if (items.length < 1) { 46 | return core.error("No matching pull requests found"); 47 | } 48 | const pullRequestNumber = items[0].number 49 | console.info("Pull request number is", pullRequestNumber) 50 | 51 | // get the list of artifacts 52 | const artifacts = await github.paginate( 53 | github.rest.actions.listWorkflowRunArtifacts, {owner, repo, run_id} 54 | ); 55 | 56 | if (!artifacts.length) { 57 | return core.error(`No artifacts found`); 58 | } 59 | 60 | for (const artifact of artifacts) { 61 | if (artifact.name == "documentation") { 62 | const link = `https://nightly.link/${owner}/${repo}/actions/artifacts/${artifact.id}.zip` 63 | 64 | let body = `Here is the build version of the cookbook in this pull request: [documentation.zip](${link}), `; 65 | body += 'you can view it locally by unzipping `documentation.zip` and open the `index.html` with your favorite browser.'; 66 | 67 | core.info("Review thread message body:", body); 68 | await insertUpdateComment(owner, repo, pullRequestNumber, "link-to-documentation", body); 69 | 70 | return; 71 | } 72 | } 73 | 74 | return core.error(`failed to find "documentation" artifact`); 75 | -------------------------------------------------------------------------------- /.github/workflows/docs.yml: -------------------------------------------------------------------------------- 1 | name: Documentation 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | tags: ["*"] 7 | pull_request: 8 | # Check all PR 9 | schedule: 10 | - cron: '0 8 * * 1' # run every Monday at 8am UTC 11 | 12 | jobs: 13 | setup: 14 | runs-on: ubuntu-latest 15 | outputs: 16 | examplesmatrix: ${{ steps.gatherInfo.outputs.examplesjson }} 17 | latest_docs_run: ${{ steps.gatherInfo.outputs.latest_docs_run }} 18 | steps: 19 | - uses: actions/checkout@v4 20 | with: 21 | # The checkout by default doesn't fetch any history, but for PR 22 | # we want to check which files have been modified. 23 | # The action actions/checkout@v4 squashes the history of the PR, 24 | # into a single commit so we need to fetch with a depth of 2. 25 | fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }} 26 | 27 | - id: gatherInfo 28 | # Collect the examples that need to be run, and the id of the latest 29 | # workflow run on the main branch. 30 | run: | 31 | GET_EXAMPLES_ARGS="" 32 | if ${{ github.event_name == 'pull_request' }}; then 33 | GET_EXAMPLES_ARGS=" --modified-files $(git diff --name-only -r HEAD^1 HEAD)" 34 | fi 35 | echo examplesjson=$(./src/get_examples.py ${GET_EXAMPLES_ARGS}) >> $GITHUB_OUTPUT 36 | echo latest_docs_run=$(./src/latest_docs_run.py id) >> $GITHUB_OUTPUT 37 | 38 | generate-example: 39 | needs: setup 40 | runs-on: ubuntu-latest 41 | # Handle the case where there are no examples to run. 42 | if: ${{ needs.setup.outputs.examplesmatrix != ''}} 43 | strategy: 44 | matrix: 45 | ${{ fromJson(needs.setup.outputs.examplesmatrix) }} 46 | 47 | steps: 48 | - uses: actions/checkout@v4 49 | 50 | - name: setup Python 51 | uses: actions/setup-python@v5 52 | with: 53 | python-version: "3.12" 54 | 55 | - name: install dependencies 56 | run: python -m pip install nox docutils 57 | 58 | - name: build example 59 | run: nox -e ${{ matrix.example-name }} 60 | 61 | - name: store example as a github artifact 62 | uses: actions/upload-artifact@v4 63 | with: 64 | name: example-${{ matrix.example-name }} 65 | path: docs/src/examples/* # folders for each example will be merged later 66 | overwrite: true # only keep the latest version of the example 67 | 68 | build-and-publish: 69 | # Run this job even if the generate-example job was skipped due to 70 | # no examples to run. I.e. only avoid if generate-example failed. 71 | if: ${{ always() && needs.generate-example.conclusion != 'failure' }} 72 | needs: [setup, generate-example] 73 | runs-on: ubuntu-latest 74 | steps: 75 | - uses: actions/checkout@v4 76 | 77 | - name: setup Python 78 | uses: actions/setup-python@v5 79 | with: 80 | python-version: "3.12" 81 | 82 | - name: install dependencies 83 | run: python -m pip install nox docutils 84 | 85 | - name: Download latest main branch built examples 86 | uses: actions/download-artifact@v4 87 | if: ${{ github.event_name == 'pull_request' }} 88 | with: 89 | path: docs/src/examples 90 | pattern: example-* 91 | github-token: ${{ secrets.GH_READ_TOKEN }} 92 | run-id: ${{ needs.setup.outputs.latest_docs_run }} 93 | merge-multiple: true 94 | 95 | - name: Overwrite examples with the ones built in this run 96 | uses: actions/download-artifact@v4 97 | with: 98 | path: docs/src/examples 99 | pattern: example-* 100 | merge-multiple: true 101 | 102 | - name: build documentation 103 | run: nox -e build_docs 104 | 105 | - name: store documentation as github artifact to be downloaded by users 106 | uses: actions/upload-artifact@v4 107 | with: 108 | name: documentation 109 | path: docs/build/html/* 110 | overwrite: true # only keep the latest version of the documentation 111 | 112 | - name: put documentation in the website 113 | run: | 114 | git clone https://github.com/$GITHUB_REPOSITORY --branch gh-pages gh-pages 115 | rm -rf gh-pages/.git 116 | cd gh-pages 117 | 118 | # deploys directly to the root of the website 119 | rm -rf * 120 | mv ../docs/build/html/* . 121 | 122 | - name: deploy to gh-pages 123 | if: github.event_name == 'push' 124 | uses: peaceiris/actions-gh-pages@v4 125 | with: 126 | github_token: ${{ secrets.GITHUB_TOKEN }} 127 | publish_dir: ./gh-pages/ 128 | force_orphan: true 129 | cname: atomistic-cookbook.org 130 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | # Lint tests run on PR 2 | # but should not run after push to main because reporting 3 | # these after push is meaningless to the building of the package 4 | name: Lint 5 | 6 | on: 7 | pull_request: 8 | branches: [main] 9 | schedule: 10 | - cron: '0 8 * * 1' # run every Monday at 8am UTC 11 | 12 | jobs: 13 | lint: 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - uses: actions/checkout@v4 18 | - name: Set up Python 19 | uses: actions/setup-python@v5 20 | with: 21 | python-version: "3.11" 22 | 23 | - name: install dependencies 24 | run: pip install nox docutils 25 | 26 | - name: test lint 27 | run: nox -e lint 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | docs/src/examples/ 2 | docs/src/_static/all-examples-data.js 3 | 4 | *build* 5 | *egg-info/ 6 | 7 | .nox/ 8 | -------------------------------------------------------------------------------- /.isort.cfg: -------------------------------------------------------------------------------- 1 | [settings] 2 | profile = black 3 | line_length = 88 4 | indent = 4 5 | include_trailing_comma = true 6 | lines_after_imports = 2 7 | -------------------------------------------------------------------------------- /CONDUCT.md: -------------------------------------------------------------------------------- 1 | 2 | # Code of Conduct 3 | 4 | ## Our Pledge 5 | 6 | In the interest of fostering an open and welcoming environment, we as contributors and 7 | maintainers pledge to making participation in our project and our community a 8 | harassment-free experience for everyone, regardless of age, body size, disability, 9 | ethnicity, gender identity and expression, level of experience, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment include: 15 | 16 | * Using welcoming and inclusive language 17 | * Being respectful of differing viewpoints and experiences 18 | * Gracefully accepting constructive criticism 19 | * Focusing on what is best for the community 20 | * Showing empathy towards other community members 21 | 22 | Examples of unacceptable behavior by participants include: 23 | 24 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 25 | * Trolling, insulting/derogatory comments, and personal or political attacks 26 | * Public or private harassment 27 | * Publishing others' private information, such as a physical or electronic address, 28 | without explicit permission 29 | * Other conduct which could reasonably be considered inappropriate in a professional 30 | setting 31 | 32 | ## Our Responsibilities 33 | 34 | Project maintainers are responsible for clarifying the standards of acceptable behavior 35 | and are expected to take appropriate and fair corrective action in response to any 36 | instances of unacceptable behavior. 37 | 38 | Project maintainers have the right and responsibility to remove, edit, or reject 39 | comments, commits, code, wiki edits, issues, and other contributions that are not 40 | aligned to this Code of Conduct, or to ban temporarily or permanently any contributor 41 | for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 42 | 43 | ## Scope 44 | 45 | This Code of Conduct applies both within project spaces and in public spaces when an 46 | individual is representing the project or its community. Examples of representing a 47 | project or community include using an official project e-mail address, posting via an 48 | official social media account, or acting as an appointed representative at an online or 49 | offline event. Representation of a project may be further defined and clarified by 50 | project maintainers. 51 | 52 | ## Enforcement 53 | 54 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by 55 | contacting the project team. The project team will review and investigate all 56 | complaints, and will respond in a way that it deems appropriate to the circumstances. 57 | The project team is obligated to maintain confidentiality with regard to the reporter of 58 | an incident. Further details of specific enforcement policies may be posted separately. 59 | 60 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may 61 | face temporary or permanent repercussions as determined by other members of the 62 | project's leadership. 63 | 64 | ## Attribution 65 | 66 | This Code of Conduct is adapted from the [Contributor Covenant, version 67 | 1.4](http://contributor-covenant.org/version/1/4). 68 | -------------------------------------------------------------------------------- /CONTRIBUTING.rst: -------------------------------------------------------------------------------- 1 | Contributing 2 | ============ 3 | 4 | .. marker-contrib-start 5 | 6 | Contributions are welcome, and they are greatly appreciated, even it they 7 | are just reporting bugs in one of the existing recipes. Please use github 8 | to report errors and submit contributions, as this helps with making your 9 | work visible and giving you credit. 10 | If you intend to submit a new recipe, please read 11 | the guidelines below to ensure that your contributions 12 | fit within the scope and the general style of the cookbook. 13 | 14 | Requirements for new contributions 15 | ---------------------------------- 16 | 17 | All code included in the `cookbook repository 18 | `_ 19 | is executed in each pull request. This 20 | ensures that the code in remains compatible and executable for a longer time 21 | frame. Because of that we do not want to have examples with heavy calculations 22 | that require more than a couple of minutes to execute. 23 | If you are unsure whether a contribution is suitable, or if you want to 24 | discuss how to structure your recipe, feel free to 25 | `open an issue `_. 26 | 27 | Adding a new recipe 28 | ------------------- 29 | 30 | The examples in this repository are python files that we render for the website 31 | using `sphinx-gallery`_. In short, these are python files containing comments 32 | formatted as `RestructuredText`_, which are executed, and then the comments, 33 | code and outputs (including plots, ``print`` outputs, etc.) are assembled in a 34 | single HTML webpage. 35 | 36 | To add a new example, you'll need to create a new folder in example (substitute 37 | ```` with the folder name in the instructions below), and add the 38 | following files inside: 39 | 40 | - ``README.rst``, can be empty or can contain a short description of the example; 41 | - ``environment.yml``, a `conda`_ environment file containing the list of 42 | dependencies needed by your example; 43 | - as many Python files as you want, each one will be converted to a separate 44 | HTML page. 45 | 46 | Example dependencies 47 | ~~~~~~~~~~~~~~~~~~~~ 48 | 49 | The Python ecosystem moves fast and breaks things. Examples should always 50 | be able to run in the CI system to generate webpages, and it's best for 51 | users if they also work out-of-the-box when downloaded. For these reasons, 52 | we recommend constraining the package version in the environment file. 53 | At the same time, it's best to run on updated versions that might contain 54 | important bugfixes. We recommend using semantic versioning to achieve 55 | this, e.g. indicating the version known to work and the next major update 56 | 57 | .. code-block:: yaml 58 | 59 | - my-package >=1.3.1,<2.0 60 | 61 | This way if the example breaks further down the line it is easy to 62 | bring it back to a working state converting these to strict pinnings, 63 | yet most harmless updates will be applied automatically. 64 | 65 | Data files 66 | ~~~~~~~~~~ 67 | 68 | Keep in mind that sphinx-gallery will make it easy to download a Python file and 69 | the notebook generated from it, but it won't give direct access to additional 70 | files. If your example needs such data files, there are a few options available: 71 | 72 | - (preferred) have the data file stored in a publicly accessible location, e.g. 73 | a Zotero record, and download the data file from the script 74 | - if the data files are small (few 10s of Kb) you may also include them in a 75 | ``data/`` folder within the example folder. A zip file will be generated that 76 | can be downloaded from the example page. 77 | 78 | Thematic listings 79 | ~~~~~~~~~~~~~~~~~ 80 | 81 | Each new recipe will be automatically added to the list of new recipes, but 82 | you should also add it to the relevant software and topical sections. To do 83 | so, edit the appropriate ``.sec`` file within ``docs/src/software`` and 84 | ``docs/src/topics``. 85 | 86 | .. _sphinx-gallery: https://sphinx-gallery.github.io/ 87 | .. _RestructuredText: https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html 88 | .. _conda: https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#create-env-file-manually 89 | 90 | 91 | Converting a Jupyter notebook to a sphinx-gallery compatible Python script 92 | -------------------------------------------------------------------------- 93 | 94 | It is often more convenient to work in a Jupyter notebook and convert it 95 | to sphinx-gallery example. To convert your Jupyter notebook you can use the 96 | `ipynb-to-gallery.py `_ script, in the ``src`` folder of 97 | the repository 98 | 99 | .. code-block:: bash 100 | 101 | python src/ipynb-to-gallery.py 102 | 103 | Running your example and visualizing the HTML 104 | --------------------------------------------- 105 | 106 | We use `nox`_ as a task runner to run all examples and assemble the final 107 | documentation. You can install it with ``pip install nox``. 108 | 109 | To run your example and make sure it conforms to the expected code formatting, 110 | you can use the following commands: 111 | 112 | .. code-block:: bash 113 | 114 | # execute the example and render it to HTML 115 | nox -e 116 | 117 | # build web pages for the examples that have been already run 118 | nox -e build_docs 119 | 120 | To visualize the generated cookbook open ``docs/build/html/index.html`` 121 | in a web browser. If there are dynamical elements that have to be loaded, 122 | it might be better to serve the website using a HTTP server, e.g. 123 | running 124 | 125 | .. code-block:: bash 126 | 127 | python -m http.server PORT_NUMBER 128 | 129 | from within the ``docs/build/html/`` folder. The website will be served 130 | on ``localhost:PORT_NUMBER``. 131 | 132 | Before committing your recipe, you should check that it complies 133 | with the coding style, which you can check automatically using 134 | 135 | .. code-block:: bash 136 | 137 | nox -e lint 138 | 139 | Most (but not all) formatting errors can be fixed automatically with: 140 | 141 | .. code-block:: bash 142 | 143 | nox -e format 144 | 145 | You can also build all examples (warning, this will take quite some time) with: 146 | 147 | .. code-block:: bash 148 | 149 | nox -e docs 150 | 151 | Alternatively, you can download the executed examples from the latest CI build: 152 | 153 | .. code-block:: bash 154 | 155 | python src/latest_docs_run.py download-examples 156 | 157 | You can select which examples to download. Use ``--help`` to see the available options. 158 | 159 | .. _nox: https://nox.thea.codes/ 160 | 161 | Chemiscope widgets 162 | ------------------ 163 | 164 | If you want to visualize one or more structures, or an interactive 165 | plot, in your example, you can use a `chemiscope `_ 166 | widget. To get some ideas on how the widgets can be used to better 167 | explain the recipes, you can start looking at the 168 | :ref:`examples from the cookbook `. 169 | 170 | .. marker-contrib-end 171 | 172 | Support 173 | ------- 174 | 175 | If you still have problems adding your example to the repository, please feel 176 | free to contact one of the developers, e.g. 177 | 178 | `@davidetisi (Davide Tisi) `_ 179 | 180 | Code of Conduct 181 | --------------- 182 | 183 | Please note that this project is released with a 184 | `Contributor Code of Conduct `_. 185 | By contributing to this project you agree to abide by its terms. 186 | -------------------------------------------------------------------------------- /INSTALLING.rst: -------------------------------------------------------------------------------- 1 | Installing a recipe 2 | =================== 3 | 4 | The main repository contains the source files of all recipes, but you 5 | should only fetch the entire repository if you plan on 6 | `contributing a recipe `_. 7 | If you are interested in learning the techniques discussed in a specific 8 | recipe, this is not recommended, as you will also have to understand the 9 | build mechanism for the website. 10 | 11 | .. marker-install-start 12 | 13 | Each recipe of the atomistic cookbook can be viewed online as an interactive 14 | HTML page, but can also be downloaded as a stand-alone ``.py`` script, or a 15 | ``.ipynb`` Jupyter notebook. To simplify setting up an environment that 16 | contains all the dependencies needed for each recipe, each recipe can 17 | be downloaded as an archive that contains the script and notebook 18 | versions, together with any necessary data file and an ``environment.yml`` file 19 | that you can use with conda to create a custom environment to run the example. 20 | If you have never used conda before, you may want to read this 21 | `beginners guide 22 | `_. 23 | 24 | .. code-block:: bash 25 | 26 | # Deflate the downloaded archive of the recipe 27 | unzip recipe.zip 28 | 29 | # Pick a path where to create the environment and replace 30 | # with it - this creates a local folder 31 | # to avoid cluttering the global conda folder 32 | conda env create --prefix --file environment.yml 33 | 34 | 35 | Whenever you want to run the recipe you just need to activate the environment 36 | and run the recipe file. 37 | 38 | .. code-block:: bash 39 | 40 | # When you want to use the environment 41 | conda env activate --name 42 | 43 | # You should be able to run the recipe within the environment 44 | python recipe.py 45 | 46 | 47 | The ``environment.yml`` contents should also help you set up your own 48 | conda or pip environment to run without having to enter the recipe-specific 49 | environment. 50 | 51 | Given that many recipes contain post-processing and visualizations that 52 | are used to render the HTML page of the recipe, you may prefer to run the 53 | recipe as a Jupyter notebook. If you want to do so and have not installed 54 | the dependencies globally, you will also have to create a kernel that uses 55 | the environment. Assuming you have a functioning Jupyter installation globally, 56 | you should run 57 | 58 | .. code-block:: bash 59 | 60 | # Activate the environment 61 | conda env activate --name 62 | pip install ipykernel # in case is not part of the environment 63 | 64 | # Create the kernel definition 65 | python -m ipykernel install --user --name recipei-env-path --display-name "Python (recipe)" 66 | 67 | # You can launch Jupyter from outside the conda environment, 68 | # unless you also need conda-installed executables. When you open 69 | # the notebook, make sure you selected "Python (recipe_env)" as the 70 | # kernel to run it 71 | jupyter lab recipe.ipynb 72 | 73 | .. marker-install-end 74 | 75 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2023, cosmo software cookbook developers 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | 3. Neither the name of the copyright holder nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | Source code for the Atomistic Cookbook 2 | ====================================== 3 | 4 | .. image:: ./docs/src/_static/cookbook-icon.svg 5 | :alt: A cookbook with a cover showing a water molecule and mathematical symbols 6 | :align: center 7 | :width: 30% 8 | 9 | 10 | This repository contains the source code for a collection of software recipes, 11 | that combine a multitude of libraries and modeling tools to perform computer 12 | simulations of matter at the atomic scale. It also contains the infrastructure to 13 | automatically compile and deploy the recipes as a GitHub pages site, 14 | accessible at `atomistic-cookbook.org `_. 15 | 16 | You usually don't need to clone the whole repository if you want to try 17 | a recipe: the files needed to execute one, as well as the environment 18 | description, can be downloaded from the corresponding page. 19 | You should get the entire repository if you want to build all recipes 20 | locally, or if you want to use it as a template for your own cookbook. 21 | 22 | Contributing 23 | ------------ 24 | 25 | If you want contribute an example, recipe or tutorial that combines multiple software 26 | tools together, check out the `contributing guidelines `_ first. 27 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | _static/all-examples-data.js 2 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | sphinx 2 | sphinx-sitemap 3 | sphinx-design 4 | sphinx-gallery 5 | sphinx-toggleprompt 6 | docutils 7 | furo 8 | chemiscope>=0.8.5 9 | -------------------------------------------------------------------------------- /docs/src/.gitignore: -------------------------------------------------------------------------------- 1 | sg_execution_times.rst 2 | all-examples.rst 3 | -------------------------------------------------------------------------------- /docs/src/_static/cookbook-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab-cosmo/atomistic-cookbook/5c526f3aa2f0eccfbdcac5160672d45eaa994e9f/docs/src/_static/cookbook-icon.png -------------------------------------------------------------------------------- /docs/src/_static/cookbook.css: -------------------------------------------------------------------------------- 1 | /* center logo text */ 2 | .sidebar-brand-text { 3 | text-align: center; 4 | } 5 | 6 | /* Hide sphinx gallery download buttons */ 7 | .sphx-glr-download-jupyter, .sphx-glr-download-python{ 8 | display: none; 9 | } -------------------------------------------------------------------------------- /docs/src/_static/daily-recipe.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | // Calculate days since Unix epoch (January 1, 1970) 3 | var millisecondsPerDay = 1000 * 60 * 60 * 24; 4 | var today = new Date(); 5 | var utcMidnight = Date.UTC(today.getFullYear(), today.getMonth(), today.getDate()); 6 | var epoch = Date.UTC(1970, 0, 1); 7 | var daysSinceEpoch = Math.floor((utcMidnight - epoch) / millisecondsPerDay); 8 | 9 | // Calculate index based on the day of the year 10 | var index = daysSinceEpoch % examplesData.length; 11 | 12 | // Get the example 13 | var example = examplesData[index]; 14 | 15 | // Build the HTML code 16 | var html = ''; 17 | html += '
'; 18 | html += '
'; 19 | html += '
'; 20 | html += ' '; 21 | html += '

' + example.title + '

'; 22 | html += ' ' + example.html + ''; 23 | html += '
'; 24 | html += ' ' + example.html; 25 | html += '
'; 26 | html += '
'; 27 | html += '
'; 28 | 29 | // Insert the HTML into the page 30 | var container = document.getElementById('daily-thumbnail'); 31 | if (container) { 32 | container.innerHTML = html; 33 | } 34 | })(); 35 | -------------------------------------------------------------------------------- /docs/src/conf.py: -------------------------------------------------------------------------------- 1 | import os 2 | import xml.etree.ElementTree as ET 3 | from datetime import datetime 4 | 5 | 6 | # Add any Sphinx extension module names here, as strings. 7 | extensions = [ 8 | "sphinx_sitemap", 9 | "sphinx_design", 10 | "sphinx.ext.viewcode", 11 | "sphinx.ext.intersphinx", 12 | "sphinx_gallery.load_style", 13 | "chemiscope.sphinx", 14 | ] 15 | 16 | templates_path = ["_templates"] 17 | exclude_patterns = ["_build"] 18 | 19 | project = "atomistic-cookbook" 20 | copyright = ( 21 | "BSD 3-Clause License, " 22 | f"Copyright (c) {datetime.now().date().year}, " 23 | "The atomistic cookbook team" 24 | ) 25 | 26 | intersphinx_mapping = { 27 | "ase": ("https://wiki.fysik.dtu.dk/ase/", None), 28 | "metatensor": ("https://docs.metatensor.org/latest/", None), 29 | "numpy": ("https://numpy.org/doc/stable/", None), 30 | "matplotlib": ("https://matplotlib.org/stable/", None), 31 | "python": ("https://docs.python.org/3", None), 32 | "featomic": ("https://metatensor.github.io/featomic/latest/", None), 33 | "scipy": ("https://docs.scipy.org/doc/scipy/", None), 34 | "torchpme": ("https://lab-cosmo.github.io/torch-pme/latest/", None), 35 | } 36 | 37 | html_js_files = [ 38 | ( # plausible.io tracking 39 | "https://plausible.io/js/script.file-downloads.hash.outbound-links.pageview-props.tagged-events.js", # noqa: E501 40 | {"data-domain": "atomistic-cookbook.org", "defer": "defer"}, 41 | ), 42 | "all-examples-data.js", # data for the recipe-of-the-day 43 | "daily-recipe.js", # loader for the recipe-of-the-day 44 | ] 45 | 46 | 47 | htmlhelp_basename = "The Atomistic Cookbook" 48 | html_theme = "furo" 49 | html_theme_options = { 50 | "top_of_page_buttons": [], 51 | } 52 | html_use_index = False 53 | html_static_path = ["_static"] 54 | html_favicon = "_static/cookbook-icon.png" 55 | html_logo = "_static/cookbook-icon.svg" 56 | html_title = "The Atomistic Cookbook" 57 | 58 | # sitemap/SEO settings 59 | html_baseurl = "https://atomistic-cookbook.org/" 60 | version = "" 61 | release = "" 62 | sitemap_url_scheme = "{link}" 63 | html_extra_path = ["google4ae5e3529d19a84c.html", "robots.txt"] 64 | 65 | 66 | # -- Custom post-build function --------------------------------------------- 67 | def post_build_tweaks(app, exception): 68 | """ 69 | Couple of small fixes (mostly SEO) after having 70 | built the docs. 71 | """ 72 | 73 | conf_dir = os.path.abspath(os.path.dirname(__file__)) 74 | build_folder = os.path.abspath(os.path.join(conf_dir, "..", "build", "html")) 75 | 76 | # adds custom urls to the sitemap 77 | custom_urls = [ 78 | {"loc": "https://atomistic-cookbook.org", "priority": 1.0}, 79 | ] 80 | 81 | sitemap_file = os.path.join(build_folder, "sitemap.xml") 82 | ET.register_namespace("", "http://www.sitemaps.org/schemas/sitemap/0.9") 83 | tree = ET.parse(sitemap_file) 84 | root = tree.getroot() 85 | 86 | for url in custom_urls: 87 | url_element = ET.SubElement(root, "url") 88 | loc_element = ET.SubElement(url_element, "loc") 89 | loc_element.text = url["loc"] 90 | if "priority" in url: 91 | priority_element = ET.SubElement(url_element, "priority") 92 | priority_element.text = str(url["priority"]) 93 | 94 | tree.write(sitemap_file) 95 | 96 | # changes the canonical name of the main page 97 | file_path = os.path.join(build_folder, "index.html") 98 | with open(file_path, "r", encoding="utf-8") as f: 99 | content = f.read() 100 | 101 | # Replace the canonical URL (if it exists) with the desired URL 102 | new_content = content.replace( 103 | '', 104 | r""" 105 | 106 | 107 | 120 | 152 | """, 153 | ) 154 | 155 | # Write the modified content back to index.html 156 | with open(file_path, "w", encoding="utf-8") as f: 157 | f.write(new_content) 158 | 159 | print(f"Canonical URL modified in {file_path}") 160 | 161 | 162 | def setup(app): 163 | app.connect("build-finished", post_build_tweaks) 164 | app.add_css_file("cookbook.css") 165 | -------------------------------------------------------------------------------- /docs/src/contributing.rst: -------------------------------------------------------------------------------- 1 | Contributing a recipe 2 | ===================== 3 | 4 | .. include:: ../../CONTRIBUTING.rst 5 | :start-after: marker-contrib-start 6 | :end-before: marker-contrib-end 7 | 8 | -------------------------------------------------------------------------------- /docs/src/downloading.rst: -------------------------------------------------------------------------------- 1 | Downloading and running the recipes 2 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3 | 4 | .. include:: ../../INSTALLING.rst 5 | :start-after: marker-install-start 6 | :end-before: marker-install-end 7 | -------------------------------------------------------------------------------- /docs/src/google4ae5e3529d19a84c.html: -------------------------------------------------------------------------------- 1 | google-site-verification: google4ae5e3529d19a84c.html -------------------------------------------------------------------------------- /docs/src/index.rst: -------------------------------------------------------------------------------- 1 | .. meta:: 2 | :description: Computational recipes for modeling matter at the atomic scale. 3 | Interactive guides that you can also run locally and use as templates for 4 | your own simulations. 5 | :keywords: Atomistic simulations, statistical mechanics, machine learning, 6 | molecular dynamics, quantum chemistry, materials modeling, 7 | computational chemistry 8 | 9 | The Atomistic Cookbook 10 | ====================== 11 | 12 | The cookbook contains recipes for atomic-scale modelling of materials and 13 | molecules, with a particular focus on machine learning and statistical 14 | sampling methods. 15 | Many of the examples rely heavily on software developed by the laboratory of 16 | computational science and modeling (COSMO, see its `github page 17 | `_) but the cookbook is open for recipes using 18 | all types of modeling tools and techniques. 19 | Rather than focusing on the usage of a specific package, this cookbook provides 20 | examples of the solution of concrete modeling problems, often using a combination 21 | of several tools. 22 | 23 | You can view the recipes online, compiled as webpages containing explanations, 24 | code snippets, plots and interactive viewers based on 25 | `chemiscope `_. However, it is also possible (and 26 | hopefully simple) to download scripts, and `conda environments 27 | `_, 28 | to run the recipe on your computer. You can use these as a starting point and 29 | a template that can be easily adapted to your own use case. 30 | 31 | Table of contents 32 | ~~~~~~~~~~~~~~~~~ 33 | 34 | .. toctree:: 35 | :maxdepth: 1 36 | 37 | topics/index 38 | software/index 39 | all-examples 40 | downloading 41 | contributing 42 | 43 | Recipe of the day 44 | ~~~~~~~~~~~~~~~~~ 45 | 46 | Want to try something new? Each day, one of the recipes in the cookbook 47 | is highlighted on the front page. There is one to suit everyone's taste! 48 | 49 | .. raw:: html 50 | 51 |
52 | -------------------------------------------------------------------------------- /docs/src/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | 3 | Disallow: /_sources/ 4 | Disallow: /_datasets/ 5 | Disallow: /_downloads/ 6 | 7 | Sitemap: https://atomistic-cookbook.org/sitemap.xml 8 | 9 | -------------------------------------------------------------------------------- /docs/src/software/.gitignore: -------------------------------------------------------------------------------- 1 | *.rst 2 | !index.rst 3 | -------------------------------------------------------------------------------- /docs/src/software/chemiscope.sec: -------------------------------------------------------------------------------- 1 | .. _chemiscope: 2 | 3 | chemiscope 4 | ========== 5 | 6 | Chemiscope is a tool for interactive exploration of databases of materials and 7 | molecules, correlating local and global structural representations with the 8 | properties of the systems. Chemiscope files can be viewed `online 9 | `_, generated using a `python library 10 | `_ and used inside jupyter notebooks or 11 | sphinx documentations, which is how it's used in the cookbook examples. You can 12 | check the `documentation `_ and the `github 13 | repository `_. 14 | 15 | - examples/roy-gch/roy-gch 16 | - examples/gaas-map/gaas-map 17 | - examples/pi-metad/pi-metad 18 | - examples/path-integrals/path-integrals 19 | - examples/thermostats/thermostats 20 | - examples/pi-mts-rpc/mts-rpc 21 | - examples/water-model/water-model 22 | - examples/polarizability/polarizability 23 | - examples/learn-tensors-with-mcov/learn-tensors-with-mcov 24 | - examples/pet-mad/pet-mad 25 | - examples/pet-mad/pet-mad-nc 26 | - examples/flashmd/flashmd-demo 27 | -------------------------------------------------------------------------------- /docs/src/software/cp2k.sec: -------------------------------------------------------------------------------- 1 | cp2k 2 | ==== 3 | 4 | CP2K is a quantum chemistry and solid state physics software package that can 5 | perform atomistic simulations of solid state, liquid, molecular, periodic, 6 | material, crystal, and biological systems. Learn more about it on its `homepage 7 | `_. 8 | 9 | - examples/batch-cp2k/reference-trajectory 10 | - examples/periodic-hamiltonian/periodic-hamiltonian 11 | -------------------------------------------------------------------------------- /docs/src/software/featomic.sec: -------------------------------------------------------------------------------- 1 | featomic 2 | ========= 3 | 4 | `featomic` is a library for the efficient computing of features for 5 | atomistic machine learning also called “representations”, 6 | “descriptors” or “fingerprints”. These features 7 | can be used for atomistic machine learning (ML) models including 8 | ML potentials, visualization or similarity analysis. You can learn how to use it 9 | reading the `documentation `_, and get the latest 10 | version from the `github repository `_ 11 | 12 | - examples/gaas-map/gaas-map 13 | - examples/lpr/lpr 14 | - examples/dos-align/dos-align 15 | - examples/lode-linear/lode-linear 16 | - examples/roy-gch/roy-gch 17 | - examples/sample-selection/sample-selection 18 | - examples/periodic-hamiltonian/periodic-hamiltonian 19 | - examples/rotate-equivariants/rotate-equivariants 20 | - examples/polarizability/polarizability 21 | - examples/learn-tensors-with-mcov/learn-tensors-with-mcov 22 | -------------------------------------------------------------------------------- /docs/src/software/i-pi.sec: -------------------------------------------------------------------------------- 1 | i-PI 2 | ==== 3 | 4 | i-PI is a universal force engine interface written in Python, designed to be 5 | used together with an ab-initio, machine-learned, or force-field based 6 | evaluation of the interactions between the atoms. You can see learn more about 7 | it on the `ipi-code website `_, the `documentation pages 8 | `_ or `the github repository 9 | `_. 10 | 11 | - examples/thermostats/thermostats 12 | - examples/path-integrals/path-integrals 13 | - examples/pi-metad/pi-metad 14 | - examples/heat-capacity/heat-capacity 15 | - examples/pi-mts-rpc/mts-rpc 16 | - examples/water-model/water-model 17 | - examples/pet-mad/pet-mad 18 | - examples/pet-mad-nc/pet-mad-nc 19 | - examples/flashmd/flashmd-demo 20 | -------------------------------------------------------------------------------- /docs/src/software/index.rst: -------------------------------------------------------------------------------- 1 | Recipes grouped by software used 2 | ================================ 3 | 4 | Cookbook recipes often combine multiple modeling tools. 5 | Here you can find them organized based on the software 6 | they use. They may give you ideas on how to use them 7 | in your own atomistic cooking. 8 | 9 | .. toctree:: 10 | :maxdepth: 1 11 | 12 | i-pi 13 | chemiscope 14 | featomic 15 | scikit-matter 16 | cp2k 17 | lammps 18 | metatensor 19 | plumed 20 | torch-pme 21 | -------------------------------------------------------------------------------- /docs/src/software/lammps.sec: -------------------------------------------------------------------------------- 1 | LAMMPS 2 | ====== 3 | 4 | LAMMPS is a classical molecular dynamics (MD) code, with a focus on materials 5 | simulations. It includes a wealth of interatomic potentials, and of basic and 6 | advanced molecular simulations techniques, and is highly parallelized using an 7 | efficient domain decomposition scheme. Learn more about LAMMPS on its `homepage 8 | `_. 9 | 10 | - examples/thermostats/thermostats 11 | - examples/path-integrals/path-integrals 12 | - examples/heat-capacity/heat-capacity 13 | - examples/water-model/water-model 14 | - examples/pet-mad/pet-mad 15 | -------------------------------------------------------------------------------- /docs/src/software/metatensor.sec: -------------------------------------------------------------------------------- 1 | metatensor 2 | ========== 3 | 4 | `Metatensor `_ 5 | is a library providing a cross-platform data interchange API 6 | for atomistic simulation and beyond. It also powers 7 | ``metatomic`` -- an API to define atomistic models that can be 8 | used to run simulations using several different atomistic 9 | simulation packages and ``metatrain`` a set of tools to facilitate 10 | training and evaluating ML models. 11 | 12 | - examples/water-model/water-model 13 | - examples/polarizability/polarizability 14 | - examples/learn-tensors-with-mcov/learn-tensors-with-mcov 15 | - examples/pet-mad/pet-mad 16 | - examples/pet-mad-nc/pet-mad-nc 17 | - examples/flashmd/flashmd-demo 18 | -------------------------------------------------------------------------------- /docs/src/software/plumed.sec: -------------------------------------------------------------------------------- 1 | PLUMED 2 | ====== 3 | 4 | PLUMED is an open-source, community-developed library that provides a wide range 5 | of different methods, which include enhanced-sampling algorithms, free-energy 6 | methods, tools to analyze the vast amounts of data produced by molecular 7 | dynamics (MD) simulations. These techniques can be used in combination with a 8 | large toolbox of collective variables that describe complex processes in 9 | physics, chemistry, material science, and biology. Documentation, examples and 10 | installation instructions for the various packages are discussed on the `PLUMED 11 | website `_. 12 | 13 | - examples/pi-metad/pi-metad 14 | -------------------------------------------------------------------------------- /docs/src/software/scikit-matter.sec: -------------------------------------------------------------------------------- 1 | scikit-matter 2 | ============= 3 | 4 | scikit-matter is a toolbox of methods developed in the computational chemical 5 | and materials science community, following the scikit-learn API and coding 6 | guidelines to promote usability and interoperability with existing workflows. 7 | You can get the latest version from its `github repository 8 | `_ and learn how to use 9 | it from its `documentation `_. 10 | 11 | - examples/sample-selection/sample-selection 12 | - examples/roy-gch/roy-gch 13 | - examples/lpr/lpr 14 | - examples/gaas-map/gaas-map 15 | -------------------------------------------------------------------------------- /docs/src/software/torch-pme.sec: -------------------------------------------------------------------------------- 1 | torch-pme 2 | ========= 3 | 4 | `torch-pme `_ 5 | provides a modular implementation of classical algorithms 6 | for the evaluation of long-range interactions (e.g. Ewald, 7 | particle-mesh Ewald - PME, and P3M). 8 | It can be used to build traditional electrostatic models, 9 | as well as long-range descriptors for machine-learning 10 | applications. 11 | 12 | - examples/water-model/water-model 13 | - examples/torchpme/torchpme_learning 14 | -------------------------------------------------------------------------------- /docs/src/topics/.gitignore: -------------------------------------------------------------------------------- 1 | *.rst 2 | !index.rst 3 | -------------------------------------------------------------------------------- /docs/src/topics/analysis.sec: -------------------------------------------------------------------------------- 1 | Analysis and post-processing 2 | ============================ 3 | 4 | This section contains recipes that analyze the output of a simulation, 5 | for post-processing, diagnostics or visualization purposes. 6 | 7 | - examples/gaas-map/gaas-map 8 | - examples/lpr/lpr 9 | - examples/roy-gch/roy-gch 10 | - examples/rotate-equivariants/rotate-equivariants 11 | -------------------------------------------------------------------------------- /docs/src/topics/index.rst: -------------------------------------------------------------------------------- 1 | Recipes grouped by topic 2 | ======================== 3 | 4 | You can navigate through the various recipes grouped 5 | in thematic areas, including classes of simulation problems 6 | and of modeling techniques. Recipes may be listed in 7 | more than one area, when relevant. 8 | 9 | .. toctree:: 10 | :maxdepth: 1 11 | 12 | sampling 13 | analysis 14 | ml-models 15 | nqes 16 | -------------------------------------------------------------------------------- /docs/src/topics/ml-models.sec: -------------------------------------------------------------------------------- 1 | Machine learning models 2 | ======================= 3 | 4 | This section contains recipes that concern the training of machine-learning 5 | models, or the pre-processing of data to optimize the model architecture or 6 | data. 7 | 8 | - examples/dos-align/dos-align 9 | - examples/lode-linear/lode-linear 10 | - examples/sample-selection/sample-selection 11 | - examples/periodic-hamiltonian/periodic-hamiltonian 12 | - examples/polarizability/polarizability 13 | - examples/learn-tensors-with-mcov/learn-tensors-with-mcov 14 | - examples/pet-mad/pet-mad 15 | - examples/pet-mad-nc/pet-mad-nc 16 | - examples/flashmd/flashmd-demo 17 | -------------------------------------------------------------------------------- /docs/src/topics/nqes.sec: -------------------------------------------------------------------------------- 1 | Nuclear quantum effects 2 | ======================= 3 | 4 | Most atomistic simulations treat nuclei as classical particles, that sample a 5 | Boltzmann distribution. This approximation breaks down for light nuclei 6 | (hydrogen above all) and high-frequency vibrations, requiring more sophisticated 7 | statistical sampling to compute accurate statistical and dynamical properties. 8 | 9 | - examples/path-integrals/path-integrals 10 | - examples/pi-metad/pi-metad 11 | - examples/heat-capacity/heat-capacity 12 | - examples/pi-mts-rpc/mts-rpc 13 | -------------------------------------------------------------------------------- /docs/src/topics/sampling.sec: -------------------------------------------------------------------------------- 1 | Statistical sampling and dynamics 2 | ================================= 3 | 4 | This section contains recipes that compute thermodynamic averages by sampling, 5 | evaluates dynamical properties, or otherwise computes the properties of a 6 | set of configurations of an atomistic system. 7 | 8 | - examples/thermostats/thermostats 9 | - examples/path-integrals/path-integrals 10 | - examples/pi-metad/pi-metad 11 | - examples/batch-cp2k/reference-trajectory 12 | - examples/heat-capacity/heat-capacity 13 | - examples/pi-mts-rpc/mts-rpc 14 | - examples/water-model/water-model 15 | -------------------------------------------------------------------------------- /examples/INSTALLING.rst: -------------------------------------------------------------------------------- 1 | Installation instructions 2 | ========================= 3 | 4 | These installation instructions are common to all recipes from the 5 | `atomistic cookbook `_ and should help 6 | you getting started. We refer to generic ``recipe.*`` filenames, but 7 | it should be obvious what files you should use at each step. 8 | When using the recipes keep in mind that examples 9 | are designed to showcase a modeling technique or a software package, 10 | and are constrained to have limited execution time, so the simulation 11 | parameters are pushed to the limits and may require adjustment when 12 | running a production calculation. 13 | 14 | You should be reading this from within a folder you obtained as a 15 | ``recipe.zip`` archive, either from the website or from a colleague. 16 | Each recipe consists of a a stand-alone ``.py`` script, a matching 17 | ``.ipynb`` Jupyter notebook, an ``environment.yml`` file that allows 18 | recreating an environment to run the recipe, and possibly one or more 19 | supporting data files. 20 | 21 | The fist step to run your recipe is to create a `conda` custom environment 22 | If you have never used conda before, you may want to read this 23 | `beginners guide `_. 24 | 25 | .. code-block:: bash 26 | 27 | # Deflate the downloaded archive of the recipe 28 | unzip recipe.zip # you may have done this already 29 | 30 | # Pick a path where to create the environment and replace 31 | # with it - this creates a local folder 32 | # to avoid cluttering the global conda folder 33 | conda env create --prefix --file environment.yml 34 | 35 | 36 | Whenever you want to run the recipe you just need to activate the environment 37 | and run the recipe file. 38 | 39 | .. code-block:: bash 40 | 41 | # When you want to use the environment 42 | conda env activate --name 43 | 44 | # You should be able to run the recipe within the environment 45 | python recipe.py 46 | 47 | 48 | The ``environment.yml`` contents should also help you set up your own 49 | conda or pip environment to run without having to enter the recipe-specific 50 | environment. 51 | 52 | Given that many recipes contain post-processing and visualizations that 53 | are used to render the HTML page of the recipe, you may prefer to run the 54 | recipe as a Jupyter notebook. If you want to do so and have not installed 55 | the dependencies globally, you will also have to create a kernel that uses 56 | the environment. Assuming you have a functioning Jupyter installation globally, 57 | you should run 58 | 59 | .. code-block:: bash 60 | 61 | # Activate the environment 62 | conda env activate --name 63 | pip install ipykernel # in case is not part of the environment 64 | 65 | # Create the kernel definition 66 | python -m ipykernel install --user --name recipei-env-path --display-name "Python (recipe)" 67 | 68 | # You can launch Jupyter from outside the conda environment, 69 | # unless you also need conda-installed executables. When you open 70 | # the notebook, make sure you selected "Python (recipe_env)" as the 71 | # kernel to run it 72 | jupyter lab recipe.ipynb 73 | -------------------------------------------------------------------------------- /examples/batch-cp2k/.gitignore: -------------------------------------------------------------------------------- 1 | production/ 2 | parameters/ 3 | 4 | cp2k.out 5 | cp2k.inp 6 | -------------------------------------------------------------------------------- /examples/batch-cp2k/README.rst: -------------------------------------------------------------------------------- 1 | CP2K bash computation 2 | ============================ 3 | 4 | This is an example of a batch calculation using CP2K. 5 | The inputs are a set of structures in `example.xyz` 6 | using the parameters defined in `./data/reftraj_template.cp2k` 7 | importing basisset and pseudopotentials from the local CP2K install. 8 | -------------------------------------------------------------------------------- /examples/batch-cp2k/environment.yml: -------------------------------------------------------------------------------- 1 | channels: 2 | - conda-forge 3 | dependencies: 4 | - python=3.11 5 | - pip 6 | - pip: 7 | - ase 8 | - matplotlib 9 | -------------------------------------------------------------------------------- /examples/batch-cp2k/example.xyz: -------------------------------------------------------------------------------- 1 | 6 2 | Lattice="3.9111732301689224 0.0 0.0 0.0 3.9111732301689224 0.0 0.0 0.0 3.9111732301689224" Properties=species:S:1:pos:R:3 #=T CELL(abcABC):=T 3.91117=T 90.00000=T Step:=T 1975600=T Bead:=T 0=T x_centroidangstrom=T cellangstrom=T count=0 pbc="T T T" 3 | H 2.55799292 0.30476323 0.67883354 4 | H 1.46739292 0.53584100 3.59015677 5 | O 1.78619292 3.82685646 0.31171354 6 | H 3.52058031 2.55936677 2.71091323 7 | H 0.84863385 2.05009677 1.85452646 8 | O 0.09813385 1.75660677 2.33837646 9 | -------------------------------------------------------------------------------- /examples/batch-cp2k/reftraj_template.cp2k: -------------------------------------------------------------------------------- 1 | @SET PREP 0 2 | 3 | @SET SCF_GUESS RESTART 4 | @SET SCREEN_ON_INITIAL_P TRUE 5 | 6 | @IF ${PREP} 7 | @SET SCF_GUESS ATOMIC 8 | @SET SCREEN_ON_INITIAL_P FALSE 9 | @ENDIF 10 | 11 | &GLOBAL 12 | PROJECT //PROJECT// 13 | PREFERRED_FFT_LIBRARY FFTW 14 | FFTW_PLAN_TYPE MEASURE 15 | RUN_TYPE MD 16 | PRINT_LEVEL LOW 17 | &END GLOBAL 18 | 19 | &MOTION 20 | &PRINT 21 | &CELL 22 | &EACH 23 | MD 1 24 | &END EACH 25 | &END CELL 26 | &FORCES 27 | &EACH 28 | MD 1 29 | &END EACH 30 | &END FORCES 31 | &END PRINT 32 | &MD 33 | ENSEMBLE REFTRAJ 34 | &REFTRAJ ! Loads an external trajectory file and performs analysis on the loaded snapshots. 35 | EVAL_ENERGY_FORCES TRUE 36 | EVAL_FORCES TRUE 37 | CELL_FILE_NAME reftraj.cell 38 | TRAJ_FILE_NAME reftraj.xyz 39 | FIRST_SNAPSHOT 1 40 | VARIABLE_VOLUME TRUE 41 | LAST_SNAPSHOT //LAST_SNAPSHOT// 42 | &END REFTRAJ 43 | &END MD 44 | &END MOTION 45 | 46 | &FORCE_EVAL 47 | &PRINT 48 | &FORCES 49 | &EACH 50 | MD 1 51 | &END EACH 52 | &END FORCES 53 | &END PRINT 54 | &DFT 55 | BASIS_SET_FILE_NAME ../../parameters/GTH_BASIS_SETS 56 | BASIS_SET_FILE_NAME ../../parameters/BASIS_ADMM 57 | POTENTIAL_FILE_NAME ../../parameters/POTENTIAL 58 | &MGRID 59 | CUTOFF 400 60 | &END MGRID 61 | &SCF 62 | SCF_GUESS ${SCF_GUESS} 63 | MAX_SCF 20 64 | EPS_SCF 5.0E-7 65 | &OT 66 | MINIMIZER DIIS 67 | PRECONDITIONER FULL_ALL 68 | &END OT 69 | &OUTER_SCF 70 | MAX_SCF 20 71 | EPS_SCF 5.0E-7 72 | &END OUTER_SCF 73 | &END SCF 74 | &QS 75 | EPS_DEFAULT 1.0E-12 76 | EPS_PGF_ORB 1.0E-16 77 | EXTRAPOLATION_ORDER 5 78 | &END QS 79 | &XC # revPBE0-TC-D3 80 | &XC_FUNCTIONAL 81 | &PBE 82 | PARAMETRIZATION REVPBE 83 | SCALE_X 0.75 84 | SCALE_C 1.0 85 | &END 86 | &END XC_FUNCTIONAL 87 | &HF 88 | FRACTION 0.25 89 | &SCREENING 90 | EPS_SCHWARZ 1.0E-6 91 | SCREEN_ON_INITIAL_P ${SCREEN_ON_INITIAL_P} 92 | &END 93 | &MEMORY 94 | MAX_MEMORY 37000 95 | EPS_STORAGE_SCALING 0.1 96 | &END 97 | &INTERACTION_POTENTIAL 98 | POTENTIAL_TYPE TRUNCATED 99 | CUTOFF_RADIUS 3.0 100 | T_C_G_DATA ../../parameters/t_c_g.dat 101 | &END 102 | &HF_INFO 103 | &END HF_INFO 104 | &END 105 | &VDW_POTENTIAL 106 | POTENTIAL_TYPE PAIR_POTENTIAL 107 | &PAIR_POTENTIAL 108 | TYPE DFTD3 109 | R_CUTOFF 15 110 | LONG_RANGE_CORRECTION TRUE 111 | REFERENCE_FUNCTIONAL revPBE0 112 | PARAMETER_FILE_NAME ../../parameters/dftd3.dat 113 | &END 114 | &END 115 | &XC_GRID 116 | XC_DERIV SPLINE2 117 | &END 118 | &END XC 119 | &AUXILIARY_DENSITY_MATRIX_METHOD 120 | METHOD BASIS_PROJECTION 121 | ADMM_PURIFICATION_METHOD MO_DIAG 122 | &END AUXILIARY_DENSITY_MATRIX_METHOD 123 | &END DFT 124 | &SUBSYS 125 | &TOPOLOGY 126 | COORD_FILE_NAME init.xyz 127 | COORD_FILE_FORMAT XYZ 128 | CONN_FILE_FORMAT GENERATE 129 | &END TOPOLOGY 130 | &CELL 131 | ABC [angstrom] //CELL// 132 | &END CELL 133 | &KIND H 134 | BASIS_SET TZV2P-GTH 135 | BASIS_SET AUX_FIT cpFIT3 136 | POTENTIAL GTH-PBE-q1 137 | &END KIND 138 | &KIND O 139 | BASIS_SET TZV2P-GTH 140 | BASIS_SET AUX_FIT cpFIT3 141 | POTENTIAL GTH-PBE-q6 142 | &END KIND 143 | &END SUBSYS 144 | &END FORCE_EVAL 145 | -------------------------------------------------------------------------------- /examples/batch-cp2k/run_calcs.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | for i in $(find ./production/ -mindepth 1 -type d); do 4 | cd $i 5 | cp2k.ssmp -i in.cp2k 6 | cd - 7 | done 8 | -------------------------------------------------------------------------------- /examples/dos-align/README.rst: -------------------------------------------------------------------------------- 1 | Optimizing the energy reference of the DOS during training 2 | ========================================================== 3 | 4 | This example illustrates how one can optimize the energy reference of the 5 | DOS during model training. The dataset consists 104 Silicon diamond structures. 6 | There are 2 atoms in each unit cell. 7 | 8 | The example uses ``ase`` to process quantum-espresso output files, 9 | ``rascaline`` to compute structural descriptors, ``scipy`` to calculate 10 | cubic Hermite splines and ``matplotlib`` for visualisation. 11 | -------------------------------------------------------------------------------- /examples/dos-align/environment.yml: -------------------------------------------------------------------------------- 1 | channels: 2 | - conda-forge 3 | dependencies: 4 | - python=3.11 5 | - pip 6 | - rust > 1.65 7 | - pip: 8 | - ase==3.22.1 9 | - matplotlib 10 | - featomic 11 | - torch 12 | - scipy 13 | - numpy 14 | -------------------------------------------------------------------------------- /examples/flashmd/README.rst: -------------------------------------------------------------------------------- 1 | FlashMD tutorial 2 | ================ 3 | 4 | An example of using the FlashMD universal direct MD scheme 5 | using i-PI. 6 | -------------------------------------------------------------------------------- /examples/flashmd/data/input-al110-base.xml: -------------------------------------------------------------------------------- 1 | 2 | 1000 3 | 4 | positions 5 | [ step, time{picosecond}, temperature{kelvin}, potential{electronvolt}, conserved{electronvolt} ] 6 | velocities 7 | 8 | 9 | 32123 10 | 11 | 12 | metatensor 13 | {template:data/al110.xyz,model:pet-mad-latest.pt,device:cpu} 14 | 15 | 16 | 17 | 18 | 19 | 20 | data/al110.xyz 21 | 600 22 | 23 | 24 | 25 | 64 26 | 100 27 | 28 | 29 | 30 | 600 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /examples/flashmd/data/input-ala2-base.xml: -------------------------------------------------------------------------------- 1 | 2 | 1000 3 | 4 | positions 5 | [ step, time{picosecond}, temperature{kelvin}, potential{electronvolt}, conserved{electronvolt}, pressure_md{bar}, volume{angstrom3} ] 6 | velocities 7 | 8 | 9 | 32123 10 | 11 | 12 | metatensor 13 | {template:data/ala2.xyz,model:pet-mad-latest.pt,device:cpu} 14 | 15 | 16 | 17 | 18 | 19 | 20 | data/ala2.xyz 21 | 450 22 | 23 | 24 | 25 | 16 26 | 100 27 | 28 | 29 | 100 30 | 31 | 200 32 | 33 | 34 | 35 | 36 | 450 37 | 1.0 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /examples/flashmd/environment.yml: -------------------------------------------------------------------------------- 1 | channels: 2 | - metatensor 3 | - conda-forge 4 | dependencies: 5 | - python=3.12 6 | - pip 7 | - pip: 8 | - ase>=3.23 9 | - ipi==3.1.5 10 | - pet-mad>=1.1.0,<1.2 11 | - vesin[torch]>=0.3.2,<0.4 12 | - flashmd>=0.1.1 13 | - chemiscope>=0.8.5,<0.9 14 | - matplotlib 15 | -------------------------------------------------------------------------------- /examples/flashmd/flashmd-demo.py: -------------------------------------------------------------------------------- 1 | """ 2 | Long-stride trajectories with a universal FlashMD model 3 | ======================================================= 4 | 5 | :Authors: Michele Ceriotti `@ceriottm `_ 6 | 7 | This example demonstrates how to run long-stride molecular dynamics using the 8 | universal FlashMD model. FlashMD predicts directly positions and momenta of atoms 9 | at a later time based on the current positions and momenta. 10 | It is trained on MD trajectories obtained with the 11 | `PET-MAD universal potential `_. 12 | You can read more about the model and its limitations in 13 | `this preprint `_. 14 | """ 15 | 16 | # %% 17 | # 18 | # Start by importing the required libraries. You will need the 19 | # `PET-MAD potential `_, 20 | # as well as `FlashMD `_ 21 | # and a recent version of `i-PI `_. 22 | # 23 | # .. code-block:: bash 24 | # 25 | # pip install pet-mad flashmd ipi 26 | # 27 | 28 | import chemiscope 29 | import matplotlib.image as mpimg 30 | import matplotlib.pyplot as plt 31 | from flashmd import get_universal_model 32 | from flashmd.ipi import get_npt_stepper, get_nvt_stepper 33 | from ipi.utils.parsing import read_output, read_trajectory 34 | from ipi.utils.scripting import InteractiveSimulation 35 | from pet_mad.calculator import PETMADCalculator 36 | 37 | 38 | # %% 39 | # A rough schematic of the architecture of FlashMD is shown below. 40 | # Each model is trained for a specific stride length, aiming to 41 | # reproduce the trajectories obtained with a traditional velocity 42 | # Verlet integrator. 43 | 44 | # use matplotlib to display the image so it also display as a thumbnail 45 | fig, ax = plt.subplots(figsize=(5728 / 300, 2598 / 300), dpi=300) 46 | img = mpimg.imread("flashmd-scheme.png") 47 | ax.imshow(img) 48 | ax.axis("off") 49 | fig.tight_layout() 50 | plt.show() 51 | 52 | 53 | # %% 54 | # We start by getting the FlashMD models from the ``flashmd`` package. 55 | # We will also use the PET-MAD universal potential as an accompanying energy model 56 | 57 | device = "cpu" # change to "cuda" if you have a GPU; don't forget to change it in the 58 | # i-PI xml input files as well! 59 | 60 | flashmd_model_16 = get_universal_model(16) 61 | flashmd_model_16.to(device) 62 | 63 | flashmd_model_64 = get_universal_model(64) 64 | flashmd_model_64.to(device) 65 | 66 | calculator = PETMADCalculator(version="latest", device=device) 67 | calculator._model.save("pet-mad-latest.pt") 68 | 69 | 70 | # %% 71 | # Al(110) surface dynamics 72 | # ------------------------ 73 | # 74 | # The (110) surface of aluminum exhibits `an interesting dynamical behavior 75 | # `_ well below the bulk melting 76 | # temperature. This manifests itself in the spontaneous formation of surface 77 | # defects, with mobile adatoms emerging at the surface. 78 | # 79 | # We run a FlashMD simulation with 64 fs strides (as opposed to 1 or 2 fs) at 80 | # 600 K, observing the motion of the adatom at the surface. We use the 81 | # ``i-PI`` scripting API to set up the simulation and run it interactively. 82 | 83 | # %% 84 | # The starting point is a "base" XML file that contains the setup for a traditional 85 | # MD simulation in i-PI. It contains PET-MAD as the potential energy calculator 86 | # (needed for the optional energy rescaling filter), and the only difference is 87 | # the use of a much larger large time step than conventional MD. 88 | 89 | with open("data/input-al110-base.xml", "r") as input_xml: 90 | sim = InteractiveSimulation(input_xml) 91 | 92 | # %% 93 | # To run FlashMD, we set up a custom step, using the ``get_nvt_stepper`` 94 | # utility function from the `flashmd.ipi` module. Note the filters 95 | # ``rescale_energy=True`` and ``random_rotation=True``. The first one 96 | # ensures that the total energy of the system is conserved, while the second one 97 | # allows for random rotations of the system, which is useful to correct for the 98 | # fact that the model is not exactly equivariant with respect to rotations. 99 | 100 | sim.set_motion_step( 101 | get_nvt_stepper( 102 | sim, flashmd_model_64, device, rescale_energy=True, random_rotation=True 103 | ) 104 | ) 105 | 106 | # run for a few steps - this is a large box, and is rather slow on CPU 107 | sim.run(20) 108 | 109 | # %% 110 | # The trajectory is stable, and one can check that the mean fluctuations 111 | # of the adatom are qualitatively correct, by comparing with a (much slower) 112 | # PET-MAD simulation. 113 | 114 | data, info = read_output("al110-nvt-flashmd.out") 115 | trj = read_trajectory("al110-nvt-flashmd.pos_0.extxyz") 116 | 117 | chemiscope.show( 118 | frames=trj, 119 | properties={ 120 | "time": data["time"], 121 | "potential": data["potential"], 122 | "temperature": data["temperature"], 123 | }, 124 | mode="default", 125 | settings=chemiscope.quick_settings( 126 | map_settings={ 127 | "x": {"property": "time", "scale": "linear"}, 128 | "y": {"property": "potential", "scale": "linear"}, 129 | }, 130 | structure_settings={ 131 | "unitCell": True, 132 | }, 133 | trajectory=True, 134 | ), 135 | ) 136 | 137 | # %% 138 | # Solvated alanine dipeptide 139 | # -------------------------- 140 | # 141 | # As a second example, we run a constant-pressure simulation of explicitly 142 | # solvated alanine dipeptide, using the FlashMD universal model with 16 fs 143 | # time steps (as opposed to 0.5 fs). The setup is very similar to the previous 144 | # example, but we use an input template that contains a NpT setup, and use 145 | # the ``get_npt_stepper`` utility function to set up a stepper that 146 | # combine the FlashMD velocity-Verlet step with cell updates. 147 | 148 | with open("data/input-ala2-base.xml", "r") as input_xml: 149 | sim = InteractiveSimulation(input_xml) 150 | 151 | sim.set_motion_step( 152 | get_npt_stepper( 153 | sim, flashmd_model_16, device, rescale_energy=True, random_rotation=True 154 | ) 155 | ) 156 | sim.run(10) # only run 10 steps, again, pretty slow on CPU 157 | 158 | # %% 159 | # The cell fluctuates around the equilibrium volume, in a way that 160 | # is consistent with the correct NpT ensemble. The trajectory is stable 161 | # and the alanine molecule explores the different conformations 162 | # (obviously when running for a reasonably long time). 163 | 164 | data, info = read_output("ala2-npt-flashmd.out") 165 | trj = read_trajectory("ala2-npt-flashmd.pos_0.extxyz") 166 | 167 | chemiscope.show( 168 | frames=trj, 169 | properties={ 170 | "time": data["time"], 171 | "volume": data["volume"], 172 | "potential": data["potential"], 173 | "pressure": data["pressure_md"], 174 | "temperature": data["temperature"], 175 | }, 176 | mode="default", 177 | settings=chemiscope.quick_settings( 178 | map_settings={ 179 | "x": {"property": "time", "scale": "linear"}, 180 | "y": {"property": "volume", "scale": "linear"}, 181 | }, 182 | structure_settings={ 183 | "unitCell": True, 184 | }, 185 | trajectory=True, 186 | ), 187 | ) 188 | # %% 189 | -------------------------------------------------------------------------------- /examples/flashmd/flashmd-scheme.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab-cosmo/atomistic-cookbook/5c526f3aa2f0eccfbdcac5160672d45eaa994e9f/examples/flashmd/flashmd-scheme.png -------------------------------------------------------------------------------- /examples/gaas-map/.gitignore: -------------------------------------------------------------------------------- 1 | gaas_training.xyz 2 | gaas_map.chemiscope.json.gz 3 | -------------------------------------------------------------------------------- /examples/gaas-map/README.rst: -------------------------------------------------------------------------------- 1 | Structure-property map for a GaAs training set 2 | ============================================== 3 | 4 | This is an example of the analysis of a training set for ML potentials. 5 | The data consists in a collection of Ga(x)As(1-x) structures, spanning 6 | a broad range of geometries and compositions. 7 | 8 | The example uses ``rascaline`` to compute structural descriptors, and 9 | ``scikit-matter`` to determine an informative low-dimensional representation. 10 | Finally, the resulting map is visualized using ``chemiscope`` widgets, 11 | including also the visualization of force data as vector shapes. 12 | -------------------------------------------------------------------------------- /examples/gaas-map/environment.yml: -------------------------------------------------------------------------------- 1 | channels: 2 | - conda-forge 3 | dependencies: 4 | - python=3.11 5 | - pip 6 | - rust >=1.65 7 | - pip: 8 | - ase==3.22.1 9 | - chemiscope>=0.7 10 | - matplotlib 11 | - metatensor 12 | - featomic 13 | - scikit-learn 14 | - skmatter 15 | -------------------------------------------------------------------------------- /examples/heat-capacity/README.rst: -------------------------------------------------------------------------------- 1 | Heat capacity of water from path integral molecular dynamics 2 | ============================================================ 3 | 4 | This example shows how to calculate the constant-volume heat 5 | capacity from a path integral molecular dynamics simulation 6 | using ``i-PI``. `LAMMPS `_ is used 7 | as the driver for the evaluation of the q-TIP4P/f water model. 8 | -------------------------------------------------------------------------------- /examples/heat-capacity/data/in.lmp: -------------------------------------------------------------------------------- 1 | units electron 2 | atom_style full 3 | 4 | pair_style lj/cut/tip4p/long 1 2 1 1 0.278072379 17.001 5 | # high-pppm precision and shift to get meaningful fd estimates 6 | kspace_style pppm/tip4p 1e-5 7 | pair_modify shift yes 8 | bond_style class2 9 | angle_style harmonic 10 | 11 | 12 | read_data data/water_32_data.lmp 13 | pair_coeff * * 0 0 14 | pair_coeff 1 1 0.000295147 5.96946 15 | 16 | neighbor 2.0 bin 17 | 18 | 19 | timestep 0.00025 20 | 21 | #velocity all create 298.0 2345187 22 | 23 | #thermo_style multi 24 | #thermo 1 25 | 26 | #fix 1 all nvt temp 298.0 298.0 30.0 tchain 1 27 | #fix 1 all nve 28 | fix 1 all ipi h2o-lammps 32342 unix 29 | 30 | 31 | #dump 1 all xyz 25 dump.xyz 32 | 33 | run 100000000 34 | 35 | -------------------------------------------------------------------------------- /examples/heat-capacity/data/input.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | [ step, time{picosecond}, conserved, potential, kinetic_cv, 5 | scaledcoords(fd_delta=5e-3) ] 6 | 7 | 8 | 2000 9 | 10 | 32342 11 | 12 | 13 |
h2o-lammps
1e-4 14 |
15 | 16 | 17 | data/water_32.pdb 18 | 298 19 | 20 | 21 | lmpserial 22 | 23 | 24 | 298 25 | 26 | 27 | 28 | 29 | 5.0 30 | 31 | 0.5 32 | 33 | 34 | 35 |
36 | -------------------------------------------------------------------------------- /examples/heat-capacity/data/water_32.pdb: -------------------------------------------------------------------------------- 1 | CRYST1 10.260 10.260 10.260 90.00 90.00 90.00 P 1 2 | ATOM 1 O 1 1 3.756 4.710 9.494 0.00 0.00 O 3 | ATOM 2 H 1 1 4.604 4.272 9.671 0.00 0.00 H 4 | ATOM 3 H 1 1 3.998 5.320 8.788 0.00 0.00 H 5 | ATOM 4 O 1 1 9.933 8.841 0.366 0.00 0.00 O 6 | ATOM 5 H 1 1 10.132 8.196 1.120 0.00 0.00 H 7 | ATOM 6 H 1 1 9.368 8.449 -0.316 0.00 0.00 H 8 | ATOM 7 O 1 1 0.321 1.492 5.796 0.00 0.00 O 9 | ATOM 8 H 1 1 -0.287 1.993 5.241 0.00 0.00 H 10 | ATOM 9 H 1 1 0.791 2.061 6.364 0.00 0.00 H 11 | ATOM 10 O 1 1 8.035 9.735 4.307 0.00 0.00 O 12 | ATOM 11 H 1 1 7.203 9.789 4.847 0.00 0.00 H 13 | ATOM 12 H 1 1 8.636 9.307 4.920 0.00 0.00 H 14 | ATOM 13 O 1 1 5.663 9.082 0.660 0.00 0.00 O 15 | ATOM 14 H 1 1 6.378 9.721 0.814 0.00 0.00 H 16 | ATOM 15 H 1 1 5.213 8.991 1.552 0.00 0.00 H 17 | ATOM 16 O 1 1 8.130 0.215 1.201 0.00 0.00 O 18 | ATOM 17 H 1 1 8.196 -0.065 2.118 0.00 0.00 H 19 | ATOM 18 H 1 1 8.938 -0.161 0.818 0.00 0.00 H 20 | ATOM 19 O 1 1 8.177 4.165 0.716 0.00 0.00 O 21 | ATOM 20 H 1 1 7.895 5.066 0.840 0.00 0.00 H 22 | ATOM 21 H 1 1 7.722 3.562 1.341 0.00 0.00 H 23 | ATOM 22 O 1 1 6.341 3.256 9.678 0.00 0.00 O 24 | ATOM 23 H 1 1 7.133 3.423 10.189 0.00 0.00 H 25 | ATOM 24 H 1 1 6.507 2.398 9.350 0.00 0.00 H 26 | ATOM 25 O 1 1 0.136 7.798 2.738 0.00 0.00 O 27 | ATOM 26 H 1 1 -0.006 8.300 3.584 0.00 0.00 H 28 | ATOM 27 H 1 1 0.314 6.905 2.966 0.00 0.00 H 29 | ATOM 28 O 1 1 5.027 2.563 6.169 0.00 0.00 O 30 | ATOM 29 H 1 1 5.538 3.336 6.262 0.00 0.00 H 31 | ATOM 30 H 1 1 5.313 2.031 6.922 0.00 0.00 H 32 | ATOM 31 O 1 1 7.164 2.542 2.418 0.00 0.00 O 33 | ATOM 32 H 1 1 6.248 2.467 2.667 0.00 0.00 H 34 | ATOM 33 H 1 1 7.384 1.681 2.057 0.00 0.00 H 35 | ATOM 34 O 1 1 3.336 9.051 3.265 0.00 0.00 O 36 | ATOM 35 H 1 1 2.818 8.341 2.787 0.00 0.00 H 37 | ATOM 36 H 1 1 2.733 9.794 3.398 0.00 0.00 H 38 | ATOM 37 O 1 1 1.476 1.420 0.819 0.00 0.00 O 39 | ATOM 38 H 1 1 1.060 0.568 0.631 0.00 0.00 H 40 | ATOM 39 H 1 1 1.582 1.509 1.770 0.00 0.00 H 41 | ATOM 40 O 1 1 1.222 4.946 3.218 0.00 0.00 O 42 | ATOM 41 H 1 1 2.111 4.703 3.522 0.00 0.00 H 43 | ATOM 42 H 1 1 1.342 4.956 2.245 0.00 0.00 H 44 | ATOM 43 O 1 1 6.790 6.491 4.488 0.00 0.00 O 45 | ATOM 44 H 1 1 7.083 5.755 5.074 0.00 0.00 H 46 | ATOM 45 H 1 1 6.747 7.293 4.975 0.00 0.00 H 47 | ATOM 46 O 1 1 9.330 3.465 4.430 0.00 0.00 O 48 | ATOM 47 H 1 1 9.974 3.956 3.918 0.00 0.00 H 49 | ATOM 48 H 1 1 8.583 3.143 3.966 0.00 0.00 H 50 | ATOM 49 O 1 1 7.484 4.543 6.379 0.00 0.00 O 51 | ATOM 50 H 1 1 7.604 4.450 7.328 0.00 0.00 H 52 | ATOM 51 H 1 1 8.241 4.098 5.987 0.00 0.00 H 53 | ATOM 52 O 1 1 0.448 5.701 8.219 0.00 0.00 O 54 | ATOM 53 H 1 1 0.573 4.840 7.871 0.00 0.00 H 55 | ATOM 54 H 1 1 0.720 5.651 9.123 0.00 0.00 H 56 | ATOM 55 O 1 1 0.736 4.082 0.545 0.00 0.00 O 57 | ATOM 56 H 1 1 1.032 3.147 0.501 0.00 0.00 H 58 | ATOM 57 H 1 1 -0.250 3.978 0.476 0.00 0.00 H 59 | ATOM 58 O 1 1 4.229 2.582 3.562 0.00 0.00 O 60 | ATOM 59 H 1 1 4.650 2.364 4.424 0.00 0.00 H 61 | ATOM 60 H 1 1 4.306 3.526 3.496 0.00 0.00 H 62 | ATOM 61 O 1 1 3.749 5.318 3.591 0.00 0.00 O 63 | ATOM 62 H 1 1 3.577 5.600 2.690 0.00 0.00 H 64 | ATOM 63 H 1 1 4.519 5.812 3.831 0.00 0.00 H 65 | ATOM 64 O 1 1 0.242 8.540 5.195 0.00 0.00 O 66 | ATOM 65 H 1 1 0.243 9.452 5.454 0.00 0.00 H 67 | ATOM 66 H 1 1 0.725 8.102 5.864 0.00 0.00 H 68 | ATOM 67 O 1 1 6.065 0.243 8.171 0.00 0.00 O 69 | ATOM 68 H 1 1 6.685 -0.360 8.559 0.00 0.00 H 70 | ATOM 69 H 1 1 5.235 -0.020 8.586 0.00 0.00 H 71 | ATOM 70 O 1 1 7.362 8.029 9.049 0.00 0.00 O 72 | ATOM 71 H 1 1 6.719 7.831 8.312 0.00 0.00 H 73 | ATOM 72 H 1 1 6.813 7.839 9.757 0.00 0.00 H 74 | ATOM 73 O 1 1 1.971 1.171 3.631 0.00 0.00 O 75 | ATOM 74 H 1 1 1.520 1.399 4.474 0.00 0.00 H 76 | ATOM 75 H 1 1 2.821 1.577 3.533 0.00 0.00 H 77 | ATOM 76 O 1 1 7.674 6.605 2.134 0.00 0.00 O 78 | ATOM 77 H 1 1 7.143 6.490 2.918 0.00 0.00 H 79 | ATOM 78 H 1 1 8.563 6.681 2.409 0.00 0.00 H 80 | ATOM 79 O 1 1 2.769 7.384 7.275 0.00 0.00 O 81 | ATOM 80 H 1 1 2.353 8.088 7.748 0.00 0.00 H 82 | ATOM 81 H 1 1 2.249 6.554 7.408 0.00 0.00 H 83 | ATOM 82 O 1 1 2.253 2.791 7.349 0.00 0.00 O 84 | ATOM 83 H 1 1 2.718 3.230 8.076 0.00 0.00 H 85 | ATOM 84 H 1 1 2.955 2.671 6.707 0.00 0.00 H 86 | ATOM 85 O 1 1 3.652 9.953 9.290 0.00 0.00 O 87 | ATOM 86 H 1 1 4.114 9.509 9.983 0.00 0.00 H 88 | ATOM 87 H 1 1 3.199 10.639 9.784 0.00 0.00 H 89 | ATOM 88 O 1 1 5.263 6.708 7.589 0.00 0.00 O 90 | ATOM 89 H 1 1 4.318 7.082 7.707 0.00 0.00 H 91 | ATOM 90 H 1 1 5.455 7.057 6.733 0.00 0.00 H 92 | ATOM 91 O 1 1 3.507 6.721 1.020 0.00 0.00 O 93 | ATOM 92 H 1 1 4.097 7.303 0.607 0.00 0.00 H 94 | ATOM 93 H 1 1 3.586 5.984 0.419 0.00 0.00 H 95 | ATOM 94 O 1 1 5.455 9.196 5.888 0.00 0.00 O 96 | ATOM 95 H 1 1 5.473 9.602 6.758 0.00 0.00 H 97 | ATOM 96 H 1 1 4.549 9.238 5.484 0.00 0.00 H 98 | END 99 | -------------------------------------------------------------------------------- /examples/heat-capacity/data/water_32_data.lmp: -------------------------------------------------------------------------------- 1 | LAMMPS Description 2 | 3 | 96 atoms 4 | 64 bonds 5 | 32 angles 6 | 7 | 2 atom types 8 | 1 bond types 9 | 1 angle types 10 | 11 | -19 19.38859 xlo xhi 12 | -10 19.38859 ylo yhi 13 | -19 19.38859 zlo zhi 14 | 15 | Masses 16 | 17 | 1 15.9994 18 | 2 1.0080 19 | 20 | Bond Coeffs 21 | 22 | 1 1.78 0.2708585 -0.327738785 0.231328959 23 | 24 | Angle Coeffs 25 | 26 | 1 0.0700 107.400000 27 | 28 | Atoms 29 | 30 | 1 1 1 -1.1128 7.098 8.901 17.941 31 | 2 1 2 0.5564 8.700 8.073 18.276 32 | 3 1 2 0.5564 7.555 10.053 16.607 33 | 4 2 1 -1.1128 18.771 16.707 0.692 34 | 5 2 2 0.5564 19.147 15.488 2.116 35 | 6 2 2 0.5564 17.703 15.966 -0.597 36 | 7 3 1 -1.1128 0.607 2.819 10.953 37 | 8 3 2 0.5564 -0.542 3.766 9.904 38 | 9 3 2 0.5564 1.495 3.895 12.026 39 | 10 4 1 -1.1128 15.184 18.396 8.139 40 | 11 4 2 0.5564 13.612 18.499 9.160 41 | 12 4 2 0.5564 16.320 17.588 9.297 42 | 13 5 1 -1.1128 10.702 17.162 1.247 43 | 14 5 2 0.5564 12.053 18.370 1.538 44 | 15 5 2 0.5564 9.851 16.991 2.933 45 | 16 6 1 -1.1128 15.363 0.406 2.270 46 | 17 6 2 0.5564 15.488 -0.123 4.002 47 | 18 6 2 0.5564 16.890 -0.304 1.546 48 | 19 7 1 -1.1128 15.452 7.871 1.353 49 | 20 7 2 0.5564 14.919 9.573 1.587 50 | 21 7 2 0.5564 14.592 6.731 2.534 51 | 22 8 1 -1.1128 11.983 6.153 18.289 52 | 23 8 2 0.5564 13.479 6.469 19.254 53 | 24 8 2 0.5564 12.296 4.532 17.669 54 | 25 9 1 -1.1128 0.257 14.736 5.174 55 | 26 9 2 0.5564 -0.011 15.685 6.773 56 | 27 9 2 0.5564 0.593 13.049 5.605 57 | 28 10 1 -1.1128 9.500 4.843 11.658 58 | 29 10 2 0.5564 10.465 6.304 11.833 59 | 30 10 2 0.5564 10.040 3.838 13.081 60 | 31 11 1 -1.1128 13.538 4.804 4.569 61 | 32 11 2 0.5564 11.807 4.662 5.040 62 | 33 11 2 0.5564 13.954 3.177 3.887 63 | 34 12 1 -1.1128 6.304 17.104 6.170 64 | 35 12 2 0.5564 5.325 15.762 5.267 65 | 36 12 2 0.5564 5.165 18.508 6.421 66 | 37 13 1 -1.1128 2.789 2.683 1.548 67 | 38 13 2 0.5564 2.003 1.073 1.192 68 | 39 13 2 0.5564 2.990 2.852 3.345 69 | 40 14 1 -1.1128 2.309 9.347 6.081 70 | 41 14 2 0.5564 3.989 8.887 6.656 71 | 42 14 2 0.5564 2.536 9.365 4.242 72 | 43 15 1 -1.1128 12.831 12.266 8.481 73 | 44 15 2 0.5564 13.385 10.875 9.588 74 | 45 15 2 0.5564 12.750 13.782 9.401 75 | 46 16 1 -1.1128 17.631 6.548 8.371 76 | 47 16 2 0.5564 18.848 7.476 7.404 77 | 48 16 2 0.5564 16.220 5.939 7.495 78 | 49 17 1 -1.1128 14.143 8.585 12.055 79 | 50 17 2 0.5564 14.369 8.409 13.848 80 | 51 17 2 0.5564 15.573 7.744 11.314 81 | 52 18 1 -1.1128 0.847 10.773 15.532 82 | 53 18 2 0.5564 1.083 9.146 14.874 83 | 54 18 2 0.5564 1.361 10.679 17.240 84 | 55 19 1 -1.1128 1.391 7.714 1.030 85 | 56 19 2 0.5564 1.950 5.947 0.947 86 | 57 19 2 0.5564 -0.472 7.517 0.900 87 | 58 20 1 -1.1128 7.992 4.879 6.731 88 | 59 20 2 0.5564 8.787 4.467 8.360 89 | 60 20 2 0.5564 8.137 6.663 6.606 90 | 61 21 1 -1.1128 7.085 10.050 6.786 91 | 62 21 2 0.5564 6.760 10.582 5.083 92 | 63 21 2 0.5564 8.540 10.983 7.240 93 | 64 22 1 -1.1128 0.457 16.138 9.817 94 | 65 22 2 0.5564 0.459 17.862 10.307 95 | 66 22 2 0.5564 1.370 15.311 11.081 96 | 67 23 1 -1.1128 11.461 0.459 15.441 97 | 68 23 2 0.5564 12.633 -0.680 16.174 98 | 69 23 2 0.5564 9.893 -0.038 16.225 99 | 70 24 1 -1.1128 13.912 15.173 17.100 100 | 71 24 2 0.5564 12.697 14.798 15.707 101 | 72 24 2 0.5564 12.875 14.814 18.438 102 | 73 25 1 -1.1128 3.725 2.213 6.862 103 | 74 25 2 0.5564 2.872 2.644 8.455 104 | 75 25 2 0.5564 5.331 2.980 6.676 105 | 76 26 1 -1.1128 14.502 12.482 4.033 106 | 77 26 2 0.5564 13.498 12.264 5.514 107 | 78 26 2 0.5564 16.182 12.625 4.552 108 | 79 27 1 -1.1128 5.233 13.954 13.748 109 | 80 27 2 0.5564 4.447 15.284 14.642 110 | 81 27 2 0.5564 4.250 12.385 13.999 111 | 82 28 1 -1.1128 4.258 5.274 13.888 112 | 83 28 2 0.5564 5.136 6.104 15.261 113 | 84 28 2 0.5564 5.584 5.047 12.674 114 | 85 29 1 -1.1128 6.901 18.808 17.556 115 | 86 29 2 0.5564 7.774 17.969 18.865 116 | 87 29 2 0.5564 6.045 20.105 18.489 117 | 88 30 1 -1.1128 9.946 12.676 14.341 118 | 89 30 2 0.5564 8.160 13.383 14.564 119 | 90 30 2 0.5564 10.308 13.336 12.724 120 | 91 31 1 -1.1128 6.627 12.701 1.928 121 | 92 31 2 0.5564 7.742 13.801 1.147 122 | 93 31 2 0.5564 6.777 11.308 0.792 123 | 94 32 1 -1.1128 10.308 17.378 11.127 124 | 95 32 2 0.5564 10.342 18.145 12.771 125 | 96 32 2 0.5564 8.596 17.457 10.363 126 | 127 | Bonds 128 | 129 | 1 1 1 2 130 | 2 1 1 3 131 | 3 1 4 5 132 | 4 1 4 6 133 | 5 1 7 8 134 | 6 1 7 9 135 | 7 1 10 11 136 | 8 1 10 12 137 | 9 1 13 14 138 | 10 1 13 15 139 | 11 1 16 17 140 | 12 1 16 18 141 | 13 1 19 20 142 | 14 1 19 21 143 | 15 1 22 23 144 | 16 1 22 24 145 | 17 1 25 26 146 | 18 1 25 27 147 | 19 1 28 29 148 | 20 1 28 30 149 | 21 1 31 32 150 | 22 1 31 33 151 | 23 1 34 35 152 | 24 1 34 36 153 | 25 1 37 38 154 | 26 1 37 39 155 | 27 1 40 41 156 | 28 1 40 42 157 | 29 1 43 44 158 | 30 1 43 45 159 | 31 1 46 47 160 | 32 1 46 48 161 | 33 1 49 50 162 | 34 1 49 51 163 | 35 1 52 53 164 | 36 1 52 54 165 | 37 1 55 56 166 | 38 1 55 57 167 | 39 1 58 59 168 | 40 1 58 60 169 | 41 1 61 62 170 | 42 1 61 63 171 | 43 1 64 65 172 | 44 1 64 66 173 | 45 1 67 68 174 | 46 1 67 69 175 | 47 1 70 71 176 | 48 1 70 72 177 | 49 1 73 74 178 | 50 1 73 75 179 | 51 1 76 77 180 | 52 1 76 78 181 | 53 1 79 80 182 | 54 1 79 81 183 | 55 1 82 83 184 | 56 1 82 84 185 | 57 1 85 86 186 | 58 1 85 87 187 | 59 1 88 89 188 | 60 1 88 90 189 | 61 1 91 92 190 | 62 1 91 93 191 | 63 1 94 95 192 | 64 1 94 96 193 | 194 | Angles 195 | 196 | 1 1 2 1 3 197 | 2 1 5 4 6 198 | 3 1 8 7 9 199 | 4 1 11 10 12 200 | 5 1 14 13 15 201 | 6 1 17 16 18 202 | 7 1 20 19 21 203 | 8 1 23 22 24 204 | 9 1 26 25 27 205 | 10 1 29 28 30 206 | 11 1 32 31 33 207 | 12 1 35 34 36 208 | 13 1 38 37 39 209 | 14 1 41 40 42 210 | 15 1 44 43 45 211 | 16 1 47 46 48 212 | 17 1 50 49 51 213 | 18 1 53 52 54 214 | 19 1 56 55 57 215 | 20 1 59 58 60 216 | 21 1 62 61 63 217 | 22 1 65 64 66 218 | 23 1 68 67 69 219 | 24 1 71 70 72 220 | 25 1 74 73 75 221 | 26 1 77 76 78 222 | 27 1 80 79 81 223 | 28 1 83 82 84 224 | 29 1 86 85 87 225 | 30 1 89 88 90 226 | 31 1 92 91 93 227 | 32 1 95 94 96 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | -------------------------------------------------------------------------------- /examples/heat-capacity/environment.yml: -------------------------------------------------------------------------------- 1 | channels: 2 | - conda-forge 3 | dependencies: 4 | - python=3.11 5 | - pip 6 | - lammps 7 | - pip: 8 | - ase==3.22.1 9 | - chemiscope>=0.7 10 | - git+https://github.com/i-pi/i-pi.git@main 11 | - matplotlib 12 | - skmatter 13 | -------------------------------------------------------------------------------- /examples/learn-tensors-with-mcov/README.rst: -------------------------------------------------------------------------------- 1 | Equivariant model for tensorial properties based on scalar features 2 | =================================================================== 3 | 4 | This example demonstrates how to train a `metatensor atomistic model 5 | `_ on dipole moments and polarizabilities 6 | of small molecular systems using 7 | the `metatrain`_ package. 8 | -------------------------------------------------------------------------------- /examples/learn-tensors-with-mcov/architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab-cosmo/atomistic-cookbook/5c526f3aa2f0eccfbdcac5160672d45eaa994e9f/examples/learn-tensors-with-mcov/architecture.png -------------------------------------------------------------------------------- /examples/learn-tensors-with-mcov/environment.yml: -------------------------------------------------------------------------------- 1 | channels: 2 | - conda-forge 3 | dependencies: 4 | - python=3.12 5 | - pip 6 | - pip: 7 | - ase 8 | - metatrain[soap-bpnn]>=2025.6,<2026 9 | - chemiscope>=0.8.5,<0.9 10 | - featomic>=0.6.1,<0.7 11 | - matplotlib -------------------------------------------------------------------------------- /examples/learn-tensors-with-mcov/eval.yaml: -------------------------------------------------------------------------------- 1 | systems: 2 | read_from: test_set.xyz 3 | targets: 4 | mtt::dipole: 5 | read_from: test_dipoles.mts 6 | type: 7 | spherical: 8 | irreps: 9 | - {o3_lambda: 1, o3_sigma: 1} 10 | mtt::polarizability: 11 | read_from: test_polarizabilities.mts 12 | type: 13 | spherical: 14 | irreps: 15 | - {o3_lambda: 0, o3_sigma: 1} 16 | - {o3_lambda: 2, o3_sigma: 1} 17 | -------------------------------------------------------------------------------- /examples/learn-tensors-with-mcov/options.yaml: -------------------------------------------------------------------------------- 1 | base_precision: 32 2 | seed: 0 3 | architecture: 4 | name: soap_bpnn 5 | training: 6 | batch_size: 10 7 | num_epochs: 10 8 | learning_rate: 0.001 9 | log_interval: 1 10 | training_set: 11 | systems: 12 | read_from: training_set.xyz 13 | targets: 14 | mtt::dipole: 15 | read_from: training_dipoles.mts 16 | type: 17 | spherical: 18 | irreps: 19 | - {o3_lambda: 1, o3_sigma: 1} 20 | mtt::polarizability: 21 | read_from: training_polarizabilities.mts 22 | type: 23 | spherical: 24 | irreps: 25 | - {o3_lambda: 0, o3_sigma: 1} 26 | - {o3_lambda: 2, o3_sigma: 1} 27 | validation_set: 28 | systems: 29 | read_from: validation_set.xyz 30 | targets: 31 | mtt::dipole: 32 | read_from: validation_dipoles.mts 33 | type: 34 | spherical: 35 | irreps: 36 | - {o3_lambda: 1, o3_sigma: 1} 37 | mtt::polarizability: 38 | read_from: validation_polarizabilities.mts 39 | type: 40 | spherical: 41 | irreps: 42 | - {o3_lambda: 0, o3_sigma: 1} 43 | - {o3_lambda: 2, o3_sigma: 1} 44 | test_set: 45 | systems: 46 | read_from: test_set.xyz 47 | targets: 48 | mtt::dipole: 49 | read_from: test_dipoles.mts 50 | type: 51 | spherical: 52 | irreps: 53 | - {o3_lambda: 1, o3_sigma: 1} 54 | mtt::polarizability: 55 | read_from: test_polarizabilities.mts 56 | type: 57 | spherical: 58 | irreps: 59 | - {o3_lambda: 0, o3_sigma: 1} 60 | - {o3_lambda: 2, o3_sigma: 1} 61 | -------------------------------------------------------------------------------- /examples/lode-linear/README.rst: -------------------------------------------------------------------------------- 1 | LODE Tutorial 2 | ============= 3 | 4 | -------------------------------------------------------------------------------- /examples/lode-linear/environment.yml: -------------------------------------------------------------------------------- 1 | channels: 2 | - conda-forge 3 | dependencies: 4 | - python=3.11 5 | - pip 6 | - rust >=1.65 7 | - pip: 8 | - ase==3.22.1 9 | - equisolve @ git+https://github.com/lab-cosmo/equisolve.git@c858bedef4b2799eb445e4c92535ee387224089a 10 | - matplotlib 11 | - metatensor 12 | - metatensor-core==0.1.11 13 | - featomic 14 | -------------------------------------------------------------------------------- /examples/lpr/.gitignore: -------------------------------------------------------------------------------- 1 | notebooks 2 | datasets 3 | LPR_supp_notebook_dataset.tar.gz 4 | -------------------------------------------------------------------------------- /examples/lpr/README.rst: -------------------------------------------------------------------------------- 1 | Local Prediction Rigidity (LPR) 2 | =============================== 3 | 4 | This is an example of how one can calculate the local prediction rigidity 5 | for the atoms of "test" set structures, given two differently composed 6 | "training" set structures. 7 | 8 | It uses ``rascaline`` to compute descriptors for a database of atomic 9 | structures, and ``scikit-matter`` to compute the LPR. The results are 10 | visualized using ``chemiscope`` widgets. 11 | -------------------------------------------------------------------------------- /examples/lpr/environment.yml: -------------------------------------------------------------------------------- 1 | channels: 2 | - conda-forge 3 | dependencies: 4 | - python=3.11 5 | - pip 6 | - rust >=1.65 7 | - pip: 8 | - ase==3.22.1 9 | - matplotlib 10 | - featomic 11 | - skmatter 12 | -------------------------------------------------------------------------------- /examples/path-integrals/README.rst: -------------------------------------------------------------------------------- 1 | Running, analizing and visualizing a path integral MD simulation 2 | ================================================================ 3 | 4 | This example shows how to run a path integral molecular dynamics 5 | simulation using ``i-PI``, analyze the output and visualize the 6 | trajectory in ``chemiscope``. It uses `LAMMPS `_ 7 | as the driver to simulate the q-TIP4P/f water model. 8 | -------------------------------------------------------------------------------- /examples/path-integrals/data/in.lmp: -------------------------------------------------------------------------------- 1 | units electron 2 | atom_style full 3 | 4 | pair_style lj/cut/tip4p/long 1 2 1 1 0.278072379 17.007 5 | bond_style class2 6 | angle_style harmonic 7 | kspace_style pppm/tip4p 0.0001 8 | 9 | read_data data/water_32_data.lmp 10 | pair_coeff * * 0 0 11 | pair_coeff 1 1 0.000295147 5.96946 12 | 13 | neighbor 2.0 bin 14 | 15 | timestep 0.00025 16 | 17 | #velocity all create 298.0 2345187 18 | 19 | #thermo_style multi 20 | #thermo 1 21 | 22 | #fix 1 all nvt temp 298.0 298.0 30.0 tchain 1 23 | #fix 1 all nve 24 | fix 1 all ipi h2o-lammps 32342 unix 25 | 26 | 27 | #dump 1 all xyz 25 dump.xyz 28 | 29 | run 100000000 30 | 31 | -------------------------------------------------------------------------------- /examples/path-integrals/data/input_pimd.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | [ step, time{picosecond}, conserved{electronvolt}, temperature{kelvin}, kinetic_cv{electronvolt}, potential{electronvolt}, pressure_cv{megapascal}, kinetic_td{electronvolt} ] 4 | positions 5 | kinetic_cv 6 | kinetic_od 7 | 8 | 200 9 | 10 | 32342 11 | 12 | 13 |
h2o-lammps
1e-4 14 |
15 | 16 | 17 | data/water_32.pdb 18 | 298 19 | 20 | 21 | lmpserial 22 | 23 | 24 | 298 25 | 26 | 27 | 28 | 29 | 5.0 30 | 31 | 0.5 32 | 33 | 34 | 35 |
36 | -------------------------------------------------------------------------------- /examples/path-integrals/data/water_32.pdb: -------------------------------------------------------------------------------- 1 | CRYST1 10.260 10.260 10.260 90.00 90.00 90.00 P 1 2 | ATOM 1 O 1 1 3.756 4.710 9.494 0.00 0.00 O 3 | ATOM 2 H 1 1 4.604 4.272 9.671 0.00 0.00 H 4 | ATOM 3 H 1 1 3.998 5.320 8.788 0.00 0.00 H 5 | ATOM 4 O 1 1 9.933 8.841 0.366 0.00 0.00 O 6 | ATOM 5 H 1 1 10.132 8.196 1.120 0.00 0.00 H 7 | ATOM 6 H 1 1 9.368 8.449 -0.316 0.00 0.00 H 8 | ATOM 7 O 1 1 0.321 1.492 5.796 0.00 0.00 O 9 | ATOM 8 H 1 1 -0.287 1.993 5.241 0.00 0.00 H 10 | ATOM 9 H 1 1 0.791 2.061 6.364 0.00 0.00 H 11 | ATOM 10 O 1 1 8.035 9.735 4.307 0.00 0.00 O 12 | ATOM 11 H 1 1 7.203 9.789 4.847 0.00 0.00 H 13 | ATOM 12 H 1 1 8.636 9.307 4.920 0.00 0.00 H 14 | ATOM 13 O 1 1 5.663 9.082 0.660 0.00 0.00 O 15 | ATOM 14 H 1 1 6.378 9.721 0.814 0.00 0.00 H 16 | ATOM 15 H 1 1 5.213 8.991 1.552 0.00 0.00 H 17 | ATOM 16 O 1 1 8.130 0.215 1.201 0.00 0.00 O 18 | ATOM 17 H 1 1 8.196 -0.065 2.118 0.00 0.00 H 19 | ATOM 18 H 1 1 8.938 -0.161 0.818 0.00 0.00 H 20 | ATOM 19 O 1 1 8.177 4.165 0.716 0.00 0.00 O 21 | ATOM 20 H 1 1 7.895 5.066 0.840 0.00 0.00 H 22 | ATOM 21 H 1 1 7.722 3.562 1.341 0.00 0.00 H 23 | ATOM 22 O 1 1 6.341 3.256 9.678 0.00 0.00 O 24 | ATOM 23 H 1 1 7.133 3.423 10.189 0.00 0.00 H 25 | ATOM 24 H 1 1 6.507 2.398 9.350 0.00 0.00 H 26 | ATOM 25 O 1 1 0.136 7.798 2.738 0.00 0.00 O 27 | ATOM 26 H 1 1 -0.006 8.300 3.584 0.00 0.00 H 28 | ATOM 27 H 1 1 0.314 6.905 2.966 0.00 0.00 H 29 | ATOM 28 O 1 1 5.027 2.563 6.169 0.00 0.00 O 30 | ATOM 29 H 1 1 5.538 3.336 6.262 0.00 0.00 H 31 | ATOM 30 H 1 1 5.313 2.031 6.922 0.00 0.00 H 32 | ATOM 31 O 1 1 7.164 2.542 2.418 0.00 0.00 O 33 | ATOM 32 H 1 1 6.248 2.467 2.667 0.00 0.00 H 34 | ATOM 33 H 1 1 7.384 1.681 2.057 0.00 0.00 H 35 | ATOM 34 O 1 1 3.336 9.051 3.265 0.00 0.00 O 36 | ATOM 35 H 1 1 2.818 8.341 2.787 0.00 0.00 H 37 | ATOM 36 H 1 1 2.733 9.794 3.398 0.00 0.00 H 38 | ATOM 37 O 1 1 1.476 1.420 0.819 0.00 0.00 O 39 | ATOM 38 H 1 1 1.060 0.568 0.631 0.00 0.00 H 40 | ATOM 39 H 1 1 1.582 1.509 1.770 0.00 0.00 H 41 | ATOM 40 O 1 1 1.222 4.946 3.218 0.00 0.00 O 42 | ATOM 41 H 1 1 2.111 4.703 3.522 0.00 0.00 H 43 | ATOM 42 H 1 1 1.342 4.956 2.245 0.00 0.00 H 44 | ATOM 43 O 1 1 6.790 6.491 4.488 0.00 0.00 O 45 | ATOM 44 H 1 1 7.083 5.755 5.074 0.00 0.00 H 46 | ATOM 45 H 1 1 6.747 7.293 4.975 0.00 0.00 H 47 | ATOM 46 O 1 1 9.330 3.465 4.430 0.00 0.00 O 48 | ATOM 47 H 1 1 9.974 3.956 3.918 0.00 0.00 H 49 | ATOM 48 H 1 1 8.583 3.143 3.966 0.00 0.00 H 50 | ATOM 49 O 1 1 7.484 4.543 6.379 0.00 0.00 O 51 | ATOM 50 H 1 1 7.604 4.450 7.328 0.00 0.00 H 52 | ATOM 51 H 1 1 8.241 4.098 5.987 0.00 0.00 H 53 | ATOM 52 O 1 1 0.448 5.701 8.219 0.00 0.00 O 54 | ATOM 53 H 1 1 0.573 4.840 7.871 0.00 0.00 H 55 | ATOM 54 H 1 1 0.720 5.651 9.123 0.00 0.00 H 56 | ATOM 55 O 1 1 0.736 4.082 0.545 0.00 0.00 O 57 | ATOM 56 H 1 1 1.032 3.147 0.501 0.00 0.00 H 58 | ATOM 57 H 1 1 -0.250 3.978 0.476 0.00 0.00 H 59 | ATOM 58 O 1 1 4.229 2.582 3.562 0.00 0.00 O 60 | ATOM 59 H 1 1 4.650 2.364 4.424 0.00 0.00 H 61 | ATOM 60 H 1 1 4.306 3.526 3.496 0.00 0.00 H 62 | ATOM 61 O 1 1 3.749 5.318 3.591 0.00 0.00 O 63 | ATOM 62 H 1 1 3.577 5.600 2.690 0.00 0.00 H 64 | ATOM 63 H 1 1 4.519 5.812 3.831 0.00 0.00 H 65 | ATOM 64 O 1 1 0.242 8.540 5.195 0.00 0.00 O 66 | ATOM 65 H 1 1 0.243 9.452 5.454 0.00 0.00 H 67 | ATOM 66 H 1 1 0.725 8.102 5.864 0.00 0.00 H 68 | ATOM 67 O 1 1 6.065 0.243 8.171 0.00 0.00 O 69 | ATOM 68 H 1 1 6.685 -0.360 8.559 0.00 0.00 H 70 | ATOM 69 H 1 1 5.235 -0.020 8.586 0.00 0.00 H 71 | ATOM 70 O 1 1 7.362 8.029 9.049 0.00 0.00 O 72 | ATOM 71 H 1 1 6.719 7.831 8.312 0.00 0.00 H 73 | ATOM 72 H 1 1 6.813 7.839 9.757 0.00 0.00 H 74 | ATOM 73 O 1 1 1.971 1.171 3.631 0.00 0.00 O 75 | ATOM 74 H 1 1 1.520 1.399 4.474 0.00 0.00 H 76 | ATOM 75 H 1 1 2.821 1.577 3.533 0.00 0.00 H 77 | ATOM 76 O 1 1 7.674 6.605 2.134 0.00 0.00 O 78 | ATOM 77 H 1 1 7.143 6.490 2.918 0.00 0.00 H 79 | ATOM 78 H 1 1 8.563 6.681 2.409 0.00 0.00 H 80 | ATOM 79 O 1 1 2.769 7.384 7.275 0.00 0.00 O 81 | ATOM 80 H 1 1 2.353 8.088 7.748 0.00 0.00 H 82 | ATOM 81 H 1 1 2.249 6.554 7.408 0.00 0.00 H 83 | ATOM 82 O 1 1 2.253 2.791 7.349 0.00 0.00 O 84 | ATOM 83 H 1 1 2.718 3.230 8.076 0.00 0.00 H 85 | ATOM 84 H 1 1 2.955 2.671 6.707 0.00 0.00 H 86 | ATOM 85 O 1 1 3.652 9.953 9.290 0.00 0.00 O 87 | ATOM 86 H 1 1 4.114 9.509 9.983 0.00 0.00 H 88 | ATOM 87 H 1 1 3.199 10.639 9.784 0.00 0.00 H 89 | ATOM 88 O 1 1 5.263 6.708 7.589 0.00 0.00 O 90 | ATOM 89 H 1 1 4.318 7.082 7.707 0.00 0.00 H 91 | ATOM 90 H 1 1 5.455 7.057 6.733 0.00 0.00 H 92 | ATOM 91 O 1 1 3.507 6.721 1.020 0.00 0.00 O 93 | ATOM 92 H 1 1 4.097 7.303 0.607 0.00 0.00 H 94 | ATOM 93 H 1 1 3.586 5.984 0.419 0.00 0.00 H 95 | ATOM 94 O 1 1 5.455 9.196 5.888 0.00 0.00 O 96 | ATOM 95 H 1 1 5.473 9.602 6.758 0.00 0.00 H 97 | ATOM 96 H 1 1 4.549 9.238 5.484 0.00 0.00 H 98 | END 99 | -------------------------------------------------------------------------------- /examples/path-integrals/data/water_32_data.lmp: -------------------------------------------------------------------------------- 1 | LAMMPS Description 2 | 3 | 96 atoms 4 | 64 bonds 5 | 32 angles 6 | 7 | 2 atom types 8 | 1 bond types 9 | 1 angle types 10 | 11 | -19 19.38859 xlo xhi 12 | -10 19.38859 ylo yhi 13 | -19 19.38859 zlo zhi 14 | 15 | Masses 16 | 17 | 1 15.9994 18 | 2 1.0080 19 | 20 | Bond Coeffs 21 | 22 | 1 1.78 0.2708585 -0.327738785 0.231328959 23 | 24 | Angle Coeffs 25 | 26 | 1 0.0700 107.400000 27 | 28 | Atoms 29 | 30 | 1 1 1 -1.1128 7.098 8.901 17.941 31 | 2 1 2 0.5564 8.700 8.073 18.276 32 | 3 1 2 0.5564 7.555 10.053 16.607 33 | 4 2 1 -1.1128 18.771 16.707 0.692 34 | 5 2 2 0.5564 19.147 15.488 2.116 35 | 6 2 2 0.5564 17.703 15.966 -0.597 36 | 7 3 1 -1.1128 0.607 2.819 10.953 37 | 8 3 2 0.5564 -0.542 3.766 9.904 38 | 9 3 2 0.5564 1.495 3.895 12.026 39 | 10 4 1 -1.1128 15.184 18.396 8.139 40 | 11 4 2 0.5564 13.612 18.499 9.160 41 | 12 4 2 0.5564 16.320 17.588 9.297 42 | 13 5 1 -1.1128 10.702 17.162 1.247 43 | 14 5 2 0.5564 12.053 18.370 1.538 44 | 15 5 2 0.5564 9.851 16.991 2.933 45 | 16 6 1 -1.1128 15.363 0.406 2.270 46 | 17 6 2 0.5564 15.488 -0.123 4.002 47 | 18 6 2 0.5564 16.890 -0.304 1.546 48 | 19 7 1 -1.1128 15.452 7.871 1.353 49 | 20 7 2 0.5564 14.919 9.573 1.587 50 | 21 7 2 0.5564 14.592 6.731 2.534 51 | 22 8 1 -1.1128 11.983 6.153 18.289 52 | 23 8 2 0.5564 13.479 6.469 19.254 53 | 24 8 2 0.5564 12.296 4.532 17.669 54 | 25 9 1 -1.1128 0.257 14.736 5.174 55 | 26 9 2 0.5564 -0.011 15.685 6.773 56 | 27 9 2 0.5564 0.593 13.049 5.605 57 | 28 10 1 -1.1128 9.500 4.843 11.658 58 | 29 10 2 0.5564 10.465 6.304 11.833 59 | 30 10 2 0.5564 10.040 3.838 13.081 60 | 31 11 1 -1.1128 13.538 4.804 4.569 61 | 32 11 2 0.5564 11.807 4.662 5.040 62 | 33 11 2 0.5564 13.954 3.177 3.887 63 | 34 12 1 -1.1128 6.304 17.104 6.170 64 | 35 12 2 0.5564 5.325 15.762 5.267 65 | 36 12 2 0.5564 5.165 18.508 6.421 66 | 37 13 1 -1.1128 2.789 2.683 1.548 67 | 38 13 2 0.5564 2.003 1.073 1.192 68 | 39 13 2 0.5564 2.990 2.852 3.345 69 | 40 14 1 -1.1128 2.309 9.347 6.081 70 | 41 14 2 0.5564 3.989 8.887 6.656 71 | 42 14 2 0.5564 2.536 9.365 4.242 72 | 43 15 1 -1.1128 12.831 12.266 8.481 73 | 44 15 2 0.5564 13.385 10.875 9.588 74 | 45 15 2 0.5564 12.750 13.782 9.401 75 | 46 16 1 -1.1128 17.631 6.548 8.371 76 | 47 16 2 0.5564 18.848 7.476 7.404 77 | 48 16 2 0.5564 16.220 5.939 7.495 78 | 49 17 1 -1.1128 14.143 8.585 12.055 79 | 50 17 2 0.5564 14.369 8.409 13.848 80 | 51 17 2 0.5564 15.573 7.744 11.314 81 | 52 18 1 -1.1128 0.847 10.773 15.532 82 | 53 18 2 0.5564 1.083 9.146 14.874 83 | 54 18 2 0.5564 1.361 10.679 17.240 84 | 55 19 1 -1.1128 1.391 7.714 1.030 85 | 56 19 2 0.5564 1.950 5.947 0.947 86 | 57 19 2 0.5564 -0.472 7.517 0.900 87 | 58 20 1 -1.1128 7.992 4.879 6.731 88 | 59 20 2 0.5564 8.787 4.467 8.360 89 | 60 20 2 0.5564 8.137 6.663 6.606 90 | 61 21 1 -1.1128 7.085 10.050 6.786 91 | 62 21 2 0.5564 6.760 10.582 5.083 92 | 63 21 2 0.5564 8.540 10.983 7.240 93 | 64 22 1 -1.1128 0.457 16.138 9.817 94 | 65 22 2 0.5564 0.459 17.862 10.307 95 | 66 22 2 0.5564 1.370 15.311 11.081 96 | 67 23 1 -1.1128 11.461 0.459 15.441 97 | 68 23 2 0.5564 12.633 -0.680 16.174 98 | 69 23 2 0.5564 9.893 -0.038 16.225 99 | 70 24 1 -1.1128 13.912 15.173 17.100 100 | 71 24 2 0.5564 12.697 14.798 15.707 101 | 72 24 2 0.5564 12.875 14.814 18.438 102 | 73 25 1 -1.1128 3.725 2.213 6.862 103 | 74 25 2 0.5564 2.872 2.644 8.455 104 | 75 25 2 0.5564 5.331 2.980 6.676 105 | 76 26 1 -1.1128 14.502 12.482 4.033 106 | 77 26 2 0.5564 13.498 12.264 5.514 107 | 78 26 2 0.5564 16.182 12.625 4.552 108 | 79 27 1 -1.1128 5.233 13.954 13.748 109 | 80 27 2 0.5564 4.447 15.284 14.642 110 | 81 27 2 0.5564 4.250 12.385 13.999 111 | 82 28 1 -1.1128 4.258 5.274 13.888 112 | 83 28 2 0.5564 5.136 6.104 15.261 113 | 84 28 2 0.5564 5.584 5.047 12.674 114 | 85 29 1 -1.1128 6.901 18.808 17.556 115 | 86 29 2 0.5564 7.774 17.969 18.865 116 | 87 29 2 0.5564 6.045 20.105 18.489 117 | 88 30 1 -1.1128 9.946 12.676 14.341 118 | 89 30 2 0.5564 8.160 13.383 14.564 119 | 90 30 2 0.5564 10.308 13.336 12.724 120 | 91 31 1 -1.1128 6.627 12.701 1.928 121 | 92 31 2 0.5564 7.742 13.801 1.147 122 | 93 31 2 0.5564 6.777 11.308 0.792 123 | 94 32 1 -1.1128 10.308 17.378 11.127 124 | 95 32 2 0.5564 10.342 18.145 12.771 125 | 96 32 2 0.5564 8.596 17.457 10.363 126 | 127 | Bonds 128 | 129 | 1 1 1 2 130 | 2 1 1 3 131 | 3 1 4 5 132 | 4 1 4 6 133 | 5 1 7 8 134 | 6 1 7 9 135 | 7 1 10 11 136 | 8 1 10 12 137 | 9 1 13 14 138 | 10 1 13 15 139 | 11 1 16 17 140 | 12 1 16 18 141 | 13 1 19 20 142 | 14 1 19 21 143 | 15 1 22 23 144 | 16 1 22 24 145 | 17 1 25 26 146 | 18 1 25 27 147 | 19 1 28 29 148 | 20 1 28 30 149 | 21 1 31 32 150 | 22 1 31 33 151 | 23 1 34 35 152 | 24 1 34 36 153 | 25 1 37 38 154 | 26 1 37 39 155 | 27 1 40 41 156 | 28 1 40 42 157 | 29 1 43 44 158 | 30 1 43 45 159 | 31 1 46 47 160 | 32 1 46 48 161 | 33 1 49 50 162 | 34 1 49 51 163 | 35 1 52 53 164 | 36 1 52 54 165 | 37 1 55 56 166 | 38 1 55 57 167 | 39 1 58 59 168 | 40 1 58 60 169 | 41 1 61 62 170 | 42 1 61 63 171 | 43 1 64 65 172 | 44 1 64 66 173 | 45 1 67 68 174 | 46 1 67 69 175 | 47 1 70 71 176 | 48 1 70 72 177 | 49 1 73 74 178 | 50 1 73 75 179 | 51 1 76 77 180 | 52 1 76 78 181 | 53 1 79 80 182 | 54 1 79 81 183 | 55 1 82 83 184 | 56 1 82 84 185 | 57 1 85 86 186 | 58 1 85 87 187 | 59 1 88 89 188 | 60 1 88 90 189 | 61 1 91 92 190 | 62 1 91 93 191 | 63 1 94 95 192 | 64 1 94 96 193 | 194 | Angles 195 | 196 | 1 1 2 1 3 197 | 2 1 5 4 6 198 | 3 1 8 7 9 199 | 4 1 11 10 12 200 | 5 1 14 13 15 201 | 6 1 17 16 18 202 | 7 1 20 19 21 203 | 8 1 23 22 24 204 | 9 1 26 25 27 205 | 10 1 29 28 30 206 | 11 1 32 31 33 207 | 12 1 35 34 36 208 | 13 1 38 37 39 209 | 14 1 41 40 42 210 | 15 1 44 43 45 211 | 16 1 47 46 48 212 | 17 1 50 49 51 213 | 18 1 53 52 54 214 | 19 1 56 55 57 215 | 20 1 59 58 60 216 | 21 1 62 61 63 217 | 22 1 65 64 66 218 | 23 1 68 67 69 219 | 24 1 71 70 72 220 | 25 1 74 73 75 221 | 26 1 77 76 78 222 | 27 1 80 79 81 223 | 28 1 83 82 84 224 | 29 1 86 85 87 225 | 30 1 89 88 90 226 | 31 1 92 91 93 227 | 32 1 95 94 96 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | -------------------------------------------------------------------------------- /examples/path-integrals/environment.yml: -------------------------------------------------------------------------------- 1 | channels: 2 | - conda-forge 3 | dependencies: 4 | - python=3.11 5 | - pip 6 | - lammps 7 | - pip: 8 | - ase==3.22.1 9 | - chemiscope>=0.7 10 | - ipi 11 | - matplotlib 12 | - skmatter 13 | -------------------------------------------------------------------------------- /examples/path-integrals/pimd-slices-round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab-cosmo/atomistic-cookbook/5c526f3aa2f0eccfbdcac5160672d45eaa994e9f/examples/path-integrals/pimd-slices-round.png -------------------------------------------------------------------------------- /examples/periodic-hamiltonian/README.rst: -------------------------------------------------------------------------------- 1 | Periodic Hamiltonian Learning 2 | ============================= 3 | 4 | -------------------------------------------------------------------------------- /examples/periodic-hamiltonian/data/BASIS_STO3G: -------------------------------------------------------------------------------- 1 | 2 | 3 | #---------------------------------------------------------------------- 4 | # Basis Set Exchange 5 | # Version v0.9.1 6 | # https://www.basissetexchange.org 7 | #---------------------------------------------------------------------- 8 | # Basis set: STO-3G 9 | # Description: STO-3G Minimal Basis (3 functions/AO) 10 | # Role: orbital 11 | # Version: 1 (Data from Gaussian09) 12 | #---------------------------------------------------------------------- 13 | 14 | 15 | # Carbon STO-3G (6s,3p) -> [2s,1p] 16 | C STO-3G 17 | 2 18 | 1 0 0 3 1 19 | 0.7161683735E+02 0.1543289673E+00 20 | 0.1304509632E+02 0.5353281423E+00 21 | 0.3530512160E+01 0.4446345422E+00 22 | 1 0 1 3 1 1 23 | 0.2941249355E+01 -0.9996722919E-01 0.1559162750E+00 24 | 0.6834830964E+00 0.3995128261E+00 0.6076837186E+00 25 | 0.2222899159E+00 0.7001154689E+00 0.3919573931E+00 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /examples/periodic-hamiltonian/data/reftraj_hamiltonian.cp2k: -------------------------------------------------------------------------------- 1 | &GLOBAL 2 | PROJECT //PROJECT// 3 | RUN_TYPE MD 4 | PRINT_LEVEL MEDIUM 5 | FFTW_PLAN_TYPE MEASURE 6 | &END GLOBAL 7 | 8 | &MOTION 9 | &PRINT 10 | &CELL 11 | &EACH 12 | MD 1 13 | &END EACH 14 | &END CELL 15 | &FORCES 16 | &EACH 17 | MD 1 18 | &END EACH 19 | &END FORCES 20 | &END PRINT 21 | &MD 22 | ENSEMBLE REFTRAJ 23 | &REFTRAJ ! Loads an external trajectory file and performs analysis on the loaded snapshots. 24 | EVAL ENERGY_FORCES 25 | CELL_FILE_NAME reftraj.cell 26 | TRAJ_FILE_NAME reftraj.xyz 27 | FIRST_SNAPSHOT 1 28 | VARIABLE_VOLUME TRUE 29 | LAST_SNAPSHOT //LAST_SNAPSHOT// 30 | &END REFTRAJ 31 | &END MD 32 | &END MOTION 33 | 34 | &FORCE_EVAL 35 | METHOD Quickstep 36 | &DFT 37 | &MGRID 38 | NGRIDS 5 39 | CUTOFF 200 40 | REL_CUTOFF 70 41 | &END MGRID 42 | UKS F 43 | BASIS_SET_FILE_NAME ../BASIS_STO3G 44 | POTENTIAL_FILE_NAME ../POTENTIAL 45 | 46 | &QS 47 | METHOD GAPW 48 | EXTRAPOLATION USE_GUESS 49 | EPS_DEFAULT 1.0E-12 50 | &END QS 51 | &SCF 52 | SCF_GUESS ATOMIC 53 | EPS_SCF 1.0E-8 54 | MAX_SCF 300 55 | ADDED_MOS -1 56 | &DIAGONALIZATION 57 | ALGORITHM STANDARD 58 | &END DIAGONALIZATION 59 | &SMEAR ON 60 | METHOD FERMI_DIRAC 61 | ELECTRONIC_TEMPERATURE [K] 300 62 | &END SMEAR 63 | 64 | &MIXING 65 | METHOD BROYDEN_MIXING 66 | ALPHA 0.4 67 | BETA 0.5 68 | NBROYDEN 8 69 | &END MIXING 70 | 71 | &END SCF 72 | &XC 73 | &XC_FUNCTIONAL PBE 74 | &END XC_FUNCTIONAL 75 | &END XC 76 | &KPOINTS 77 | SCHEME MONKHORST-PACK 15 15 1 78 | WAVEFUNCTIONS COMPLEX 79 | &END KPOINTS 80 | &PRINT 81 | &KS_CSR_WRITE 82 | REAL_SPACE 83 | FILENAME ./FOCK/ 84 | &END KS_CSR_WRITE 85 | &S_CSR_WRITE 86 | REAL_SPACE 87 | FILENAME ./OVER/ 88 | &END S_CSR_WRITE 89 | &END PRINT 90 | &END DFT 91 | 92 | &SUBSYS 93 | &CELL 94 | A //CELL_A// 95 | B //CELL_B// 96 | C //CELL_C// 97 | PERIODIC XYZ 98 | &END CELL 99 | &TOPOLOGY 100 | COORD_FILE_NAME init.xyz 101 | COORD_FILE_FORMAT XYZ 102 | &END TOPOLOGY 103 | &KIND C 104 | ELEMENT C 105 | BASIS_SET ORB STO-3G 106 | POTENTIAL ALL 107 | &END KIND 108 | &END SUBSYS 109 | &END FORCE_EVAL 110 | -------------------------------------------------------------------------------- /examples/periodic-hamiltonian/environment.yml: -------------------------------------------------------------------------------- 1 | channels: 2 | - conda-forge 3 | dependencies: 4 | - python>=3.11 5 | - pip 6 | - graphviz 7 | - pyscf=2.3.0 8 | - rust>=1.65 9 | - pip: 10 | - pyscfad @ git+https://github.com/fishjojo/pyscfad.git@ml#egg=pyscfad 11 | - ase==3.22.1 12 | - seekpath 13 | - requests 14 | - --extra-index-url https://download.pytorch.org/whl/cpu 15 | - lightning 16 | - xitorch 17 | - keras_core 18 | - tensorboard 19 | - torchviz 20 | - mlelec @ git+https://github.com/curiosity54/mlelec.git@tutorial_periodic#egg=mlelec 21 | -------------------------------------------------------------------------------- /examples/periodic-hamiltonian/equivariantnonlinear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab-cosmo/atomistic-cookbook/5c526f3aa2f0eccfbdcac5160672d45eaa994e9f/examples/periodic-hamiltonian/equivariantnonlinear.png -------------------------------------------------------------------------------- /examples/periodic-hamiltonian/graphene_lattice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab-cosmo/atomistic-cookbook/5c526f3aa2f0eccfbdcac5160672d45eaa994e9f/examples/periodic-hamiltonian/graphene_lattice.png -------------------------------------------------------------------------------- /examples/periodic-hamiltonian/simpleMLP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab-cosmo/atomistic-cookbook/5c526f3aa2f0eccfbdcac5160672d45eaa994e9f/examples/periodic-hamiltonian/simpleMLP.png -------------------------------------------------------------------------------- /examples/pet-mad-nc/README.rst: -------------------------------------------------------------------------------- 1 | Non-conservative MTS MD 2 | ======================= 3 | 4 | An example of running hybrid conservative/non-conservative MD 5 | using PET-MAD and i-PI. 6 | -------------------------------------------------------------------------------- /examples/pet-mad-nc/data/input-nc-nve-mts.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | [step, time{picosecond}, conserved{electronvolt}, temperature{kelvin}, 5 | kinetic_md{electronvolt}, potential{electronvolt}, 6 | pot_component(0){electronvolt}, pot_component(1){electronvolt} 7 | ] 8 | 9 | positions 10 | forces_component(0) 11 | forces_component(1) 12 | 13 | 14 | 50 15 | 12345 16 | 17 | 18 | metatensor 19 | {template:data/bmimcl.xyz,model:pet-mad-latest.pt,device:cpu,non_conservative:False} 20 | 21 | 22 | metatensor 23 | {template:data/bmimcl.xyz,model:pet-mad-latest.pt,device:cpu,non_conservative:True} 24 | 25 | 26 | 27 | data/bmimcl.xyz 28 | 400.0 29 | 30 | 31 | 32 | [1,0] 33 | 34 | 35 | [-1,1] 36 | 37 | 38 | 39 | 40 | 4 41 | [1,8] 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /examples/pet-mad-nc/data/input-nc-nve.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | [step, time{picosecond}, conserved{electronvolt}, temperature{kelvin}, 5 | kinetic_md{electronvolt}, potential{electronvolt}, 6 | pot_component(0){electronvolt} 7 | ] 8 | 9 | positions 10 | forces_component(0) 11 | 12 | 13 | 160 14 | 12345 15 | 16 | metatensor 17 | {template:data/bmimcl.xyz,model:pet-mad-latest.pt,device:cpu,non_conservative:True} 18 | 19 | 20 | 21 | data/bmimcl.xyz 22 | 400.0 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 0.5 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /examples/pet-mad-nc/data/input-nve.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | [step, time{picosecond}, conserved{electronvolt}, temperature{kelvin}, 5 | kinetic_md{electronvolt}, potential{electronvolt}, 6 | pot_component(0){electronvolt} 7 | ] 8 | 9 | positions 10 | forces_component(0) 11 | 12 | 13 | 32 14 | 12345 15 | 16 | metatensor 17 | {template:data/bmimcl.xyz,model:pet-mad-latest.pt,device:cpu,non_conservative:False} 18 | 19 | 20 | 21 | data/bmimcl.xyz 22 | 400.0 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 0.5 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /examples/pet-mad-nc/environment.yml: -------------------------------------------------------------------------------- 1 | channels: 2 | - metatensor 3 | - conda-forge 4 | dependencies: 5 | - python=3.12 6 | - pip 7 | - pip: 8 | - ase>=3.23 9 | - pet-mad>=1.1.0,<2.0 10 | - ipi>=3.1.4,<4.0 11 | - chemiscope>=0.8.5,<0.9 12 | - matplotlib>=3.10,<4.0 13 | - vesin[torch]>=0.3.2,<0.4 14 | -------------------------------------------------------------------------------- /examples/pet-mad/.gitignore: -------------------------------------------------------------------------------- 1 | *.data 2 | *.pt 3 | log.lammps 4 | trajectory.xyz 5 | tmp* 6 | 7 | extensions/* 8 | -------------------------------------------------------------------------------- /examples/pet-mad/README.rst: -------------------------------------------------------------------------------- 1 | PET-MAD tutorial 2 | ================ 3 | 4 | An example of using the PET-MAD universal machine-learning potential with ASE, 5 | i-PI and LAMMPS. 6 | 7 | -------------------------------------------------------------------------------- /examples/pet-mad/data/al6xxx-o2.in: -------------------------------------------------------------------------------- 1 | units metal # Angstroms, eV, picoseconds 2 | atom_style atomic 3 | read_data al6xxx-o2.data 4 | # loads pet-mad-model 5 | pair_style metatensor & 6 | pet-mad-latest.pt & 7 | device cpu & 8 | extensions extensions/ 9 | # define interactions between all atoms and maps the LAMMPS types to elements 10 | pair_coeff * * 13 12 8 14 11 | neighbor 2.0 bin 12 | timestep 0.005 13 | dump myDump all xyz 10 trajectory.xyz 14 | dump_modify myDump element Al Mg O Si 15 | thermo_style multi 16 | thermo 1 17 | velocity all create 800 87287 mom yes rot yes 18 | fix 1 all nvt temp 800 800 0.10 19 | # fix 2 all atom/swap 1 1 12345 800 types 1 2 20 | # fix 2 all atom/swap 1 1 12345 800 types 1 3 21 | # fix 2 all atom/swap 1 1 12345 800 types 1 4 22 | run 80 23 | 24 | -------------------------------------------------------------------------------- /examples/pet-mad/environment.yml: -------------------------------------------------------------------------------- 1 | channels: 2 | - metatensor 3 | - conda-forge 4 | dependencies: 5 | - python=3.12 6 | - lammps-metatensor=*=cpu*nompi* 7 | - pet-mad>=1.1.0,<1.2 8 | - pip 9 | - pip: 10 | - ase 11 | - ipi==3.1.2 12 | - chemiscope>=0.8.5,<0.9 13 | - matplotlib 14 | -------------------------------------------------------------------------------- /examples/pi-metad/README.rst: -------------------------------------------------------------------------------- 1 | Path integral metadynamics with i-PI and PLUMED 2 | =============================================== 3 | 4 | This example shows how to combine path integral simulations to 5 | model quantum nuclear fluctuations and metadynamics to accelerate 6 | sampling, so as to evaluate the quantum free energy for a delocalized 7 | proton. 8 | -------------------------------------------------------------------------------- /examples/pi-metad/data/FES-md_hiq.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab-cosmo/atomistic-cookbook/5c526f3aa2f0eccfbdcac5160672d45eaa994e9f/examples/pi-metad/data/FES-md_hiq.bz2 -------------------------------------------------------------------------------- /examples/pi-metad/data/FES-pimd_hiq.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab-cosmo/atomistic-cookbook/5c526f3aa2f0eccfbdcac5160672d45eaa994e9f/examples/pi-metad/data/FES-pimd_hiq.bz2 -------------------------------------------------------------------------------- /examples/pi-metad/data/h5o2+.xyz: -------------------------------------------------------------------------------- 1 | 7 2 | # CELL(abcABC): 13.38377 13.38377 13.38377 90.00000 90.00000 90.00000 cell{angstrom} Traj: positions{angstrom} Step: 0 Bead: 10 3 | O 5.40450e-01 -9.74850e-01 -2.16580e-01 4 | O 2.92484e+00 -8.39252e-01 1.52397e-01 5 | H 1.83860e-01 -1.25804e+00 -1.07875e+00 6 | H 1.74329e+00 -9.09278e-01 -1.00395e-01 7 | H 3.29707e+00 -1.59324e+00 6.47253e-01 8 | H 3.53033e+00 -6.08138e-01 -5.76078e-01 9 | H 4.23316e-02 -1.94860e-01 9.22810e-02 10 | -------------------------------------------------------------------------------- /examples/pi-metad/data/input-md.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1.00000000e-04
zundel
4 |
5 | 6 | data/h5o2+.xyz 7 | data/plumed-md.dat 8 | [doo, co1.lessthan, co2.lessthan, dc, mtd.bias ] 9 | 10 | 5000 11 | 12 | positions{angstrom} 13 | extras_bias 14 | 15 | [ step, time, conserved, temperature{kelvin}, kinetic_md, 16 | potential, temperature{kelvin}(H), temperature{kelvin}(O), ensemble_bias ] 17 | 18 | 19 | 20 | 18885 21 | 22 | 23 | 24 | 25 | 26 | 27 | data/h5o2+.xyz 28 | 29 | [ 25.29166, 0, 0, 0, 25.29166, 0, 0, 0, 25.29166 ] 30 | 31 | 32 | 33 | 300.0 34 | 35 | 36 | 37 | 38 | 39 | False 40 | 41 | 1.0 42 | 55 | 56 | 57 | [ 8.191023526179e-4, 8.328506066524e-3, 1.657771834013e-3, 9.736989925341e-4, 2.841803794895e-4, -3.176846864198e-5, -2.967010478210e-4, 58 | -8.389856546341e-4, 2.405526974742e-2, -1.507872374848e-2, 2.589784240185e-3, 1.516783633362e-3, -5.958833418565e-4, 4.198422349789e-4, 59 | 7.798710586406e-4, 1.507872374848e-2, 8.569039501219e-3, 6.001000899602e-3, 1.062029383877e-3, 1.093939147968e-3, -2.661575532976e-3, 60 | -9.676783161546e-4, -2.589784240185e-3, -6.001000899602e-3, 2.680459336535e-5, -5.214694469742e-5, 4.231304910751e-4, -2.104894919743e-5, 61 | -2.841997149166e-4, -1.516783633362e-3, -1.062029383877e-3, 5.214694469742e-5, 1.433903506353e-9, -4.241574212449e-5, 7.910178912362e-5, 62 | 3.333208286893e-5, 5.958833418565e-4, -1.093939147968e-3, -4.231304910751e-4, 4.241574212449e-5, 2.385554468441e-8, -3.139255482869e-5, 63 | 2.967533789056e-4, -4.198422349789e-4, 2.661575532976e-3, 2.104894919743e-5, -7.910178912362e-5, 3.139255482869e-5, 2.432567259684e-11 64 | ] 65 | 66 | 67 | 68 | 69 | 70 | 71 | [ plumed ] 72 | 73 |
74 | -------------------------------------------------------------------------------- /examples/pi-metad/data/input-md_hiq.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1.00000000e-04
zundel
4 |
5 | 6 | data/h5o2+.xyz 7 | data/plumed-md_hiq.dat 8 | [doo, co1.lessthan, co2.lessthan, dc, mtd.bias ] 9 | 10 | 2000000 11 | 12 | positions{angstrom} 13 | extras_bias 14 | 15 | [ step, time, conserved, temperature{kelvin}, kinetic_md, 16 | potential, temperature{kelvin}(H), temperature{kelvin}(O), ensemble_bias ] 17 | 18 | 19 | 20 | 18885 21 | 22 | 23 | 24 | 25 | 26 | 27 | data/h5o2+.xyz 28 | 29 | [ 25.29166, 0, 0, 0, 25.29166, 0, 0, 0, 25.29166 ] 30 | 31 | 32 | 33 | 300.0 34 | 35 | 36 | 37 | 38 | 39 | False 40 | 41 | 0.5 42 | 55 | 56 | 57 | [ 8.191023526179e-4, 8.328506066524e-3, 1.657771834013e-3, 9.736989925341e-4, 2.841803794895e-4, -3.176846864198e-5, -2.967010478210e-4, 58 | -8.389856546341e-4, 2.405526974742e-2, -1.507872374848e-2, 2.589784240185e-3, 1.516783633362e-3, -5.958833418565e-4, 4.198422349789e-4, 59 | 7.798710586406e-4, 1.507872374848e-2, 8.569039501219e-3, 6.001000899602e-3, 1.062029383877e-3, 1.093939147968e-3, -2.661575532976e-3, 60 | -9.676783161546e-4, -2.589784240185e-3, -6.001000899602e-3, 2.680459336535e-5, -5.214694469742e-5, 4.231304910751e-4, -2.104894919743e-5, 61 | -2.841997149166e-4, -1.516783633362e-3, -1.062029383877e-3, 5.214694469742e-5, 1.433903506353e-9, -4.241574212449e-5, 7.910178912362e-5, 62 | 3.333208286893e-5, 5.958833418565e-4, -1.093939147968e-3, -4.231304910751e-4, 4.241574212449e-5, 2.385554468441e-8, -3.139255482869e-5, 63 | 2.967533789056e-4, -4.198422349789e-4, 2.661575532976e-3, 2.104894919743e-5, -7.910178912362e-5, 3.139255482869e-5, 2.432567259684e-11 64 | ] 65 | 66 | 67 | 68 | 69 | 70 | 71 | [ plumed ] 72 | 73 |
74 | -------------------------------------------------------------------------------- /examples/pi-metad/data/input-pimd.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1.00000000e-04
zundel
4 |
5 | 6 | data/h5o2+.xyz 7 | data/plumed-pimd.dat 8 | [doo, co1.lessthan, co2.lessthan, dc, mtd.bias ] 9 | 10 | 5000 11 | 12 | positions{angstrom} 13 | x_centroid{angstrom} 14 | extras_bias 15 | [ step, time, conserved, temperature{kelvin}, kinetic_cv, 16 | potential, temperature{kelvin}(H), temperature{kelvin}(O), ensemble_bias ] 17 | 18 | 19 | 18885 20 | 21 | 22 | 23 | 24 | 25 | 26 | data/h5o2+.xyz 27 | 28 | [ 25.29166, 0, 0, 0, 25.29166, 0, 0, 0, 25.29166 ] 29 | 30 | 31 | 32 | 300.0 33 | 34 | 35 | [ doo, dc, mtd.bias ] 36 | 37 | 38 | 39 | 40 | False 41 | 42 | 1.0 43 | 56 | 57 | 58 | [ 8.191023526179e-4, 8.328506066524e-3, 1.657771834013e-3, 9.736989925341e-4, 2.841803794895e-4, -3.176846864198e-5, -2.967010478210e-4, 59 | -8.389856546341e-4, 2.405526974742e-2, -1.507872374848e-2, 2.589784240185e-3, 1.516783633362e-3, -5.958833418565e-4, 4.198422349789e-4, 60 | 7.798710586406e-4, 1.507872374848e-2, 8.569039501219e-3, 6.001000899602e-3, 1.062029383877e-3, 1.093939147968e-3, -2.661575532976e-3, 61 | -9.676783161546e-4, -2.589784240185e-3, -6.001000899602e-3, 2.680459336535e-5, -5.214694469742e-5, 4.231304910751e-4, -2.104894919743e-5, 62 | -2.841997149166e-4, -1.516783633362e-3, -1.062029383877e-3, 5.214694469742e-5, 1.433903506353e-9, -4.241574212449e-5, 7.910178912362e-5, 63 | 3.333208286893e-5, 5.958833418565e-4, -1.093939147968e-3, -4.231304910751e-4, 4.241574212449e-5, 2.385554468441e-8, -3.139255482869e-5, 64 | 2.967533789056e-4, -4.198422349789e-4, 2.661575532976e-3, 2.104894919743e-5, -7.910178912362e-5, 3.139255482869e-5, 2.432567259684e-11 65 | ] 66 | 67 | 68 | 69 | 70 | 71 | 72 | [ plumed ] 73 | 74 |
75 | -------------------------------------------------------------------------------- /examples/pi-metad/data/input-pimd_hiq.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1.00000000e-04
zundel
4 |
5 | 6 | data/h5o2+.xyz 7 | data/plumed-pimd_hiq.dat 8 | [doo, co1.lessthan, co2.lessthan, dc, mtd.bias ] 9 | 10 | 2000000 11 | 12 | positions{angstrom} 13 | x_centroid{angstrom} 14 | extras_bias 15 | [ step, time, conserved, temperature{kelvin}, kinetic_cv, 16 | potential, temperature{kelvin}(H), temperature{kelvin}(O), ensemble_bias ] 17 | 18 | 19 | 18885 20 | 21 | 22 | 23 | 24 | 25 | 26 | data/h5o2+.xyz 27 | 28 | [ 25.29166, 0, 0, 0, 25.29166, 0, 0, 0, 25.29166 ] 29 | 30 | 31 | 32 | 300.0 33 | 34 | 35 | [ doo, dc, mtd.bias ] 36 | 37 | 38 | 39 | 40 | False 41 | 42 | 0.5 43 | 56 | 57 | 58 | [ 8.191023526179e-4, 8.328506066524e-3, 1.657771834013e-3, 9.736989925341e-4, 2.841803794895e-4, -3.176846864198e-5, -2.967010478210e-4, 59 | -8.389856546341e-4, 2.405526974742e-2, -1.507872374848e-2, 2.589784240185e-3, 1.516783633362e-3, -5.958833418565e-4, 4.198422349789e-4, 60 | 7.798710586406e-4, 1.507872374848e-2, 8.569039501219e-3, 6.001000899602e-3, 1.062029383877e-3, 1.093939147968e-3, -2.661575532976e-3, 61 | -9.676783161546e-4, -2.589784240185e-3, -6.001000899602e-3, 2.680459336535e-5, -5.214694469742e-5, 4.231304910751e-4, -2.104894919743e-5, 62 | -2.841997149166e-4, -1.516783633362e-3, -1.062029383877e-3, 5.214694469742e-5, 1.433903506353e-9, -4.241574212449e-5, 7.910178912362e-5, 63 | 3.333208286893e-5, 5.958833418565e-4, -1.093939147968e-3, -4.231304910751e-4, 4.241574212449e-5, 2.385554468441e-8, -3.139255482869e-5, 64 | 2.967533789056e-4, -4.198422349789e-4, 2.661575532976e-3, 2.104894919743e-5, -7.910178912362e-5, 3.139255482869e-5, 2.432567259684e-11 65 | ] 66 | 67 | 68 | 69 | 70 | 71 | 72 | [ plumed ] 73 | 74 |
75 | -------------------------------------------------------------------------------- /examples/pi-metad/data/plumed-md.dat: -------------------------------------------------------------------------------- 1 | # default units are LENGTH=nm ENERGY=kJ/mol TIME=ps 2 | doo: DISTANCE ATOMS=1,2 3 | co1: DISTANCES GROUPA=1 GROUPB=3-7 LESS_THAN={RATIONAL R_0=0.14} 4 | co2: DISTANCES GROUPA=2 GROUPB=3-7 LESS_THAN={RATIONAL R_0=0.14} 5 | dc: COMBINE ARG=co1.lessthan,co2.lessthan COEFFICIENTS=1,-1 PERIODIC=NO 6 | mtd: METAD ARG=doo,dc PACE=10 SIGMA=0.005,0.05 HEIGHT=4 FILE=HILLS-md BIASFACTOR=10 TEMP=300 7 | uwall: UPPER_WALLS ARG=doo AT=0.4 KAPPA=250 8 | 9 | PRINT ARG=doo,co1.*,co2.*,dc,mtd.*,uwall.* STRIDE=10 FILE=COLVAR-md 10 | FLUSH STRIDE=1 11 | -------------------------------------------------------------------------------- /examples/pi-metad/data/plumed-md_hiq.dat: -------------------------------------------------------------------------------- 1 | # default units are LENGTH=nm ENERGY=kJ/mol TIME=ps 2 | doo: DISTANCE ATOMS=1,2 3 | co1: DISTANCES GROUPA=1 GROUPB=3-7 LESS_THAN={RATIONAL R_0=0.14} 4 | co2: DISTANCES GROUPA=2 GROUPB=3-7 LESS_THAN={RATIONAL R_0=0.14} 5 | dc: COMBINE ARG=co1.lessthan,co2.lessthan COEFFICIENTS=1,-1 PERIODIC=NO 6 | mtd: METAD ARG=doo,dc PACE=100 SIGMA=0.0025,0.025 HEIGHT=1 FILE=HILLS-md_hiq BIASFACTOR=8 TEMP=300 7 | uwall: UPPER_WALLS ARG=doo AT=0.4 KAPPA=250 8 | 9 | PRINT ARG=doo,co1.*,co2.*,dc,mtd.*,uwall.* STRIDE=20 FILE=COLVAR-md_hiq 10 | FLUSH STRIDE=1 11 | -------------------------------------------------------------------------------- /examples/pi-metad/data/plumed-pimd.dat: -------------------------------------------------------------------------------- 1 | # default units are LENGTH=nm ENERGY=kJ/mol TIME=ps 2 | doo: DISTANCE ATOMS=1,2 3 | co1: DISTANCES GROUPA=1 GROUPB=3-7 LESS_THAN={RATIONAL R_0=0.14} 4 | co2: DISTANCES GROUPA=2 GROUPB=3-7 LESS_THAN={RATIONAL R_0=0.14} 5 | dc: COMBINE ARG=co1.lessthan,co2.lessthan COEFFICIENTS=1,-1 PERIODIC=NO 6 | mtd: METAD ARG=doo,dc PACE=10 SIGMA=0.005,0.05 HEIGHT=4 FILE=HILLS-pimd BIASFACTOR=10 TEMP=300 7 | uwall: UPPER_WALLS ARG=doo AT=0.4 KAPPA=250 8 | 9 | PRINT ARG=doo,co1.*,co2.*,dc,mtd.*,uwall.* STRIDE=10 FILE=COLVAR-pimd 10 | FLUSH STRIDE=1 11 | -------------------------------------------------------------------------------- /examples/pi-metad/data/plumed-pimd_hiq.dat: -------------------------------------------------------------------------------- 1 | # default units are LENGTH=nm ENERGY=kJ/mol TIME=ps 2 | doo: DISTANCE ATOMS=1,2 3 | co1: DISTANCES GROUPA=1 GROUPB=3-7 LESS_THAN={RATIONAL R_0=0.14} 4 | co2: DISTANCES GROUPA=2 GROUPB=3-7 LESS_THAN={RATIONAL R_0=0.14} 5 | dc: COMBINE ARG=co1.lessthan,co2.lessthan COEFFICIENTS=1,-1 PERIODIC=NO 6 | mtd: METAD ARG=doo,dc PACE=100 SIGMA=0.0025,0.025 HEIGHT=1 FILE=HILLS-pimd_hiq BIASFACTOR=8 TEMP=300 7 | uwall: UPPER_WALLS ARG=doo AT=0.4 KAPPA=250 8 | 9 | PRINT ARG=doo,co1.*,co2.*,dc,mtd.*,uwall.* STRIDE=10 FILE=COLVAR-pimd_hiq 10 | FLUSH STRIDE=1 11 | -------------------------------------------------------------------------------- /examples/pi-metad/environment.yml: -------------------------------------------------------------------------------- 1 | channels: 2 | - plumed/label/nightly 3 | - conda-forge 4 | dependencies: 5 | - python=3.11 6 | - pip 7 | - gfortran 8 | - make 9 | - git 10 | - plumed 11 | - py-plumed 12 | - pip: 13 | - ase==3.22.1 14 | - chemiscope 15 | - git+https://github.com/i-pi/i-pi.git@main#egg=ipi 16 | - matplotlib 17 | - skmatter 18 | variables: 19 | PYTHONPATH: 20 | PLUMED_KERNEL: 21 | -------------------------------------------------------------------------------- /examples/pi-metad/metad-scheme.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab-cosmo/atomistic-cookbook/5c526f3aa2f0eccfbdcac5160672d45eaa994e9f/examples/pi-metad/metad-scheme.png -------------------------------------------------------------------------------- /examples/pi-metad/plumed-tutorials.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab-cosmo/atomistic-cookbook/5c526f3aa2f0eccfbdcac5160672d45eaa994e9f/examples/pi-metad/plumed-tutorials.zip -------------------------------------------------------------------------------- /examples/pi-mts-rpc/README.rst: -------------------------------------------------------------------------------- 1 | Multiple time stepping and ring-polymer contraction 2 | =================================================== 3 | 4 | This notebook provides an introduction to two closely-related techniques, 5 | that are geared towards reducing the cost of calculations by separating 6 | slowly-varying (and computationally-expensive) components of the potential 7 | energy from the fast-varying (and hopefully cheaper) ones. 8 | 9 | The first is named `multiple time stepping`, and is a well-established technique 10 | to avoid evaluating the slowly-varying components at every time step of a MD simulation. 11 | It was first introduced in `LAMMPS `_. 12 | `M. Tuckerman, B. J. Berne, and G. J. Martyna, JCP 97(3), 1990 (1992) `_ 13 | and can be applied to classical simulations, 14 | typically to avoid the evaluation of long-range electrostatics in classical potentials. 15 | 16 | The second is named `ring polymer contraction`, first introduced in 17 | `T. E. Markland and D. E. Manolopoulos, JCP 129(2), 024105 (2008) `_ 18 | can be seen as performing a similar simplification `in imaginary time`, 19 | evaluating the expensive part of the potential on a smaller number of PI replicas. 20 | 21 | The techniques can be combined, which reduces even further the computational effort. 22 | This dual approach, which was introduced in 23 | `V. Kapil, J. VandeVondele, and M. Ceriotti, JCP 144(5), 054111 (2016) <(https://doi.org/10.1063/1.4941091>`_ 24 | and `O. Marsalek and T. E. Markland, JCP 144(5), (2016) `_, 25 | is the one that we will discuss here, allowing us to showcase two advanced features of i-PI. 26 | It is worth stressing that MTS and/or RPC can be used very conveniently together with 27 | machine-learning potentials 28 | (see e.g. `V. Kapil, J. Behler, and M. Ceriotti, JCP 145(23), 234103 (2016 `_ 29 | for an early application). 30 | 31 | -------------------------------------------------------------------------------- /examples/pi-mts-rpc/data/h2o_md.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | [step, time{picosecond}, conserved{electronvolt}, temperature{kelvin}, potential{electronvolt}, kinetic_md{electronvolt}, pressure_md{megapascal} ] 4 | positions{angstrom} 5 | 6 | 7 | 20000 8 | 9 |
qtip4pf-md
10 |
11 | 12 | 13 | data/water_32.pdb 14 | 300 15 | 16 | 17 | 18 | 19 | 20 | 300 21 | 22 | 23 | 24 | 0.5 25 | 26 | 500 27 | 28 | 29 | 30 | 31 |
32 | -------------------------------------------------------------------------------- /examples/pi-mts-rpc/data/h2o_mts.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | [step, time{picosecond}, conserved{electronvolt}, temperature{kelvin}, potential{electronvolt}, kinetic_md{electronvolt}, pressure_md{megapascal}, pot_component{electronvolt}(0), pot_component{electronvolt}(1) ] 4 | positions{angstrom} 5 | 6 | 7 | 5000 8 | 9 |
qtip4pf-mts-full
10 |
11 | 12 |
qtip4pf-mts-sr
13 |
14 | 15 | 16 | data/water_32.pdb 17 | 300 18 | 19 | 20 | 21 | [1,0] 22 | 23 | 24 | [-1,1] 25 | 26 | 27 | 28 | 300 29 | 30 | 31 | 32 | 2.0 33 | [1,4] 34 | 35 | 500 36 | 37 | 38 | 39 | 40 |
41 | -------------------------------------------------------------------------------- /examples/pi-mts-rpc/data/water_32.pdb: -------------------------------------------------------------------------------- 1 | CRYST1 10.260 10.260 10.260 90.00 90.00 90.00 P 1 2 | ATOM 1 O 1 1 3.756 4.710 9.494 0.00 0.00 O 3 | ATOM 2 H 1 1 4.604 4.272 9.671 0.00 0.00 H 4 | ATOM 3 H 1 1 3.998 5.320 8.788 0.00 0.00 H 5 | ATOM 4 O 1 1 9.933 8.841 0.366 0.00 0.00 O 6 | ATOM 5 H 1 1 10.132 8.196 1.120 0.00 0.00 H 7 | ATOM 6 H 1 1 9.368 8.449 -0.316 0.00 0.00 H 8 | ATOM 7 O 1 1 0.321 1.492 5.796 0.00 0.00 O 9 | ATOM 8 H 1 1 -0.287 1.993 5.241 0.00 0.00 H 10 | ATOM 9 H 1 1 0.791 2.061 6.364 0.00 0.00 H 11 | ATOM 10 O 1 1 8.035 9.735 4.307 0.00 0.00 O 12 | ATOM 11 H 1 1 7.203 9.789 4.847 0.00 0.00 H 13 | ATOM 12 H 1 1 8.636 9.307 4.920 0.00 0.00 H 14 | ATOM 13 O 1 1 5.663 9.082 0.660 0.00 0.00 O 15 | ATOM 14 H 1 1 6.378 9.721 0.814 0.00 0.00 H 16 | ATOM 15 H 1 1 5.213 8.991 1.552 0.00 0.00 H 17 | ATOM 16 O 1 1 8.130 0.215 1.201 0.00 0.00 O 18 | ATOM 17 H 1 1 8.196 -0.065 2.118 0.00 0.00 H 19 | ATOM 18 H 1 1 8.938 -0.161 0.818 0.00 0.00 H 20 | ATOM 19 O 1 1 8.177 4.165 0.716 0.00 0.00 O 21 | ATOM 20 H 1 1 7.895 5.066 0.840 0.00 0.00 H 22 | ATOM 21 H 1 1 7.722 3.562 1.341 0.00 0.00 H 23 | ATOM 22 O 1 1 6.341 3.256 9.678 0.00 0.00 O 24 | ATOM 23 H 1 1 7.133 3.423 10.189 0.00 0.00 H 25 | ATOM 24 H 1 1 6.507 2.398 9.350 0.00 0.00 H 26 | ATOM 25 O 1 1 0.136 7.798 2.738 0.00 0.00 O 27 | ATOM 26 H 1 1 -0.006 8.300 3.584 0.00 0.00 H 28 | ATOM 27 H 1 1 0.314 6.905 2.966 0.00 0.00 H 29 | ATOM 28 O 1 1 5.027 2.563 6.169 0.00 0.00 O 30 | ATOM 29 H 1 1 5.538 3.336 6.262 0.00 0.00 H 31 | ATOM 30 H 1 1 5.313 2.031 6.922 0.00 0.00 H 32 | ATOM 31 O 1 1 7.164 2.542 2.418 0.00 0.00 O 33 | ATOM 32 H 1 1 6.248 2.467 2.667 0.00 0.00 H 34 | ATOM 33 H 1 1 7.384 1.681 2.057 0.00 0.00 H 35 | ATOM 34 O 1 1 3.336 9.051 3.265 0.00 0.00 O 36 | ATOM 35 H 1 1 2.818 8.341 2.787 0.00 0.00 H 37 | ATOM 36 H 1 1 2.733 9.794 3.398 0.00 0.00 H 38 | ATOM 37 O 1 1 1.476 1.420 0.819 0.00 0.00 O 39 | ATOM 38 H 1 1 1.060 0.568 0.631 0.00 0.00 H 40 | ATOM 39 H 1 1 1.582 1.509 1.770 0.00 0.00 H 41 | ATOM 40 O 1 1 1.222 4.946 3.218 0.00 0.00 O 42 | ATOM 41 H 1 1 2.111 4.703 3.522 0.00 0.00 H 43 | ATOM 42 H 1 1 1.342 4.956 2.245 0.00 0.00 H 44 | ATOM 43 O 1 1 6.790 6.491 4.488 0.00 0.00 O 45 | ATOM 44 H 1 1 7.083 5.755 5.074 0.00 0.00 H 46 | ATOM 45 H 1 1 6.747 7.293 4.975 0.00 0.00 H 47 | ATOM 46 O 1 1 9.330 3.465 4.430 0.00 0.00 O 48 | ATOM 47 H 1 1 9.974 3.956 3.918 0.00 0.00 H 49 | ATOM 48 H 1 1 8.583 3.143 3.966 0.00 0.00 H 50 | ATOM 49 O 1 1 7.484 4.543 6.379 0.00 0.00 O 51 | ATOM 50 H 1 1 7.604 4.450 7.328 0.00 0.00 H 52 | ATOM 51 H 1 1 8.241 4.098 5.987 0.00 0.00 H 53 | ATOM 52 O 1 1 0.448 5.701 8.219 0.00 0.00 O 54 | ATOM 53 H 1 1 0.573 4.840 7.871 0.00 0.00 H 55 | ATOM 54 H 1 1 0.720 5.651 9.123 0.00 0.00 H 56 | ATOM 55 O 1 1 0.736 4.082 0.545 0.00 0.00 O 57 | ATOM 56 H 1 1 1.032 3.147 0.501 0.00 0.00 H 58 | ATOM 57 H 1 1 -0.250 3.978 0.476 0.00 0.00 H 59 | ATOM 58 O 1 1 4.229 2.582 3.562 0.00 0.00 O 60 | ATOM 59 H 1 1 4.650 2.364 4.424 0.00 0.00 H 61 | ATOM 60 H 1 1 4.306 3.526 3.496 0.00 0.00 H 62 | ATOM 61 O 1 1 3.749 5.318 3.591 0.00 0.00 O 63 | ATOM 62 H 1 1 3.577 5.600 2.690 0.00 0.00 H 64 | ATOM 63 H 1 1 4.519 5.812 3.831 0.00 0.00 H 65 | ATOM 64 O 1 1 0.242 8.540 5.195 0.00 0.00 O 66 | ATOM 65 H 1 1 0.243 9.452 5.454 0.00 0.00 H 67 | ATOM 66 H 1 1 0.725 8.102 5.864 0.00 0.00 H 68 | ATOM 67 O 1 1 6.065 0.243 8.171 0.00 0.00 O 69 | ATOM 68 H 1 1 6.685 -0.360 8.559 0.00 0.00 H 70 | ATOM 69 H 1 1 5.235 -0.020 8.586 0.00 0.00 H 71 | ATOM 70 O 1 1 7.362 8.029 9.049 0.00 0.00 O 72 | ATOM 71 H 1 1 6.719 7.831 8.312 0.00 0.00 H 73 | ATOM 72 H 1 1 6.813 7.839 9.757 0.00 0.00 H 74 | ATOM 73 O 1 1 1.971 1.171 3.631 0.00 0.00 O 75 | ATOM 74 H 1 1 1.520 1.399 4.474 0.00 0.00 H 76 | ATOM 75 H 1 1 2.821 1.577 3.533 0.00 0.00 H 77 | ATOM 76 O 1 1 7.674 6.605 2.134 0.00 0.00 O 78 | ATOM 77 H 1 1 7.143 6.490 2.918 0.00 0.00 H 79 | ATOM 78 H 1 1 8.563 6.681 2.409 0.00 0.00 H 80 | ATOM 79 O 1 1 2.769 7.384 7.275 0.00 0.00 O 81 | ATOM 80 H 1 1 2.353 8.088 7.748 0.00 0.00 H 82 | ATOM 81 H 1 1 2.249 6.554 7.408 0.00 0.00 H 83 | ATOM 82 O 1 1 2.253 2.791 7.349 0.00 0.00 O 84 | ATOM 83 H 1 1 2.718 3.230 8.076 0.00 0.00 H 85 | ATOM 84 H 1 1 2.955 2.671 6.707 0.00 0.00 H 86 | ATOM 85 O 1 1 3.652 9.953 9.290 0.00 0.00 O 87 | ATOM 86 H 1 1 4.114 9.509 9.983 0.00 0.00 H 88 | ATOM 87 H 1 1 3.199 10.639 9.784 0.00 0.00 H 89 | ATOM 88 O 1 1 5.263 6.708 7.589 0.00 0.00 O 90 | ATOM 89 H 1 1 4.318 7.082 7.707 0.00 0.00 H 91 | ATOM 90 H 1 1 5.455 7.057 6.733 0.00 0.00 H 92 | ATOM 91 O 1 1 3.507 6.721 1.020 0.00 0.00 O 93 | ATOM 92 H 1 1 4.097 7.303 0.607 0.00 0.00 H 94 | ATOM 93 H 1 1 3.586 5.984 0.419 0.00 0.00 H 95 | ATOM 94 O 1 1 5.455 9.196 5.888 0.00 0.00 O 96 | ATOM 95 H 1 1 5.473 9.602 6.758 0.00 0.00 H 97 | ATOM 96 H 1 1 4.549 9.238 5.484 0.00 0.00 H 98 | END 99 | -------------------------------------------------------------------------------- /examples/pi-mts-rpc/environment.yml: -------------------------------------------------------------------------------- 1 | channels: 2 | - conda-forge 3 | dependencies: 4 | - python=3.11 5 | - pip 6 | - gfortran 7 | - make 8 | - pip: 9 | - numpy 10 | - ase==3.22.1 11 | - chemiscope>=0.8 12 | - git+https://github.com/i-pi/i-pi.git@main#egg=ipi 13 | - ipi 14 | - matplotlib 15 | -------------------------------------------------------------------------------- /examples/pi-mts-rpc/pimd-mts-integrator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab-cosmo/atomistic-cookbook/5c526f3aa2f0eccfbdcac5160672d45eaa994e9f/examples/pi-mts-rpc/pimd-mts-integrator.png -------------------------------------------------------------------------------- /examples/pi-mts-rpc/pimd-mts-pots.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab-cosmo/atomistic-cookbook/5c526f3aa2f0eccfbdcac5160672d45eaa994e9f/examples/pi-mts-rpc/pimd-mts-pots.png -------------------------------------------------------------------------------- /examples/pi-mts-rpc/pimd-mts-rpc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab-cosmo/atomistic-cookbook/5c526f3aa2f0eccfbdcac5160672d45eaa994e9f/examples/pi-mts-rpc/pimd-mts-rpc.png -------------------------------------------------------------------------------- /examples/pi-mts-rpc/rpc-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab-cosmo/atomistic-cookbook/5c526f3aa2f0eccfbdcac5160672d45eaa994e9f/examples/pi-mts-rpc/rpc-4.png -------------------------------------------------------------------------------- /examples/polarizability/README.rst: -------------------------------------------------------------------------------- 1 | Equivariant model for polarizability 2 | ==================================== 3 | 4 | This example shows how to use the `featomic` library to build an equivariant 5 | linear model for the polarizability tensor of atomistic systems. -------------------------------------------------------------------------------- /examples/polarizability/environment.yml: -------------------------------------------------------------------------------- 1 | channels: 2 | - conda-forge 3 | dependencies: 4 | - python=3.11 5 | - pip 6 | - pip: 7 | - ase 8 | - featomic-torch<0.7,>0.6 9 | - metatensor-torch<0.8 10 | - metatensor-operations 11 | - metatensor-learn 12 | - matplotlib 13 | - torch 14 | - scikit-learn -------------------------------------------------------------------------------- /examples/rotate-equivariants/README.rst: -------------------------------------------------------------------------------- 1 | Rotating equivariant properties 2 | =============================== 3 | 4 | This example goes through the rotation of spherical tensor properties. 5 | This basic, but not obvious, technique is useful in the context of 6 | training non-equivariant neural networks with rotational augmentation 7 | or writing tests for equivariant operations within rotationally equivariant 8 | models. 9 | -------------------------------------------------------------------------------- /examples/rotate-equivariants/environment.yml: -------------------------------------------------------------------------------- 1 | channels: 2 | - conda-forge 3 | dependencies: 4 | - python=3.11 5 | - pip 6 | - pip: 7 | - ase==3.22.1 8 | - spherical 9 | - featomic 10 | -------------------------------------------------------------------------------- /examples/rotate-equivariants/rotate-equivariants.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab-cosmo/atomistic-cookbook/5c526f3aa2f0eccfbdcac5160672d45eaa994e9f/examples/rotate-equivariants/rotate-equivariants.png -------------------------------------------------------------------------------- /examples/roy-gch/.gitignore: -------------------------------------------------------------------------------- 1 | *.json.gz 2 | *.npz 3 | -------------------------------------------------------------------------------- /examples/roy-gch/README.rst: -------------------------------------------------------------------------------- 1 | Generalized Convex Hull analysis of the polymorphs of ROY 2 | ========================================================= 3 | 4 | This is an example of the construction of a generalized convex hull 5 | based on SOAP features, for a dataset containing known (and hypothetical) 6 | polymorphs of 5-methyl-2-[(2-nitrophenyl)amino]-3-thiophenecabonitrile 7 | (ROY). 8 | 9 | It showcases the use of ``rascaline`` to compute descriptors for a 10 | database of atomic structures, and ``scikit-matter`` to compute the 11 | convex hull. The structures are visualized using ``chemiscope`` widgets. 12 | -------------------------------------------------------------------------------- /examples/roy-gch/data/beran_roy_structures.xyz.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab-cosmo/atomistic-cookbook/5c526f3aa2f0eccfbdcac5160672d45eaa994e9f/examples/roy-gch/data/beran_roy_structures.xyz.bz2 -------------------------------------------------------------------------------- /examples/roy-gch/environment.yml: -------------------------------------------------------------------------------- 1 | channels: 2 | - conda-forge 3 | dependencies: 4 | - python=3.11 5 | - pip 6 | - rust>=1.65 7 | - pip: 8 | - ase==3.22.1 9 | - chemiscope>=0.7 10 | - matplotlib 11 | - scipy<1.15 12 | - metatensor 13 | - featomic 14 | - scikit-learn<1.6 15 | - git+https://github.com/scikit-learn-contrib/scikit-matter@722d582f9d88ecefb486dae90e0ca6d835d42024 16 | -------------------------------------------------------------------------------- /examples/sample-selection/.gitignore: -------------------------------------------------------------------------------- 1 | sample-selection.json.gz 2 | -------------------------------------------------------------------------------- /examples/sample-selection/README.rst: -------------------------------------------------------------------------------- 1 | Sample and Feature Selection 2 | ============================ 3 | 4 | This is an example of the selection of a diverse subset of structures 5 | from a dataset of candidates (a collection of barium titanate structures) 6 | using SOAP features and FPS and CUR selection. It then also demonstrates 7 | how the same techniques can be used to select the most relevant features. 8 | 9 | It showcases the use of ``featomic`` to compute descriptors for a 10 | database of atomic structures, and ``scikit-matter`` to compute the 11 | FPS and CUR selections. The structures are visualized using ``chemiscope`` widgets. 12 | 13 | -------------------------------------------------------------------------------- /examples/sample-selection/environment.yml: -------------------------------------------------------------------------------- 1 | channels: 2 | - conda-forge 3 | dependencies: 4 | - python=3.11 5 | - pip 6 | - rust >=1.65 7 | - pip: 8 | - ase==3.22.1 9 | - chemiscope>=0.7 10 | - matplotlib 11 | - metatensor 12 | - featomic 13 | - skmatter @ git+https://github.com/scikit-learn-contrib/scikit-matter.git@ac4558b52b5269c0cc1b0794f0230a264a938fce 14 | 15 | -------------------------------------------------------------------------------- /examples/thermostats/README.rst: -------------------------------------------------------------------------------- 1 | Thermostatting molecular dynamics simulations, a primer 2 | ====================================================== 3 | 4 | This example provides some practical guidelines to set up and 5 | run simulations using different types of (primarily stochastic) 6 | thermostats. It discusses both `i-PI `_ and 7 | `LAMMPS `_ as practical codes, and it 8 | analizes and visualize the output using ``matplotlib`` and 9 | `chemiscope `_. 10 | -------------------------------------------------------------------------------- /examples/thermostats/data/gle.lmp: -------------------------------------------------------------------------------- 1 | units electron 2 | atom_style full 3 | 4 | pair_style lj/cut/tip4p/long 1 2 1 1 0.278072379 17.007 5 | bond_style class2 6 | angle_style harmonic 7 | kspace_style pppm/tip4p 0.0001 8 | 9 | read_data data/water_32_data.lmp 10 | pair_coeff * * 0 0 11 | pair_coeff 1 1 0.000295147 5.96946 12 | 13 | neighbor 2.0 bin 14 | 15 | velocity all create 300.0 2345187 16 | 17 | dump 1 all xyz 100 lammps_pos.xyz 18 | thermo 100 19 | thermo_style custom step temp press pe etotal 20 | variable T equal temp 21 | variable P equal press 22 | variable PE equal pe 23 | variable ETOTAL equal etotal 24 | fix thermo_out all ave/time 10 1 10 v_T v_PE v_ETOTAL v_P file lammps_out.dat 25 | 26 | timestep 1.0 27 | fix 1 all gle 6 300 300 31415 data/smart.A 28 | run 10000 29 | 30 | -------------------------------------------------------------------------------- /examples/thermostats/data/in.lmp: -------------------------------------------------------------------------------- 1 | units electron 2 | atom_style full 3 | 4 | pair_style lj/cut/tip4p/long 1 2 1 1 0.278072379 17.007 5 | bond_style class2 6 | angle_style harmonic 7 | kspace_style pppm/tip4p 0.0001 8 | 9 | read_data data/water_32_data.lmp 10 | pair_coeff * * 0 0 11 | pair_coeff 1 1 0.000295147 5.96946 12 | 13 | neighbor 2.0 bin 14 | 15 | timestep 0.00025 16 | 17 | #velocity all create 298.0 2345187 18 | 19 | #thermo_style multi 20 | #thermo 1 21 | 22 | #fix 1 all nvt temp 298.0 298.0 30.0 tchain 1 23 | #fix 1 all nve 24 | fix 1 all ipi h2o-lammps 32342 unix 25 | 26 | 27 | #dump 1 all xyz 25 dump.xyz 28 | 29 | run 100000000 30 | 31 | -------------------------------------------------------------------------------- /examples/thermostats/data/input_cvv_sample.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | [ step, time{picosecond}, conserved{electronvolt}, 5 | temperature{kelvin}, kinetic_md{electronvolt}, potential{electronvolt}, 6 | temperature(H){kelvin}, temperature(O){kelvin} ] 7 | 8 | 9 | 20000 10 | 11 | 32342 12 | 13 | 14 |
h2o-lammps
1e-4 15 |
16 | 17 | 18 | data/water_32.pdb 19 | 300 20 | 21 | 22 | lmpserial 23 | 24 | 25 | 300 26 | 27 | 28 | 29 | 1.0 30 | 31 | 32 | [ 8.191023526179e-4, 8.328506066524e-3, 1.657771834013e-3, 9.736989925341e-4, 2.841803794895e-4, -3.176846864198e-5, -2.967010478210e-4, 33 | -8.389856546341e-4, 2.405526974742e-2, -1.507872374848e-2, 2.589784240185e-3, 1.516783633362e-3, -5.958833418565e-4, 4.198422349789e-4, 34 | 7.798710586406e-4, 1.507872374848e-2, 8.569039501219e-3, 6.001000899602e-3, 1.062029383877e-3, 1.093939147968e-3, -2.661575532976e-3, 35 | -9.676783161546e-4, -2.589784240185e-3, -6.001000899602e-3, 2.680459336535e-5, -5.214694469742e-5, 4.231304910751e-4, -2.104894919743e-5, 36 | -2.841997149166e-4, -1.516783633362e-3, -1.062029383877e-3, 5.214694469742e-5, 1.433903506353e-9, -4.241574212449e-5, 7.910178912362e-5, 37 | 3.333208286893e-5, 5.958833418565e-4, -1.093939147968e-3, -4.231304910751e-4, 4.241574212449e-5, 2.385554468441e-8, -3.139255482869e-5, 38 | 2.967533789056e-4, -4.198422349789e-4, 2.661575532976e-3, 2.104894919743e-5, -7.910178912362e-5, 3.139255482869e-5, 2.432567259684e-11 39 | ] 40 | 41 | 42 | 43 | 44 | 45 |
46 | -------------------------------------------------------------------------------- /examples/thermostats/data/input_cvv_traj.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | [ step, time{picosecond}, conserved{electronvolt}, 5 | temperature{kelvin}, kinetic_md{electronvolt}, potential{electronvolt}, 6 | temperature(H){kelvin}, temperature(O){kelvin} ] 7 | positions 8 | velocities 9 | 10 | 2000 11 | 12 | 32342 13 | 14 | 15 |
h2o-lammps
1e-4 16 |
17 | 18 | ['ITRAJ'] 19 | [1] 20 | [2] 21 | [3] 22 | [4] 23 | [5] 24 | [6] 25 | [7] 26 | [8 ] 27 | 47 | 48 |
49 | -------------------------------------------------------------------------------- /examples/thermostats/data/input_gle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | [ step, time{picosecond}, conserved{electronvolt}, 5 | temperature{kelvin}, kinetic_md{electronvolt}, potential{electronvolt}, 6 | temperature(H){kelvin}, temperature(O){kelvin} ] 7 | positions 8 | velocities 9 | 10 | 2000 11 | 12 | 32342 13 | 14 | 15 |
h2o-lammps
1e-4 16 |
17 | 18 | 19 | data/water_32.pdb 20 | 300 21 | 22 | 23 | lmpserial 24 | 25 | 26 | 300 27 | 28 | 29 | 30 | 1.0 31 | 32 | 33 | [ 8.191023526179e-4, 8.328506066524e-3, 1.657771834013e-3, 9.736989925341e-4, 2.841803794895e-4, -3.176846864198e-5, -2.967010478210e-4, 34 | -8.389856546341e-4, 2.405526974742e-2, -1.507872374848e-2, 2.589784240185e-3, 1.516783633362e-3, -5.958833418565e-4, 4.198422349789e-4, 35 | 7.798710586406e-4, 1.507872374848e-2, 8.569039501219e-3, 6.001000899602e-3, 1.062029383877e-3, 1.093939147968e-3, -2.661575532976e-3, 36 | -9.676783161546e-4, -2.589784240185e-3, -6.001000899602e-3, 2.680459336535e-5, -5.214694469742e-5, 4.231304910751e-4, -2.104894919743e-5, 37 | -2.841997149166e-4, -1.516783633362e-3, -1.062029383877e-3, 5.214694469742e-5, 1.433903506353e-9, -4.241574212449e-5, 7.910178912362e-5, 38 | 3.333208286893e-5, 5.958833418565e-4, -1.093939147968e-3, -4.231304910751e-4, 4.241574212449e-5, 2.385554468441e-8, -3.139255482869e-5, 39 | 2.967533789056e-4, -4.198422349789e-4, 2.661575532976e-3, 2.104894919743e-5, -7.910178912362e-5, 3.139255482869e-5, 2.432567259684e-11 40 | ] 41 | 42 | 43 | 44 | 45 | 46 |
47 | -------------------------------------------------------------------------------- /examples/thermostats/data/input_higamma.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | [ step, time{picosecond}, conserved{electronvolt}, 5 | temperature{kelvin}, kinetic_md{electronvolt}, potential{electronvolt}, 6 | temperature(H){kelvin}, temperature(O){kelvin} ] 7 | positions 8 | velocities 9 | 10 | 2000 11 | 12 | 32342 13 | 14 | 15 |
h2o-lammps
1e-4 16 |
17 | 18 | 19 | data/water_32.pdb 20 | 300 21 | 22 | 23 | lmpserial 24 | 25 | 26 | 300 27 | 28 | 29 | 30 | 1.0 31 | 32 | 10 33 | 34 | 35 | 36 | 37 |
38 | -------------------------------------------------------------------------------- /examples/thermostats/data/input_nve.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | [ step, time{picosecond}, conserved{electronvolt}, 5 | temperature{kelvin}, kinetic_md{electronvolt}, potential{electronvolt}, 6 | temperature(H){kelvin}, temperature(O){kelvin} ] 7 | positions 8 | velocities 9 | 10 | 2000 11 | 12 | 32342 13 | 14 | 15 |
h2o-lammps
1e-4 16 |
17 | 18 | 19 | data/water_32.pdb 20 | 300 21 | 22 | 23 | lmpserial 24 | 25 | 26 | 300 27 | 28 | 29 | 30 | 1.0 31 | 32 | 33 | 34 |
35 | -------------------------------------------------------------------------------- /examples/thermostats/data/input_svr.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | [ step, time{picosecond}, conserved{electronvolt}, 5 | temperature{kelvin}, kinetic_md{electronvolt}, potential{electronvolt}, 6 | temperature(H){kelvin}, temperature(O){kelvin} ] 7 | positions 8 | velocities 9 | 10 | 2000 11 | 12 | 32342 13 | 14 | 15 |
h2o-lammps
1e-4 16 |
17 | 18 | 19 | data/water_32.pdb 20 | 300 21 | 22 | 23 | lmpserial 24 | 25 | 26 | 300 27 | 28 | 29 | 30 | 1.0 31 | 32 | 10 33 | 34 | 35 | 36 | 37 |
38 | -------------------------------------------------------------------------------- /examples/thermostats/data/run_traj.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This is a simple script to run some reference 4 | # NVE trajectories for the autocorrelation function, 5 | # starting from samples collected from a NVT trajectory 6 | 7 | # First, we launch the sampling trajectory. This 8 | # outputs checkpoint files every 2 ps. 9 | 10 | i-pi data/input_cvv_sample.xml & sleep 4 11 | lmp < data/in.lmp 12 | 13 | # Then, we run an i-PI input that launches multiple 14 | # NVE trajectories 15 | 16 | i-pi data/input_cvv_traj.xml & sleep 4 17 | for i in {1..8}; do lmp < data/in.lmp & done 18 | wait 19 | 20 | # Finally, run the i-PI post-processing on the 21 | # concatenated velocity trajectories. The block size 22 | # is chosen so each trajectory is a separate block. 23 | 24 | cat traj-*_traj.vel_0.xyz &> traj-all.xyz 25 | i-pi-getacf -ifile traj-all.xyz -mlag 1000 -bsize 2001 -ftpad 2000 -ftwin cosine-blackman -dt "1 femtosecond" -oprefix traj-all 26 | -------------------------------------------------------------------------------- /examples/thermostats/data/smart.A: -------------------------------------------------------------------------------- 1 | 3.386281653149e-2 3.443118824048e-1 6.853456504773e-2 4.025405400887e-2 1.174840729213e-2 -1.313352136850e-3 -1.226602892172e-2 2 | -3.468481955231e-2 9.944778982366e-1 -6.233751547554e-1 1.070652383078e-1 6.270591914470e-2 -2.463463597066e-2 1.735685476891e-2 3 | 3.224094094292e-2 6.233751547554e-1 3.542558650374e-1 2.480896213019e-1 4.390575373437e-2 4.522494721916e-2 -1.100331889779e-1 4 | -4.000515097620e-2 -1.070652383078e-1 -2.480896213019e-1 1.108138713594e-3 -2.155826332720e-3 1.749279579329e-2 -8.701924766486e-4 5 | -1.174920664525e-2 -6.270591914470e-2 -4.390575373437e-2 2.155826332720e-3 5.927954083432e-8 -1.753525049730e-3 3.270176631583e-3 6 | 1.377994097069e-3 2.463463597066e-2 -4.522494721916e-2 -1.749279579329e-2 1.753525049730e-3 9.862209897519e-7 -1.297811343382e-3 7 | 1.226819236065e-2 -1.735685476891e-2 1.100331889779e-1 8.701924766486e-4 -3.270176631583e-3 1.297811343382e-3 1.005656723509e-9 8 | -------------------------------------------------------------------------------- /examples/thermostats/data/water_32.pdb: -------------------------------------------------------------------------------- 1 | CRYST1 10.260 10.260 10.260 90.00 90.00 90.00 P 1 2 | ATOM 1 O 1 1 3.756 4.710 9.494 0.00 0.00 O 3 | ATOM 2 H 1 1 4.604 4.272 9.671 0.00 0.00 H 4 | ATOM 3 H 1 1 3.998 5.320 8.788 0.00 0.00 H 5 | ATOM 4 O 1 1 9.933 8.841 0.366 0.00 0.00 O 6 | ATOM 5 H 1 1 10.132 8.196 1.120 0.00 0.00 H 7 | ATOM 6 H 1 1 9.368 8.449 -0.316 0.00 0.00 H 8 | ATOM 7 O 1 1 0.321 1.492 5.796 0.00 0.00 O 9 | ATOM 8 H 1 1 -0.287 1.993 5.241 0.00 0.00 H 10 | ATOM 9 H 1 1 0.791 2.061 6.364 0.00 0.00 H 11 | ATOM 10 O 1 1 8.035 9.735 4.307 0.00 0.00 O 12 | ATOM 11 H 1 1 7.203 9.789 4.847 0.00 0.00 H 13 | ATOM 12 H 1 1 8.636 9.307 4.920 0.00 0.00 H 14 | ATOM 13 O 1 1 5.663 9.082 0.660 0.00 0.00 O 15 | ATOM 14 H 1 1 6.378 9.721 0.814 0.00 0.00 H 16 | ATOM 15 H 1 1 5.213 8.991 1.552 0.00 0.00 H 17 | ATOM 16 O 1 1 8.130 0.215 1.201 0.00 0.00 O 18 | ATOM 17 H 1 1 8.196 -0.065 2.118 0.00 0.00 H 19 | ATOM 18 H 1 1 8.938 -0.161 0.818 0.00 0.00 H 20 | ATOM 19 O 1 1 8.177 4.165 0.716 0.00 0.00 O 21 | ATOM 20 H 1 1 7.895 5.066 0.840 0.00 0.00 H 22 | ATOM 21 H 1 1 7.722 3.562 1.341 0.00 0.00 H 23 | ATOM 22 O 1 1 6.341 3.256 9.678 0.00 0.00 O 24 | ATOM 23 H 1 1 7.133 3.423 10.189 0.00 0.00 H 25 | ATOM 24 H 1 1 6.507 2.398 9.350 0.00 0.00 H 26 | ATOM 25 O 1 1 0.136 7.798 2.738 0.00 0.00 O 27 | ATOM 26 H 1 1 -0.006 8.300 3.584 0.00 0.00 H 28 | ATOM 27 H 1 1 0.314 6.905 2.966 0.00 0.00 H 29 | ATOM 28 O 1 1 5.027 2.563 6.169 0.00 0.00 O 30 | ATOM 29 H 1 1 5.538 3.336 6.262 0.00 0.00 H 31 | ATOM 30 H 1 1 5.313 2.031 6.922 0.00 0.00 H 32 | ATOM 31 O 1 1 7.164 2.542 2.418 0.00 0.00 O 33 | ATOM 32 H 1 1 6.248 2.467 2.667 0.00 0.00 H 34 | ATOM 33 H 1 1 7.384 1.681 2.057 0.00 0.00 H 35 | ATOM 34 O 1 1 3.336 9.051 3.265 0.00 0.00 O 36 | ATOM 35 H 1 1 2.818 8.341 2.787 0.00 0.00 H 37 | ATOM 36 H 1 1 2.733 9.794 3.398 0.00 0.00 H 38 | ATOM 37 O 1 1 1.476 1.420 0.819 0.00 0.00 O 39 | ATOM 38 H 1 1 1.060 0.568 0.631 0.00 0.00 H 40 | ATOM 39 H 1 1 1.582 1.509 1.770 0.00 0.00 H 41 | ATOM 40 O 1 1 1.222 4.946 3.218 0.00 0.00 O 42 | ATOM 41 H 1 1 2.111 4.703 3.522 0.00 0.00 H 43 | ATOM 42 H 1 1 1.342 4.956 2.245 0.00 0.00 H 44 | ATOM 43 O 1 1 6.790 6.491 4.488 0.00 0.00 O 45 | ATOM 44 H 1 1 7.083 5.755 5.074 0.00 0.00 H 46 | ATOM 45 H 1 1 6.747 7.293 4.975 0.00 0.00 H 47 | ATOM 46 O 1 1 9.330 3.465 4.430 0.00 0.00 O 48 | ATOM 47 H 1 1 9.974 3.956 3.918 0.00 0.00 H 49 | ATOM 48 H 1 1 8.583 3.143 3.966 0.00 0.00 H 50 | ATOM 49 O 1 1 7.484 4.543 6.379 0.00 0.00 O 51 | ATOM 50 H 1 1 7.604 4.450 7.328 0.00 0.00 H 52 | ATOM 51 H 1 1 8.241 4.098 5.987 0.00 0.00 H 53 | ATOM 52 O 1 1 0.448 5.701 8.219 0.00 0.00 O 54 | ATOM 53 H 1 1 0.573 4.840 7.871 0.00 0.00 H 55 | ATOM 54 H 1 1 0.720 5.651 9.123 0.00 0.00 H 56 | ATOM 55 O 1 1 0.736 4.082 0.545 0.00 0.00 O 57 | ATOM 56 H 1 1 1.032 3.147 0.501 0.00 0.00 H 58 | ATOM 57 H 1 1 -0.250 3.978 0.476 0.00 0.00 H 59 | ATOM 58 O 1 1 4.229 2.582 3.562 0.00 0.00 O 60 | ATOM 59 H 1 1 4.650 2.364 4.424 0.00 0.00 H 61 | ATOM 60 H 1 1 4.306 3.526 3.496 0.00 0.00 H 62 | ATOM 61 O 1 1 3.749 5.318 3.591 0.00 0.00 O 63 | ATOM 62 H 1 1 3.577 5.600 2.690 0.00 0.00 H 64 | ATOM 63 H 1 1 4.519 5.812 3.831 0.00 0.00 H 65 | ATOM 64 O 1 1 0.242 8.540 5.195 0.00 0.00 O 66 | ATOM 65 H 1 1 0.243 9.452 5.454 0.00 0.00 H 67 | ATOM 66 H 1 1 0.725 8.102 5.864 0.00 0.00 H 68 | ATOM 67 O 1 1 6.065 0.243 8.171 0.00 0.00 O 69 | ATOM 68 H 1 1 6.685 -0.360 8.559 0.00 0.00 H 70 | ATOM 69 H 1 1 5.235 -0.020 8.586 0.00 0.00 H 71 | ATOM 70 O 1 1 7.362 8.029 9.049 0.00 0.00 O 72 | ATOM 71 H 1 1 6.719 7.831 8.312 0.00 0.00 H 73 | ATOM 72 H 1 1 6.813 7.839 9.757 0.00 0.00 H 74 | ATOM 73 O 1 1 1.971 1.171 3.631 0.00 0.00 O 75 | ATOM 74 H 1 1 1.520 1.399 4.474 0.00 0.00 H 76 | ATOM 75 H 1 1 2.821 1.577 3.533 0.00 0.00 H 77 | ATOM 76 O 1 1 7.674 6.605 2.134 0.00 0.00 O 78 | ATOM 77 H 1 1 7.143 6.490 2.918 0.00 0.00 H 79 | ATOM 78 H 1 1 8.563 6.681 2.409 0.00 0.00 H 80 | ATOM 79 O 1 1 2.769 7.384 7.275 0.00 0.00 O 81 | ATOM 80 H 1 1 2.353 8.088 7.748 0.00 0.00 H 82 | ATOM 81 H 1 1 2.249 6.554 7.408 0.00 0.00 H 83 | ATOM 82 O 1 1 2.253 2.791 7.349 0.00 0.00 O 84 | ATOM 83 H 1 1 2.718 3.230 8.076 0.00 0.00 H 85 | ATOM 84 H 1 1 2.955 2.671 6.707 0.00 0.00 H 86 | ATOM 85 O 1 1 3.652 9.953 9.290 0.00 0.00 O 87 | ATOM 86 H 1 1 4.114 9.509 9.983 0.00 0.00 H 88 | ATOM 87 H 1 1 3.199 10.639 9.784 0.00 0.00 H 89 | ATOM 88 O 1 1 5.263 6.708 7.589 0.00 0.00 O 90 | ATOM 89 H 1 1 4.318 7.082 7.707 0.00 0.00 H 91 | ATOM 90 H 1 1 5.455 7.057 6.733 0.00 0.00 H 92 | ATOM 91 O 1 1 3.507 6.721 1.020 0.00 0.00 O 93 | ATOM 92 H 1 1 4.097 7.303 0.607 0.00 0.00 H 94 | ATOM 93 H 1 1 3.586 5.984 0.419 0.00 0.00 H 95 | ATOM 94 O 1 1 5.455 9.196 5.888 0.00 0.00 O 96 | ATOM 95 H 1 1 5.473 9.602 6.758 0.00 0.00 H 97 | ATOM 96 H 1 1 4.549 9.238 5.484 0.00 0.00 H 98 | END 99 | -------------------------------------------------------------------------------- /examples/thermostats/data/water_32_data.lmp: -------------------------------------------------------------------------------- 1 | LAMMPS Description 2 | 3 | 96 atoms 4 | 64 bonds 5 | 32 angles 6 | 7 | 2 atom types 8 | 1 bond types 9 | 1 angle types 10 | 11 | -9.694295 9.694295 xlo xhi 12 | -9.694295 9.694295 ylo yhi 13 | -9.694295 9.694295 zlo zhi 14 | 15 | Masses 16 | 17 | 1 15.9994 18 | 2 1.0080 19 | 20 | Bond Coeffs 21 | 22 | 1 1.78 0.2708585 -0.327738785 0.231328959 23 | 24 | Angle Coeffs 25 | 26 | 1 0.0700 107.400000 27 | 28 | Atoms 29 | 30 | 1 1 1 -1.1128 7.098 8.901 17.941 31 | 2 1 2 0.5564 8.700 8.073 18.276 32 | 3 1 2 0.5564 7.555 10.053 16.607 33 | 4 2 1 -1.1128 18.771 16.707 0.692 34 | 5 2 2 0.5564 19.147 15.488 2.116 35 | 6 2 2 0.5564 17.703 15.966 -0.597 36 | 7 3 1 -1.1128 0.607 2.819 10.953 37 | 8 3 2 0.5564 -0.542 3.766 9.904 38 | 9 3 2 0.5564 1.495 3.895 12.026 39 | 10 4 1 -1.1128 15.184 18.396 8.139 40 | 11 4 2 0.5564 13.612 18.499 9.160 41 | 12 4 2 0.5564 16.320 17.588 9.297 42 | 13 5 1 -1.1128 10.702 17.162 1.247 43 | 14 5 2 0.5564 12.053 18.370 1.538 44 | 15 5 2 0.5564 9.851 16.991 2.933 45 | 16 6 1 -1.1128 15.363 0.406 2.270 46 | 17 6 2 0.5564 15.488 -0.123 4.002 47 | 18 6 2 0.5564 16.890 -0.304 1.546 48 | 19 7 1 -1.1128 15.452 7.871 1.353 49 | 20 7 2 0.5564 14.919 9.573 1.587 50 | 21 7 2 0.5564 14.592 6.731 2.534 51 | 22 8 1 -1.1128 11.983 6.153 18.289 52 | 23 8 2 0.5564 13.479 6.469 19.254 53 | 24 8 2 0.5564 12.296 4.532 17.669 54 | 25 9 1 -1.1128 0.257 14.736 5.174 55 | 26 9 2 0.5564 -0.011 15.685 6.773 56 | 27 9 2 0.5564 0.593 13.049 5.605 57 | 28 10 1 -1.1128 9.500 4.843 11.658 58 | 29 10 2 0.5564 10.465 6.304 11.833 59 | 30 10 2 0.5564 10.040 3.838 13.081 60 | 31 11 1 -1.1128 13.538 4.804 4.569 61 | 32 11 2 0.5564 11.807 4.662 5.040 62 | 33 11 2 0.5564 13.954 3.177 3.887 63 | 34 12 1 -1.1128 6.304 17.104 6.170 64 | 35 12 2 0.5564 5.325 15.762 5.267 65 | 36 12 2 0.5564 5.165 18.508 6.421 66 | 37 13 1 -1.1128 2.789 2.683 1.548 67 | 38 13 2 0.5564 2.003 1.073 1.192 68 | 39 13 2 0.5564 2.990 2.852 3.345 69 | 40 14 1 -1.1128 2.309 9.347 6.081 70 | 41 14 2 0.5564 3.989 8.887 6.656 71 | 42 14 2 0.5564 2.536 9.365 4.242 72 | 43 15 1 -1.1128 12.831 12.266 8.481 73 | 44 15 2 0.5564 13.385 10.875 9.588 74 | 45 15 2 0.5564 12.750 13.782 9.401 75 | 46 16 1 -1.1128 17.631 6.548 8.371 76 | 47 16 2 0.5564 18.848 7.476 7.404 77 | 48 16 2 0.5564 16.220 5.939 7.495 78 | 49 17 1 -1.1128 14.143 8.585 12.055 79 | 50 17 2 0.5564 14.369 8.409 13.848 80 | 51 17 2 0.5564 15.573 7.744 11.314 81 | 52 18 1 -1.1128 0.847 10.773 15.532 82 | 53 18 2 0.5564 1.083 9.146 14.874 83 | 54 18 2 0.5564 1.361 10.679 17.240 84 | 55 19 1 -1.1128 1.391 7.714 1.030 85 | 56 19 2 0.5564 1.950 5.947 0.947 86 | 57 19 2 0.5564 -0.472 7.517 0.900 87 | 58 20 1 -1.1128 7.992 4.879 6.731 88 | 59 20 2 0.5564 8.787 4.467 8.360 89 | 60 20 2 0.5564 8.137 6.663 6.606 90 | 61 21 1 -1.1128 7.085 10.050 6.786 91 | 62 21 2 0.5564 6.760 10.582 5.083 92 | 63 21 2 0.5564 8.540 10.983 7.240 93 | 64 22 1 -1.1128 0.457 16.138 9.817 94 | 65 22 2 0.5564 0.459 17.862 10.307 95 | 66 22 2 0.5564 1.370 15.311 11.081 96 | 67 23 1 -1.1128 11.461 0.459 15.441 97 | 68 23 2 0.5564 12.633 -0.680 16.174 98 | 69 23 2 0.5564 9.893 -0.038 16.225 99 | 70 24 1 -1.1128 13.912 15.173 17.100 100 | 71 24 2 0.5564 12.697 14.798 15.707 101 | 72 24 2 0.5564 12.875 14.814 18.438 102 | 73 25 1 -1.1128 3.725 2.213 6.862 103 | 74 25 2 0.5564 2.872 2.644 8.455 104 | 75 25 2 0.5564 5.331 2.980 6.676 105 | 76 26 1 -1.1128 14.502 12.482 4.033 106 | 77 26 2 0.5564 13.498 12.264 5.514 107 | 78 26 2 0.5564 16.182 12.625 4.552 108 | 79 27 1 -1.1128 5.233 13.954 13.748 109 | 80 27 2 0.5564 4.447 15.284 14.642 110 | 81 27 2 0.5564 4.250 12.385 13.999 111 | 82 28 1 -1.1128 4.258 5.274 13.888 112 | 83 28 2 0.5564 5.136 6.104 15.261 113 | 84 28 2 0.5564 5.584 5.047 12.674 114 | 85 29 1 -1.1128 6.901 18.808 17.556 115 | 86 29 2 0.5564 7.774 17.969 18.865 116 | 87 29 2 0.5564 6.045 20.105 18.489 117 | 88 30 1 -1.1128 9.946 12.676 14.341 118 | 89 30 2 0.5564 8.160 13.383 14.564 119 | 90 30 2 0.5564 10.308 13.336 12.724 120 | 91 31 1 -1.1128 6.627 12.701 1.928 121 | 92 31 2 0.5564 7.742 13.801 1.147 122 | 93 31 2 0.5564 6.777 11.308 0.792 123 | 94 32 1 -1.1128 10.308 17.378 11.127 124 | 95 32 2 0.5564 10.342 18.145 12.771 125 | 96 32 2 0.5564 8.596 17.457 10.363 126 | 127 | Bonds 128 | 129 | 1 1 1 2 130 | 2 1 1 3 131 | 3 1 4 5 132 | 4 1 4 6 133 | 5 1 7 8 134 | 6 1 7 9 135 | 7 1 10 11 136 | 8 1 10 12 137 | 9 1 13 14 138 | 10 1 13 15 139 | 11 1 16 17 140 | 12 1 16 18 141 | 13 1 19 20 142 | 14 1 19 21 143 | 15 1 22 23 144 | 16 1 22 24 145 | 17 1 25 26 146 | 18 1 25 27 147 | 19 1 28 29 148 | 20 1 28 30 149 | 21 1 31 32 150 | 22 1 31 33 151 | 23 1 34 35 152 | 24 1 34 36 153 | 25 1 37 38 154 | 26 1 37 39 155 | 27 1 40 41 156 | 28 1 40 42 157 | 29 1 43 44 158 | 30 1 43 45 159 | 31 1 46 47 160 | 32 1 46 48 161 | 33 1 49 50 162 | 34 1 49 51 163 | 35 1 52 53 164 | 36 1 52 54 165 | 37 1 55 56 166 | 38 1 55 57 167 | 39 1 58 59 168 | 40 1 58 60 169 | 41 1 61 62 170 | 42 1 61 63 171 | 43 1 64 65 172 | 44 1 64 66 173 | 45 1 67 68 174 | 46 1 67 69 175 | 47 1 70 71 176 | 48 1 70 72 177 | 49 1 73 74 178 | 50 1 73 75 179 | 51 1 76 77 180 | 52 1 76 78 181 | 53 1 79 80 182 | 54 1 79 81 183 | 55 1 82 83 184 | 56 1 82 84 185 | 57 1 85 86 186 | 58 1 85 87 187 | 59 1 88 89 188 | 60 1 88 90 189 | 61 1 91 92 190 | 62 1 91 93 191 | 63 1 94 95 192 | 64 1 94 96 193 | 194 | Angles 195 | 196 | 1 1 2 1 3 197 | 2 1 5 4 6 198 | 3 1 8 7 9 199 | 4 1 11 10 12 200 | 5 1 14 13 15 201 | 6 1 17 16 18 202 | 7 1 20 19 21 203 | 8 1 23 22 24 204 | 9 1 26 25 27 205 | 10 1 29 28 30 206 | 11 1 32 31 33 207 | 12 1 35 34 36 208 | 13 1 38 37 39 209 | 14 1 41 40 42 210 | 15 1 44 43 45 211 | 16 1 47 46 48 212 | 17 1 50 49 51 213 | 18 1 53 52 54 214 | 19 1 56 55 57 215 | 20 1 59 58 60 216 | 21 1 62 61 63 217 | 22 1 65 64 66 218 | 23 1 68 67 69 219 | 24 1 71 70 72 220 | 25 1 74 73 75 221 | 26 1 77 76 78 222 | 27 1 80 79 81 223 | 28 1 83 82 84 224 | 29 1 86 85 87 225 | 30 1 89 88 90 226 | 31 1 92 91 93 227 | 32 1 95 94 96 228 | -------------------------------------------------------------------------------- /examples/thermostats/environment.yml: -------------------------------------------------------------------------------- 1 | channels: 2 | - conda-forge 3 | dependencies: 4 | - python=3.11 5 | - pip 6 | - lammps 7 | - pip: 8 | - ase==3.22.1 9 | - chemiscope>=0.7 10 | - git+https://github.com/i-pi/i-pi.git@main 11 | - matplotlib 12 | - skmatter 13 | -------------------------------------------------------------------------------- /examples/torchpme/README.rst: -------------------------------------------------------------------------------- 1 | Learning Capabilities with torchpme 2 | ======================================= 3 | 4 | This example demonstrates the capabilities of the `torchpme` package, focusing on 5 | learning target charges and utilizing the :class:`CombinedPotential` class to evaluate 6 | potentials that combine multiple pairwise interactions with optimizable ``weights``. -------------------------------------------------------------------------------- /examples/torchpme/environment.yml: -------------------------------------------------------------------------------- 1 | channels: 2 | - conda-forge 3 | dependencies: 4 | - python=3.11 5 | - pip 6 | - pip: 7 | - ase==3.22.1 8 | - mpltex 9 | - matplotlib 10 | - numpy 11 | - vesin 12 | - torch-pme -------------------------------------------------------------------------------- /examples/water-model/.gitignore: -------------------------------------------------------------------------------- 1 | *.data 2 | *.json 3 | *.pt 4 | *RESTART* 5 | *qtip4pf-md* 6 | 7 | data.zip 8 | log.lammps 9 | trajectory.xyz 10 | -------------------------------------------------------------------------------- /examples/water-model/README.rst: -------------------------------------------------------------------------------- 1 | Empircal water models 2 | ===================== 3 | 4 | This example shows implemenetations of three and four point flexible water models and 5 | uses them to run molecular dynamics simulations of water. 6 | -------------------------------------------------------------------------------- /examples/water-model/data/spcfw.in: -------------------------------------------------------------------------------- 1 | units metal # Angstroms, eV, picoseconds 2 | atom_style atomic 3 | read_data water_32.data 4 | 5 | # loads metatomic SPC/Fw model 6 | pair_style metatensor spcfw-mta.pt 7 | pair_coeff * * 1 8 8 | 9 | neighbor 2.0 bin 10 | timestep 0.0005 11 | 12 | dump myDump all xyz 20 trajectory.xyz 13 | dump_modify myDump element H O 14 | 15 | thermo_style multi 16 | thermo 1 17 | 18 | fix 1 all nve 19 | fix 2 all langevin 300 300 1.00 12345 20 | 21 | run 200 22 | -------------------------------------------------------------------------------- /examples/water-model/environment.yml: -------------------------------------------------------------------------------- 1 | channels: 2 | - abmazitov 3 | - conda-forge 4 | dependencies: 5 | - python=3.12 6 | - lammps-metatensor=*=cpu*nompi* 7 | - pip 8 | - pip: 9 | - ase 10 | - chemiscope>=0.7 11 | - ipi 12 | - metatensor-torch<0.8 13 | - metatensor-operations 14 | - matplotlib 15 | - torch-pme 16 | - vesin[torch] 17 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | nox 2 | docutils 3 | -------------------------------------------------------------------------------- /src/generate-gallery.py: -------------------------------------------------------------------------------- 1 | import os 2 | import shutil 3 | import sys 4 | 5 | import chemiscope # noqa: F401 6 | import sphinx_gallery.gen_gallery 7 | import sphinx_gallery.gen_rst 8 | from chemiscope.sphinx import ChemiscopeScraper 9 | 10 | 11 | ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "../")) 12 | 13 | 14 | class AttrDict(dict): 15 | def __init__(self): 16 | super().__init__() 17 | self.__dict__ = self 18 | 19 | 20 | class PseudoSphinxApp: 21 | """ 22 | Class pretending to be a sphinx App, used to configure and run sphinx-gallery 23 | from the command line, without having an actual sphinx project. 24 | """ 25 | 26 | def __init__(self, example): 27 | gallery_dir = os.path.join( 28 | ROOT, "docs", "src", "examples", os.path.basename(example) 29 | ) 30 | if os.path.exists(gallery_dir): 31 | shutil.rmtree(gallery_dir) 32 | 33 | # the options here are the minimal set of options to get sphinx-gallery to run 34 | # feel free to add more if sphinx-gallery uses more options in the future 35 | self.config = AttrDict() 36 | self.config.html_static_path = [] 37 | self.config.templates_path = [] 38 | self.config.source_suffix = [".rst"] 39 | self.config.default_role = "" 40 | self.config.sphinx_gallery_conf = { 41 | "filename_pattern": ".*", 42 | "examples_dirs": os.path.join(ROOT, example), 43 | "gallery_dirs": gallery_dir, 44 | "write_computation_times": False, 45 | "copyfile_regex": r".*\.(sh|xyz|cp2k|yml|yaml|jpg|jpeg|png|zip)", 46 | "matplotlib_animations": True, 47 | "within_subsection_order": "FileNameSortKey", 48 | "image_scrapers": ("matplotlib", ChemiscopeScraper()), 49 | } 50 | 51 | self.builder = AttrDict() 52 | self.builder.srcdir = os.path.join(ROOT, "docs", "src") 53 | self.builder.outdir = "" 54 | self.builder.name = os.path.basename(example) 55 | 56 | self.extensions = [ 57 | "chemiscope.sphinx", 58 | ] 59 | 60 | self.builder.config = AttrDict() 61 | self.builder.config.plot_gallery = "True" 62 | self.builder.config.abort_on_example_error = True 63 | self.builder.config.highlight_language = None 64 | 65 | def add_css_file(self, path): 66 | pass 67 | 68 | 69 | if __name__ == "__main__": 70 | if len(sys.argv) < 2: 71 | print(f"usage: {sys.argv[0]} ") 72 | sys.exit(1) 73 | 74 | # To change the download text, we change the ZIP_DOWNLOAD variable in 75 | # sphinx_gallery.gen_rst. This is a bit of a hack, but arguably not 76 | # worse than postmodifying RST. We perform some checks here to make 77 | # sure that the hack is still valid and it does not fail silently. 78 | assert hasattr(sphinx_gallery.gen_rst, "ZIP_DOWNLOAD") 79 | assert isinstance(sphinx_gallery.gen_rst.ZIP_DOWNLOAD, str) 80 | 81 | sphinx_gallery.gen_rst.ZIP_DOWNLOAD = """ 82 | .. container:: sphx-glr-download sphx-glr-download-zip 83 | 84 | :download:`Download recipe: {0} <{0}>` 85 | """ 86 | 87 | app = PseudoSphinxApp(example=sys.argv[1]) 88 | sphinx_gallery.gen_gallery.fill_gallery_conf_defaults(app, app.config) 89 | sphinx_gallery.gen_gallery.update_gallery_conf_builder_inited(app) 90 | sphinx_gallery.gen_gallery.generate_gallery_rst(app) 91 | -------------------------------------------------------------------------------- /src/get_examples.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """Script to create JSON string suitable for a github action matrix.""" 3 | import glob 4 | import json 5 | import os 6 | from pathlib import Path 7 | 8 | 9 | ROOT = os.path.realpath(os.path.join(os.path.dirname(__file__), "..")) 10 | EXAMPLES = os.path.join(ROOT, "examples") 11 | # Changes in the following files will trigger all examples to be run. 12 | GLOBAL_FILES = [ 13 | "noxfile.py", 14 | "src/generate-gallery.py", 15 | "src/ipynb-to-gallery.py", 16 | ] 17 | 18 | 19 | def get_examples(): 20 | """The current list of examples, determined from the directories on disk""" 21 | return [ 22 | os.path.basename(os.path.normpath(file)) 23 | for file in glob.glob(f"{EXAMPLES}/*") 24 | if os.path.isdir(file) 25 | ] 26 | 27 | 28 | def get_examples_from_modified_files(modified_files: list[Path]): 29 | """Get only examples for which files have been modified. 30 | 31 | Parameters 32 | ---------- 33 | modified_files : 34 | List of modified files. 35 | 36 | This can be obtained from something like ``git diff --name-only``. 37 | """ 38 | modified_files = [file.resolve().relative_to(ROOT) for file in modified_files] 39 | 40 | if any(str(file) in GLOBAL_FILES for file in modified_files): 41 | # This means that there is a modified file that could affect all examples. 42 | return get_examples() 43 | 44 | def is_inside_example(file: Path) -> bool: 45 | """Check if a file is inside an example.""" 46 | # The path should start with "examples", and the second part should be 47 | # the example directory (not a file). 48 | return ( 49 | file.parts[0] == "examples" and Path(file.parts[0], file.parts[1]).is_dir() 50 | ) 51 | 52 | return list( 53 | set(file.parts[1] for file in modified_files if is_inside_example(file)) 54 | ) 55 | 56 | 57 | def create_ci_jobs_json(modified_files: str): 58 | """A JSON string suitable for a github action matrix.""" 59 | if modified_files: 60 | modified_files = map(Path, modified_files) 61 | examples = get_examples_from_modified_files(modified_files) 62 | else: 63 | examples = get_examples() 64 | 65 | if len(examples) == 0: 66 | # We return an empty string which will be easily detected 67 | # by the Github Workflow as having no examples to run. 68 | return "" 69 | 70 | return json.dumps({"example-name": examples}) 71 | 72 | 73 | if __name__ == "__main__": 74 | import argparse 75 | 76 | parser = argparse.ArgumentParser( 77 | description="Print a JSON string with the list of examples." 78 | ) 79 | parser.add_argument( 80 | "--modified-files", 81 | type=str, 82 | nargs="*", 83 | help="""List of modified files. 84 | If provided, only examples with modified files will be included.""", 85 | default=None, 86 | ) 87 | 88 | print(create_ci_jobs_json(parser.parse_args().modified_files)) 89 | -------------------------------------------------------------------------------- /src/ipynb-to-gallery.py: -------------------------------------------------------------------------------- 1 | """ 2 | Code is from 3 | https://gist.github.com/chsasank/7218ca16f8d022e02a9c0deb94a310fe 4 | 5 | Convert jupyter notebook to sphinx gallery notebook styled examples. 6 | 7 | Usage: python ipynb_to_gallery.py 8 | 9 | Dependencies: 10 | pypandoc: install using `pip install pypandoc` 11 | """ 12 | 13 | import json 14 | 15 | import pypandoc as pdoc 16 | 17 | 18 | def convert_ipynb_to_gallery(file_name): 19 | python_file = "" 20 | 21 | nb_dict = json.load(open(file_name)) 22 | cells = nb_dict["cells"] 23 | 24 | for i, cell in enumerate(cells): 25 | if i == 0: 26 | assert cell["cell_type"] == "markdown", "First cell has to be markdown" 27 | 28 | md_source = "".join(cell["source"]) 29 | rst_source = pdoc.convert_text(md_source, "rst", "md") 30 | python_file = f'"""\n{rst_source}"""' 31 | else: 32 | if cell["cell_type"] == "markdown": 33 | md_source = "".join(cell["source"]) 34 | rst_source = pdoc.convert_text(md_source, "rst", "md") 35 | commented_source = "\n".join(["# " + x for x in rst_source.split("\n")]) 36 | python_file = f"{python_file}\n\n\n# %%\n{commented_source}" 37 | elif cell["cell_type"] == "code": 38 | source = "".join(cell["source"]) 39 | python_file = f"{python_file}\n\n{source}" 40 | 41 | python_file = python_file.replace("\n%", "\n# %") 42 | open(file_name.replace(".ipynb", ".py"), "w").write(python_file) 43 | 44 | 45 | if __name__ == "__main__": 46 | import sys 47 | 48 | convert_ipynb_to_gallery(sys.argv[-1]) 49 | -------------------------------------------------------------------------------- /src/latest_docs_run.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """This script uses the Github API to get the ID of the latest 3 | successful Documentation run on the main branch. 4 | 5 | It then prints the ID""" 6 | 7 | import io 8 | import urllib.request 9 | import zipfile 10 | from pathlib import Path 11 | from typing import Optional 12 | 13 | import requests 14 | 15 | from get_examples import get_examples 16 | 17 | 18 | ROOT = Path(__file__).resolve().parent.parent 19 | 20 | GITHUB_ACTIONS_API = "https://api.github.com/repos/lab-cosmo/atomistic-cookbook/actions" 21 | NIGHTLY_LINK = "https://nightly.link/lab-cosmo/atomistic-cookbook/workflows/docs/main" 22 | 23 | 24 | def get_latest_successful_docs_run(): 25 | 26 | doc_runs_endpoint = GITHUB_ACTIONS_API + "/workflows/docs.yml/runs" 27 | 28 | response = requests.get( 29 | doc_runs_endpoint, 30 | params={ 31 | "branch": "main", 32 | "per_page": 1, 33 | "status": "success", 34 | "exclude_pull_requests": True, 35 | }, 36 | ) 37 | 38 | if response.status_code != 200: 39 | print(f"Error [{response.status_code}]: {response.text}") 40 | return None 41 | 42 | latest_successful_run = response.json()["workflow_runs"][0] 43 | 44 | return latest_successful_run["id"] 45 | 46 | 47 | def download_latest_examples( 48 | overwrite: bool = False, 49 | examples: Optional[list[str]] = None, 50 | exclude: list[str] = (), 51 | ): 52 | """Download built examples from latest Github's CI run on the main branch. 53 | 54 | It uses nightly.link instead of the Github API so that artifacts can be 55 | downloaded without logging in. 56 | """ 57 | # If examples is not provided, get all examples 58 | if examples is None: 59 | examples = get_examples() 60 | 61 | # Remove examples that the user wants to exclude 62 | if len(exclude) > 0: 63 | examples = [example for example in examples if example not in exclude] 64 | 65 | # Iterate over examples and download each of them 66 | n_examples = len(examples) 67 | examples_dir = ROOT / "docs/src/examples" 68 | for i, example in enumerate(examples): 69 | 70 | # Skip examples that exist if overwrite is False 71 | if not overwrite and Path(examples_dir / example).exists(): 72 | print(f"[{i + 1} / {n_examples}] Skipping {example} (already exists)") 73 | continue 74 | 75 | # Get the url to download the example artifact 76 | download_url = NIGHTLY_LINK + f"/example-{example}.zip" 77 | 78 | try: 79 | # Download the example artifact 80 | response = urllib.request.urlopen(download_url) 81 | 82 | print(f"[{i + 1} / {n_examples}] Downloaded {example}") 83 | 84 | # Extract the contents of the artifact into the examples directory 85 | myzip = zipfile.ZipFile(io.BytesIO(response.read())) 86 | myzip.extractall(examples_dir) 87 | except urllib.error.HTTPError as e: 88 | print(f"[{i + 1} / {n_examples}] Error downloading {example}: {e}") 89 | continue 90 | 91 | 92 | if __name__ == "__main__": 93 | 94 | import argparse 95 | 96 | parser = argparse.ArgumentParser( 97 | description="Interactions with the latest successful docs run on Github Actions" 98 | ) 99 | 100 | subparsers = parser.add_subparsers(dest="command") 101 | 102 | subparsers.add_parser( 103 | "id", 104 | help="Get the ID of the latest successful docs run", 105 | ) 106 | 107 | download_parser = subparsers.add_parser( 108 | "download-examples", 109 | help=download_latest_examples.__doc__, 110 | ) 111 | 112 | download_parser.add_argument( 113 | "examples", 114 | default=None, 115 | nargs="*", 116 | help="List of examples to download. If None, all examples will be downloaded.", 117 | ) 118 | 119 | download_parser.add_argument( 120 | "--exclude", 121 | default=[], 122 | nargs="*", 123 | help="Examples that should not be downloaded.", 124 | ) 125 | 126 | download_parser.add_argument( 127 | "--overwrite", 128 | default=False, 129 | action=argparse.BooleanOptionalAction, 130 | help="Overwrite existing examples", 131 | ) 132 | 133 | args = parser.parse_args() 134 | 135 | if args.command == "download-examples": 136 | download_latest_examples( 137 | overwrite=args.overwrite, 138 | examples=args.examples or None, 139 | exclude=args.exclude, 140 | ) 141 | elif args.command == "id": 142 | print(get_latest_successful_docs_run()) 143 | --------------------------------------------------------------------------------