Skip to content

Commit

Permalink
Merge pull request #245 from JaGeo/enhance_batch_sg
Browse files Browse the repository at this point in the history
Add cutoff args to batch structure graphs featurizer
  • Loading branch information
JaGeo authored Feb 26, 2024
2 parents 6916d28 + b6678dc commit f1688c2
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 132 deletions.
10 changes: 10 additions & 0 deletions lobsterpy/featurize/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,8 @@ class BatchStructureGraphs:
:param path_to_lobster_calcs: path to root directory consisting of all lobster calc
:param add_additional_data_sg: bool indicating whether to include `icoop` and `icobi` data as edge properties
:param which_bonds: selects which kind of bonds are analyzed. "all" is the default
:param cutoff_icohp: only bonds that are stronger than cutoff_icohp * strongest ICOHP will be considered.
:param noise_cutoff: if provided hardcodes the lower limit of icohps considered.
:param start: start energy for bonding antibonding percent integration
:param n_jobs: parallel processes to run
Expand All @@ -583,6 +585,8 @@ def __init__(
path_to_lobster_calcs: str | Path,
add_additional_data_sg: bool = True,
which_bonds: str = "all",
cutoff_icohp: float = 0.10,
noise_cutoff: float = 0.1,
start: float | None = None,
n_jobs: int = 4,
):
Expand All @@ -592,13 +596,17 @@ def __init__(
:param path_to_lobster_calcs: path to root directory consisting of all lobster calc
:param add_additional_data_sg: bool indicating whether to include `icoop` and `icobi` data as edge properties
:param which_bonds: selects which kind of bonds are analyzed. "all" is the default
:param cutoff_icohp: only bonds that are stronger than cutoff_icohp * strongest ICOHP will be considered.
:param noise_cutoff: if provided hardcodes the lower limit of icohps considered.
:param start: start energy for bonding antibonding percent integration
:param n_jobs: parallel processes to run
"""
self.path_to_lobster_calcs = path_to_lobster_calcs
self.add_additional_data_sg = add_additional_data_sg
self.which_bonds = which_bonds
self.cutff_icohp = cutoff_icohp
self.noise_cutoff = noise_cutoff
self.start = start
self.n_jobs = n_jobs

Expand Down Expand Up @@ -627,6 +635,8 @@ def _get_sg_df(self, path_to_lobster_calc: str | Path) -> pd.DataFrame:
path_to_icobilist=str(file_paths.get("icobilist")),
path_to_madelung=str(file_paths.get("madelung")),
which_bonds=self.which_bonds,
cutoff_icohp=self.cutff_icohp,
noise_cutoff=self.noise_cutoff,
start=self.start,
)

Expand Down
5 changes: 5 additions & 0 deletions lobsterpy/structuregraph/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class LobsterGraph:
:param path_to_icobilist: path to ICOBILIST.lobster (e.g., "ICOBILIST.lobster").
:param path_to_madelung: path to MadelungEnergies.lobster (e.g., "MadelungEnergies.lobster")
:param cutoff_icohp: only bonds that are stronger than cutoff_icohp * strongest ICOHP will be considered.
:param noise_cutoff: if provided hardcodes the lower limit of icohps considered.
:param add_additional_data_sg: if True will add the information from ICOOPLIST.lobster
and ICOBILIST.lobster based on ICOHPLIST.lobster relevant bond.
:param which_bonds: selects which kind of bonds are analyzed. "all" is the default.
Expand All @@ -57,6 +58,7 @@ def __init__(
path_to_icobilist: str | Path | None = None,
which_bonds: str = "all",
cutoff_icohp: float = 0.10,
noise_cutoff: float = 0.1,
start: float | None = None,
):
"""Initialize and return a structure graph object."""
Expand All @@ -79,6 +81,7 @@ def __init__(
self.path_to_madelung = path_to_madelung
self.which_bonds = which_bonds
self.cutoff_icohp = cutoff_icohp
self.noise_cutoff = noise_cutoff

if self.which_bonds == "all":
self.additional_condition = 0
Expand Down Expand Up @@ -115,6 +118,7 @@ def get_decorated_sg(self):
id_blist_sg2="ICOOP",
valences_from_charges=True,
adapt_extremum_to_add_cond=True,
noise_cutoff=self.noise_cutoff,
)

else:
Expand All @@ -128,6 +132,7 @@ def get_decorated_sg(self):
add_additional_data_sg=self.add_additional_data_sg,
valences_from_charges=True,
adapt_extremum_to_add_cond=True,
noise_cutoff=self.noise_cutoff,
)

# Adds Mulliken and Löwdin charges as site properties to structure object (node properties)
Expand Down
Loading

0 comments on commit f1688c2

Please sign in to comment.