Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vald broadening implementation #225

Merged
merged 34 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
757474b
vald broadening implementation
jvshields Oct 28, 2024
b47cab0
apply black
jvshields Oct 28, 2024
7c2163d
apply black (again)
jvshields Oct 28, 2024
bb876cd
use vald broadening by default
jvshields Oct 28, 2024
e882507
slight capitalization formatting in config schema
jvshields Oct 28, 2024
a4da85f
fix inconsistent broadcasting error
jvshields Oct 28, 2024
fbf01bf
fix equation bug
jvshields Oct 28, 2024
fde11dd
hwhm to fwhm
jvshields Nov 4, 2024
e3c5f65
add molecules
jvshields Nov 5, 2024
5c41d21
remove redunant code
jvshields Nov 5, 2024
e82b872
fix stark broadening mask
jvshields Nov 6, 2024
65c192a
refactor broadening calc
jvshields Nov 6, 2024
9b5ebe4
documentation
jvshields Nov 6, 2024
2952b00
use atomic number rather than ion number
jvshields Nov 7, 2024
be63c23
use more accurate temperature scaling for vdW gamma
jvshields Nov 7, 2024
147a263
fix broadcasting bug
jvshields Nov 7, 2024
ce24028
fix carsus bug
jvshields Nov 13, 2024
d3f4769
force int with loc to avoid warning
jvshields Nov 14, 2024
1cbae1a
remove leftover accidental self-assignment
jvshields Nov 14, 2024
f0cbd35
more comprehensive dtype object buigfix
jvshields Nov 26, 2024
4aa835a
add autoionization lines if using vald broadening
jvshields Nov 27, 2024
9d90fb2
apply black (though we should use ruff instead)
jvshields Nov 27, 2024
5dad8f5
fix bug with using broadening without a linelist
jvshields Nov 27, 2024
602847c
molecular broadening bugfix
jvshields Dec 2, 2024
9dd5afb
logger messages
jvshields Dec 2, 2024
a88ab25
more logger debugging
jvshields Dec 2, 2024
4a15957
debug logging
jvshields Dec 2, 2024
f41542a
debug logging
jvshields Dec 2, 2024
8501db9
more debugging
jvshields Dec 2, 2024
22d5207
try memory efficient arrays for delta_nus
jvshields Dec 2, 2024
ca71801
remove old logger messages
jvshields Dec 2, 2024
7073b1a
black
jvshields Dec 9, 2024
f8f4213
add comments
jvshields Dec 10, 2024
5d729fc
remove 4pi comment
jvshields Dec 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions stardis/config_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ properties:
shortlist:
type: boolean
default: false
use_vald_broadening:
type: boolean
default: true
description: Options for whether to use a vald linelist. Linelist must be included the atom_data and cannot be supplied separately.
include_molecules:
type: boolean
Expand All @@ -143,7 +146,7 @@ properties:
description: Number of angles to use in the simulation.
result_options:
type: object
additionalProperties: False
additionalProperties: false
default: {}
properties:
return_model:
Expand All @@ -154,7 +157,7 @@ properties:
default: false
return_radiation_field:
type: boolean
default: True
default: true
description: Options for what to return from the simulation.
required:
- stardis_config_version
Expand Down
8 changes: 4 additions & 4 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"]) / (
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
jvshields marked this conversation as resolved.
Show resolved Hide resolved

# 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,8 +449,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

# Need to remove autoionization lines - can't handle with current broadening treatment because can't calculate effective principal quantum number
Expand Down
14 changes: 10 additions & 4 deletions stardis/radiation_field/opacities/opacities_solvers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ def calc_alpha_line_at_nu(
# add ionization energy to lines
ionization_data = stellar_plasma.ionization_data.reset_index()
ionization_data["ion_number"] -= 1
ionization_data["ion_number"] = ionization_data["ion_number"]
jvshields marked this conversation as resolved.
Show resolved Hide resolved
lines = pd.merge(
lines, ionization_data, how="left", on=["atomic_number", "ion_number"]
)
Expand Down Expand Up @@ -406,12 +407,17 @@ def calc_alpha_line_at_nu(
.to_numpy()
)

lines_sorted_in_range["ion_number"] = lines_sorted_in_range["ion_number"].astype(
int
) # weird bug cropped up with ion_number being an object instead of an int

gammas, doppler_widths = calculate_broadening(
lines_sorted_in_range,
stellar_model,
stellar_plasma,
line_opacity_config.broadening,
) # This can be further improved by only calculating the broadening for the lines that are within the range.
use_vald_broadening=line_opacity_config.vald_linelist.use_vald_broadening,
)

delta_nus = tracing_nus.value - line_nus[:, np.newaxis]

Expand Down Expand Up @@ -815,9 +821,9 @@ def calc_alphas(
opacity_config.line,
n_threads,
)
stellar_radiation_field.opacities.opacities_dict[
"alpha_line_at_nu"
] = alpha_line_at_nu
stellar_radiation_field.opacities.opacities_dict["alpha_line_at_nu"] = (
alpha_line_at_nu
)
stellar_radiation_field.opacities.opacities_dict["alpha_line_at_nu_gammas"] = gammas
stellar_radiation_field.opacities.opacities_dict[
"alpha_line_at_nu_doppler_widths"
Expand Down
Loading
Loading