symcrys for Python
Crystallographic symmetry calculations: the 32 crystal classes and the 122 magnetic point groups with their settings (ITC and Birss conventions), symbols, symmetry elements, site symmetry and the forms of property tensors of rank 0 to 4 they allow, and for the crystal classes Wyckoff positions, checked against print (ITC, Birss, Yariv).
This package is the TypeScript library symcrys of the same
version, run in an embedded JavaScript engine (quickjs-ng).
The results are those of the TypeScript library (up to rounding in the last bit of a float); the names follow a fixed rule (tensorForm →
tensor_form), and matrices and vectors are NumPy arrays.
pip install symcrys
Example: second-harmonic generation at a surface
import numpy as np
import symcrys
SHG = {"rank": 3, "parity": "polar", "intrinsic": "jk"}
symcrys.tensor_form("m-3m", SHG)["basis"].shape # (0, 27): no SHG from the bulk
ops = symcrys.operations("m-3m")
site = symcrys.site_symmetry(ops, [1, 1, 1]) # symmetry of the (111) surface normal
form = symcrys.tensor_form_of([ops[i] for i in site["operations"]], SHG)
form["parameters"] # 4 free components (3m)
# The same form in a frame with z along the normal and x along a mirror normal:
z = np.array([1, 1, 1]) / np.sqrt(3)
x = np.array([1, -1, 0]) / np.sqrt(2)
frame = np.array([x, np.cross(z, x), z])
basis = np.array([symcrys.rotate_tensor(b, frame, SHG) for b in form["basis"]])
chi = basis.reshape(-1, 3, 3, 3) # chi[k] is the k-th basis tensor chi_ijk
A property has a name where its tensor has one (symcrys.TENSOR_PROPERTIES):
symcrys.allows_property("432", "piezoelectric") is False, symcrys.allowed_properties("32") is
["piezoelectric", "gyrotropic"], and symcrys.tensor_form("32", "piezoelectric") is the form of
that tensor. What is fixed once the group is named is a key of symcrys.point_group("32"):
crystal_system, order, centrosymmetric, polar, chiral, laue_class.
Crystal classes and magnetic point groups
symcrys is the crystallographic API: the 32 crystal classes, without time reversal.
symcrys.magnetic is the magnetic API: the 122 magnetic point groups, under the same function
names, with time_reversal in an operation and time_parity in a tensor specification. The module
decides how a key is read: in symcrys, "32" is a crystal class, that of quartz; in
symcrys.magnetic it is a white group, the symmetry of a magnetically ordered crystal, and quartz
has the grey group "321'".
from symcrys import magnetic
magnetic.allowed_properties("321'") # ['piezoelectric', 'gyrotropic']: quartz
magnetic.allowed_properties("32") # the white group: also 'magnetoelectric', 'piezomagnetic'
magnetic.allowed_properties("m'm'2") # six of the seven names: all but 'ferroaxial'
magnetic.tensor_form("m'm'2", "ferromagnetic")["parameters"] # [[2]]: M_s along z
A question that involves time reversal (a magnetic key, a time-odd tensor or property, an operation
with time reversal) raises SymcrysError in symcrys.
A tensor form has basis (rows of length 3**rank in reduced row echelon form, components in C
order, so reshape((3,)*rank) gives the tensor), parameters (the free components as index
lists) and relations (rows r with r @ t = 0). Each call costs about a millisecond or more: fetch
forms and operations once, then compute with NumPy.
Documentation
- Conventions, frames and the print sources of every result: docs/conventions.md.
- Functions: the docstrings here, and the TypeScript API they call (same names in camelCase).
- Errors from the library raise
symcrys.SymcrysError, a subclass ofValueError.
Python 3.10 or later. quickjs-ng has no wheel for macOS on Intel; pip builds it from source there (a C compiler is needed). Licence: MIT.
Metadata
Release files for symcrys 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| symcrys-0.6.0.tar.gz | 31.7 kB | With provenance | Details for symcrys-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| symcrys-0.6.0-py3-none-any.whl | Python 3 | none | any | Details for symcrys-0.6.0-py3-none-any.whl |
Total release size: 66.2 kB
Release files / symcrys-0.6.0.tar.gz
| Download URL | symcrys-0.6.0.tar.gz |
|---|---|
| Size | 31.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8da6ad1f4d1c5590b5df8684f9159dbe20cd2a75a9c5e39277b3bf82d58d9ddf
|
|
BLAKE2b-256 checksum How to use checksums |
dc2040cde22032dabf7b9cf8cfcb97cf4fa23f3ef345c2257af72380b64a4836
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.
Transparency logRelease files / symcrys-0.6.0-py3-none-any.whl
| Download URL | symcrys-0.6.0-py3-none-any.whl |
|---|---|
| Size | 34.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
48840073d78a1df1622df5df74f64bb21ede4beb8e820f411c591b6e28baa142
|
|
BLAKE2b-256 checksum How to use checksums |
45ee98852511c898bbe517cfa6ecc46db0559e41282f0d2c019fb3e6567d5f21
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.
Transparency logSecurity for symcrys 0.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for symcrys-0.6.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.