diff --git a/parser/parser-elk/parser_elk.py b/parser/parser-elk/parser_elk.py index b16731973a4781ec15360c0346492a676e5d6510..0bf88fc2d78549561877e58f4257669f1a5b5afa 100644 --- a/parser/parser-elk/parser_elk.py +++ b/parser/parser-elk/parser_elk.py @@ -26,25 +26,26 @@ class ElkContext(object): self.enTot = [] self.atom_pos = [] self.atom_labels = [] + self.spinTreat = None def onClose_x_elk_section_lattice_vectors(self, backend, gIndex, section): latticeX = section["x_elk_geometry_lattice_vector_x"] latticeY = section["x_elk_geometry_lattice_vector_y"] latticeZ = section["x_elk_geometry_lattice_vector_z"] - cell = [[latticeX[0],latticeY[0],latticeZ[0]], + cell = np.array([[latticeX[0],latticeY[0],latticeZ[0]], [latticeX[1],latticeY[1],latticeZ[1]], - [latticeX[2],latticeY[2],latticeZ[2]]] -# print ("celll= ", cell) - backend.addValue("simulation_cell", cell) + [latticeX[2],latticeY[2],latticeZ[2]]]) +# print ("celll= ", latticeZ) + backend.addArrayValues("simulation_cell", cell) def onClose_x_elk_section_reciprocal_lattice_vectors(self, backend, gIndex, section): recLatticeX = section["x_elk_geometry_reciprocal_lattice_vector_x"] recLatticeY = section["x_elk_geometry_reciprocal_lattice_vector_y"] recLatticeZ = section["x_elk_geometry_reciprocal_lattice_vector_z"] - recCell = [[recLatticeX[0],recLatticeY[0],recLatticeZ[0]], + recCell = np.array([[recLatticeX[0],recLatticeY[0],recLatticeZ[0]], [recLatticeX[1],recLatticeY[1],recLatticeZ[1]], - [recLatticeX[2],recLatticeY[2],recLatticeZ[2]]] - backend.addValue("x_elk_simulation_reciprocal_cell", recCell) + [recLatticeX[2],recLatticeY[2],recLatticeZ[2]]]) + backend.addArrayValues("x_elk_simulation_reciprocal_cell", recCell) def onClose_x_elk_section_xc(self, backend, gIndex, section): xcNr = section["x_elk_xc_functional"][0] @@ -114,9 +115,24 @@ class ElkContext(object): backend.addArrayValues("eigenvalues_kpoints", np.asarray(eigvalKpoint)) backend.addArrayValues("eigenvalues_values", np.asarray([eigvalVal])) backend.addArrayValues("eigenvalues_occupation", np.asarray([eigvalOcc])) + backend.closeSection("section_eigenvalues",eigvalGIndex) backend.addValue("energy_total", self.enTot[-1]) + def onClose_x_elk_section_spin(self, backend, gIndex, section): +# pass + spin = section["x_elk_spin_treatment"][0] +# print("prima",len(spin)) + spin = spin.strip() +# print("dopo",len(spin)) +# print("spin=",spin,"spin", type(spin)) + if spin == "spin-polarised": +# print("Vero") + self.spinTreat = True + else: +# print("Falso") + self.spinTreat = False + def onClose_section_system(self, backend, gIndex, section): backend.addArrayValues('configuration_periodic_dimensions', np.asarray([True, True, True])) self.secSystemDescriptionIndex = gIndex @@ -138,7 +154,7 @@ class ElkContext(object): if self.atom_labels is not None: backend.addArrayValues('atom_labels', np.asarray(self.atom_labels)) self.atom_labels = [] - +# print("self.atom_labels=",self.atom_labels) def onClose_x_elk_section_atoms_group(self, backend, gIndex, section): pos = [section['x_elk_geometry_atom_positions_' + i] for i in ['x', 'y', 'z']] pl = [len(comp) for comp in pos] @@ -186,13 +202,18 @@ mainFileDescription = \ SM(r"\s*Species\s*:\s*[0-9]\s*\((?P[-a-zA-Z0-9]+)\)", repeats = True, sections = ["x_elk_section_atoms_group"], subMatchers = [ - SM(r"\s*muffin-tin radius\s*:\s*(?P[-0-9.]+)"), - SM(r"\s*number of radial points in muffin-tin\s*:\s*(?P[-0-9.]+)"), +# SM(r"\s*muffin-tin radius\s*:\s*(?P[-0-9.]+)"), +# SM(r"\s*number of radial points in muffin-tin\s*:\s*(?P[-0-9.]+)"), SM(startReStr = r"\s*atomic positions\s*\(lattice\)\, magnetic fields \(Cartesian\)\s*:\s*", subMatchers = [ SM(r"\s*(?P[+0-9]+)\s*:\s*(?P[-+0-9.]+)\s*(?P[-+0-9.]+)\s*(?P[-+0-9.]+)", repeats = True) ]) ]), + SM(startReStr = r"\s*Spin treatment\s*:\s*", + sections = ["x_elk_section_spin"], + subMatchers = [ + SM(r"\s*(?P[-a-zA-Z\s*]+)") + ]), SM(r"\s*k-point grid\s*:\s*(?P[-0-9.]+)\s+(?P[-0-9.]+)\s+(?P[-0-9.]+)"), SM(r"\s*k-point offset\s*:\s*(?P[-0-9.]+)\s+(?P[-0-9.]+)\s+(?P[-0-9.]+)"), SM(r"\s*Total number of k-points\s*:\s*(?P[-0-9.]+)"),