Skip to content

Commit

Permalink
Merge pull request #328 from TheoChem-VU/302-add-support-for-generati…
Browse files Browse the repository at this point in the history
…ng-cube-files-besides-orbitals

Added generating of density
  • Loading branch information
YHordijk authored Oct 24, 2024
2 parents 3870c74 + a74a373 commit 7fc9a90
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/tcutility/job/adf.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ def __init__(self, *args, **kwargs):
self.gridsize()
self._mos = []
self._sfos = []
self._extras = []
self.settings.ADFFile = None

def __str__(self):
Expand Down Expand Up @@ -655,6 +656,18 @@ def orbital(self, orbital: "pyfmo.orbitals.sfo.SFO" or "pyfmo.orbitals.mo.MO"):
elif self.settings.ADFFile != orbital.kfpath:
raise TCJobError(job_class=self.__class__.__name__, message="RKF file that was previously set not the same as the one being set now. Please start a new job for each RKF file.")

def density(self, orbitals: 'pyfmo.orbitals.Orbitals'):

Check failure on line 659 in src/tcutility/job/adf.py

View workflow job for this annotation

GitHub Actions / build (3.8)

Ruff (F821)

src/tcutility/job/adf.py:659:33: F821 Undefined name `pyfmo`

Check failure on line 659 in src/tcutility/job/adf.py

View workflow job for this annotation

GitHub Actions / build (3.9)

Ruff (F821)

src/tcutility/job/adf.py:659:33: F821 Undefined name `pyfmo`

Check failure on line 659 in src/tcutility/job/adf.py

View workflow job for this annotation

GitHub Actions / build (3.10)

Ruff (F821)

src/tcutility/job/adf.py:659:33: F821 Undefined name `pyfmo`

Check failure on line 659 in src/tcutility/job/adf.py

View workflow job for this annotation

GitHub Actions / build (3.11)

Ruff (F821)

src/tcutility/job/adf.py:659:33: F821 Undefined name `pyfmo`
import pyfmo

# check if the ADFFile is the same for all added orbitals
if self.settings.ADFFile is None:
self.settings.ADFFile = orbitals.kfpath

elif self.settings.ADFFile != orbitals.kfpath:
raise ValueError('RKF file that was previously set not the same as the one being set now. Please start a new job for each RKF file.')

self._extras.append('Density SCF')

def _setup_job(self):
os.makedirs(self.workdir, exist_ok=True)

Expand All @@ -674,8 +687,12 @@ def _setup_job(self):
if len(self._sfos) > 0:
inpf.write("Orbitals SFO\n")
for orb in self._sfos:
inpf.write(f" {orb.symmetry} {orb.index}\n")
inpf.write("END\n")
inpf.write(f' {orb.symmetry} {orb.index}\n')
inpf.write('END\n')

for line in self._extras:
inpf.write(line + '\n')

# cuboutput prefix is always the original run directory containing the adf.rkf file and includes the grid size
inpf.write(f"CUBOUTPUT {os.path.split(self.settings.ADFFile)[0]}/{self.settings.grid}\n")
inpf.write("eor\n")
Expand Down Expand Up @@ -705,6 +722,10 @@ def output_cub_paths(self):
spin_part = '' if sfo.spin == 'AB' else f'_{sfo.spin}'
paths.append(f'{cuboutput}%SFO_{sfo.symmetry}{spin_part}%{sfo.index}.cub')

for extra in self._extras:
if extra == 'Density SCF':
paths.append(f'{cuboutput}%SCF%Density.cub')

return paths

def can_skip(self):
Expand Down

0 comments on commit 7fc9a90

Please sign in to comment.