pyorbb 0.12.7__py3-none-any.whl

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.
Files changed (37) hide show
  1. pyorbb/__init__.py +203 -0
  2. pyorbb/__main__.py +28 -0
  3. pyorbb/analysis/__init__.py +3 -0
  4. pyorbb/analysis/mixing.py +886 -0
  5. pyorbb/analysis/movie.py +109 -0
  6. pyorbb/analysis/sequential.py +437 -0
  7. pyorbb/application/components/action_widget.py +35 -0
  8. pyorbb/application/components/carousel.py +308 -0
  9. pyorbb/application/components/column_dragger.py +122 -0
  10. pyorbb/application/components/editable_tabs.py +197 -0
  11. pyorbb/application/components/latex_renderer.py +169 -0
  12. pyorbb/application/components/orbital_selector.py +580 -0
  13. pyorbb/application/components/rich_widgets.py +375 -0
  14. pyorbb/application/components/settings.py +635 -0
  15. pyorbb/application/components/shadow.py +24 -0
  16. pyorbb/application/components/spoilers.py +207 -0
  17. pyorbb/application/components/theme_switcher.py +40 -0
  18. pyorbb/application/main.py +2187 -0
  19. pyorbb/cli_scripts/excel.py +23 -0
  20. pyorbb/cli_scripts/open_GUI.py +33 -0
  21. pyorbb/cli_scripts/pyorbbparser.py +42 -0
  22. pyorbb/nested_dict.py +80 -0
  23. pyorbb/orbitals/__init__.py +2 -0
  24. pyorbb/orbitals/_symmetry_free.py +32 -0
  25. pyorbb/orbitals/adf.py +555 -0
  26. pyorbb/orbitals/fragments.py +115 -0
  27. pyorbb/orbitals/objects.py +1546 -0
  28. pyorbb/plotting/__init__.py +1 -0
  29. pyorbb/plotting/orbital_diagram.py +340 -0
  30. pyorbb/plotting/simple_orbital_diagram.py +284 -0
  31. pyorbb/write_excel.py +729 -0
  32. pyorbb-0.12.7.dist-info/METADATA +131 -0
  33. pyorbb-0.12.7.dist-info/RECORD +37 -0
  34. pyorbb-0.12.7.dist-info/WHEEL +5 -0
  35. pyorbb-0.12.7.dist-info/entry_points.txt +2 -0
  36. pyorbb-0.12.7.dist-info/licenses/LICENSE +21 -0
  37. pyorbb-0.12.7.dist-info/top_level.txt +1 -0
pyorbb/__init__.py ADDED
@@ -0,0 +1,203 @@
1
+ import os
2
+ import re
3
+ import yaml
4
+
5
+ from . import orbitals # noqa
6
+ from .orbitals import Orbitals, MO, FMO # noqa
7
+ from . import plotting # noqa
8
+ from . import analysis # noqa
9
+ from .analysis import Mixer # noqa
10
+ from . import application # noqa
11
+
12
+ if os.path.exists(os.path.join(os.path.split(__file__)[0], 'VERSION')):
13
+ with open(os.path.join(os.path.split(__file__)[0], 'VERSION')) as version:
14
+ __version__ = version.read().strip()
15
+ else:
16
+ __version__ = '0.0.0'
17
+
18
+
19
+
20
+ IRREP_TRANSLATION_LATEX = {
21
+ "E1:1": r"E$_\mathrm{1}^\mathrm{1}$",
22
+ "E1:2": r"E$_\mathrm{1}^\mathrm{2}$",
23
+ "EE1:1": r"E$^{\mathrm{1}\prime}_\mathrm{1}$",
24
+ "EE1:2": r"E$^{\mathrm{2}\prime}_\mathrm{1}$",
25
+ "EEE1:1": r"E$^{\mathrm{1}\prime\prime}_\mathrm{1}$",
26
+ "EEE1:2": r"E$^{\mathrm{2}\prime\prime}_\mathrm{1}$",
27
+ "AA": r"A$^{\prime}$",
28
+ "AAA": r"A$^{\prime\prime}$",
29
+ "AA1": r"A$^{\prime}_\mathrm{1}$",
30
+ "AA2": r"A$^{\prime}_\mathrm{2}$",
31
+ "AAA1": r"A$^{\prime\prime}_\mathrm{1}$",
32
+ "AAA2": r"A$^{\prime\prime}_\mathrm{2}$",
33
+ "A": r"A",
34
+ "A1": r"A$_\mathrm{1}$",
35
+ "A2": r"A$_\mathrm{2}$",
36
+ "B1": r"B$_\mathrm{1}$",
37
+ "B2": r"B$_\mathrm{2}$",
38
+ "T1": r"T$_\mathrm{1}$",
39
+ "T2": r"T$_\mathrm{2}$",
40
+ "E": r"E",
41
+
42
+ "SIGMA": r"$\Sigma$",
43
+ "PI": r"$\Pi$",
44
+ "DELTA": r"$\Delta$",
45
+ "PHI": r"$\Phi$",
46
+
47
+ "S": r"$s$",
48
+ "P": r"$p$",
49
+ "D": r"$d$",
50
+ "F": r"$f$",
51
+ }
52
+
53
+
54
+ IRREP_TRANSLATION_HTML = {
55
+ "E1": "E<sub>1</sub>",
56
+ "E1:1": "E<sub>1</sub><sup>1</sup>",
57
+ "E1:2": "E<sub>1</sub><sup>2</sup>",
58
+ "EE1": "E<sup>1</sup>′",
59
+ "EE1:1": "E<sup>1</sup>′<sub>1</sub>",
60
+ "EE1:2": "E<sup>2</sup>′<sub>1</sub>",
61
+ "EEE1": "E<sup>1</sup>′′",
62
+ "EEE1:1": "E<sup>1</sup>′′<sub>1</sub>",
63
+ "EEE1:2": "E<sup>2</sup>′′<sub>1</sub>",
64
+ "AA": "A′",
65
+ "AAA": "A″",
66
+ "AA1": "A′<sub>1</sub>",
67
+ "AA2": "A′<sub>2</sub>",
68
+ "AAA1": "A′′<sub>1</sub>",
69
+ "AAA2": "A′′<sub>2</sub>",
70
+ "A": "A",
71
+ "A1": "A<sub>1</sub>",
72
+ "A2": "A<sub>2</sub>",
73
+ "B1": "B<sub>1</sub>",
74
+ "B2": "B<sub>2</sub>",
75
+ "T1": "T<sub>1</sub>",
76
+ "T2": "T<sub>2</sub>",
77
+ "E": "E",
78
+
79
+ "SIGMA": "<i>σ</i>",
80
+ "PI": "<i>π</i>",
81
+ "DELTA": "<i>δ</i>",
82
+ "PHI": "<i>φ</i>",
83
+
84
+ "S": "<i>s</i>",
85
+ "P": "<i>p</i>",
86
+ "D": "<i>d</i>",
87
+ "F": "<i>f</i>",
88
+ }
89
+
90
+ rcParams_dir = os.path.join(os.path.split(__file__)[0], 'rcParams')
91
+ if os.path.exists(os.path.join(rcParams_dir, 'user.yaml')):
92
+ rcParams_path = os.path.join(rcParams_dir, 'user.yaml')
93
+ else:
94
+ rcParams_path = os.path.join(rcParams_dir, 'default.yaml')
95
+
96
+ with open(rcParams_path) as config:
97
+ rcParams = yaml.safe_load(config)
98
+
99
+
100
+ def save_rcParams():
101
+ with open(os.path.join(rcParams_dir, 'user.yaml'), 'w+') as user_config:
102
+ yaml.dump(rcParams, user_config)
103
+
104
+
105
+ def reset_rcParams():
106
+ global rcParams
107
+
108
+ with open(os.path.join(rcParams_dir, 'default.yaml')) as config:
109
+ rcParams = yaml.safe_load(config)
110
+
111
+
112
+ def translate_irrep_label(symm_label: str, mode='latex', use_formatting=True) -> str:
113
+ if mode == 'latex':
114
+ if symm_label in IRREP_TRANSLATION_LATEX:
115
+ return IRREP_TRANSLATION_LATEX[symm_label]
116
+
117
+ if ':' in symm_label:
118
+ subspecies, dimension = symm_label.split(':')
119
+ else:
120
+ subspecies = symm_label
121
+ dimension = None
122
+
123
+ if '.' in subspecies:
124
+ subspecies, parity = subspecies.split('.')
125
+ else:
126
+ parity = None
127
+
128
+ s = IRREP_TRANSLATION_LATEX.get(subspecies, subspecies)
129
+ if parity is not None:
130
+ s += rf'$_\mathrm{{{parity}}}$'
131
+
132
+ if dimension is not None:
133
+
134
+ if re.search(r"\d+", dimension):
135
+ dimension = re.sub(r"([xyz])(\d+)", r"\1^{\2}", dimension)
136
+ s += rf'$_{{{dimension}}}$'
137
+
138
+ return s
139
+
140
+ if mode == 'html':
141
+ if symm_label in IRREP_TRANSLATION_HTML:
142
+ s = IRREP_TRANSLATION_HTML[symm_label]
143
+ else:
144
+ if ':' in symm_label:
145
+ subspecies, dimension = symm_label.split(':')
146
+ else:
147
+ subspecies = symm_label
148
+ dimension = None
149
+
150
+ if '.' in subspecies:
151
+ subspecies, parity = subspecies.split('.')
152
+ else:
153
+ parity = None
154
+
155
+ s = IRREP_TRANSLATION_HTML.get(subspecies, subspecies)
156
+ if parity is not None:
157
+ s += f'<sub>{parity}</sub>'
158
+ if dimension is not None:
159
+
160
+ if re.search(r"\d+", dimension):
161
+ dimension = re.sub(r"([xyz])(\d+)", r"\1<sup>\2</sup>", dimension)
162
+ s += f'<sub><i>{dimension}</i></sub>'
163
+
164
+ if not use_formatting:
165
+ for format_tag in ['<i>', '</i>', '<sub>', '</sub>', '<sup>', '</sup>']:
166
+ s = s.replace(format_tag, '')
167
+
168
+ return s
169
+
170
+ return symm_label
171
+
172
+
173
+ def generate_label(orb, mode='latex', include_fragment=False, use_formatting=True):
174
+ if mode == 'latex':
175
+ spin_part = {
176
+ 'A': r'$\alpha$',
177
+ 'B': r'$\beta$'
178
+ }.get(orb.spin, '')
179
+ elif mode == 'html':
180
+ spin_part = {
181
+ 'A': '<i>α</i>',
182
+ 'B': '<i>β</i>'
183
+ }.get(orb.spin, '')
184
+
185
+ if isinstance(orb, orbitals.objects.MO):
186
+ orb_name = f'{orb.name}{spin_part}'
187
+ orb_name = orb_name.replace(orb.symmetry, translate_irrep_label(orb.symmetry, mode=mode))
188
+ else:
189
+ orb_name = orb.name
190
+ if include_fragment:
191
+ fragname = orb.fragment
192
+ orb_name = f'{fragname}({orb_name})'
193
+ if orb.spin != 'AB':
194
+ orb_name += spin_part
195
+
196
+ orb_name = orb_name.replace(orb.subspecies, translate_irrep_label(orb.subspecies, mode=mode))
197
+
198
+ if not use_formatting:
199
+ for format_tag in ['<i>', '</i>', '<sub>', '</sub>', '<sup>', '</sup>']:
200
+ orb_name = orb_name.replace(format_tag, '')
201
+
202
+ return orb_name
203
+
pyorbb/__main__.py ADDED
@@ -0,0 +1,28 @@
1
+ def main():
2
+ import platformdirs
3
+ import os
4
+ # import contextlib
5
+ from datetime import datetime
6
+ import traceback
7
+ # import faulthandler
8
+
9
+ # faulthandler.enable()
10
+
11
+ log_dir = platformdirs.user_log_dir(appname="PyOrbb", appauthor="TheoCheMVU", ensure_exists=True)
12
+ now = str(datetime.now()).replace(" ", "_").replace(":", "-").split(".")[0]
13
+ log_file = os.path.join(log_dir, now + ".txt")
14
+ print("WRITING STDOUT/STDERR TO", log_file)
15
+ # with open(log_file, "w+") as outp:
16
+ # with contextlib.redirect_stdout(outp), contextlib.redirect_stderr(outp):
17
+ try:
18
+ from pyorbb.application import main
19
+
20
+ with main.PyOrbbApp():
21
+ ...
22
+
23
+ except Exception as e:
24
+ print("".join(traceback.format_exception(type(e), e, e.__traceback__)))
25
+
26
+
27
+ if __name__ == '__main__':
28
+ main()
@@ -0,0 +1,3 @@
1
+ from . import mixing, movie # noqa
2
+ from .mixing import Mixer # noqa
3
+ from .sequential import MOTracker # noqa