Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cp2k inp #270

Merged
merged 7 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions electronicparsers/cp2k/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1570,24 +1570,23 @@ def parse(name, data, section):
input_files = get_files(
input_filename, self.filepath, self.mainfile, deep=False
)
if not input_files:
self.logger.warning(
'Input *.inp file not found. We will attempt finding the restart file from '
'the project_name appending a -1, <project_name>-1.restart.',
data={'project_name': project_name},
)
# Patch to check if the input is .restart and CP2K appended a -1 after the name
if not input_files: # ? what is the purpose of this recovery logic
self.logger.warning('Input (*.inp) file not found.')
if project_name:
project_filename = f'{project_name}-1.restart'
self.logger.warning(
f'Will attempt from restart file ({project_filename})'
)
input_files = get_files(
project_filename, self.filepath, self.mainfile, deep=False
)
else:
return
if len(input_files) > 1:
if len(input_files) == 0:
return
elif len(input_files) > 1:
self.logger.warning(
f'Multiple input files found. We will parse the first read file.'
)
f'Multiple input files found. Will parse the first file retrieved.'
) # ! TODO: employ better heuristic OR parse all
# cover single or multiple `input_files`
self.inp_parser.mainfile = input_files[0]

parse('x_cp2k_section_input', self.inp_parser.tree, self.archive.run[-1])
Expand Down
18 changes: 10 additions & 8 deletions electronicparsers/wien2k/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1127,18 +1127,20 @@ def parse_method(self):
atom_obj = AtomParameters()
atom_obj.atom_index = atom_index
atom_obj.core_hole = CoreHole(
j_quantum_number = j_quantum_number,
l_quantum_number = l_quantum_number,
n_quantum_number = n_quantum_number,
n_electrons_excited = electrons_excited,
occupation = occupancy,
dscf_state = 'final',
j_quantum_number=j_quantum_number,
l_quantum_number=l_quantum_number,
n_quantum_number=n_quantum_number,
n_electrons_excited=electrons_excited,
occupation=occupancy,
dscf_state='final',
)
atom_par.append(atom_obj)
break
else:
self.logger.warning("inc file is missing, no corehole information "
"will be parsed if corehole present.")
self.logger.warning(
'inc file is missing, no corehole information '
'will be parsed if corehole present.'
)
# basis
if self.in1_parser.mainfile:
self.in1_parser.parse()
Expand Down
2 changes: 2 additions & 0 deletions tests/test_wien2kparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
CoreHole,
)


def approx(value, abs=0, rel=1e-6):
return pytest.approx(value, abs=abs, rel=rel)

Expand Down Expand Up @@ -125,6 +126,7 @@ def test_dos(parser, caplog):
2.7395685667470246e17
)


def test_core_hole(parser, caplog):
archive = EntryArchive()
parser.parse('tests/data/wien2k/TiN-corehole/TiN-corehole.scf', archive, None)
Expand Down
Loading