Skip to content

Commit

Permalink
Fix pdos and traj parsing in cp2k
Browse files Browse the repository at this point in the history
  • Loading branch information
ladinesa committed Nov 14, 2023
1 parent aabe6e7 commit e541d88
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions electronicparsers/cp2k/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ def str_to_information(val_in):
Quantity(
'ensemble_type', r'ENSEMBLE TYPE\s*=\s*(.+)'),
Quantity(
'step_number', r'STEP NUMBER\s*=\s*(\d+)', dtype=int),
'step', r'STEP NUMBER\s*=\s*(\d+)', dtype=int),
Quantity(
'time', rf'TIME \[fs\]\s*=\s*({re_float})', dtype=float),
Quantity(
Expand Down Expand Up @@ -698,26 +698,13 @@ def str_to_information(val_in):
]


class CP2KPDOSParser(TextParser):
# TODO change to DataTextParser when @Alvin implements it.
def __init__(self):
super().__init__(None)

def init_parameters(self):
self._data = None

class CP2KPDOSParser(DataTextParser):
def init_quantities(self):
self._quantities = [
Quantity('atom_kind', r'\# *Projected DOS for atomic kind *([\da-zA-Z]+) *at'),
Quantity('orbitals', r' *Occupation(.+)', repeats=False),
Quantity('iter', r' *at iteration step i *\= *(\d+)')]

@property
def data(self):
if self._data is None:
self._data = np.loadtxt(self.mainfile)
return self._data


class CP2KParser:
def __init__(self):
Expand Down Expand Up @@ -1449,7 +1436,7 @@ def parse_calculations(calculations):

# write only the last one to scc
scf = self_consistent[-1] if self_consistent else calculation
frame = n + self._step_start - 1
frame = calculation.get('step', n)
scf._frame = frame
sec_scc = self.parse_scc(scf)
md = self.sampling_method == 'molecular_dynamics'
Expand Down

0 comments on commit e541d88

Please sign in to comment.