digichem-core 6.0.0rc1__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 (111) hide show
  1. digichem/__init__.py +75 -0
  2. digichem/basis.py +116 -0
  3. digichem/config/README +3 -0
  4. digichem/config/__init__.py +5 -0
  5. digichem/config/base.py +321 -0
  6. digichem/config/locations.py +14 -0
  7. digichem/config/parse.py +90 -0
  8. digichem/config/util.py +117 -0
  9. digichem/data/README +4 -0
  10. digichem/data/batoms/COPYING +18 -0
  11. digichem/data/batoms/LICENSE +674 -0
  12. digichem/data/batoms/README +2 -0
  13. digichem/data/batoms/__init__.py +0 -0
  14. digichem/data/batoms/batoms-renderer.py +351 -0
  15. digichem/data/config/digichem.yaml +714 -0
  16. digichem/data/functionals.csv +15 -0
  17. digichem/data/solvents.csv +185 -0
  18. digichem/data/tachyon/COPYING.md +5 -0
  19. digichem/data/tachyon/LICENSE +30 -0
  20. digichem/data/tachyon/tachyon_LINUXAMD64 +0 -0
  21. digichem/data/vmd/common.tcl +468 -0
  22. digichem/data/vmd/generate_combined_orbital_images.tcl +70 -0
  23. digichem/data/vmd/generate_density_images.tcl +45 -0
  24. digichem/data/vmd/generate_dipole_images.tcl +68 -0
  25. digichem/data/vmd/generate_orbital_images.tcl +57 -0
  26. digichem/data/vmd/generate_spin_images.tcl +66 -0
  27. digichem/data/vmd/generate_structure_images.tcl +40 -0
  28. digichem/datas.py +14 -0
  29. digichem/exception/__init__.py +7 -0
  30. digichem/exception/base.py +133 -0
  31. digichem/exception/uncatchable.py +63 -0
  32. digichem/file/__init__.py +1 -0
  33. digichem/file/base.py +364 -0
  34. digichem/file/cube.py +284 -0
  35. digichem/file/fchk.py +94 -0
  36. digichem/file/prattle.py +277 -0
  37. digichem/file/types.py +97 -0
  38. digichem/image/__init__.py +6 -0
  39. digichem/image/base.py +113 -0
  40. digichem/image/excited_states.py +335 -0
  41. digichem/image/graph.py +293 -0
  42. digichem/image/orbitals.py +239 -0
  43. digichem/image/render.py +617 -0
  44. digichem/image/spectroscopy.py +797 -0
  45. digichem/image/structure.py +115 -0
  46. digichem/image/vmd.py +826 -0
  47. digichem/input/__init__.py +3 -0
  48. digichem/input/base.py +78 -0
  49. digichem/input/digichem_input.py +500 -0
  50. digichem/input/gaussian.py +140 -0
  51. digichem/log.py +179 -0
  52. digichem/memory.py +166 -0
  53. digichem/misc/__init__.py +4 -0
  54. digichem/misc/argparse.py +44 -0
  55. digichem/misc/base.py +61 -0
  56. digichem/misc/io.py +239 -0
  57. digichem/misc/layered_dict.py +285 -0
  58. digichem/misc/text.py +139 -0
  59. digichem/misc/time.py +73 -0
  60. digichem/parse/__init__.py +13 -0
  61. digichem/parse/base.py +220 -0
  62. digichem/parse/cclib.py +138 -0
  63. digichem/parse/dump.py +253 -0
  64. digichem/parse/gaussian.py +130 -0
  65. digichem/parse/orca.py +96 -0
  66. digichem/parse/turbomole.py +201 -0
  67. digichem/parse/util.py +523 -0
  68. digichem/result/__init__.py +6 -0
  69. digichem/result/alignment/AA.py +114 -0
  70. digichem/result/alignment/AAA.py +61 -0
  71. digichem/result/alignment/FAP.py +148 -0
  72. digichem/result/alignment/__init__.py +3 -0
  73. digichem/result/alignment/base.py +310 -0
  74. digichem/result/angle.py +153 -0
  75. digichem/result/atom.py +742 -0
  76. digichem/result/base.py +258 -0
  77. digichem/result/dipole_moment.py +332 -0
  78. digichem/result/emission.py +402 -0
  79. digichem/result/energy.py +323 -0
  80. digichem/result/excited_state.py +821 -0
  81. digichem/result/ground_state.py +94 -0
  82. digichem/result/metadata.py +644 -0
  83. digichem/result/multi.py +98 -0
  84. digichem/result/nmr.py +1086 -0
  85. digichem/result/orbital.py +647 -0
  86. digichem/result/result.py +244 -0
  87. digichem/result/soc.py +272 -0
  88. digichem/result/spectroscopy.py +514 -0
  89. digichem/result/tdm.py +267 -0
  90. digichem/result/vibration.py +167 -0
  91. digichem/test/__init__.py +6 -0
  92. digichem/test/conftest.py +4 -0
  93. digichem/test/test_basis.py +71 -0
  94. digichem/test/test_calculate.py +30 -0
  95. digichem/test/test_config.py +78 -0
  96. digichem/test/test_cube.py +369 -0
  97. digichem/test/test_exception.py +16 -0
  98. digichem/test/test_file.py +104 -0
  99. digichem/test/test_image.py +337 -0
  100. digichem/test/test_input.py +64 -0
  101. digichem/test/test_parsing.py +79 -0
  102. digichem/test/test_prattle.py +36 -0
  103. digichem/test/test_result.py +489 -0
  104. digichem/test/test_translate.py +112 -0
  105. digichem/test/util.py +207 -0
  106. digichem/translate.py +591 -0
  107. digichem_core-6.0.0rc1.dist-info/METADATA +96 -0
  108. digichem_core-6.0.0rc1.dist-info/RECORD +111 -0
  109. digichem_core-6.0.0rc1.dist-info/WHEEL +4 -0
  110. digichem_core-6.0.0rc1.dist-info/licenses/COPYING.md +10 -0
  111. digichem_core-6.0.0rc1.dist-info/licenses/LICENSE +11 -0
@@ -0,0 +1,369 @@
1
+ import pytest
2
+ from pathlib import Path
3
+
4
+ from digichem.image.excited_states import Excited_states_diagram_maker
5
+ from digichem.image.graph import Convergence_graph_maker
6
+ from digichem.image.orbitals import Orbital_diagram_maker
7
+ from digichem.image.spectroscopy import Absorption_graph_maker, Emission_graph_maker, \
8
+ Frequency_graph_maker, NMR_graph_maker, NMR_graph_zoom_maker
9
+ from digichem.image.structure import Skeletal_image_maker
10
+ from digichem.image.vmd import Structure_image_maker, Orbital_image_maker, Density_image_maker, \
11
+ Combined_orbital_image_maker, Permanent_dipole_image_maker, Transition_dipole_image_maker
12
+ from digichem.file.cube import Fchk_to_cube, Fchk_to_density_cube, Fchk_to_nto_cube, Fchk_to_spin_cube
13
+ from digichem.parse.util import open_for_parsing, parse_calculation
14
+
15
+ from digichem.test.util import digichem_options, data_directory
16
+ from digichem.test.test_result import gaussian_ES_result, turbomole_ES_result, orca_ES_result, \
17
+ gaussian_opt_result, turbomole_opt_result, orca_opt_result, orca_opt_freq_result, \
18
+ orca_nmr_result
19
+
20
+ pytest.skip(allow_module_level=True)
21
+
22
+ @pytest.mark.parametrize("result_set", [
23
+ pytest.lazy_fixture("gaussian_ES_result"),
24
+ pytest.lazy_fixture("turbomole_ES_result"),
25
+ pytest.lazy_fixture("orca_ES_result")
26
+ ])
27
+ def test_es_diagram(result_set, tmp_path, digichem_options):
28
+ """Can we make an excited states diagram?"""
29
+ maker = Excited_states_diagram_maker.from_options(
30
+ tmp_path / "tmp.png",
31
+ excited_states = result_set.excited_states,
32
+ ground_state = result_set.ground_state,
33
+ options = digichem_options
34
+ )
35
+
36
+ maker.get_image()
37
+ assert Path(tmp_path, "tmp.png").exists()
38
+
39
+
40
+ @pytest.mark.parametrize("result_set", [
41
+ pytest.lazy_fixture("gaussian_opt_result"),
42
+ pytest.lazy_fixture("turbomole_opt_result"),
43
+ pytest.lazy_fixture("orca_opt_result")
44
+ ])
45
+ def test_convergence_diagram(result_set, tmp_path, digichem_options):
46
+ """Can we make an optimisation graph?"""
47
+ maker = Convergence_graph_maker.from_options(
48
+ tmp_path / "tmp.png",
49
+ energies = result_set.energies.scf,
50
+ options = digichem_options
51
+ )
52
+
53
+ maker.get_image()
54
+ assert Path(tmp_path, "tmp.png").exists()
55
+
56
+
57
+ @pytest.mark.parametrize("result_set", [
58
+ pytest.lazy_fixture("gaussian_opt_result"),
59
+ pytest.lazy_fixture("turbomole_opt_result"),
60
+ pytest.lazy_fixture("orca_opt_result")
61
+ ])
62
+ def test_orbital_diagram(result_set, tmp_path, digichem_options):
63
+ """Can we make an orbital diagram?"""
64
+ maker = Orbital_diagram_maker.from_options(
65
+ tmp_path / "tmp.png",
66
+ orbitals = result_set.orbitals,
67
+ options = digichem_options
68
+ )
69
+
70
+ maker.get_image()
71
+ assert Path(tmp_path, "tmp.png").exists()
72
+
73
+
74
+ @pytest.mark.parametrize("result_set", [
75
+ pytest.lazy_fixture("gaussian_ES_result"),
76
+ pytest.lazy_fixture("turbomole_ES_result"),
77
+ pytest.lazy_fixture("orca_ES_result")
78
+ ])
79
+ def test_abs_diagram(result_set, tmp_path, digichem_options):
80
+ """Can we make an absorption spectrum?"""
81
+ maker = Absorption_graph_maker.from_options(
82
+ tmp_path / "tmp.png",
83
+ excited_states = result_set.excited_states,
84
+ options = digichem_options
85
+ )
86
+
87
+ maker.get_image()
88
+ assert Path(tmp_path, "tmp.png").exists()
89
+
90
+
91
+ @pytest.mark.parametrize("result_set", [
92
+ pytest.lazy_fixture("gaussian_ES_result"),
93
+ pytest.lazy_fixture("turbomole_ES_result"),
94
+ pytest.lazy_fixture("orca_ES_result")
95
+ ])
96
+ def test_pl_diagram(result_set, tmp_path, digichem_options):
97
+ """Can we make an emission spectrum?"""
98
+ maker = Emission_graph_maker.from_options(
99
+ tmp_path / "tmp.png",
100
+ excited_states = result_set.excited_states,
101
+ options = digichem_options
102
+ )
103
+
104
+ maker.get_image()
105
+ assert Path(tmp_path, "tmp.png").exists()
106
+
107
+
108
+ @pytest.mark.parametrize("result_set", [
109
+ pytest.lazy_fixture("gaussian_opt_result"),
110
+ pytest.lazy_fixture("turbomole_opt_result"),
111
+ pytest.lazy_fixture("orca_opt_freq_result")
112
+ ])
113
+ def test_freq_diagram(result_set, tmp_path, digichem_options):
114
+ """Can we make an IR spectrum?"""
115
+ maker = Frequency_graph_maker.from_options(
116
+ tmp_path / "tmp.png",
117
+ vibrations = result_set.vibrations,
118
+ options = digichem_options
119
+ )
120
+
121
+ maker.get_image()
122
+ assert Path(tmp_path, "tmp.png").exists()
123
+
124
+
125
+ @pytest.mark.parametrize("result_set", [
126
+ pytest.lazy_fixture("orca_nmr_result"),
127
+ ])
128
+ def test_nmr_diagram(result_set, tmp_path, digichem_options):
129
+ """Can we make an NMR spectrum?"""
130
+ # Get a suitable spectrometer object.
131
+ spectrometer = result_set.nmr.spectrometer
132
+
133
+ maker = NMR_graph_maker.from_options(
134
+ tmp_path / "tmp.png",
135
+ graph = spectrometer.get_graph(1, 1),
136
+ options = digichem_options
137
+ )
138
+
139
+ maker.get_image()
140
+ assert Path(tmp_path, "tmp.png").exists()
141
+
142
+
143
+ @pytest.mark.parametrize("result_set", [
144
+ pytest.lazy_fixture("orca_nmr_result"),
145
+ ])
146
+ def test_focus_nmr_diagram(result_set, tmp_path, digichem_options):
147
+ """Can we make an NMR spectrum?"""
148
+ # Get a suitable spectrometer object.
149
+ spectrometer = result_set.nmr.spectrometer
150
+
151
+ maker = NMR_graph_zoom_maker.from_options(
152
+ tmp_path / "tmp.png",
153
+ graph = spectrometer.get_graph(1, 1),
154
+ focus = result_set.atoms.groups[(2, "H")],
155
+ options = digichem_options
156
+ )
157
+
158
+ maker.get_image()
159
+ assert Path(tmp_path, "tmp.png").exists()
160
+
161
+
162
+ @pytest.mark.parametrize("result_set", [
163
+ pytest.lazy_fixture("gaussian_opt_result"),
164
+ pytest.lazy_fixture("turbomole_opt_result"),
165
+ pytest.lazy_fixture("orca_opt_freq_result")
166
+ ])
167
+ def test_2d_diagram(result_set, tmp_path, digichem_options):
168
+ """Can we make an IR spectrum?"""
169
+ maker = Skeletal_image_maker.from_options(
170
+ tmp_path / "tmp.png",
171
+ atoms = result_set.atoms,
172
+ options = digichem_options
173
+ )
174
+
175
+ maker.get_image()
176
+ assert Path(tmp_path, "tmp.png").exists()
177
+
178
+
179
+ @pytest.mark.parametrize("result_path", [
180
+ Path(data_directory(), "Pyridine/Gaussian 16 Optimisation Frequencies PBE1PBE (GD3BJ) Toluene 6-31G(d,p).tar.gz")
181
+ ], ids = ["Gaussian"])
182
+ @pytest.mark.parametrize("maker_cls", [
183
+ Structure_image_maker,
184
+ Orbital_image_maker,
185
+ ])
186
+ def test_3d_image(result_path, maker_cls, tmp_path, digichem_options):
187
+ """Can we make a 3D structure image?"""
188
+ with open_for_parsing(result_path) as open_files:
189
+ result_set = parse_calculation(*open_files, options = digichem_options)
190
+ maker = maker_cls.from_options(
191
+ tmp_path / "tmp.png",
192
+ cube_file = Fchk_to_cube.from_options(
193
+ tmp_path / "tmp.cube",
194
+ fchk_file = result_set.metadata.auxiliary_files['fchk_file'],
195
+ options = digichem_options
196
+ ),
197
+ options = digichem_options
198
+ )
199
+
200
+ maker.get_file('x0y0z0')
201
+ assert Path(tmp_path, "tmp.x0y0z0.png").exists()
202
+
203
+
204
+ # @pytest.mark.parametrize("result_path", [
205
+ # Path(data_directory(), "Pyridine/Gaussian 16 Optimisation Frequencies PBE1PBE (GD3BJ) Toluene 6-31G(d,p).tar.gz")
206
+ # ], ids = ["Gaussian"])
207
+ # @pytest.mark.parametrize("density", [
208
+ # "SCF"
209
+ # ])
210
+
211
+ @pytest.mark.parametrize("result_path, density", [
212
+ [Path(data_directory(), "Pyridine/Gaussian 16 Optimisation Frequencies PBE1PBE (GD3BJ) Toluene 6-31G(d,p).tar.gz"), "SCF"]
213
+ ], ids = ["Gaussian"])
214
+ def test_density_image(result_path, density, tmp_path, digichem_options):
215
+ """Can we make a 3D structure image?"""
216
+ with open_for_parsing(result_path) as open_files:
217
+ result_set = parse_calculation(*open_files, options = digichem_options)
218
+ maker = Density_image_maker.from_options(
219
+ tmp_path / "tmp.png",
220
+ cube_file = Fchk_to_density_cube.from_options(
221
+ tmp_path / "tmp.SCF.cube",
222
+ fchk_file = result_set.metadata.auxiliary_files['fchk_file'],
223
+ density_type = density,
224
+ options = digichem_options
225
+ ),
226
+ options = digichem_options
227
+ )
228
+
229
+ maker.get_file('x0y0z0')
230
+ assert Path(tmp_path, "tmp.x0y0z0.png").exists()
231
+
232
+
233
+ @pytest.mark.parametrize("result_path, density", [
234
+ [Path(data_directory(), "Pyridine/Gaussian 16 Optimisation Frequencies PBE1PBE (GD3BJ) Toluene 6-31G(d,p).tar.gz"), "SCF"]
235
+ ], ids = ["Gaussian"])
236
+ def test_spin_density_image(result_path, density, tmp_path, digichem_options):
237
+ """Can we make a 3D structure image?"""
238
+ with open_for_parsing(result_path) as open_files:
239
+ result_set = parse_calculation(*open_files, options = digichem_options)
240
+ maker = Density_image_maker.from_options(
241
+ tmp_path / "tmp.png",
242
+ cube_file = Fchk_to_spin_cube.from_options(
243
+ tmp_path / "tmp.Spin.cube",
244
+ fchk_file = result_set.metadata.auxiliary_files['fchk_file'],
245
+ spin_density = density,
246
+ options = digichem_options
247
+ ),
248
+ options = digichem_options
249
+ )
250
+
251
+ maker.get_file('x0y0z0')
252
+ assert Path(tmp_path, "tmp.x0y0z0.png").exists()
253
+
254
+
255
+ @pytest.mark.parametrize("result_path", [
256
+ Path(data_directory(), "Pyridine/Gaussian 16 Optimisation Frequencies PBE1PBE (GD3BJ) Toluene 6-31G(d,p).tar.gz")
257
+ ], ids = ["Gaussian"])
258
+ def test_combined_orbital_image(result_path, tmp_path, digichem_options):
259
+ """Can we make a 3D structure image?"""
260
+ with open_for_parsing(result_path) as open_files:
261
+ result_set = parse_calculation(*open_files, options = digichem_options)
262
+ maker = Combined_orbital_image_maker.from_options(
263
+ tmp_path / "tmp.png",
264
+ HOMO_cube_file = Fchk_to_cube.from_options(
265
+ tmp_path / "tmp.HOMO.cube",
266
+ fchk_file = result_set.metadata.auxiliary_files['fchk_file'],
267
+ orbital = "LUMO",
268
+ options = digichem_options
269
+ ),
270
+ LUMO_cube_file = Fchk_to_cube.from_options(
271
+ tmp_path / "tmp.LUMO.cube",
272
+ fchk_file = result_set.metadata.auxiliary_files['fchk_file'],
273
+ orbital = "LUMO",
274
+ options = digichem_options
275
+ ),
276
+ options = digichem_options
277
+ )
278
+
279
+ maker.get_file('x0y0z0')
280
+ assert Path(tmp_path, "tmp.x0y0z0.png").exists()
281
+
282
+
283
+ @pytest.mark.parametrize("result_path", [
284
+ Path(data_directory(), "Benzene Anion/Gaussian 16 Optimisation Frequencies PBE1PBE (GD3BJ) Gas Phase 6-31G(d,p).tar.gz")
285
+ ], ids = ["Gaussian"])
286
+ def test_unrestricted_orbital_image(result_path, tmp_path, digichem_options):
287
+ """Can we make a 3D structure image?"""
288
+ with open_for_parsing(result_path) as open_files:
289
+ result_set = parse_calculation(*open_files, options = digichem_options)
290
+ maker = Orbital_image_maker.from_options(
291
+ tmp_path / "tmp.png",
292
+ cube_file = Fchk_to_cube.from_options(
293
+ tmp_path / "tmp.cube",
294
+ fchk_file = result_set.metadata.auxiliary_files['fchk_file'],
295
+ cubegen_type = "AMO",
296
+ orbital = "HOMO",
297
+ options = digichem_options
298
+ ),
299
+ options = digichem_options
300
+ )
301
+
302
+ maker.get_file('x0y0z0')
303
+ assert Path(tmp_path, "tmp.x0y0z0.png").exists()
304
+
305
+
306
+ @pytest.mark.parametrize("result_path", [
307
+ Path(data_directory(), "Pyridine/Gaussian 16 Optimisation Frequencies PBE1PBE (GD3BJ) Toluene 6-31G(d,p).tar.gz")
308
+ ])
309
+ def test_pdm_image(result_path, tmp_path, digichem_options):
310
+ """Can we make a 3D structure image?"""
311
+ with open_for_parsing(result_path) as open_files:
312
+ result_set = parse_calculation(*open_files, options = digichem_options)
313
+ maker = Permanent_dipole_image_maker.from_options(
314
+ tmp_path / "tmp.png",
315
+ cube_file = Fchk_to_cube.from_options(
316
+ tmp_path / "tmp.cube",
317
+ fchk_file = result_set.metadata.auxiliary_files['fchk_file'],
318
+ options = digichem_options
319
+ ),
320
+ dipole_moment = result_set.dipole_moment,
321
+ options = digichem_options
322
+ )
323
+
324
+ maker.get_file('x0y0z0')
325
+ assert Path(tmp_path, "tmp.x0y0z0.png").exists()
326
+
327
+
328
+ @pytest.mark.parametrize("result_path", [
329
+ Path(data_directory(), "Pyridine/Gaussian 16 Excited States TDA Optimised S(1) PBE1PBE (GD3BJ) Toluene 6-31G(d,p).tar.gz"),
330
+ ])
331
+ def test_tdm_image(result_path, tmp_path, digichem_options):
332
+ """Can we make a 3D structure image?"""
333
+ with open_for_parsing(result_path) as open_files:
334
+ result_set = parse_calculation(*open_files, options = digichem_options)
335
+ maker = Transition_dipole_image_maker.from_options(
336
+ tmp_path / "tmp.png",
337
+ cube_file = Fchk_to_cube.from_options(
338
+ tmp_path / "tmp.cube",
339
+ fchk_file = result_set.metadata.auxiliary_files['fchk_file'],
340
+ options = digichem_options
341
+ ),
342
+ dipole_moment = result_set.excited_states.find("S(1)").transition_dipole_moment.electric,
343
+ magnetic_dipole_moment = result_set.excited_states.find("S(1)").transition_dipole_moment.magnetic,
344
+ options = digichem_options
345
+ )
346
+
347
+ maker.get_file('x0y0z0')
348
+ assert Path(tmp_path, "tmp.x0y0z0.png").exists()
349
+
350
+
351
+ @pytest.mark.parametrize("result_path", [
352
+ Path(data_directory(), "Pyridine/Gaussian 16 Excited States TDA Optimised S(1) PBE1PBE (GD3BJ) Toluene 6-31G(d,p).tar.gz"),
353
+ ])
354
+ def test_nto_image(result_path, tmp_path, digichem_options):
355
+ """Can we make a 3D structure image?"""
356
+ with open_for_parsing(result_path) as open_files:
357
+ result_set = parse_calculation(*open_files, options = digichem_options)
358
+ maker = Orbital_image_maker.from_options(
359
+ tmp_path / "tmp.png",
360
+ cube_file = Fchk_to_nto_cube.from_options(
361
+ tmp_path / "tmp.cube",
362
+ fchk_file = result_set.metadata.auxiliary_files['fchk_file'],
363
+ options = digichem_options
364
+ ),
365
+ options = digichem_options
366
+ )
367
+
368
+ maker.get_file('x0y0z0')
369
+ assert Path(tmp_path, "tmp.x0y0z0.png").exists()
@@ -0,0 +1,16 @@
1
+ import pytest
2
+
3
+ from digichem.exception.uncatchable import Submission_paused, Signal_caught, Uncatchable_exception
4
+
5
+ @pytest.mark.parametrize("exception", [
6
+ Submission_paused(None), Signal_caught(None, None)
7
+ ], ids=["Submission_paused", "Signal_caught"])
8
+ def test_uncatachable(exception):
9
+ """Can we only catch uncatachables if we really try?"""
10
+ with pytest.raises(Uncatchable_exception):
11
+ try:
12
+ raise exception
13
+
14
+ except Exception:
15
+ # This should get ignored.
16
+ pass
@@ -0,0 +1,104 @@
1
+ import pytest
2
+ from pathlib import Path
3
+ import shutil
4
+
5
+ from digichem.file.fchk import Chk_to_fchk
6
+ from digichem.file.cube import Fchk_to_cube
7
+ from digichem.parse.util import open_for_parsing, parse_calculation
8
+ from digichem.exception import File_maker_exception
9
+
10
+ from digichem.test.util import digichem_options, data_directory
11
+ from digichem.test.test_result import gaussian_ES_result, turbomole_ES_result, orca_ES_result, \
12
+ gaussian_opt_result, turbomole_opt_result, orca_opt_result, orca_opt_freq_result, \
13
+ orca_nmr_result
14
+
15
+ @pytest.mark.skipif(not shutil.which("cubegen"),
16
+ reason="No cubegen available")
17
+ @pytest.mark.parametrize("result_path", [
18
+ Path(data_directory(), "Pyridine/Gaussian 16 Excited States TDA Optimised S(1) PBE1PBE (GD3BJ) Toluene 6-31G(d,p).tar.gz"),
19
+ ], ids=["Pyridine"])
20
+ @pytest.mark.parametrize("sanity", [False, True], ids=["Normal", "Sanitize"])
21
+ def test_cube_from_fchk(result_path, sanity, tmp_path, digichem_options):
22
+ """Can we make a cube file from an fchk file?"""
23
+ with open_for_parsing(result_path) as open_files:
24
+ result_set = parse_calculation(*open_files, options = digichem_options)
25
+ maker = Fchk_to_cube.from_options(
26
+ tmp_path / "tmp.cube",
27
+ fchk_file = result_set.metadata.auxiliary_files['fchk_file'],
28
+ options = digichem_options,
29
+ )
30
+ maker.sanitize = sanity
31
+
32
+ assert maker.get_file().exists()
33
+
34
+ # Check the cube is formatted correctly.
35
+ with open(maker.get_file()) as cube:
36
+ line = next(cube)
37
+ line = next(cube)
38
+ line = next(cube)
39
+ split_line = line.split()
40
+ if sanity:
41
+ assert len(split_line) == 4
42
+
43
+ else:
44
+ assert len(split_line) == 5
45
+
46
+
47
+ def test_no_cubegen_error(digichem_options, tmp_path):
48
+ """Do we throw the right exception if cubegen doesn't exist?"""
49
+ maker = Fchk_to_cube.from_options(
50
+ tmp_path / "tmp.cube",
51
+ fchk_file = "foobar",
52
+ options = digichem_options,
53
+ )
54
+ maker.cubegen_executable = "NOTREAL"
55
+
56
+ with pytest.raises(File_maker_exception):
57
+ maker.get_file()
58
+
59
+ def test_no_fchk_error(digichem_options, tmp_path):
60
+ """Do we throw the right exception if we don't give an fchk file?"""
61
+ maker = Fchk_to_cube.from_options(
62
+ tmp_path / "tmp.cube",
63
+ fchk_file = "foobar",
64
+ options = digichem_options,
65
+ )
66
+
67
+ with pytest.raises(File_maker_exception):
68
+ maker.get_file()
69
+
70
+ @pytest.mark.skipif(not shutil.which("formchk"),
71
+ reason="No formchk available")
72
+ def test_chk_to_fchk(digichem_options, tmp_path):
73
+ """Can we convert a chk to an fchk file?"""
74
+ maker = Chk_to_fchk.from_options(
75
+ tmp_path / "tmp.fchk",
76
+ chk_file = Path(data_directory(), "Chk/Pyridine.opt.chk"),
77
+ options = digichem_options
78
+ )
79
+ assert maker.get_file().exists()
80
+
81
+
82
+ def test_no_formchk_error(digichem_options, tmp_path):
83
+ """Do we throw the right exception if formchk doesn't exist?"""
84
+ maker = Chk_to_fchk.from_options(
85
+ tmp_path / "tmp.fchk",
86
+ chk_file = Path(data_directory(), "Input/Benzene.chk"),
87
+ options = digichem_options
88
+ )
89
+ maker.formchk_executable = "NOTREAL"
90
+
91
+ with pytest.raises(File_maker_exception):
92
+ maker.get_file()
93
+
94
+
95
+ def test_no_chk_error(digichem_options, tmp_path):
96
+ """Do we throw the right exception if we don't give a chk file?"""
97
+ maker = Chk_to_fchk.from_options(
98
+ tmp_path / "tmp.fchk",
99
+ chk_file = "foobar",
100
+ options = digichem_options
101
+ )
102
+
103
+ with pytest.raises(File_maker_exception):
104
+ maker.get_file()