orto 1.0.0__py3-none-any.whl → 1.0.2__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.
orto/__version__.py CHANGED
@@ -1 +1 @@
1
- __version__ = '1.0.0'
1
+ __version__ = '1.0.2'
orto/cli.py CHANGED
@@ -1,43 +1,21 @@
1
1
  import argparse
2
2
  import xyz_py as xyzp
3
- import xyz_py.atomic as atomic
4
- import matplotlib.pyplot as plt
5
- import matplotlib as mpl
3
+ from xyz_py.atomic import elements as atomic_elements
6
4
  import sys
7
5
  import pathlib
8
6
  import os
9
7
  import copy
10
8
  import subprocess
11
- import pandas as pd
12
- import scipy.constants as constants
9
+ import csv
13
10
  import numpy as np
14
- import extto
15
- import docx
16
11
  import re
17
- import mmap
18
- import shutil
12
+ from mmap import mmap, ACCESS_READ
13
+ from shutil import move as shutilmove
19
14
 
20
-
21
- from docx.enum.text import WD_ALIGN_PARAGRAPH
22
- from docx.enum.table import WD_ALIGN_VERTICAL
23
- from docx.shared import Pt
24
-
25
- from . import plotter
26
- from . import extractor as oe
27
15
  from . import job
28
16
  from . import utils as ut
29
- from . import input as inp
30
-
31
- # Change matplotlib font size to be larger
32
- mpl.rcParams.update({'font.size': 12})
33
-
34
- # Set user specified font name
35
- if os.getenv('orto_fontname'):
36
- try:
37
- plt.rcParams['font.family'] = os.getenv('orto_fontname')
38
- except ValueError:
39
- ut.cprint('Error in orto_fontname environment variable', 'red')
40
- sys.exit(1)
17
+ from . import constants as cst
18
+ from .exceptions import DataNotFoundError, DataFormattingError
41
19
 
42
20
  _SHOW_CONV = {
43
21
  'on': True,
@@ -69,6 +47,7 @@ def extract_coords_func(uargs, save=True):
69
47
  -------
70
48
  None
71
49
  '''
50
+ from . import extractor as oe
72
51
 
73
52
  # Open file and extract coordinates
74
53
  labels, coords = oe.get_coords(
@@ -96,6 +75,11 @@ def extract_sf_energies_func(uargs):
96
75
  '''
97
76
  Wrapper for cli call to extract spin-free energies
98
77
  '''
78
+ from . import extractor as oe
79
+ from docx import Document
80
+ from docx.enum.text import WD_ALIGN_PARAGRAPH
81
+ from docx.enum.table import WD_ALIGN_VERTICAL
82
+ from docx.shared import Pt
99
83
 
100
84
  all_data = oe.SpinFreeEnergyExtractor().extract(
101
85
  uargs.output_file
@@ -126,7 +110,7 @@ def extract_sf_energies_func(uargs):
126
110
  title = 'Spin-Free energies'
127
111
 
128
112
  # Create document
129
- doc = docx.Document()
113
+ doc = Document()
130
114
 
131
115
  doc.add_heading(title, 0)
132
116
 
@@ -179,6 +163,7 @@ def extract_so_energies_func(uargs):
179
163
  '''
180
164
  Wrapper for cli call to extract spin-orbit energies
181
165
  '''
166
+ from . import extractor as oe
182
167
 
183
168
  all_energies = oe.SpinOrbitEnergyExtractor().extract(
184
169
  uargs.output_file
@@ -219,6 +204,11 @@ def extract_gmatrix_func(uargs, save=True):
219
204
  -------
220
205
  None
221
206
  '''
207
+ from . import extractor as oe
208
+ from docx import Document
209
+ from docx.enum.text import WD_ALIGN_PARAGRAPH
210
+ from docx.enum.table import WD_ALIGN_VERTICAL
211
+ from docx.shared import Pt
222
212
 
223
213
  choices = {
224
214
  'total': oe.GMatrixExtractor,
@@ -261,7 +251,7 @@ def extract_gmatrix_func(uargs, save=True):
261
251
  title = titles[uargs.type]
262
252
 
263
253
  # Create document
264
- doc = docx.Document()
254
+ doc = Document()
265
255
 
266
256
  doc.add_heading(title, 0)
267
257
 
@@ -357,12 +347,12 @@ def gen_trunc_molden_func(uargs):
357
347
  # occurrences of 'Occup='
358
348
  _patt = re.compile(b'Sym=')
359
349
  with open(uargs.input_file, mode="r") as file_obj:
360
- with mmap.mmap(file_obj.fileno(), length=0, access=mmap.ACCESS_READ) as mmap_obj: # noqa
350
+ with mmap(file_obj.fileno(), length=0, access=ACCESS_READ) as mmap_obj:
361
351
  n_MO = len(_patt.findall(mmap_obj))
362
352
 
363
353
  _patt = re.compile(b'Occup= 0.000000')
364
354
  with open(uargs.input_file, mode="r") as file_obj:
365
- with mmap.mmap(file_obj.fileno(), length=0, access=mmap.ACCESS_READ) as mmap_obj: # noqa
355
+ with mmap(file_obj.fileno(), length=0, access=ACCESS_READ) as mmap_obj:
366
356
  n_virt = len(_patt.findall(mmap_obj))
367
357
 
368
358
  ut.cprint(
@@ -399,7 +389,7 @@ def gen_trunc_molden_func(uargs):
399
389
  # If no output file given
400
390
  if uargs.output_file == '.tmp.molden':
401
391
  # Copy new file to original name
402
- shutil.move(uargs.output_file, uargs.input_file)
392
+ shutilmove(uargs.output_file, uargs.input_file)
403
393
  uargs.output_file = uargs.input_file
404
394
 
405
395
  ut.cprint(f'New molden file written to {uargs.output_file}', 'cyan')
@@ -420,6 +410,7 @@ def gen_job_func(uargs):
420
410
  -------
421
411
  None
422
412
  '''
413
+ from . import input as inp
423
414
 
424
415
  for input_file in uargs.input_files:
425
416
 
@@ -474,13 +465,13 @@ def gen_job_func(uargs):
474
465
  # Check xyz file is present
475
466
  try:
476
467
  inp.check_xyz(oj.input_file, uargs.skip_xyz)
477
- except (oe.DataNotFoundError, oe.DataFormattingError) as e:
468
+ except (DataNotFoundError, DataFormattingError) as e:
478
469
  ut.red_exit(str(e))
479
470
 
480
471
  # Check for moread and moinp
481
472
  try:
482
473
  inp.check_moinp_moread(oj.input_file)
483
- except (oe.DataNotFoundError, oe.DataFormattingError) as e:
474
+ except (DataNotFoundError, DataFormattingError) as e:
484
475
  ut.red_exit(str(e))
485
476
 
486
477
  # Submitter configuration options
@@ -491,7 +482,7 @@ def gen_job_func(uargs):
491
482
  try:
492
483
  n_procs = inp.get_nprocs(oj.input_file)
493
484
  maxcore = inp.get_maxcore(oj.input_file)
494
- except (oe.DataNotFoundError, oe.DataFormattingError) as e:
485
+ except (DataNotFoundError, DataFormattingError) as e:
495
486
  ut.red_exit(str(e))
496
487
 
497
488
  # If memory and procs specified as arguments, give warning when
@@ -554,6 +545,21 @@ def plot_abs_func(uargs):
554
545
  -------
555
546
  None
556
547
  '''
548
+ import matplotlib.pyplot as plt
549
+ import matplotlib as mpl
550
+ from . import plotter
551
+ from . import extractor as oe
552
+
553
+ # Set user specified font name
554
+ if os.getenv('orto_fontname'):
555
+ try:
556
+ plt.rcParams['font.family'] = os.getenv('orto_fontname')
557
+ except ValueError:
558
+ ut.cprint('Error in orto_fontname environment variable', 'red')
559
+ sys.exit(1)
560
+
561
+ # Change matplotlib font size to be larger
562
+ mpl.rcParams.update({'font.size': 12})
557
563
 
558
564
  version = oe.OrcaVersionExtractor.extract(uargs.output_file)
559
565
 
@@ -655,6 +661,21 @@ def plot_ir_func(uargs):
655
661
  -------
656
662
  None
657
663
  '''
664
+ import matplotlib.pyplot as plt
665
+ import matplotlib as mpl
666
+ from . import plotter
667
+ from . import extractor as oe
668
+
669
+ # Set user specified font name
670
+ if os.getenv('orto_fontname'):
671
+ try:
672
+ plt.rcParams['font.family'] = os.getenv('orto_fontname')
673
+ except ValueError:
674
+ ut.cprint('Error in orto_fontname environment variable', 'red')
675
+ sys.exit(1)
676
+
677
+ # Change matplotlib font size to be larger
678
+ mpl.rcParams.update({'font.size': 12})
658
679
 
659
680
  # Extract frequency information
660
681
  data = oe.FrequencyExtractor.extract(uargs.output_file)
@@ -665,7 +686,7 @@ def plot_ir_func(uargs):
665
686
  data = data[0]
666
687
 
667
688
  # Plot infrared spectrum
668
- fig, ax = plotter.plot_ir(
689
+ plotter.plot_ir(
669
690
  data['energy (cm^-1)'],
670
691
  data['epsilon (L mol^-1 cm^-1)'],
671
692
  linewidth=uargs.linewidth,
@@ -691,6 +712,7 @@ def distort_func(uargs):
691
712
  None
692
713
 
693
714
  '''
715
+ from . import extractor as oe
694
716
 
695
717
  # Open file and extract coordinates
696
718
  labels, coords = oe.get_coords(
@@ -737,6 +759,7 @@ def extract_orbs_func(uargs, save=True) -> None:
737
759
  -------
738
760
  None
739
761
  '''
762
+ from . import extractor as oe
740
763
 
741
764
  # Check for spin in file, if present
742
765
  try:
@@ -744,7 +767,7 @@ def extract_orbs_func(uargs, save=True) -> None:
744
767
  # Disable spin if not present in file
745
768
  if mult == 1:
746
769
  uargs.spin = None
747
- except extto.DataNotFoundError:
770
+ except DataNotFoundError:
748
771
  pass
749
772
 
750
773
  extractors = {
@@ -772,7 +795,7 @@ def extract_orbs_func(uargs, save=True) -> None:
772
795
  )
773
796
  uargs.flavour = name
774
797
  break
775
- except extto.DataNotFoundError:
798
+ except DataNotFoundError:
776
799
  failed += 1
777
800
  if failed == len(extractors):
778
801
  ut.red_exit(
@@ -783,7 +806,7 @@ def extract_orbs_func(uargs, save=True) -> None:
783
806
  data = extractors[uargs.flavour](
784
807
  uargs.output_file
785
808
  )
786
- except extto.DataNotFoundError as dne:
809
+ except DataNotFoundError as dne:
787
810
  ut.red_exit(str(dne))
788
811
 
789
812
  # Unpack data
@@ -896,6 +919,7 @@ def extract_freq_func(uargs, save=True):
896
919
  -------
897
920
  None
898
921
  '''
922
+ from . import extractor as oe
899
923
 
900
924
  # Extract frequency information
901
925
  data = oe.FrequencyExtractor.extract(uargs.output_file)
@@ -945,6 +969,7 @@ def extract_pop_func(uargs, save=True) -> None:
945
969
  -------
946
970
  None
947
971
  '''
972
+ from . import extractor as oe
948
973
 
949
974
  if uargs.flavour in ['loewdin', 'lowdin']:
950
975
  data = oe.LoewdinPopulationExtractor.extract(
@@ -955,7 +980,7 @@ def extract_pop_func(uargs, save=True) -> None:
955
980
  data = oe.MullikenPopulationExtractorDensities.extract(
956
981
  uargs.output_file
957
982
  )
958
- except extto.DataNotFoundError:
983
+ except DataNotFoundError:
959
984
  data = oe.MullikenPopulationExtractorPopulations.extract(
960
985
  uargs.output_file
961
986
  )
@@ -1018,6 +1043,13 @@ def plot_susc_func(uargs) -> None:
1018
1043
  None
1019
1044
 
1020
1045
  '''
1046
+ import matplotlib.pyplot as plt
1047
+ import matplotlib as mpl
1048
+ from . import plotter
1049
+ from . import extractor as oe
1050
+
1051
+ # Change matplotlib font size to be larger
1052
+ mpl.rcParams.update({'font.size': 12})
1021
1053
 
1022
1054
  # Extract data from file
1023
1055
  data = oe.SusceptibilityExtractor.extract(uargs.output_file)
@@ -1037,22 +1069,28 @@ def plot_susc_func(uargs) -> None:
1037
1069
  'green'
1038
1070
  )
1039
1071
 
1040
- # Load experimental data if provided
1041
1072
  if uargs.exp_file is not None:
1042
- exp_data = pd.read_csv(
1043
- uargs.exp_file,
1044
- comment='#',
1045
- skipinitialspace=True
1046
- )
1073
+ exp_data = {'Temperature (K)': [], 'chi*T (cm3*K/mol)': []}
1074
+ with open(uargs.exp_file, newline='') as csvfile:
1075
+ reader = csv.DictReader(
1076
+ row for row in csvfile if not row.startswith('#')
1077
+ )
1078
+ for row in reader:
1079
+ exp_data['Temperature (K)'].append(
1080
+ float(row['Temperature (K)'])
1081
+ )
1082
+ exp_data['chi*T (cm3*K/mol)'].append(
1083
+ float(row['chi*T (cm3*K/mol)'])
1084
+ )
1047
1085
 
1048
1086
  # Conversion factors from cm3 K mol^-1 to ...
1049
1087
  convs = {
1050
- 'A3 K': 1E24 / constants.Avogadro,
1088
+ 'A3 K': 1E24 / cst.AVOGADRO,
1051
1089
  'A3 mol-1 K': 1E24,
1052
- 'cm3 K': 1 / constants.Avogadro,
1090
+ 'cm3 K': 1 / cst.AVOGADRO,
1053
1091
  'cm3 mol-1 K': 1,
1054
- 'emu K': 1 / (4 * constants.pi * constants.Avogadro),
1055
- 'emu mol-1 K': 1 / (4 * constants.pi)
1092
+ 'emu K': 1 / (4 * np.pi * cst.AVOGADRO),
1093
+ 'emu mol-1 K': 1 / (4 * np.pi)
1056
1094
  }
1057
1095
 
1058
1096
  unit_labels = {
@@ -1078,7 +1116,10 @@ def plot_susc_func(uargs) -> None:
1078
1116
  if uargs.exp_file is not None:
1079
1117
  ax.plot(
1080
1118
  exp_data['Temperature (K)'],
1081
- exp_data['chi*T (cm3*K/mol)'] * convs[uargs.esusc_units],
1119
+ [
1120
+ val * convs[uargs.esusc_units]
1121
+ for val in exp_data['chi*T (cm3*K/mol)']
1122
+ ],
1082
1123
  lw=0,
1083
1124
  marker='o',
1084
1125
  fillstyle='none',
@@ -1113,6 +1154,13 @@ def plot_ailft_func(uargs) -> None:
1113
1154
  -------
1114
1155
  None
1115
1156
  '''
1157
+ import matplotlib.pyplot as plt
1158
+ import matplotlib as mpl
1159
+ from . import plotter
1160
+ from . import extractor as oe
1161
+
1162
+ # Change matplotlib font size to be larger
1163
+ mpl.rcParams.update({'font.size': 12})
1116
1164
 
1117
1165
  # Create extractor
1118
1166
  data = oe.AILFTOrbEnergyExtractor.extract(uargs.output_file)
@@ -1940,7 +1988,7 @@ def read_args(arg_list=None):
1940
1988
  '-e',
1941
1989
  '--elements',
1942
1990
  type=str,
1943
- default=atomic.elements,
1991
+ default=atomic_elements,
1944
1992
  nargs='+',
1945
1993
  help='Only print contributions from specified element(s) e.g. Ni'
1946
1994
  )
orto/constants.py ADDED
@@ -0,0 +1,8 @@
1
+ AVOGADRO = 6.02214076e23 # mol^-1
2
+ HARTREE2INVERSE_M = 2.194746313705E7 # m^-1
3
+ HARTREE2INVERSE_CM = 100 / HARTREE2INVERSE_M
4
+ ELECTRON_CHARGE = 1.602176487e-19 # C
5
+ ELECTRON_MASS = 9.10938215E-31 # kg
6
+ EPSILON_0 = 8.8541878128E-12 # F m^-1
7
+ SPEED_OF_LIGHT_M_S = 299792458.0 # m s^-1
8
+ SPEED_OF_LIGHT_CM_S = SPEED_OF_LIGHT_M_S * 100.0 # cm s^-1
orto/exceptions.py ADDED
@@ -0,0 +1,5 @@
1
+ from extto import DataNotFoundError as exttoDNF
2
+ from extto import DataFormattingError as exttoDFE
3
+
4
+ DataNotFoundError = exttoDNF
5
+ DataFormattingError = exttoDFE
orto/extractor.py CHANGED
@@ -7,12 +7,10 @@ import re
7
7
  import pandas as pd
8
8
  from io import StringIO
9
9
  import pathlib
10
- import scipy.constants as sc
11
10
  import copy
12
11
 
13
- # Reimplemented for convenience
14
- DataNotFoundError = extto.DataNotFoundError
15
- DataFormattingError = extto.DataFormattingError
12
+ from .exceptions import DataFormattingError
13
+ from . import constants as const
16
14
 
17
15
 
18
16
  class OrcaVersionExtractor(extto.LineExtractor):
@@ -569,26 +567,24 @@ class FrequencyExtractor(extto.BetweenExtractor):
569
567
  # in atomic units
570
568
  # b^2 = hbar/(2*c*nubar) --> 1/(2*nubar)
571
569
  # m_e^-1/2 a_0
572
- icm2eh = 100 / sc.physical_constants['hartree-inverse meter relationship'][0] # noqa
573
- #
574
570
  b2 = np.zeros_like(wavenumbers)
575
- b2[n_missing:] = 1 / (2 * icm2eh * wavenumbers[n_missing:])
571
+ b2[n_missing:] = 1 / (2 * const.HARTREE2INVERSE_CM * wavenumbers[n_missing:]) # noqa
576
572
  # divide by sqrt(b2)
577
573
  # to give units of e m_e^-1/2
578
574
  t[n_missing:] /= np.sqrt(b2[n_missing:])
579
575
 
580
576
  # Convert to SI
581
577
  # First convert electrons to coulombs
582
- t *= sc.e
578
+ t *= const.ELECTRON_CHARGE
583
579
 
584
580
  # and then reciprocal atomic mass units (m_e^-1/2) to kg^-1/2
585
- t *= (sc.m_e)**-0.5
581
+ t *= (const.ELECTRON_MASS)**-0.5
586
582
 
587
583
  # Calculate A_e in units of m mol^-1
588
584
  # this is "Intensity" in Orca
589
585
  ae = np.ones_like(wavenumbers)
590
586
  ae[:n_missing] = 0
591
- ae *= sc.Avogadro / (12 * sc.epsilon_0 * sc.speed_of_light**2)
587
+ ae *= const.AVOGADRO / (12 * const.EPSILON_0 * const.SPEED_OF_LIGHT_M_S**2) # noqa
592
588
  ae[n_missing:] *= t[n_missing:] ** 2
593
589
  # and convert to km mol^-1
594
590
  ae[n_missing:] /= 1000
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: orto
3
- Version: 1.0.0
3
+ Version: 1.0.2
4
4
  Summary: A package to make life easier when performing Orca calculations.
5
5
  Home-page: https://orto.kragskow.group
6
6
  Author: Jon Kragskow
@@ -0,0 +1,15 @@
1
+ orto/__init__.py,sha256=iSR4TAfpJn1_mwTnnncgwmWBz3q_ImdmhnOORKcOvE0,63
2
+ orto/__version__.py,sha256=ZTipNH6wyC6qsq1H_lZsvJyVruUa1nu3y4EysMdkpuU,22
3
+ orto/cli.py,sha256=yckaw1kryADOWz-NZPzXpXYTp8L9X89TVqUErfg3RsY,61241
4
+ orto/constants.py,sha256=2obWYg306Lce4U9Qs4MHg1yZq7SHFkazG-cnkD5svpo,343
5
+ orto/exceptions.py,sha256=D7oNeAEGeJNt5thzt6PaCn5FY6JcbJOWUE1N1LVhhuE,159
6
+ orto/extractor.py,sha256=tO2oFf6Cgwdnh_m1v8r1rXQO2_FL7s-1KBqLPy6zNco,67384
7
+ orto/input.py,sha256=UMYNPGeqOCNKvPYJVfVS2JU7Ost_xM1ZG28t5f9-Er0,7084
8
+ orto/job.py,sha256=SM0nlc_bqhhPvfuuykhMvaUnkwC3Gp-6RvYw_a0TyGc,5855
9
+ orto/plotter.py,sha256=ICrO03T_HGe-H1XKZ2qzsKYdPY44E0PKiXqIQQawd7I,15633
10
+ orto/utils.py,sha256=gVfGplkfc6xGYgLMi_7I_yAdWG-QKRaqQdy9v5F4Mck,7279
11
+ orto-1.0.2.dist-info/METADATA,sha256=CLX4q02Rz1nw7wH1ShlOOa0QHUyo7yadjv17Wjj9nXc,1140
12
+ orto-1.0.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
+ orto-1.0.2.dist-info/entry_points.txt,sha256=HXenCglMp_03JkN34pK2phkjXK9CFcXTGHKv5QaVY8I,39
14
+ orto-1.0.2.dist-info/top_level.txt,sha256=hQ-z28gTN_FZ2B5Kiwxr_9cUTcCoib9W5HjbkceDXw4,5
15
+ orto-1.0.2.dist-info/RECORD,,
@@ -1,13 +0,0 @@
1
- orto/__init__.py,sha256=iSR4TAfpJn1_mwTnnncgwmWBz3q_ImdmhnOORKcOvE0,63
2
- orto/__version__.py,sha256=RsZjRjMprNcDm97wqRRSk6rTLgTX8N0GyicZyZ8OsBQ,22
3
- orto/cli.py,sha256=4W6KgUjmdI8wYo3n5Dp74YgH8a4q7-IsxBf7fhWl6P4,59396
4
- orto/extractor.py,sha256=kJnVI_Zwz7yorbojWdgxN-NSspJIY9pKoDb1RD2dHUg,67488
5
- orto/input.py,sha256=UMYNPGeqOCNKvPYJVfVS2JU7Ost_xM1ZG28t5f9-Er0,7084
6
- orto/job.py,sha256=SM0nlc_bqhhPvfuuykhMvaUnkwC3Gp-6RvYw_a0TyGc,5855
7
- orto/plotter.py,sha256=ICrO03T_HGe-H1XKZ2qzsKYdPY44E0PKiXqIQQawd7I,15633
8
- orto/utils.py,sha256=gVfGplkfc6xGYgLMi_7I_yAdWG-QKRaqQdy9v5F4Mck,7279
9
- orto-1.0.0.dist-info/METADATA,sha256=P-6wCgp-dPyw8b8N0d8m4Et-C8MXJGBySV75lL9Y2JQ,1140
10
- orto-1.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
- orto-1.0.0.dist-info/entry_points.txt,sha256=HXenCglMp_03JkN34pK2phkjXK9CFcXTGHKv5QaVY8I,39
12
- orto-1.0.0.dist-info/top_level.txt,sha256=hQ-z28gTN_FZ2B5Kiwxr_9cUTcCoib9W5HjbkceDXw4,5
13
- orto-1.0.0.dist-info/RECORD,,
File without changes