Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexHls committed Nov 27, 2023
1 parent 0331790 commit b114908
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions tardis/plasma/properties/nlte_rate_equation_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
NLTE_POPULATION_NEGATIVE_POPULATION_TOLERANCE = (
-1e-10
) # Maximum negative population allowed before solver fails
NLTE_POPULATION_SOLVER_CHARGE_CONSERVATION_TOLERANCE = 1e-6 # Arbitrary tolerance for charge conservation, should be changed to a more reasonable value
NLTE_POPULATION_SOLVER_CHARGE_CONSERVATION_TOLERANCE = 1e-6 # Arbitrary tolerance for charge conservation, should be changed to a more reasonable value


class NLTEPopulationSolverRoot(ProcessingPlasmaProperty):
Expand Down Expand Up @@ -150,18 +150,18 @@ def calculate(
solution.x[-1],
number_density[shell],
ion_numbers,
)
)
# Check that the electron density is still in line with charge conservation
# after removing negative populations
assert (
np.abs(
np.sum(ion_numbers * ion_number_density[shell])
- electron_densities[shell]
) / electron_densities[shell]
)
/ electron_densities[shell]
< NLTE_POPULATION_SOLVER_CHARGE_CONSERVATION_TOLERANCE
), "Charge conservation not fulfilled after correcting for negative populations, solver failed."


# TODO: change the jacobian and rate matrix to use shell id and get coefficients from the attribute of the class.

return ion_number_density, electron_densities
Expand Down
5 changes: 4 additions & 1 deletion tardis/plasma/tests/test_nlte_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

import pytest
from numpy.testing import assert_allclose
from tardis.plasma.properties import NLTEPopulationSolverRoot, NLTEPopulationSolverLU
from tardis.plasma.properties import (
NLTEPopulationSolverRoot,
NLTEPopulationSolverLU,
)
from tardis.plasma.properties.nlte_rate_equation_solver import (
calculate_jacobian_matrix,
calculate_rate_matrix,
Expand Down

0 comments on commit b114908

Please sign in to comment.