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

fix bug that overwrote first entry in opacities_dict #164

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading