Skip to content

Commit

Permalink
Test temperature setting errors for each scan function together, plus…
Browse files Browse the repository at this point in the history
… fixes from testing
  • Loading branch information
kavanase committed Jan 6, 2025
1 parent 5b206ba commit 9f11297
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 55 deletions.
18 changes: 7 additions & 11 deletions doped/thermodynamics.py
Original file line number Diff line number Diff line change
Expand Up @@ -5101,14 +5101,6 @@ def _check_temperature_settings(
"Quenched temperature was set but no annealing temperature was given! Required for the "
"'frozen defect approximation', see docstrings/tutorials."
)
if temperature != 300 and quenched_temperature != 300:
# both set by user and annealing temperature is None, quenched ignored
message = message.replace("annealing_", "quenched_")
message += (
" Quenched temperature setting will be ignored and total equilibrium assumed "
"(see docstrings/tutorials)."
)
warnings.warn(message)

def _solve(
self,
Expand Down Expand Up @@ -5471,7 +5463,7 @@ def scan_dopant_concentration(

def interpolate_chempots(
self,
n_points: int,
n_points: int = 10,
chempots: Optional[Union[list[dict], dict]] = None,
limits: Optional[list[str]] = None,
el_refs: Optional[dict[str, float]] = None,
Expand Down Expand Up @@ -5505,7 +5497,7 @@ def interpolate_chempots(
Args:
n_points (int):
The number of points to generate between chemical potential
end points.
end points. Defaults to 10.
chempots (Optional[list[dict]]):
The chemical potentials to interpolate between. This can be
either a list containing two dictionaries, each representing
Expand Down Expand Up @@ -5685,7 +5677,7 @@ def _get_interpolated_chempots(

def scan_chempots(
self,
chempots: Union[list[dict[str, float]], dict[str, dict]],
chempots: Optional[Union[list[dict[str, float]], dict[str, dict]]] = None,
limits: Optional[list[str]] = None,
el_refs: Optional[dict[str, float]] = None,
annealing_temperature: Optional[float] = None,
Expand Down Expand Up @@ -5811,6 +5803,8 @@ def scan_chempots(
set of chemical potentials. Each row corresponds to a different set
of chemical potentials.
"""
if chempots is None:
chempots = self.defect_thermodynamics.chempots
self._check_temperature_settings(annealing_temperature, temperature, quenched_temperature)

if isinstance(chempots, dict): # should be a dictionary in the ``doped`` format or ``None``:
Expand Down Expand Up @@ -5943,6 +5937,7 @@ def scan_chemical_potential_grid(
pd.DataFrame: A ``DataFrame`` containing the Fermi level solutions at the grid
points, based on the provided chemical potentials and conditions.
"""
self._check_temperature_settings(annealing_temperature, temperature, quenched_temperature)
chempots, el_refs = self._parse_and_check_grid_like_chempots(chempots)
grid = ChemicalPotentialGrid(chempots).get_grid(n_points)
chempot_dict_list = [
Expand Down Expand Up @@ -6127,6 +6122,7 @@ def min_max_X(
If neither ``chempots`` nor ``self.chempots`` is provided, or if
``min_or_max`` is not ``"minimise"/"min"`` or ``"maximise"/"max"``.
"""
self._check_temperature_settings(annealing_temperature, temperature, quenched_temperature)
# Determine the dimensionality of the chemical potential space, and call appropriate method
chempots, el_refs = self._parse_and_check_grid_like_chempots(chempots)
kwargs = {
Expand Down
Loading

0 comments on commit 9f11297

Please sign in to comment.