-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* change the phonon example to rst format * update the example page and link to new phonon example rst page * update relax example * add phonon plot * add python requirement * fix equations display in model card * try to fix inline formula * try to fix inline formula * try to fix inline formula --------- Co-authored-by: Han Yang <hanyang@microsoft.com>
- Loading branch information
1 parent
e4ab7b9
commit dd70d04
Showing
7 changed files
with
100 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ Examples | |
:numbered: | ||
|
||
relax_example | ||
phonon_example.ipynb | ||
phonon_example |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
Phonon Dispersion | ||
================= | ||
|
||
This is a simple example of how to compute the phonon dispersion using the MatterSim. | ||
|
||
Import the necessary modules | ||
---------------------------- | ||
|
||
First we import the necessary modules. It is worth noting | ||
that we have a built-in workflow for phonon calculations using ``phonopy`` in MatterSim. | ||
|
||
.. code-block:: python | ||
:linenos: | ||
import numpy as np | ||
from ase.build import bulk | ||
from ase.units import GPa | ||
from ase.visualize import view | ||
from mattersim.forcefield.potential import MatterSimCalculator | ||
from mattersim.applications.phonon import PhononWorkflow | ||
.. note :: | ||
The ``phonopy`` package is required to compute the phonon dispersion. | ||
You can install it by running the following command: | ||
.. code-block:: console | ||
conda install -c conda-forge phonopy==2.14.0 | ||
Set up the MatterSim calculator | ||
------------------------------- | ||
|
||
.. code-block:: python | ||
:linenos: | ||
# initialize the structure of silicon | ||
si = bulk("Si") | ||
# attach the calculator to the atoms object | ||
si.calc = MatterSimCalculator() | ||
Set up the phonon workflow | ||
-------------------------- | ||
|
||
.. code-block:: python | ||
:linenos: | ||
ph = PhononWorkflow( | ||
atoms=si, | ||
find_prim = False, | ||
work_dir = "/tmp/phonon_si_example", | ||
amplitude = 0.01, | ||
supercell_matrix = np.diag([4,4,4]), | ||
) | ||
Compute the phonon dispersion | ||
----------------------------- | ||
|
||
.. code-block:: python | ||
:linenos: | ||
has_imag, phonons = ph.run() | ||
print(f"Has imaginary phonon: {has_imag}") | ||
print(f"Phonon frequencies: {phonons}") | ||
Inspect the phonon dispersion | ||
----------------------------- | ||
|
||
Once the calculation is done, you can find the phonon plot in the work directory. | ||
In this case, you find the plot in the directory ``/tmp/phonon_si_example``, | ||
and here is the phonon dispersion plot for the example above. | ||
|
||
.. image:: /_static/phonon_dispersion.png | ||
:width: 400 | ||
:align: center | ||
:alt: Phonon dispersion of silicon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters