Skip to content

Commit

Permalink
supress warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsquires committed May 22, 2024
1 parent de94129 commit 91850c5
Show file tree
Hide file tree
Showing 2 changed files with 967 additions and 248 deletions.
40 changes: 25 additions & 15 deletions doped/interface/fermi_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from copy import deepcopy
from itertools import product
from typing import TYPE_CHECKING, Any, Optional, Union
from warnings import warn
from warnings import warn, filterwarnings

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -68,13 +68,13 @@ class FermiSolver(MSONable):
"""

def __init__(
self, defect_thermodynamics: "DefectThermodynamics", bulk_dos_vr: str, chemical_potentials: dict
self, defect_thermodynamics: "DefectThermodynamics", bulk_dos_vr_path: str, chemical_potentials: dict
):
"""
Initialize the FermiSolver object.
"""
self.defect_thermodynamics = defect_thermodynamics
self.bulk_dos = bulk_dos_vr
self.bulk_dos = bulk_dos_vr_path
self.chemical_potentials = chemical_potentials
self._not_implemented_message = (
"This method is implemented in the derived class, "
Expand Down Expand Up @@ -758,6 +758,14 @@ def pseudo_equilibrium_solve(
quenched_temperature=quenched_temperature,
effective_dopant_concentration=effective_dopant_concentration,
)
concentrations = concentrations.drop(
columns=[
"Charge",
"Charge State Population",
"Concentration (cm^-3)",
"Formation Energy (eV)",
],
)

new_columns = {
"Fermi Level": fermi_level,
Expand All @@ -770,15 +778,8 @@ def pseudo_equilibrium_solve(
for column, value in new_columns.items():
concentrations[column] = value

trimmed_concentrations = concentrations.drop(
columns=[
"Charge",
"Charge State Population",
"Concentration (cm^-3)",
"Formation Energy (eV)",
],
)
trimmed_concentrations_sub_duplicates = trimmed_concentrations.drop_duplicates()
# trimmed_concentrations =
trimmed_concentrations_sub_duplicates = concentrations.drop_duplicates()
excluded_columns = ["Defect"]
for column in concentrations.columns.difference(excluded_columns):
concentrations[column] = concentrations[column].astype(float)
Expand Down Expand Up @@ -828,18 +829,19 @@ class FermiSolverPyScFermi(FermiSolver):
def __init__(
self,
defect_thermodynamics: "DefectThermodynamics",
bulk_dos_vr: str,
bulk_dos_vr_path: str,
multiplicity_scaling=None,
chemical_potentials=None,
supress_warnings=True,
):
"""
Initialize the FermiSolverPyScFermi object.
"""
super().__init__(defect_thermodynamics, bulk_dos_vr, chemical_potentials)
super().__init__(defect_thermodynamics, bulk_dos_vr_path, chemical_potentials)
vr = Vasprun(self.bulk_dos)
self.bulk_dos = self.DOS.from_vasprun(self.bulk_dos, nelect=vr.parameters["NELECT"])
self.volume = vr.final_structure.volume
self.chemical_potentials = chemical_potentials
self.supress_warnings = supress_warnings

if multiplicity_scaling is None:
ms = self.defect_thermodynamics.defect_entries[0].defect.structure.volume / self.volume
Expand Down Expand Up @@ -969,6 +971,10 @@ def equilibrium_solve(
pd.DataFrame: DataFrame containing defect and carrier concentrations
and the self consistent Fermi energy
"""

if self.supress_warnings:
filterwarnings("ignore", category=RuntimeWarning)

defect_system = self.generate_defect_system(
chemical_potentials=chempots,
temperature=temperature,
Expand Down Expand Up @@ -1015,6 +1021,10 @@ def pseudo_equilibrium_solve(
pd.DataFrame: DataFrame containing defect and carrier concentrations
and the self consistent Fermi energy
"""

if self.supress_warnings:
filterwarnings("ignore", category=RuntimeWarning)

defect_system = self.generate_annealed_defect_system(
chemical_potentials=chempots,
quenched_temperature=quenched_temperature,
Expand Down
Loading

0 comments on commit 91850c5

Please sign in to comment.