{"id":27953526,"url":"https://github.com/lab-cosmo/torch-pme","last_synced_at":"2025-05-07T17:13:04.578Z","repository":{"id":266438066,"uuid":"684293624","full_name":"lab-cosmo/torch-pme","owner":"lab-cosmo","description":"Particle-mesh based calculations of long-range interactions in PyTorch","archived":false,"fork":false,"pushed_at":"2025-05-05T13:58:34.000Z","size":8457,"stargazers_count":47,"open_issues_count":18,"forks_count":5,"subscribers_count":17,"default_branch":"main","last_synced_at":"2025-05-07T17:12:57.708Z","etag":null,"topics":["electrostatics","fast-fourier-transform","machine-learning","material-science","molecular-dynamics","particle-mesh-ewald","pytorch"],"latest_commit_sha":null,"homepage":"https://lab-cosmo.github.io/torch-pme/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lab-cosmo.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-08-28T21:02:26.000Z","updated_at":"2025-05-05T13:53:01.000Z","dependencies_parsed_at":"2025-01-06T12:24:42.108Z","dependency_job_id":"c7b39c92-e6e6-46ea-852c-e4998c2feaea","html_url":"https://github.com/lab-cosmo/torch-pme","commit_stats":null,"previous_names":["lab-cosmo/torch-pme"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lab-cosmo%2Ftorch-pme","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lab-cosmo%2Ftorch-pme/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lab-cosmo%2Ftorch-pme/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lab-cosmo%2Ftorch-pme/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lab-cosmo","download_url":"https://codeload.github.com/lab-cosmo/torch-pme/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252922342,"owners_count":21825639,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["electrostatics","fast-fourier-transform","machine-learning","material-science","molecular-dynamics","particle-mesh-ewald","pytorch"],"created_at":"2025-05-07T17:13:03.950Z","updated_at":"2025-05-07T17:13:04.554Z","avatar_url":"https://github.com/lab-cosmo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"torch-pme\n=========\n\n.. image:: https://raw.githubusercontent.com/lab-cosmo/torch-pme/refs/heads/main/docs/logo/torch-pme.svg\n   :width: 200 px\n   :align: left\n\n|tests| |codecov| |docs|\n\n.. marker-introduction\n\n``torch-pme`` enables efficient and auto-differentiable computation of long-range\ninteractions in *PyTorch*. Auto-differentiation is supported for particle *positions*,\n\n*charges*/*dipoles*, and *cell* parameters, allowing not only the automatic computation\nof forces but also enabling general applications in machine learning tasks. For\n**monopoles** the library offers classes for Particle-Particle Particle-Mesh Ewald\n(``P3M``), Particle Mesh Ewald (``PME``), standard ``Ewald``, and non-periodic methods.\nThe library has the flexibility to calculate potentials beyond :math:`1/r`\nelectrostatics, including arbitrary order :math:`1/r^p` potentials. For **dipolar**\ninteraction we offer to calculate the :math:`1/r^3` potential using the standard\n``Ewald`` method.\n\nOptimized for both CPU and GPU devices, ``torch-pme`` is fully `TorchScriptable`_,\nallowing it to be converted into a format that runs independently of Python, such as in\nC++, making it ideal for high-performance production environments.\n\nWe also provide an experimental implementation for *JAX* in `jax-pme`_.\n\n.. _`TorchScriptable`: https://pytorch.org/docs/stable/jit.html\n.. _`jax-pme`: https://github.com/lab-cosmo/jax-pme\n\n.. marker-documentation\n\nDocumentation\n-------------\n\nFor details, tutorials, and examples, please have a look at our `documentation`_.\n\n.. _`documentation`: https://lab-cosmo.github.io/torch-pme\n\n.. marker-installation\n\nInstallation\n------------\n\nYou can install *torch-pme* using pip with\n\n.. code-block:: bash\n\n    pip install torch-pme\n\nor conda\n\n.. code-block:: bash\n\n    conda install -c conda-forge torch-pme\n\nand ``import torchpme`` to use it in your projects!\n\nWe also provide bindings to `metatensor \u003chttps://docs.metatensor.org\u003e`_ which can\noptionally be installed together and used as ``torchpme.metatensor`` via\n\n.. code-block:: bash\n\n    pip install torch-pme[metatensor]\n\n.. marker-quickstart\n\nQuickstart\n----------\n\nHere is a simple example to get started with *torch-pme*:\n\n.. code-block:: python\n\n   \u003e\u003e\u003e import torch\n   \u003e\u003e\u003e import torchpme\n\n   \u003e\u003e\u003e # Single charge in a cubic box\n   \u003e\u003e\u003e positions = torch.zeros((1, 3), requires_grad=True)\n   \u003e\u003e\u003e cell = 8 * torch.eye(3)\n   \u003e\u003e\u003e charges = torch.tensor([[1.0]])\n\n   \u003e\u003e\u003e # No neighbors for a single atom; use `vesin` for neighbors if needed\n   \u003e\u003e\u003e neighbor_indices = torch.zeros((0, 2), dtype=torch.int64)\n   \u003e\u003e\u003e neighbor_distances = torch.zeros((0,))\n\n   \u003e\u003e\u003e # Tune P3M parameters\n   \u003e\u003e\u003e smearing, p3m_parameters, _ = torchpme.tuning.tune_p3m(\n   ...    charges=charges,\n   ...    cell=cell,\n   ...    positions=positions,\n   ...    cutoff=5.0,\n   ...    neighbor_indices=neighbor_indices,\n   ...    neighbor_distances=neighbor_distances,\n   ... )\n\n   \u003e\u003e\u003e # Initialize potential and calculator\n   \u003e\u003e\u003e potential = torchpme.CoulombPotential(smearing)\n   \u003e\u003e\u003e calculator = torchpme.P3MCalculator(potential, **p3m_parameters)\n\n   \u003e\u003e\u003e # Compute (per-atom) potentials\n   \u003e\u003e\u003e potentials = calculator.forward(\n   ...    charges=charges,\n   ...    cell=cell,\n   ...    positions=positions,\n   ...    neighbor_indices=neighbor_indices,\n   ...    neighbor_distances=neighbor_distances,\n   ... )\n\n   \u003e\u003e\u003e # Calculate total energy and forces\n   \u003e\u003e\u003e energy = torch.sum(charges * potentials)\n   \u003e\u003e\u003e energy.backward()\n   \u003e\u003e\u003e forces = -positions.grad\n\nFor more examples and details, please refer to the `documentation`_.\n\n.. marker-issues\n\nHaving problems or ideas?\n-------------------------\n\nHaving a problem with *torch-pme*? Please let us know by `submitting an issue\n\u003chttps://github.com/lab-cosmo/torch-pme/issues\u003e`_.\n\nSubmit new features or bug fixes through a `pull request\n\u003chttps://github.com/lab-cosmo/torch-pme/pulls\u003e`_.\n\n.. marker-cite\n\nReference\n---------\n\nIf you use *torch-pme* for your work, please read and cite our preprint available on\n`arXiv`_.\n\n.. code-block::\n\n   @article{loche_fast_2024,\n      title = {Fast and Flexible Range-Separated Models for Atomistic Machine Learning},\n      author = {Loche, Philip and {Huguenin-Dumittan}, Kevin K. and Honarmand, Melika and Xu, Qianjun and Rumiantsev, Egor and How, Wei Bin and Langer, Marcel F. and Ceriotti, Michele},\n      year = {2024},\n      month = dec,\n      number = {arXiv:2412.03281},\n      eprint = {2412.03281},\n      primaryclass = {physics},\n      publisher = {arXiv},\n      doi = {10.48550/arXiv.2412.03281},\n      urldate = {2024-12-05},\n      archiveprefix = {arXiv}\n      }\n\n.. _`arXiv`: http://arxiv.org/abs/2412.03281\n\n.. marker-contributing\n\nContributors\n------------\n\nThanks goes to all people that make *torch-pme* possible:\n\n.. image:: https://contrib.rocks/image?repo=lab-cosmo/torch-pme\n   :target: https://github.com/lab-cosmo/torch-pme/graphs/contributors\n\n.. |tests| image:: https://github.com/lab-cosmo/torch-pme/workflows/Tests/badge.svg\n   :alt: Github Actions Tests Job Status\n   :target: https://github.com/lab-cosmo/torch-pme/actions?query=branch%3Amain\n\n.. |codecov| image:: https://codecov.io/gh/lab-cosmo/torch-pme/graph/badge.svg?token=srVKRy7r6m\n   :alt: Code coverage\n   :target: https://codecov.io/gh/lab-cosmo/torch-pme\n\n.. |docs| image:: https://img.shields.io/badge/documentation-latest-sucess\n   :alt: Documentation\n   :target: `documentation`_\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flab-cosmo%2Ftorch-pme","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flab-cosmo%2Ftorch-pme","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flab-cosmo%2Ftorch-pme/lists"}