Skip to content

Commit

Permalink
add autoionization lines if using vald broadening
Browse files Browse the repository at this point in the history
  • Loading branch information
jvshields committed Nov 27, 2024
1 parent f0cbd35 commit 4aa835a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
14 changes: 5 additions & 9 deletions stardis/plasma/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ def calculate(
linelist["level_energy_upper"] = ((linelist["e_up"].values * u.eV).cgs).value

# Radiation broadening parameter is approximated as the einstein A coefficient. Vald parameters are in log scale.
linelist["A_ul"] = 10 ** (
linelist["rad"]
linelist["A_ul"] = (
10 ** (linelist["rad"])
) # see 1995A&AS..112..525P for appropriate units - may be off by a factor of 4pi

# Need to remove autoionization lines - can't handle with current broadening treatment because can't calculate effective principal quantum number
Expand Down Expand Up @@ -449,15 +449,11 @@ def calculate(
linelist["level_energy_upper"] = ((linelist["e_up"].values * u.eV).cgs).value

# Radiation broadening parameter is approximated as the einstein A coefficient. Vald parameters are in log scale.
linelist["A_ul"] = 10 ** (
linelist["rad"]
linelist["A_ul"] = (
10 ** (linelist["rad"])
) # see 1995A&AS..112..525P for appropriate units - may be off by a factor of 4pi

# Need to remove autoionization lines - can't handle with current broadening treatment because can't calculate effective principal quantum number
valid_indices = linelist.level_energy_upper < linelist.ionization_energy

return alphas[valid_indices], linelist[valid_indices]

return alphas, linelist

# Properties that haven't been used in creating stellar plasma yet,
# might be useful in future ----------------------------------------------------
Expand Down
12 changes: 5 additions & 7 deletions stardis/plasma/molecules.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ def calculate(self, ion_number_density, t_electrons, atomic_data):
for (
molecule,
molecule_row,
) in (
molecules_df.iterrows()
): # Loop over all molecules, calculate number densities using Barklem and Collet 2016 equilibrium constants - if a component ion does not exist in the plasma or is negative, assume no molecule
) in molecules_df.iterrows(): # Loop over all molecules, calculate number densities using Barklem and Collet 2016 equilibrium constants - if a component ion does not exist in the plasma or is negative, assume no molecule
if (molecule_row.Ion1_charge == -1) or (molecule_row.Ion2_charge == -1):
logger.warning(
f"Negative ionic molecules not currently supported. Assuming no {molecule}."
Expand Down Expand Up @@ -288,8 +286,8 @@ def calculate(
linelist["level_energy_upper"] = ((linelist["e_up"].values * u.eV).cgs).value

# Radiation broadening parameter is approximated as the einstein A coefficient. Vald parameters are in log scale.
linelist["A_ul"] = 10 ** (linelist["rad"]) / (
4 * np.pi
linelist["A_ul"] = (
10 ** (linelist["rad"])
) # see 1995A&AS..112..525P for appropriate units - may be off by a factor of 4pi

return alphas, linelist
Expand Down Expand Up @@ -414,8 +412,8 @@ def calculate(
linelist["level_energy_upper"] = ((linelist["e_up"].values * u.eV).cgs).value

# Radiation broadening parameter is approximated as the einstein A coefficient. Vald parameters are in log scale.
linelist["A_ul"] = 10 ** (linelist["rad"]) / (
4 * np.pi
linelist["A_ul"] = (
10 ** (linelist["rad"])
) # see 1995A&AS..112..525P for appropriate units - may be off by a factor of 4pi

return alphas, linelist
10 changes: 10 additions & 0 deletions stardis/radiation_field/opacities/opacities_solvers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,16 @@ def calc_alpha_line_at_nu(
.to_numpy()
)

if not line_opacity_config.vald_linelist.use_vald_broadening:
autoionization_lines = (
lines_sorted_in_range.level_energy_upper
> lines_sorted_in_range.ionization_energy
).values

lines_sorted_in_range = lines_sorted_in_range[~autoionization_lines].copy()
alphas_array = alphas_array[~autoionization_lines].copy()
line_nus = line_nus[~autoionization_lines].copy()

lines_sorted_in_range = lines_sorted_in_range.apply(
pd.to_numeric
) # weird bug cropped up with ion_number being an object instead of an int
Expand Down

0 comments on commit 4aa835a

Please sign in to comment.