Skip to content

Commit

Permalink
Add structure parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
cpignedoli committed Jul 5, 2020
1 parent a6b9132 commit 58d0fc2
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions aiida_quantumespresso/parsers/pp.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def detect_important_message(logs, line):
split_line = line.split('=')
if 'negative/imaginary' in line: # QE6.1
output_dict['negative_core_charge'] = float(split_line[-1].split()[0])
output_dict['imaginary_core_charge'] = float(split_line.split()[-1])
output_dict['imaginary_core_charge'] = float(split_line[-1].split()[-1])
else: # QE6.4
output_dict['negative_core_charge'] = float(split_line[1])
if 'Min, Max, imaginary charge:' in line:
Expand Down Expand Up @@ -335,10 +335,15 @@ def parse_gaussian(self, data_file_str):
"""
lines = data_file_str.splitlines()

title = lines[0]
comment = lines[1]

atoms_line = lines[2].split()
atoms = int(atoms_line[0]) # The number of atoms listed in the file
header = lines[:6 + atoms] # Header of the file: comments, the voxel, and the number of atoms and datapoints
data_lines = lines[6 + atoms:] # The actual data: atoms and volumetric data
natoms = int(atoms_line[0]) # The number of atoms listed in the file
origin = np.array(atoms_line[1:], dtype=float)

header = lines[:6 + natoms] # Header of the file: comments, the voxel, and the number of atoms and datapoints
data_lines = lines[6 + natoms:] # The actual data: atoms and volumetric data

# Parse the declared dimensions of the volumetric data
x_line = header[3].split()
Expand All @@ -352,6 +357,12 @@ def parse_gaussian(self, data_file_str):
voxel_array = np.array([[x_line[1], x_line[2], x_line[3]], [y_line[1], y_line[2], y_line[3]],
[z_line[1], z_line[2], z_line[3]]],
dtype=np.float64)
atomic_numbers = np.empty(natoms, int)
coordinates = np.empty((natoms, 3))
for i in range(natoms):
line = header[6 + i].split()
atomic_numbers[i] = int(line[0])
coordinates[i] = [float(s) for s in line[2:]]

# Get the volumetric data
data_array = np.empty(xdim * ydim * zdim, dtype=float)
Expand All @@ -368,7 +379,9 @@ def parse_gaussian(self, data_file_str):
arraydata = orm.ArrayData()
arraydata.set_array('voxel', voxel_array)
arraydata.set_array('data', data_array)
arraydata.set_array('coordinates_units', np.array(coordinates_units))
arraydata.set_array('data_units', np.array(data_units))
arraydata.set_array('coordinates_units', np.array(coordinates_units))
arraydata.set_array('coordinates', coordinates)
arraydata.set_array('atomic_numbers', atomic_numbers)

return arraydata

0 comments on commit 58d0fc2

Please sign in to comment.