Skip to content

Commit

Permalink
fix bug that overwrote first entry in opacities_dict (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
jvshields authored Feb 6, 2024
1 parent eba2b6d commit 61b4634
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
5 changes: 2 additions & 3 deletions stardis/radiation_field/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class RadiationField:
"""
Class containing information about the radiation field.
###TODO Radiation field temperature should be a separate attribute, for the case of differing gas and radiation.
###TODO Implement a source function class. Doesn't need to be done until we have another source function than just blackbody.
Parameters
----------
Expand All @@ -30,5 +29,5 @@ class RadiationField:
def __init__(self, frequencies, source_function, stellar_model):
self.frequencies = frequencies
self.source_function = source_function
self.opacities = Opacities()
self.F_nu = np.zeros((len(stellar_model.geometry.r), len(frequencies)))
self.opacities = Opacities(frequencies, stellar_model)
self.F_nu = np.zeros((stellar_model.no_of_depth_points, len(frequencies)))
15 changes: 9 additions & 6 deletions stardis/radiation_field/opacities/base.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import numpy as np


class Opacities:
"""
Holds opacity information.
Expand All @@ -11,15 +14,15 @@ class Opacities:
Added as an attribute when calc_total_alphas() is called.
"""

def __init__(self):
def __init__(self, frequencies, stellar_model):
self.opacities_dict = {}
self.total_alphas = np.zeros(
(stellar_model.no_of_depth_points, len(frequencies))
)

###TODO: Better implementation for this
def calc_total_alphas(self):
for i, item in enumerate(self.opacities_dict.items()):
for item in self.opacities_dict.items():
if "gammas" not in item[0] and "doppler" not in item[0]:
if i == 0:
self.total_alphas = item[1]
else:
self.total_alphas += item[1]
self.total_alphas += item[1]
return self.total_alphas

0 comments on commit 61b4634

Please sign in to comment.