Skip to content
Snippets Groups Projects
Commit 3adfe8c4 authored by Anton Akhmerov's avatar Anton Akhmerov
Browse files

Merge branch 'json-serialization' into 'master'

Saving qsymm models

Closes #34

See merge request !23
parents 56be9ec9 8d1396b8
Branches
Tags
1 merge request!23Saving qsymm models
Pipeline #114417 passed
......@@ -209,3 +209,27 @@ It is exactly the Hamiltonian family we started with.
For more detailed examples see :ref:`tutorial_kdotp_generator`, :ref:`tutorial_bloch_generator`
and :ref:`tutorial_kekule`.
Saving and loading Qsymm models
-------------------------------------------------
Qsymm models and identified symmetries don't guarantee consistent ordering and basis selection
across multiple runs. To avoid irrerproducible results you may use the ``Model.tosympy`` method
and serialize the resulting sympy expression as shown below.
To save we do:
.. jupyter-execute::
H2D_sympy = H2D.tosympy()
with open("H2D.txt", "w") as f:
f.write(str(H2D))
To load we do:
.. jupyter-execute::
with open("H2D.txt") as f:
data = f.read()
loaded_H2D = qsymm.Model(sympy.parsing.sympy_parser.parse_expr(f), momenta=['k_x', 'k_z'])
......@@ -2,7 +2,7 @@ name: qsymm-latest
channels:
- conda-forge
dependencies:
- python=3.9
- python=3.10
- numpy
- scipy
- sympy
......
......@@ -4,7 +4,9 @@ filterwarnings =
# Remove once we rely on scipy v1.5 (maybe earlier)
ignore:can't resolve package from __spec__ or __package__:ImportWarning
ignore:the matrix subclass is not the recommended way to represent matrices:PendingDeprecationWarning
# Remove once we rely on sympy v1.3
# Remove once sympy fixes how it uses distutils
ignore:distutils Version classes are deprecated. Use packaging.version instead:DeprecationWarning
# Remove once this does not need to be ignored
ignore:np\.asscalar\(a\) is deprecated since NumPy v1\.16, use a\.item\(\) instead:DeprecationWarning
# Remove once setuptools figures it out
ignore:lib2to3:PendingDeprecationWarning
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment