Skip to content

Commit

Permalink
Merge pull request #161 from naik-aakash/snake_case_bond_type
Browse files Browse the repository at this point in the history
snakecase whichbonds arg and update tests
  • Loading branch information
JaGeo authored Oct 5, 2023
2 parents df26c61 + c4cbd75 commit 8f410c5
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 85 deletions.
6 changes: 3 additions & 3 deletions lobsterpy/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,16 +666,16 @@ def run(args):
"autoplotia",
]:
if args.allbonds:
whichbonds = "all"
which_bonds = "all"
else:
whichbonds = "cation-anion"
which_bonds = "cation-anion"

analyse = Analysis(
path_to_poscar=args.poscar,
path_to_charge=args.charge,
path_to_cohpcar=args.cohpcar,
path_to_icohplist=args.icohplist,
whichbonds=whichbonds,
which_bonds=which_bonds,
are_coops=args.coops,
are_cobis=args.cobis,
noise_cutoff=args.noisecutoff,
Expand Down
44 changes: 22 additions & 22 deletions lobsterpy/cohp/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Analysis:
spg: space group information
structure: Structure object
type_charge: which charges are considered here
whichbonds: which bonds will be considered in analysis
which_bonds: which bonds will be considered in analysis
"""

Expand All @@ -62,7 +62,7 @@ def __init__(
path_to_cohpcar: str,
path_to_charge: str | None = None,
path_to_madelung: str | None = None,
whichbonds: str = "cation-anion",
which_bonds: str = "cation-anion",
cutoff_icohp: float = 0.1,
noise_cutoff: float = 0.1,
summed_spins=True,
Expand All @@ -83,7 +83,7 @@ def __init__(
are_cobis : bool indicating if file contains COBI/ICOBI data
are_coops : bool indicating if file contains COOP/ICOOP data
noise_cutoff : float that sets the lower limit of icohps or icoops or icobis considered
whichbonds: selects which kind of bonds are analyzed. "cation-anion" is the default
which_bonds: selects which kind of bonds are analyzed. "cation-anion" is the default
cutoff_icohp: only bonds that are stronger than cutoff_icohp*strongest ICOHP will be considered
summed_spins: if true, spins will be summed
type_charge: If no path_to_charge is given, Valences will be used. Otherwise, Mulliken charges.
Expand All @@ -94,7 +94,7 @@ def __init__(
self.path_to_poscar = path_to_poscar
self.path_to_icohplist = path_to_icohplist
self.path_to_cohpcar = path_to_cohpcar
self.whichbonds = whichbonds
self.which_bonds = which_bonds
self.cutoff_icohp = cutoff_icohp
self.path_to_charge = path_to_charge
self.path_to_madelung = path_to_madelung
Expand Down Expand Up @@ -142,7 +142,7 @@ def setup_env(self):
self.set_equivalent_sites = list(set(equivalent_sites))
self.spg = symmetry_dataset["international"]

if self.whichbonds == "cation-anion":
if self.which_bonds == "cation-anion":
try:
self.chemenv = LobsterNeighbors(
filename_ICOHP=self.path_to_icohplist,
Expand All @@ -167,7 +167,7 @@ def setup_env(self):
" It looks like no cations are detected."
)
raise err
elif self.whichbonds == "all":
elif self.which_bonds == "all":
# raise ValueError("only cation anion bonds implemented so far")
self.chemenv = LobsterNeighbors(
filename_ICOHP=self.path_to_icohplist,
Expand All @@ -187,11 +187,11 @@ def setup_env(self):

# determine cations and anions
try:
if self.whichbonds == "cation-anion":
if self.which_bonds == "cation-anion":
self.lse = self.chemenv.get_light_structure_environment(
only_cation_environments=True
)
elif self.whichbonds == "all":
elif self.which_bonds == "all":
self.lse = self.chemenv.get_light_structure_environment(
only_cation_environments=False
)
Expand Down Expand Up @@ -226,9 +226,9 @@ def __init__(self, chemenv, valences=None):
[{"ce_symbol": None}]
)

if self.whichbonds == "all":
if self.which_bonds == "all":
self.lse = Lse(self.chemenv.list_coords)
elif self.whichbonds == "cation-anion":
elif self.which_bonds == "cation-anion":
# make a new list
self.lse = Lse(self.chemenv.list_coords, self.chemenv.valences)

Expand All @@ -240,7 +240,7 @@ def get_information_all_bonds(self, summed_spins=True):
None
"""
if self.whichbonds == "cation-anion":
if self.which_bonds == "cation-anion":
# this will only analyze cation anion bonds which simplifies the analysis
self.seq_ineq_ions = []
self.seq_coord_ions = []
Expand Down Expand Up @@ -281,7 +281,7 @@ def get_information_all_bonds(self, summed_spins=True):
self.seq_labels_cohps.append(aniontype_labels)
self.seq_cohps.append(aniontype_cohps)

elif self.whichbonds == "all":
elif self.which_bonds == "all":
# this will only analyze all bonds

self.seq_ineq_ions = []
Expand Down Expand Up @@ -681,14 +681,14 @@ def set_condensed_bonding_analysis(self):
"""
self.condensed_bonding_analysis = {}
# which icohps are considered
if self.whichbonds == "cation-anion":
if self.which_bonds == "cation-anion":
limit_icohps = self.chemenv._get_limit_from_extremum(
self.chemenv.Icohpcollection,
self.cutoff_icohp,
adapt_extremum_to_add_cond=True,
additional_condition=1,
)
elif self.whichbonds == "all":
elif self.which_bonds == "all":
limit_icohps = self.chemenv._get_limit_from_extremum(
self.chemenv.Icohpcollection,
self.cutoff_icohp,
Expand All @@ -700,9 +700,9 @@ def set_condensed_bonding_analysis(self):
# set population type
type_pop = self._get_pop_type()
# how many inequivalent cations are in the structure
if self.whichbonds == "cation-anion":
if self.which_bonds == "cation-anion":
number_considered_ions = len(self.seq_ineq_ions)
elif self.whichbonds == "all":
elif self.which_bonds == "all":
number_considered_ions = len(self.seq_ineq_ions)

# what was the maximum bond lengths that was considered
Expand All @@ -713,7 +713,7 @@ def set_condensed_bonding_analysis(self):

# dictionary including bonding information for each site
site_dict = {}
if self.whichbonds == "cation-anion":
if self.which_bonds == "cation-anion":
for ication, ce, cation_anion_infos, labels, cohps in zip(
self.seq_ineq_ions,
self.seq_coord_ions,
Expand Down Expand Up @@ -755,7 +755,7 @@ def set_condensed_bonding_analysis(self):
"charge": charge_list[ication],
"relevant_bonds": cation_anion_infos[3],
}
elif self.whichbonds == "all":
elif self.which_bonds == "all":
for iion, ce, bond_infos, labels, cohps in zip(
self.seq_ineq_ions,
self.seq_coord_ions,
Expand Down Expand Up @@ -798,7 +798,7 @@ def set_condensed_bonding_analysis(self):
}

if self.path_to_madelung is None:
if self.whichbonds == "cation-anion":
if self.which_bonds == "cation-anion":
# This sets the dictionary including the most important information on the compound
self.condensed_bonding_analysis = {
"formula": formula,
Expand All @@ -808,7 +808,7 @@ def set_condensed_bonding_analysis(self):
"sites": site_dict,
"type_charges": self.type_charge,
}
elif self.whichbonds == "all":
elif self.which_bonds == "all":
self.condensed_bonding_analysis = {
"formula": formula,
"max_considered_bond_length": max_bond_lengths,
Expand All @@ -826,7 +826,7 @@ def set_condensed_bonding_analysis(self):
elif self.type_charge == "Löwdin":
madelung_energy = madelung.madelungenergies_Loewdin
# This sets the dictionary including the most important information on the compound
if self.whichbonds == "cation-anion":
if self.which_bonds == "cation-anion":
self.condensed_bonding_analysis = {
"formula": formula,
"max_considered_bond_length": max_bond_lengths,
Expand All @@ -836,7 +836,7 @@ def set_condensed_bonding_analysis(self):
"type_charges": self.type_charge,
"madelung_energy": madelung_energy,
}
elif self.whichbonds == "all":
elif self.which_bonds == "all":
self.condensed_bonding_analysis = {
"formula": formula,
"max_considered_bond_length": max_bond_lengths,
Expand Down
8 changes: 4 additions & 4 deletions lobsterpy/cohp/describe.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def set_description(self):
type_pop = self.analysis_object._get_pop_type()
# set units for populations
units = " eV" if type_pop == "COHP" else ""
if self.analysis_object.whichbonds == "cation-anion":
if self.analysis_object.which_bonds == "cation-anion":
relevant_cations = ", ".join(
[
str(site.specie) + str(isite + 1)
Expand Down Expand Up @@ -119,7 +119,7 @@ def set_description(self):
+ str(bonds)
+ " bonds."
)
elif self.analysis_object.whichbonds == "all":
elif self.analysis_object.which_bonds == "all":
relevant_ions = ", ".join(
[
str(site.specie) + str(isite + 1)
Expand Down Expand Up @@ -236,9 +236,9 @@ def plot_cohps(
"""
seq_cohps = self.analysis_object.seq_cohps
if self.analysis_object.whichbonds == "cation-anion":
if self.analysis_object.which_bonds == "cation-anion":
seq_ineq_cations = self.analysis_object.seq_ineq_ions
elif self.analysis_object.whichbonds == "all":
elif self.analysis_object.which_bonds == "all":
seq_ineq_cations = self.analysis_object.seq_ineq_ions
seq_labels = self.analysis_object.seq_labels_cohps
structure = self.analysis_object.structure
Expand Down
Loading

0 comments on commit 8f410c5

Please sign in to comment.