Skip to content

Commit

Permalink
Bug Fixes: parse dipole files
Browse files Browse the repository at this point in the history
  • Loading branch information
robinzyb committed Nov 3, 2023
1 parent 7d0b93e commit c4d9f14
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions cp2kdata/block_parser/dipole.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
r"""
\s{2}Dipole\smoment\s\[Debye\]\n
\s{4}
X=\s{3}(?P<x>[\s-]\d+\.\d+)\s
Y=\s{3}(?P<y>[\s-]\d+\.\d+)\s
Z=\s{3}(?P<z>[\s-]\d+\.\d+)\s
\s{4}Total=\s{4}(?P<total>[\s-]\d+\.\d+)
X=\s{,3}(?P<x>[\s-]\d+\.\d+)\s
Y=\s{,3}(?P<y>[\s-]\d+\.\d+)\s
Z=\s{,3}(?P<z>[\s-]\d+\.\d+)\s
\s{,4}Total=\s{4}(?P<total>[\s-]\d+\.\d+)
""",
re.VERBOSE
)
Expand Down
10 changes: 5 additions & 5 deletions cp2kdata/cube/cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,20 @@ def __add__(self, others):
self_copy = self.copy()
if isinstance(others, Cp2kCube):
other_copy = others.copy()
self_copy.cube_vals += other_copy.cube_vals
other_copy.cube_vals = self_copy.cube_vals + other_copy.cube_vals
else:
raise RuntimeError("Unspported Class")
return self_copy
return other_copy

def __sub__(self, others):
"""magic method for subtracting two Cp2kCube instances"""
self_copy = self.copy()
if isinstance(others, Cp2kCube):
other_copy = others.copy()
self_copy.cube_vals -= other_copy.cube_vals
other_copy.cube_vals = self_copy.cube_vals - other_copy.cube_vals
else:
raise RuntimeError("Unspported Class")
return self_copy
return other_copy

def get_stc(self):
atom_list = []
Expand All @@ -225,7 +225,7 @@ def get_stc(self):
atom_list.append(atom)

stc = Atoms(atom_list)
stc.set_cell(self.cell.cell_matrix)
stc.set_cell(self.cell.cell_matrix*au2A)
return stc

def copy(self):
Expand Down

0 comments on commit c4d9f14

Please sign in to comment.