Skip to content

Commit

Permalink
running ruff formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
erinvisser committed Feb 28, 2025
1 parent 2eb6a14 commit 5126544
Showing 1 changed file with 54 additions and 25 deletions.
79 changes: 54 additions & 25 deletions tardis/workflows/v_inner_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,26 @@ def __init__(self, configuration, mean_optical_depth="rosseland", tau=None):
if tau is not None:
self.TAU_TARGET = np.log(tau)

self.iterations_w = np.full((self.total_iterations, self.simulation_state.no_of_shells), np.nan)
self.iterations_t_rad = np.full((self.total_iterations, self.simulation_state.no_of_shells), np.nan) * u.K
self.iterations_electron_densities = np.full((self.total_iterations, self.simulation_state.no_of_shells), np.nan)
self.iterations_w = np.full(

Check warning on line 41 in tardis/workflows/v_inner_solver.py

View check run for this annotation

Codecov / codecov/patch

tardis/workflows/v_inner_solver.py#L41

Added line #L41 was not covered by tests
(self.total_iterations, self.simulation_state.no_of_shells), np.nan
)
self.iterations_t_rad = (

Check warning on line 44 in tardis/workflows/v_inner_solver.py

View check run for this annotation

Codecov / codecov/patch

tardis/workflows/v_inner_solver.py#L44

Added line #L44 was not covered by tests
np.full(
(self.total_iterations, self.simulation_state.no_of_shells),
np.nan,
)
* u.K
)
self.iterations_electron_densities = np.full(

Check warning on line 51 in tardis/workflows/v_inner_solver.py

View check run for this annotation

Codecov / codecov/patch

tardis/workflows/v_inner_solver.py#L51

Added line #L51 was not covered by tests
(self.total_iterations, self.simulation_state.no_of_shells), np.nan
)
self.iterations_t_inner = np.full(self.total_iterations, np.nan) * u.K
self.iterations_v_inner_boundary = np.full(self.total_iterations, np.nan) * u.cm / u.s
self.iterations_mean_optical_depth = np.full((self.total_iterations, self.simulation_state.no_of_shells), np.nan)
self.iterations_v_inner_boundary = (

Check warning on line 55 in tardis/workflows/v_inner_solver.py

View check run for this annotation

Codecov / codecov/patch

tardis/workflows/v_inner_solver.py#L54-L55

Added lines #L54 - L55 were not covered by tests
np.full(self.total_iterations, np.nan) * u.cm / u.s
)
self.iterations_mean_optical_depth = np.full(

Check warning on line 58 in tardis/workflows/v_inner_solver.py

View check run for this annotation

Codecov / codecov/patch

tardis/workflows/v_inner_solver.py#L58

Added line #L58 was not covered by tests
(self.total_iterations, self.simulation_state.no_of_shells), np.nan
)

initial_v_inner = self.estimate_v_inner()

Expand All @@ -52,9 +66,19 @@ def __init__(self, configuration, mean_optical_depth="rosseland", tau=None):
self.simulation_state.r_inner[0]
)

def store_plasma_state(self, i, num_active_shells, t_radiative, dilution_factor, electron_densities, t_inner, v_inner_boundary, tau_integ):
"""Store current plasma information,
including the velocity of the inner boundary
def store_plasma_state(

Check warning on line 69 in tardis/workflows/v_inner_solver.py

View check run for this annotation

Codecov / codecov/patch

tardis/workflows/v_inner_solver.py#L69

Added line #L69 was not covered by tests
self,
i,
num_active_shells,
t_radiative,
dilution_factor,
electron_densities,
t_inner,
v_inner_boundary,
tau_integ,
):
"""Store current plasma information,
including the velocity of the inner boundary
and the Rosseland mean optical depth,
used in iterated i.
Expand All @@ -79,10 +103,14 @@ def store_plasma_state(self, i, num_active_shells, t_radiative, dilution_factor,
"""
self.iterations_t_rad[i, -num_active_shells:] = t_radiative
self.iterations_w[i, -num_active_shells:] = dilution_factor
self.iterations_electron_densities[i, -num_active_shells:] = electron_densities.values[-num_active_shells:]
self.iterations_electron_densities[i, -num_active_shells:] = (

Check warning on line 106 in tardis/workflows/v_inner_solver.py

View check run for this annotation

Codecov / codecov/patch

tardis/workflows/v_inner_solver.py#L104-L106

Added lines #L104 - L106 were not covered by tests
electron_densities.values[-num_active_shells:]
)
self.iterations_t_inner[i] = t_inner
self.iterations_v_inner_boundary[i] = v_inner_boundary
self.iterations_mean_optical_depth[i,-num_active_shells:] = tau_integ[-num_active_shells:]
self.iterations_mean_optical_depth[i, -num_active_shells:] = tau_integ[

Check warning on line 111 in tardis/workflows/v_inner_solver.py

View check run for this annotation

Codecov / codecov/patch

tardis/workflows/v_inner_solver.py#L109-L111

Added lines #L109 - L111 were not covered by tests
-num_active_shells:
]

def reshape_store_plasma_state(self, executed_iterations):

Check warning on line 115 in tardis/workflows/v_inner_solver.py

View check run for this annotation

Codecov / codecov/patch

tardis/workflows/v_inner_solver.py#L115

Added line #L115 was not covered by tests
"""Reshapes the storage arrays in case convergence was reached before
Expand Down Expand Up @@ -118,17 +146,18 @@ def estimate_v_inner(self):
Need some way to return and inspect the optical depths for later logging
"""

self.tau_integ = np.log(

Check warning on line 149 in tardis/workflows/v_inner_solver.py

View check run for this annotation

Codecov / codecov/patch

tardis/workflows/v_inner_solver.py#L149

Added line #L149 was not covered by tests
get_tau_integ(
self.plasma_solver,
self.opacity_states["opacity_state"],
self.simulation_state,
)[self.mean_optical_depth]
)

interpolator = interp1d(
self.tau_integ[self.simulation_state.geometry.v_inner_boundary_index:],
self.tau_integ[
self.simulation_state.geometry.v_inner_boundary_index :
],
self.simulation_state.geometry.v_inner_active, # Only use the active values as we only need a numerical estimate, not an index
fill_value="extrapolate",
)
Expand Down Expand Up @@ -388,7 +417,7 @@ def run(self):
self.plasma_solver.electron_densities,
self.simulation_state.t_inner,
self.simulation_state.geometry.v_inner_boundary,
self.tau_integ
self.tau_integ,
)

# Note that we are updating the class attribute here to ensure consistency
Expand Down Expand Up @@ -431,18 +460,18 @@ def run(self):
)

self.store_plasma_state(

Check warning on line 462 in tardis/workflows/v_inner_solver.py

View check run for this annotation

Codecov / codecov/patch

tardis/workflows/v_inner_solver.py#L462

Added line #L462 was not covered by tests
self.completed_iterations,
self.simulation_state.no_of_shells,
self.simulation_state.t_radiative,
self.simulation_state.dilution_factor,
self.plasma_solver.electron_densities,
self.simulation_state.t_inner,
self.simulation_state.geometry.v_inner_boundary,
self.tau_integ
)
self.completed_iterations,
self.simulation_state.no_of_shells,
self.simulation_state.t_radiative,
self.simulation_state.dilution_factor,
self.plasma_solver.electron_densities,
self.simulation_state.t_inner,
self.simulation_state.geometry.v_inner_boundary,
self.tau_integ,
)

self.reshape_store_plasma_state(self.completed_iterations)

Check warning on line 473 in tardis/workflows/v_inner_solver.py

View check run for this annotation

Codecov / codecov/patch

tardis/workflows/v_inner_solver.py#L473

Added line #L473 was not covered by tests

self.initialize_spectrum_solver(
transport_state,
self.opacity_states,
Expand Down

0 comments on commit 5126544

Please sign in to comment.