Skip to content

Commit

Permalink
add microturbulence to simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
jvshields committed Oct 18, 2024
1 parent 3974df7 commit 0739563
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 8 deletions.
6 changes: 5 additions & 1 deletion stardis/config_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ properties:
- van_der_waals
- radiation
default: []
description: Types of broadening to include.
description: Types of broadening to include.
disable_microturbulence:
type: boolean
default: false
description: Whether to disable microturbulence.
broadening_range:
type: [quantity, "null"]
default: null
Expand Down
2 changes: 2 additions & 0 deletions stardis/io/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ def parse_config_to_model(config_fname, add_config_dict):
stellar_model = raw_marcs_model.to_stellar_model(
adata, final_atomic_number=config.model.final_atomic_number
)
if config.opacity.line.disable_microturbulence:
stellar_model.microturbulence = stellar_model.microturbulence * 0.0

elif config.model.type == "mesa":
raw_mesa_model = read_mesa_model(Path(config.model.fname))
Expand Down
8 changes: 6 additions & 2 deletions stardis/io/model/marcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,12 @@ def to_stellar_model(self, atom_data, final_atomic_number=118):
temperatures = (
self.data.t.values[::-1] * u.K
) # Flip data to move from innermost stellar point to surface
# First two none values are old fv_geometry and abundances which are replaced by the new structures.
return StellarModel(temperatures, marcs_geometry, marcs_composition)
return StellarModel(
temperatures,
marcs_geometry,
marcs_composition,
microturbulence=self.metadata["microturbulence"],
)


def read_marcs_metadata(fpath, gzipped=True):
Expand Down
5 changes: 4 additions & 1 deletion stardis/model/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ class StellarModel(HDFWriterMixin):
Composition of the model. Includes density and atomic mass fractions.
no_of_depth_points : int
Class attribute to be easily accessible for initializing arrays that need to match the shape of the model.
microturbulence : float
Microturbulence in km/s.
"""

hdf_properties = ["temperatures", "geometry", "composition"]

def __init__(self, temperatures, geometry, composition):
def __init__(self, temperatures, geometry, composition, microturbulence=0.0):
self.temperatures = temperatures
self.geometry = geometry
self.composition = composition
self.microturbulence = microturbulence

@property
def no_of_depth_points(self):
Expand Down
15 changes: 11 additions & 4 deletions stardis/radiation_field/opacities/opacities_solvers/broadening.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


@numba.njit
def _calc_doppler_width(nu_line, temperature, atomic_mass):
def _calc_doppler_width(nu_line, temperature, atomic_mass, microturbulence):
"""
Calculates doppler width.
https://ui.adsabs.harvard.edu/abs/2003rtsa.book.....R/
Expand All @@ -51,13 +51,18 @@ def _calc_doppler_width(nu_line, temperature, atomic_mass):
return (
nu_line
/ SPEED_OF_LIGHT
* math.sqrt(2.0 * BOLTZMANN_CONSTANT * temperature / atomic_mass)
* (
math.sqrt(
2.0 * BOLTZMANN_CONSTANT * temperature / atomic_mass
+ microturbulence**2
)
)
)


@numba.vectorize(nopython=True)
def calc_doppler_width(nu_line, temperature, atomic_mass):
return _calc_doppler_width(nu_line, temperature, atomic_mass)
def calc_doppler_width(nu_line, temperature, atomic_mass, microturbulence=0.0):
return _calc_doppler_width(nu_line, temperature, atomic_mass, microturbulence)


@cuda.jit
Expand Down Expand Up @@ -699,6 +704,7 @@ def calculate_broadening(
stellar_model.composition.nuclide_masses.loc[lines.atomic_number].values[
:, np.newaxis
],
stellar_model.microturbulence.cgs.value,
)

return gammas, doppler_widths
Expand Down Expand Up @@ -727,6 +733,7 @@ def calculate_molecule_broadening(
lines.nu.values[:, np.newaxis],
stellar_model.temperatures.value,
molecule_masses,
stellar_model.microturbulence.cgs.value,
)

return gammas, doppler_widths
Expand Down

0 comments on commit 0739563

Please sign in to comment.