crystallograpy 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- crystallograpy-0.1.0/.gitignore +160 -0
- crystallograpy-0.1.0/LICENSE +39 -0
- crystallograpy-0.1.0/PKG-INFO +27 -0
- crystallograpy-0.1.0/README.md +3 -0
- crystallograpy-0.1.0/pyproject.toml +41 -0
- crystallograpy-0.1.0/scripts/build_lattice_dicts.py +261 -0
- crystallograpy-0.1.0/src/crystallograpy/__init__.py +8 -0
- crystallograpy-0.1.0/src/crystallograpy/spacegroup.py +36 -0
- crystallograpy-0.1.0/src/crystallograpy/utils.py +167 -0
- crystallograpy-0.1.0/src/crystallograpy/wyckoff.py +67 -0
- crystallograpy-0.1.0/tests/test_utils.py +202 -0
- crystallograpy-0.1.0/yaml/crystal_lattice_systems.yaml +299 -0
- crystallograpy-0.1.0/yaml/point_symmetries.yaml +279 -0
- crystallograpy-0.1.0/yaml/spacegroups.yaml +4261 -0
- crystallograpy-0.1.0/yaml/wyckoff.yaml +29754 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# poetry
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
102
|
+
#poetry.lock
|
|
103
|
+
|
|
104
|
+
# pdm
|
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
106
|
+
#pdm.lock
|
|
107
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
108
|
+
# in version control.
|
|
109
|
+
# https://pdm.fming.dev/#use-with-ide
|
|
110
|
+
.pdm.toml
|
|
111
|
+
|
|
112
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
113
|
+
__pypackages__/
|
|
114
|
+
|
|
115
|
+
# Celery stuff
|
|
116
|
+
celerybeat-schedule
|
|
117
|
+
celerybeat.pid
|
|
118
|
+
|
|
119
|
+
# SageMath parsed files
|
|
120
|
+
*.sage.py
|
|
121
|
+
|
|
122
|
+
# Environments
|
|
123
|
+
.env
|
|
124
|
+
.venv
|
|
125
|
+
env/
|
|
126
|
+
venv/
|
|
127
|
+
ENV/
|
|
128
|
+
env.bak/
|
|
129
|
+
venv.bak/
|
|
130
|
+
|
|
131
|
+
# Spyder project settings
|
|
132
|
+
.spyderproject
|
|
133
|
+
.spyproject
|
|
134
|
+
|
|
135
|
+
# Rope project settings
|
|
136
|
+
.ropeproject
|
|
137
|
+
|
|
138
|
+
# mkdocs documentation
|
|
139
|
+
/site
|
|
140
|
+
|
|
141
|
+
# mypy
|
|
142
|
+
.mypy_cache/
|
|
143
|
+
.dmypy.json
|
|
144
|
+
dmypy.json
|
|
145
|
+
|
|
146
|
+
# Pyre type checker
|
|
147
|
+
.pyre/
|
|
148
|
+
|
|
149
|
+
# pytype static type analyzer
|
|
150
|
+
.pytype/
|
|
151
|
+
|
|
152
|
+
# Cython debug symbols
|
|
153
|
+
cython_debug/
|
|
154
|
+
|
|
155
|
+
# PyCharm
|
|
156
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
157
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
158
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
159
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
160
|
+
#.idea/
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[SOFTWARE NAME] Copyright (YEAR) (COPYRIGHT HOLDER(S)/AUTHOR(S))(“Licensor”)
|
|
2
|
+
Hippocratic License Version Number: 2.1.
|
|
3
|
+
Purpose. The purpose of this License is for the Licensor named above to permit the Licensee (as defined below) broad permission, if consistent with Human Rights Laws and Human Rights Principles (as each is defined below), to use and work with the Software (as defined below) within the full scope of Licensor’s copyright and patent rights, if any, in the Software, while ensuring attribution and protecting the Licensor from liability.
|
|
4
|
+
Permission and Conditions. The Licensor grants permission by this license (“License”), free of charge, to the extent of Licensor’s rights under applicable copyright and patent law, to any person or entity (the “Licensee”) obtaining a copy of this software and associated documentation files (the “Software”), to do everything with the Software that would otherwise infringe (i) the Licensor’s copyright in the Software or (ii) any patent claims to the Software that the Licensor can license or becomes able to license, subject to all of the following terms and conditions:
|
|
5
|
+
|
|
6
|
+
*
|
|
7
|
+
Acceptance. This License is automatically offered to every person and entity subject to its terms and conditions. Licensee accepts this License and agrees to its terms and conditions by taking any action with the Software that, absent this License, would infringe any intellectual property right held by Licensor.
|
|
8
|
+
|
|
9
|
+
*
|
|
10
|
+
Notice. Licensee must ensure that everyone who gets a copy of any part of this Software from Licensee, with or without changes, also receives the License and the above copyright notice (and if included by the Licensor, patent, trademark and attribution notice). Licensee must cause any modified versions of the Software to carry prominent notices stating that Licensee changed the Software. For clarity, although Licensee is free to create modifications of the Software and distribute only the modified portion created by Licensee with additional or different terms, the portion of the Software not modified must be distributed pursuant to this License. If anyone notifies Licensee in writing that Licensee has not complied with this Notice section, Licensee can keep this License by taking all practical steps to comply within 30 days after the notice. If Licensee does not do so, Licensee’s License (and all rights licensed hereunder) shall end immediately.
|
|
11
|
+
|
|
12
|
+
*
|
|
13
|
+
Compliance with Human Rights Principles and Human Rights Laws.
|
|
14
|
+
|
|
15
|
+
*
|
|
16
|
+
Human Rights Principles.
|
|
17
|
+
(a) Licensee is advised to consult the articles of the United Nations Universal Declaration of Human Rights and the United Nations Global Compact that define recognized principles of international human rights (the “Human Rights Principles”). Licensee shall use the Software in a manner consistent with Human Rights Principles.
|
|
18
|
+
(b) Unless the Licensor and Licensee agree otherwise, any dispute, controversy, or claim arising out of or relating to (i) Section 1(a) regarding Human Rights Principles, including the breach of Section 1(a), termination of this License for breach of the Human Rights Principles, or invalidity of Section 1(a) or (ii) a determination of whether any Law is consistent or in conflict with Human Rights Principles pursuant to Section 2, below, shall be settled by arbitration in accordance with the Hague Rules on Business and Human Rights Arbitration (the “Rules”); provided, however, that Licensee may elect not to participate in such arbitration, in which event this License (and all rights licensed hereunder) shall end immediately. The number of arbitrators shall be one unless the Rules require otherwise.
|
|
19
|
+
Unless both the Licensor and Licensee agree to the contrary: (1) All documents and information concerning the arbitration shall be public and may be disclosed by any party; (2) The repository referred to under Article 43 of the Rules shall make available to the public in a timely manner all documents concerning the arbitration which are communicated to it, including all submissions of the parties, all evidence admitted into the record of the proceedings, all transcripts or other recordings of hearings and all orders, decisions and awards of the arbitral tribunal, subject only to the arbitral tribunal’s powers to take such measures as may be necessary to safeguard the integrity of the arbitral process pursuant to Articles 18, 33, 41 and 42 of the Rules; and (3) Article 26(6) of the Rules shall not apply.
|
|
20
|
+
|
|
21
|
+
*
|
|
22
|
+
Human Rights Laws. The Software shall not be used by any person or entity for any systems, activities, or other uses that violate any Human Rights Laws. “Human Rights Laws” means any applicable laws, regulations, or rules (collectively, “Laws”) that protect human, civil, labor, privacy, political, environmental, security, economic, due process, or similar rights; provided, however, that such Laws are consistent and not in conflict with Human Rights Principles (a dispute over the consistency or a conflict between Laws and Human Rights Principles shall be determined by arbitration as stated above). Where the Human Rights Laws of more than one jurisdiction are applicable or in conflict with respect to the use of the Software, the Human Rights Laws that are most protective of the individuals or groups harmed shall apply.
|
|
23
|
+
|
|
24
|
+
*
|
|
25
|
+
Indemnity. Licensee shall hold harmless and indemnify Licensor (and any other contributor) against all losses, damages, liabilities, deficiencies, claims, actions, judgments, settlements, interest, awards, penalties, fines, costs, or expenses of whatever kind, including Licensor’s reasonable attorneys’ fees, arising out of or relating to Licensee’s use of the Software in violation of Human Rights Laws or Human Rights Principles.
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
*
|
|
30
|
+
Failure to Comply. Any failure of Licensee to act according to the terms and conditions of this License is both a breach of the License and an infringement of the intellectual property rights of the Licensor (subject to exceptions under Laws, e.g., fair use). In the event of a breach or infringement, the terms and conditions of this License may be enforced by Licensor under the Laws of any jurisdiction to which Licensee is subject. Licensee also agrees that the Licensor may enforce the terms and conditions of this License against Licensee through specific performance (or similar remedy under Laws) to the extent permitted by Laws. For clarity, except in the event of a breach of this License, infringement, or as otherwise stated in this License, Licensor may not terminate this License with Licensee.
|
|
31
|
+
|
|
32
|
+
*
|
|
33
|
+
Enforceability and Interpretation. If any term or provision of this License is determined to be invalid, illegal, or unenforceable by a court of competent jurisdiction, then such invalidity, illegality, or unenforceability shall not affect any other term or provision of this License or invalidate or render unenforceable such term or provision in any other jurisdiction; provided, however, subject to a court modification pursuant to the immediately following sentence, if any term or provision of this License pertaining to Human Rights Laws or Human Rights Principles is deemed invalid, illegal, or unenforceable against Licensee by a court of competent jurisdiction, all rights in the Software granted to Licensee shall be deemed null and void as between Licensor and Licensee. Upon a determination that any term or provision is invalid, illegal, or unenforceable, to the extent permitted by Laws, the court may modify this License to affect the original purpose that the Software be used in compliance with Human Rights Principles and Human Rights Laws as closely as possible. The language in this License shall be interpreted as to its fair meaning and not strictly for or against any party.
|
|
34
|
+
|
|
35
|
+
*
|
|
36
|
+
Disclaimer. TO THE FULL EXTENT ALLOWED BY LAW, THIS SOFTWARE COMES “AS IS,” WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED, AND LICENSOR AND ANY OTHER CONTRIBUTOR SHALL NOT BE LIABLE TO ANYONE FOR ANY DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THIS LICENSE, UNDER ANY KIND OF LEGAL CLAIM.
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
This Hippocratic License is an Ethical Source license (https://ethicalsource.dev) and is offered for use by licensors and licensees at their own risk, on an “AS IS” basis, and with no warranties express or implied, to the maximum extent permitted by Laws.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: crystallograpy
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Lightweight Python utilities about crystallography properties
|
|
5
|
+
Project-URL: Homepage, https://github.com/milaforscience/crystallograpy
|
|
6
|
+
Project-URL: Issues, https://github.com/milaforscience/crystallograpy/issues
|
|
7
|
+
Author-email: alexhernandezgarcia <alex.hernandez-garcia@mila.quebec>
|
|
8
|
+
License-Expression: Hippocratic-2.1
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Requires-Dist: pyyaml>=6.0.1
|
|
14
|
+
Provides-Extra: dev
|
|
15
|
+
Requires-Dist: black>=23.9.1; extra == 'dev'
|
|
16
|
+
Requires-Dist: flake8>=6.1.0; extra == 'dev'
|
|
17
|
+
Requires-Dist: ipdb>=0.13.13; extra == 'dev'
|
|
18
|
+
Requires-Dist: isort>=5.12.0; extra == 'dev'
|
|
19
|
+
Requires-Dist: jupyter>=1.0.0; extra == 'dev'
|
|
20
|
+
Requires-Dist: pylint>=2.17.6; extra == 'dev'
|
|
21
|
+
Requires-Dist: pytest-repeat>=0.9.1; extra == 'dev'
|
|
22
|
+
Requires-Dist: pytest>=7.4.2; extra == 'dev'
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# crystallograpy (cryspy)
|
|
26
|
+
|
|
27
|
+
A simple package with data structures containing crystallographic properties and their relationships, such as space groups, Wyckoff positions, etc. as well utilities for accessing them.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "crystallograpy"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Lightweight Python utilities about crystallography properties"
|
|
5
|
+
authors = [
|
|
6
|
+
{name = "alexhernandezgarcia", email = "alex.hernandez-garcia@mila.quebec"},
|
|
7
|
+
]
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
requires-python = ">=3.10"
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Programming Language :: Python :: 3",
|
|
12
|
+
"Operating System :: OS Independent",
|
|
13
|
+
]
|
|
14
|
+
dependencies = [
|
|
15
|
+
"PyYAML >=6.0.1",
|
|
16
|
+
]
|
|
17
|
+
license = "Hippocratic-2.1"
|
|
18
|
+
license-files = ["LICEN[CS]E*"]
|
|
19
|
+
|
|
20
|
+
[project.urls]
|
|
21
|
+
Homepage = "https://github.com/milaforscience/crystallograpy"
|
|
22
|
+
Issues = "https://github.com/milaforscience/crystallograpy/issues"
|
|
23
|
+
|
|
24
|
+
[tool.setuptools]
|
|
25
|
+
package-dir = {"" = "src"}
|
|
26
|
+
|
|
27
|
+
[build-system]
|
|
28
|
+
requires = ["hatchling >= 1.26"]
|
|
29
|
+
build-backend = "hatchling.build"
|
|
30
|
+
|
|
31
|
+
[project.optional-dependencies]
|
|
32
|
+
dev = [
|
|
33
|
+
"black >=23.9.1",
|
|
34
|
+
"flake8 >=6.1.0",
|
|
35
|
+
"isort >=5.12.0",
|
|
36
|
+
"ipdb >=0.13.13",
|
|
37
|
+
"jupyter >=1.0.0",
|
|
38
|
+
"pylint >=2.17.6",
|
|
39
|
+
"pytest >=7.4.2",
|
|
40
|
+
"pytest-repeat >=0.9.1",
|
|
41
|
+
]
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Creates dictionaries of crystal systems, crystal lattices, point symmetries and space
|
|
3
|
+
groups containing their releationships.
|
|
4
|
+
|
|
5
|
+
It uses pre-stored simple variables as well as databases and methods from pymatgen.
|
|
6
|
+
|
|
7
|
+
Example:
|
|
8
|
+
python scripts/build_lattice_dicts.py \
|
|
9
|
+
--print \
|
|
10
|
+
--output_sg_yaml yaml/space_groups.yaml \
|
|
11
|
+
--output_cls_yaml yaml/crystal_lattice_systems.yaml \
|
|
12
|
+
--output_ps_yaml yaml/point_symmetries.yaml
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import sys
|
|
16
|
+
from argparse import ArgumentParser
|
|
17
|
+
|
|
18
|
+
from lattice_constants import (
|
|
19
|
+
CRYSTAL_CLASSES_WIKIPEDIA,
|
|
20
|
+
CRYSTAL_LATTICE_SYSTEMS,
|
|
21
|
+
POINT_SYMMETRIES,
|
|
22
|
+
RHOMBOHEDRAL_SPACE_GROUPS_WIKIPEDIA,
|
|
23
|
+
)
|
|
24
|
+
from pymatgen.symmetry.groups import SpaceGroup, sg_symbol_from_int_number
|
|
25
|
+
|
|
26
|
+
import yaml
|
|
27
|
+
|
|
28
|
+
N_SPACE_GROUPS = 230
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def parsed_args():
|
|
32
|
+
"""
|
|
33
|
+
Parse and returns command-line args
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
argparse.Namespace: the parsed arguments
|
|
37
|
+
"""
|
|
38
|
+
parser = ArgumentParser()
|
|
39
|
+
parser.add_argument(
|
|
40
|
+
"--output_sg_yaml",
|
|
41
|
+
default=None,
|
|
42
|
+
type=str,
|
|
43
|
+
help="Output space groups YAML dict",
|
|
44
|
+
)
|
|
45
|
+
parser.add_argument(
|
|
46
|
+
"--output_cls_yaml",
|
|
47
|
+
default=None,
|
|
48
|
+
type=str,
|
|
49
|
+
help="Output crystal-lattice system YAML dict",
|
|
50
|
+
)
|
|
51
|
+
parser.add_argument(
|
|
52
|
+
"--output_ps_yaml",
|
|
53
|
+
default=None,
|
|
54
|
+
type=str,
|
|
55
|
+
help="Output point symmetry YAML dict",
|
|
56
|
+
)
|
|
57
|
+
parser.add_argument(
|
|
58
|
+
"--print",
|
|
59
|
+
default=False,
|
|
60
|
+
action="store_true",
|
|
61
|
+
help="If True, print progress",
|
|
62
|
+
)
|
|
63
|
+
return parser.parse_args()
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _crystal_lattice_system_index(crystal_lattice_system):
|
|
67
|
+
for idx, crystal_lattice_system_iter in CRYSTAL_LATTICE_SYSTEMS.items():
|
|
68
|
+
if crystal_lattice_system == crystal_lattice_system_iter:
|
|
69
|
+
return idx
|
|
70
|
+
raise ValueError(
|
|
71
|
+
f"Crystal-lattice system {crystal_lattice_system} not found in "
|
|
72
|
+
"crystal-lattice systems dictionary"
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _point_symmetry_index(point_symmetry):
|
|
77
|
+
for idx, point_symmetry_iter in POINT_SYMMETRIES.items():
|
|
78
|
+
if point_symmetry == point_symmetry_iter:
|
|
79
|
+
return idx
|
|
80
|
+
raise ValueError(
|
|
81
|
+
f"Point symmetry {point_symmetry} not found in point symmetries dictionary"
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _point_group_to_crystal_class_and_point_symmetry(point_group):
|
|
86
|
+
for crystal_class_idx, pg_list in CRYSTAL_CLASSES_WIKIPEDIA.items():
|
|
87
|
+
if point_group in pg_list[2]:
|
|
88
|
+
crystal_class = pg_list[0]
|
|
89
|
+
point_symmetry = pg_list[3]
|
|
90
|
+
point_symmetry_idx = _point_symmetry_index(point_symmetry)
|
|
91
|
+
return (
|
|
92
|
+
crystal_class_idx,
|
|
93
|
+
crystal_class,
|
|
94
|
+
point_symmetry_idx,
|
|
95
|
+
point_symmetry,
|
|
96
|
+
)
|
|
97
|
+
raise ValueError(f"Point group {point_group} not found in point group dictionary")
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def _crystal_system_and_space_group_to_lattice_system(crystal_system, sg_symbol):
|
|
101
|
+
if crystal_system == "trigonal":
|
|
102
|
+
if sg_symbol in RHOMBOHEDRAL_SPACE_GROUPS_WIKIPEDIA:
|
|
103
|
+
return "rhombohedral"
|
|
104
|
+
else:
|
|
105
|
+
return "hexagonal"
|
|
106
|
+
else:
|
|
107
|
+
return crystal_system
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def _crystal_system_and_space_groups_to_lattice_system(
|
|
111
|
+
crystal_system, sg_symbol, sg_symbol_rhombohedral
|
|
112
|
+
):
|
|
113
|
+
if crystal_system == "trigonal":
|
|
114
|
+
if sg_symbol_rhombohedral != sg_symbol:
|
|
115
|
+
return "rhombohedral"
|
|
116
|
+
else:
|
|
117
|
+
return "hexagonal"
|
|
118
|
+
else:
|
|
119
|
+
return crystal_system
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
if __name__ == "__main__":
|
|
123
|
+
# Arguments
|
|
124
|
+
args = parsed_args()
|
|
125
|
+
|
|
126
|
+
# Make space group dictionary
|
|
127
|
+
space_groups_dict = {}
|
|
128
|
+
for idx in range(1, N_SPACE_GROUPS + 1):
|
|
129
|
+
sg_symbol = sg_symbol_from_int_number(idx, hexagonal=True)
|
|
130
|
+
sg_symbol_rhombohedral = sg_symbol_from_int_number(idx, hexagonal=False)
|
|
131
|
+
sg = SpaceGroup(sg_symbol)
|
|
132
|
+
sg_hmsymbol = sg.symbol
|
|
133
|
+
point_group = sg.point_group
|
|
134
|
+
crystal_system = sg.crystal_system
|
|
135
|
+
(
|
|
136
|
+
crystal_class_idx,
|
|
137
|
+
crystal_class,
|
|
138
|
+
point_symmetry_idx,
|
|
139
|
+
point_symmetry,
|
|
140
|
+
) = _point_group_to_crystal_class_and_point_symmetry(point_group)
|
|
141
|
+
lattice_system = _crystal_system_and_space_group_to_lattice_system(
|
|
142
|
+
crystal_system, sg_symbol_rhombohedral
|
|
143
|
+
)
|
|
144
|
+
lattice_system_pymatgen = _crystal_system_and_space_groups_to_lattice_system(
|
|
145
|
+
crystal_system, sg_symbol, sg_symbol_rhombohedral
|
|
146
|
+
)
|
|
147
|
+
assert lattice_system == lattice_system_pymatgen
|
|
148
|
+
if crystal_system != lattice_system:
|
|
149
|
+
crystal_lattice_system = f"{crystal_system}-{lattice_system}"
|
|
150
|
+
else:
|
|
151
|
+
crystal_lattice_system = crystal_system
|
|
152
|
+
crystal_lattice_system_idx = _crystal_lattice_system_index(
|
|
153
|
+
crystal_lattice_system
|
|
154
|
+
)
|
|
155
|
+
# Update dictionary
|
|
156
|
+
space_groups_dict.update(
|
|
157
|
+
{
|
|
158
|
+
idx: {
|
|
159
|
+
"full_symbol": sg_hmsymbol,
|
|
160
|
+
"symbol": sg_symbol_rhombohedral,
|
|
161
|
+
"crystal_system": crystal_system,
|
|
162
|
+
"lattice_system": lattice_system,
|
|
163
|
+
"crystal_lattice_system_idx": crystal_lattice_system_idx,
|
|
164
|
+
"point_symmetry_idx": point_symmetry_idx,
|
|
165
|
+
"point_symmetry": point_symmetry,
|
|
166
|
+
"point_group": point_group,
|
|
167
|
+
"crystal_class": crystal_class,
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
# Print
|
|
172
|
+
if args.print:
|
|
173
|
+
print(f"International number: {idx}")
|
|
174
|
+
for k, v in space_groups_dict[idx].items():
|
|
175
|
+
print(f"{k}: {v}")
|
|
176
|
+
print("---")
|
|
177
|
+
# Save YAML
|
|
178
|
+
if args.output_sg_yaml:
|
|
179
|
+
with open(args.output_sg_yaml, "w") as f:
|
|
180
|
+
yaml.dump(space_groups_dict, f)
|
|
181
|
+
|
|
182
|
+
# Make crystal-lattice system dictionary
|
|
183
|
+
crystal_lattice_system_dict = {}
|
|
184
|
+
for idx, crystal_lattice_system in CRYSTAL_LATTICE_SYSTEMS.items():
|
|
185
|
+
crystal_system = crystal_lattice_system.split("-")[0]
|
|
186
|
+
lattice_system = crystal_lattice_system.split("-")[-1]
|
|
187
|
+
space_groups = []
|
|
188
|
+
point_symmetries = []
|
|
189
|
+
for sg, sg_dict in space_groups_dict.items():
|
|
190
|
+
if (
|
|
191
|
+
sg_dict["crystal_system"] == crystal_system
|
|
192
|
+
and sg_dict["lattice_system"] == lattice_system
|
|
193
|
+
):
|
|
194
|
+
space_groups.append(sg)
|
|
195
|
+
point_symmetry_index = _point_symmetry_index(sg_dict["point_symmetry"])
|
|
196
|
+
if point_symmetry_index not in point_symmetries:
|
|
197
|
+
point_symmetries.append(point_symmetry_index)
|
|
198
|
+
# Update dictionary
|
|
199
|
+
crystal_lattice_system_dict.update(
|
|
200
|
+
{
|
|
201
|
+
idx: {
|
|
202
|
+
"crystal_system": crystal_system,
|
|
203
|
+
"lattice_system": lattice_system,
|
|
204
|
+
"point_symmetries": point_symmetries,
|
|
205
|
+
"space_groups": space_groups,
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
)
|
|
209
|
+
# Print
|
|
210
|
+
if args.print:
|
|
211
|
+
print(f"Crystal-lattice system index: {idx}")
|
|
212
|
+
for k, v in crystal_lattice_system_dict[idx].items():
|
|
213
|
+
print(f"{k}: {v}")
|
|
214
|
+
print("---")
|
|
215
|
+
# Save YAML
|
|
216
|
+
if args.output_cls_yaml:
|
|
217
|
+
with open(args.output_cls_yaml, "w") as f:
|
|
218
|
+
yaml.dump(crystal_lattice_system_dict, f)
|
|
219
|
+
|
|
220
|
+
# Make point symmetry dictionary
|
|
221
|
+
point_symmetry_dict = {}
|
|
222
|
+
for idx, point_symmetry in POINT_SYMMETRIES.items():
|
|
223
|
+
space_groups = []
|
|
224
|
+
crystal_lattice_systems = []
|
|
225
|
+
for sg, sg_dict in space_groups_dict.items():
|
|
226
|
+
if sg_dict["point_symmetry"] == point_symmetry:
|
|
227
|
+
space_groups.append(sg)
|
|
228
|
+
crystal_system = sg_dict["crystal_system"]
|
|
229
|
+
lattice_system = sg_dict["lattice_system"]
|
|
230
|
+
if crystal_system != lattice_system:
|
|
231
|
+
crystal_lattice_system = f"{crystal_system}-{lattice_system}"
|
|
232
|
+
else:
|
|
233
|
+
crystal_lattice_system = crystal_system
|
|
234
|
+
crystal_lattice_system_idx = _crystal_lattice_system_index(
|
|
235
|
+
crystal_lattice_system
|
|
236
|
+
)
|
|
237
|
+
if crystal_lattice_system_idx not in crystal_lattice_systems:
|
|
238
|
+
crystal_lattice_systems.append(crystal_lattice_system_idx)
|
|
239
|
+
# Update dictionary
|
|
240
|
+
point_symmetry_dict.update(
|
|
241
|
+
{
|
|
242
|
+
idx: {
|
|
243
|
+
"point_symmetry": point_symmetry,
|
|
244
|
+
"crystal_lattice_systems": crystal_lattice_systems,
|
|
245
|
+
"space_groups": space_groups,
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
)
|
|
249
|
+
# Print
|
|
250
|
+
if args.print:
|
|
251
|
+
print(f"Point symmetry index: {idx}")
|
|
252
|
+
for k, v in point_symmetry_dict[idx].items():
|
|
253
|
+
print(f"{k}: {v}")
|
|
254
|
+
print("---")
|
|
255
|
+
# Save YAML
|
|
256
|
+
if args.output_cls_yaml:
|
|
257
|
+
with open(args.output_ps_yaml, "w") as f:
|
|
258
|
+
yaml.dump(point_symmetry_dict, f)
|
|
259
|
+
|
|
260
|
+
# Exit
|
|
261
|
+
sys.exit()
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
from .utils import get_wyckoff_index, load_database
|
|
2
|
+
|
|
3
|
+
# Load space group and Wyckoff data when the package is imported
|
|
4
|
+
spacegroups = load_database("spacegroups.yaml")
|
|
5
|
+
wyckoff = load_database("wyckoff.yaml")
|
|
6
|
+
|
|
7
|
+
# Make configurations available at package level
|
|
8
|
+
__all__ = ["spacegroups", "wyckoff", "get_wyckoff_index"]
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from cyrstallograpy import spacegroups
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class SpaceGroup:
|
|
5
|
+
"""Class to represent space groups.
|
|
6
|
+
|
|
7
|
+
An instance of this SpaceGroup class is meant to represent one of the 230 space
|
|
8
|
+
groups as stored in ``yaml/spacegroups.yaml``.
|
|
9
|
+
|
|
10
|
+
A space group is identified by an integer corresponding to the international
|
|
11
|
+
number, as per the International Tables for Crystallography.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
def __init__(self, number: int):
|
|
15
|
+
"""Initialize a SpaceGroup instance.
|
|
16
|
+
|
|
17
|
+
Parameters
|
|
18
|
+
----------
|
|
19
|
+
number : int
|
|
20
|
+
An integer between 1 and 230 corresponding to an international number, as
|
|
21
|
+
per the data stored in ``yaml/spacegroup.yaml`` and the International
|
|
22
|
+
Tables for Crystallography.
|
|
23
|
+
"""
|
|
24
|
+
# Read space group by its number
|
|
25
|
+
assert number >= 1 and number <= 230
|
|
26
|
+
data = spacegroups[index]
|
|
27
|
+
|
|
28
|
+
self.symbol = data.symbol
|
|
29
|
+
self.full_symbol = data.full_symbol
|
|
30
|
+
self.crystal_system = data.crystal_system
|
|
31
|
+
self.crystal_lattice = data.crystal_lattice
|
|
32
|
+
self.crystal_lattice_system_index = data.crystal_lattice_system_index
|
|
33
|
+
self.point_symmetry = data.point_symmetry
|
|
34
|
+
self.point_symmetry_idx = data.point_symmetry_idx
|
|
35
|
+
self.point_group = data.point_group
|
|
36
|
+
self.crystal_class = data.crystal_class
|