Skip to content

Commit

Permalink
deploy: b57447f
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghan234 committed Dec 3, 2024
1 parent ca3616d commit d94b9f3
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 61 deletions.
File renamed without changes
File renamed without changes
17 changes: 5 additions & 12 deletions _sources/examples/phonon_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,11 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"<div class=\"alert alert-info\">\n",
" If you see the error information that the ``phonopy`` package is missing, you can install it with\n",
"</div>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<div class=\"alert alert-info\">\n",
" ``conda install phonopy -c conda-forge``\n",
"</div>"
"> If you see the error that the ``phonopy`` package is missing, you can install it with\n",
"> \n",
"> ```bash\n",
"> conda install phonopy -c conda-forge\n",
"> ```"
]
},
{
Expand Down
5 changes: 4 additions & 1 deletion _sources/user_guide/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ a list of structures using the ``Potential`` class.
.. code-block:: python
:linenos:
import torch
import numpy as np
from ase.build import bulk
from ase.units import GPa
Expand All @@ -56,7 +57,9 @@ a list of structures using the ``Potential`` class.
structures = [si] * 10
# load the model
potential = Potential.load(load_path="/path/to/checkpoint", device="cuda:0")
device = "cuda" if torch.cuda.is_available() else "cpu"
print(f"Running MatterSim on {device}")
potential = Potential.load(device=device)
# build the dataloader that is compatible with MatterSim
dataloader = build_dataloader(structures, only_inference=True)
Expand Down
5 changes: 3 additions & 2 deletions _sources/user_guide/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ To install the package, run the following command under the root of the folder:
Please note that the installation process may take a while due to the installation of the dependencies.
For faster installation, we recommend the users to install with [mamba or micromamba](https://mamba.readthedocs.io/en/latest/index.html),
and the [uv](https://docs.astral.sh/uv/) package manager.
For faster installation, we recommend the users to install with
`mamba or micromamba <https://mamba.readthedocs.io/en/latest/index.html>`_,
and the `uv <https://docs.astral.sh/uv/>`_ package manager.

.. code-block:: console
Expand Down
14 changes: 7 additions & 7 deletions examples/phonon_example.html
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,12 @@ <h1><span class="section-number">2. </span>Phonon Dispersion<a class="headerlink
</pre></div>
</div>
</div>
<div class="admonition note">
<p>If you see the error information that the <code class="docutils literal notranslate"><span class="pre">phonopy</span></code> package is missing, you can install it with</p>
</div>
<div class="admonition note">
<p><code class="docutils literal notranslate"><span class="pre">conda</span> <span class="pre">install</span> <span class="pre">phonopy</span> <span class="pre">-c</span> <span class="pre">conda-forge</span></code></p>
<blockquote>
<div><p>If you see the error that the <code class="docutils literal notranslate"><span class="pre">phonopy</span></code> package is missing, you can install it with</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>conda<span class="w"> </span>install<span class="w"> </span>phonopy<span class="w"> </span>-c<span class="w"> </span>conda-forge
</pre></div>
</div>
</div></blockquote>
<section id="Set-up-the-atomic-structure-with-attached-MatterSim-Calculator">
<h2><span class="section-number">2.1. </span>Set up the atomic structure with attached MatterSim Calculator<a class="headerlink" href="#Set-up-the-atomic-structure-with-attached-MatterSim-Calculator" title="Link to this heading">#</a></h2>
<div class="nbinput nblast docutils container">
Expand Down Expand Up @@ -454,14 +454,14 @@ <h2><span class="section-number">2.2. </span>Set up the phonon workflow<a class=
<div class="prompt empty docutils container">
</div>
<div class="output_area docutils container">
<img alt="../_images/examples_phonon_example_8_3.png" class="no-scaled-link" src="../_images/examples_phonon_example_8_3.png" style="width: 563px; height: 394px;" />
<img alt="../_images/examples_phonon_example_7_3.png" class="no-scaled-link" src="../_images/examples_phonon_example_7_3.png" style="width: 563px; height: 394px;" />
</div>
</div>
<div class="nboutput nblast docutils container">
<div class="prompt empty docutils container">
</div>
<div class="output_area docutils container">
<img alt="../_images/examples_phonon_example_8_4.png" class="no-scaled-link" src="../_images/examples_phonon_example_8_4.png" style="width: 562px; height: 428px;" />
<img alt="../_images/examples_phonon_example_7_4.png" class="no-scaled-link" src="../_images/examples_phonon_example_7_4.png" style="width: 562px; height: 428px;" />
</div>
</div>
<div class="nbinput docutils container">
Expand Down
17 changes: 5 additions & 12 deletions examples/phonon_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,11 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"<div class=\"alert alert-info\">\n",
" If you see the error information that the ``phonopy`` package is missing, you can install it with\n",
"</div>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<div class=\"alert alert-info\">\n",
" ``conda install phonopy -c conda-forge``\n",
"</div>"
"> If you see the error that the ``phonopy`` package is missing, you can install it with\n",
"> \n",
"> ```bash\n",
"> conda install phonopy -c conda-forge\n",
"> ```"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

51 changes: 27 additions & 24 deletions user_guide/getting_started.html
Original file line number Diff line number Diff line change
Expand Up @@ -360,32 +360,35 @@ <h2>Batch prediction using the <code class="docutils literal notranslate"><span
multiple structures using the <code class="docutils literal notranslate"><span class="pre">predict_properties</span></code> method.
In the following example, we demonstrate how to predict the properties of
a list of structures using the <code class="docutils literal notranslate"><span class="pre">Potential</span></code> class.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="linenos"> 1</span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="linenos"> 2</span><span class="kn">from</span> <span class="nn">ase.build</span> <span class="kn">import</span> <span class="n">bulk</span>
<span class="linenos"> 3</span><span class="kn">from</span> <span class="nn">ase.units</span> <span class="kn">import</span> <span class="n">GPa</span>
<span class="linenos"> 4</span><span class="kn">from</span> <span class="nn">mattersim.forcefield.potential</span> <span class="kn">import</span> <span class="n">Potential</span>
<span class="linenos"> 5</span><span class="kn">from</span> <span class="nn">mattersim.datasets.utils.build</span> <span class="kn">import</span> <span class="n">build_dataloader</span>
<span class="linenos"> 6</span>
<span class="linenos"> 7</span><span class="c1"># set up the structure</span>
<span class="linenos"> 8</span><span class="n">si</span> <span class="o">=</span> <span class="n">bulk</span><span class="p">(</span><span class="s2">&quot;Si&quot;</span><span class="p">,</span> <span class="s2">&quot;diamond&quot;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">5.43</span><span class="p">)</span>
<span class="linenos"> 9</span>
<span class="linenos">10</span><span class="c1"># replicate the structures to form a list</span>
<span class="linenos">11</span><span class="n">structures</span> <span class="o">=</span> <span class="p">[</span><span class="n">si</span><span class="p">]</span> <span class="o">*</span> <span class="mi">10</span>
<span class="linenos">12</span>
<span class="linenos">13</span><span class="c1"># load the model</span>
<span class="linenos">14</span><span class="n">potential</span> <span class="o">=</span> <span class="n">Potential</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">load_path</span><span class="o">=</span><span class="s2">&quot;/path/to/checkpoint&quot;</span><span class="p">,</span> <span class="n">device</span><span class="o">=</span><span class="s2">&quot;cuda:0&quot;</span><span class="p">)</span>
<span class="linenos">15</span>
<span class="linenos">16</span><span class="c1"># build the dataloader that is compatible with MatterSim</span>
<span class="linenos">17</span><span class="n">dataloader</span> <span class="o">=</span> <span class="n">build_dataloader</span><span class="p">(</span><span class="n">structures</span><span class="p">,</span> <span class="n">only_inference</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="linenos"> 1</span><span class="kn">import</span> <span class="nn">torch</span>
<span class="linenos"> 2</span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="linenos"> 3</span><span class="kn">from</span> <span class="nn">ase.build</span> <span class="kn">import</span> <span class="n">bulk</span>
<span class="linenos"> 4</span><span class="kn">from</span> <span class="nn">ase.units</span> <span class="kn">import</span> <span class="n">GPa</span>
<span class="linenos"> 5</span><span class="kn">from</span> <span class="nn">mattersim.forcefield.potential</span> <span class="kn">import</span> <span class="n">Potential</span>
<span class="linenos"> 6</span><span class="kn">from</span> <span class="nn">mattersim.datasets.utils.build</span> <span class="kn">import</span> <span class="n">build_dataloader</span>
<span class="linenos"> 7</span>
<span class="linenos"> 8</span><span class="c1"># set up the structure</span>
<span class="linenos"> 9</span><span class="n">si</span> <span class="o">=</span> <span class="n">bulk</span><span class="p">(</span><span class="s2">&quot;Si&quot;</span><span class="p">,</span> <span class="s2">&quot;diamond&quot;</span><span class="p">,</span> <span class="n">a</span><span class="o">=</span><span class="mf">5.43</span><span class="p">)</span>
<span class="linenos">10</span>
<span class="linenos">11</span><span class="c1"># replicate the structures to form a list</span>
<span class="linenos">12</span><span class="n">structures</span> <span class="o">=</span> <span class="p">[</span><span class="n">si</span><span class="p">]</span> <span class="o">*</span> <span class="mi">10</span>
<span class="linenos">13</span>
<span class="linenos">14</span><span class="c1"># load the model</span>
<span class="linenos">15</span><span class="n">device</span> <span class="o">=</span> <span class="s2">&quot;cuda&quot;</span> <span class="k">if</span> <span class="n">torch</span><span class="o">.</span><span class="n">cuda</span><span class="o">.</span><span class="n">is_available</span><span class="p">()</span> <span class="k">else</span> <span class="s2">&quot;cpu&quot;</span>
<span class="linenos">16</span><span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Running MatterSim on </span><span class="si">{</span><span class="n">device</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="linenos">17</span><span class="n">potential</span> <span class="o">=</span> <span class="n">Potential</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">device</span><span class="o">=</span><span class="n">device</span><span class="p">)</span>
<span class="linenos">18</span>
<span class="linenos">19</span><span class="c1"># make predictions</span>
<span class="linenos">20</span><span class="n">predictions</span> <span class="o">=</span> <span class="n">potential</span><span class="o">.</span><span class="n">predict_properties</span><span class="p">(</span><span class="n">dataloader</span><span class="p">,</span> <span class="n">include_forces</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">include_stresses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="linenos">19</span><span class="c1"># build the dataloader that is compatible with MatterSim</span>
<span class="linenos">20</span><span class="n">dataloader</span> <span class="o">=</span> <span class="n">build_dataloader</span><span class="p">(</span><span class="n">structures</span><span class="p">,</span> <span class="n">only_inference</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="linenos">21</span>
<span class="linenos">22</span><span class="c1"># print the predictions</span>
<span class="linenos">23</span><span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Total energy in eV: </span><span class="si">{</span><span class="n">predictions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="linenos">24</span><span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Forces in eV/Angstrom: </span><span class="si">{</span><span class="n">predictions</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="linenos">25</span><span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Stresses in GPa: </span><span class="si">{</span><span class="n">predictions</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="linenos">26</span><span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Stresses in eV/A^3: </span><span class="si">{</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">predictions</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span><span class="o">*</span><span class="n">GPa</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="linenos">22</span><span class="c1"># make predictions</span>
<span class="linenos">23</span><span class="n">predictions</span> <span class="o">=</span> <span class="n">potential</span><span class="o">.</span><span class="n">predict_properties</span><span class="p">(</span><span class="n">dataloader</span><span class="p">,</span> <span class="n">include_forces</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">include_stresses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="linenos">24</span>
<span class="linenos">25</span><span class="c1"># print the predictions</span>
<span class="linenos">26</span><span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Total energy in eV: </span><span class="si">{</span><span class="n">predictions</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="linenos">27</span><span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Forces in eV/Angstrom: </span><span class="si">{</span><span class="n">predictions</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="linenos">28</span><span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Stresses in GPa: </span><span class="si">{</span><span class="n">predictions</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="linenos">29</span><span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Stresses in eV/A^3: </span><span class="si">{</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">predictions</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span><span class="o">*</span><span class="n">GPa</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
</pre></div>
</div>
<div class="admonition warning">
Expand Down
5 changes: 3 additions & 2 deletions user_guide/installation.html
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,9 @@ <h2>Install from source code<a class="headerlink" href="#install-from-source-cod
</pre></div>
</div>
<p>Please note that the installation process may take a while due to the installation of the dependencies.
For faster installation, we recommend the users to install with [mamba or micromamba](<a class="reference external" href="https://mamba.readthedocs.io/en/latest/index.html">https://mamba.readthedocs.io/en/latest/index.html</a>),
and the [uv](<a class="reference external" href="https://docs.astral.sh/uv/">https://docs.astral.sh/uv/</a>) package manager.</p>
For faster installation, we recommend the users to install with
<a class="reference external" href="https://mamba.readthedocs.io/en/latest/index.html">mamba or micromamba</a>,
and the <a class="reference external" href="https://docs.astral.sh/uv/">uv</a> package manager.</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">mamba env create -f environment.yaml</span>
<span class="go">mamba activate mattersim</span>
<span class="go">uv pip install -e .</span>
Expand Down

0 comments on commit d94b9f3

Please sign in to comment.