Skip to content

Commit

Permalink
fix win parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
JosePizarro3 committed Sep 27, 2024
1 parent 776929e commit 4be85cc
Showing 1 changed file with 8 additions and 41 deletions.
49 changes: 8 additions & 41 deletions src/nomad_parser_wannier90/parsers/win_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,23 +139,6 @@ def _convert_position(
symbols.append(atomic_cell.atoms_state[index].chemical_symbol)
return indices, symbols

def _get_f_information(
self, atom: str, atomic_cell: AtomicCell, units: str
) -> tuple[list, list]:
position = [float(x) for x in atom.replace('f=', '').split(',')]
position = np.dot(position, atomic_cell.lattice_vectors.magnitude)
return self._convert_position(
position=position, atomic_cell=atomic_cell, units=units
)

def _get_c_information(
self, atom: str, atomic_cell: AtomicCell, units: str
) -> tuple[list, list]:
position = [float(x) for x in atom.replace('c=', '').split(',')]
return self._convert_position(
position=position, atomic_cell=atomic_cell, units=units
)

def get_branch_label_and_atom_indices(
self,
atom: Union[str, int],
Expand Down Expand Up @@ -183,12 +166,15 @@ def get_branch_label_and_atom_indices(
indices: list[int] = []
# If the atom is not a chemical element, we use the `_convert_position` method resolution for it, joining the `symbols` into a long string
if atom.startswith('f='): # fractional coordinates
indices, symbols = self._get_f_information(
atom=atom, atomic_cell=atomic_cell, units=units
position = [float(x) for x in atom.replace('f=', '').split(',')]
position = np.dot(position, atomic_cell.lattice_vectors.magnitude)
indices, symbols = self._convert_position(
position=position, atomic_cell=atomic_cell, units=units
)
elif atom.startswith('c='): # cartesian coordinates
indices, symbols = self._get_c_information(
atom=atom, atomic_cell=atomic_cell, units=units
position = [float(x) for x in atom.replace('c=', '').split(',')]
indices, symbols = self._convert_position(
position=position, atomic_cell=atomic_cell, units=units
)
# Otherwise, if the atom chemical symbol is directly specified, we store all the `atom_indices` coinciding with this label
else: # atom label directly specified
Expand All @@ -208,8 +194,6 @@ def populate_orbitals_state(
projection: list[str],
model_system_child: ModelSystem,
atomic_cell: AtomicCell,
units: str,
logger: 'BoundLogger',
) -> None:
"""
Populate the `OrbitalsState` sections for the AtomsState relevant for the Wannier projection.
Expand All @@ -225,22 +209,7 @@ def populate_orbitals_state(
if isinstance(atom, int):
return '', [atom]

# Initial check for the `atom` and their `indices`
indices: list[int] = []
if atom.startswith('f='):
indices, _ = self._get_f_information(
atom=atom, atomic_cell=atomic_cell, units=units
)
elif atom.startswith('c='):
indices, _ = self._get_c_information(
atom=atom, atomic_cell=atomic_cell, units=units
)
else:
indices = model_system_child.atom_indices
if not indices:
logger.warning('Could not extract the `AtomicCell.atoms_state` sections.')
return None

# Extracting orbitals information
orbitals = projection[1].split(';')
for atom_index in model_system_child.atom_indices:
atom_state = atomic_cell.atoms_state[atom_index]
Expand Down Expand Up @@ -325,8 +294,6 @@ def parse_child_model_systems(
projection=projection,
model_system_child=model_system_child,
atomic_cell=atomic_cell,
logger=logger,
units=wannier90_units,
)
model_system_childs.append(model_system_child)

Expand Down

1 comment on commit 4be85cc

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/nomad_parser_wannier90
   __init__.py4250%3–4
   _version.py11282%5–6
src/nomad_parser_wannier90/parsers
   __init__.py10280%24–26
   band_parser.py511571%4, 24, 50–51, 73–74, 77–78, 85–89, 98–99, 104–105
   dos_parser.py18194%13
   hr_parser.py48981%4, 28, 46–47, 59–60, 94–96
   parser.py2243883%8–9, 215, 269–270, 310, 367–368, 385, 402, 419, 475–478, 508, 539–587
   win_parser.py1082081%5, 35–36, 65, 162, 169–171, 210, 221–222, 252–255, 262, 264–265, 269, 286–290
src/nomad_parser_wannier90/parsers/utils
   utils.py291355%4, 35–37, 56–71
src/nomad_parser_wannier90/schema_packages
   __init__.py8275%9–11
   package.py550%1–11
TOTAL51710979% 

Tests Skipped Failures Errors Time
2 0 💤 0 ❌ 0 🔥 14.572s ⏱️

Please sign in to comment.