Skip to content

Commit

Permalink
faster k table combination of opacities
Browse files Browse the repository at this point in the history
  • Loading branch information
matejmalik committed Aug 12, 2022
1 parent d901b56 commit d5e6237
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions ktable/source_ktable/combination.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,24 +651,27 @@ def include_rayleigh_cross_section(self, param, ray, species, vol_mix_ratio):
else:
print("WARNING WARNING WARNING: Rayleigh scattering cross sections for species", species.name, "not found. Please double-check! Continuing without those... ")


@staticmethod
@nb.njit
def weight_and_include_opacity(vol_mix_ratio, vol_mix_ratio2, weight, mu, opac, final_nt, final_np, nx, ny, combined_opacity):
""" weights opacity and adds to total, combined opacity array """

opac = npy.array(opac)

weighted_opac = []

mass_mix_ratio = vol_mix_ratio * vol_mix_ratio2 * weight / mu

for t in range(final_nt):

for p in range(final_np):

mass_mix_ratio = vol_mix_ratio[p + final_np * t] * vol_mix_ratio2[p + final_np * t] * weight / mu[p + final_np * t]

for x in range(nx):
weighted_opac.extend(mass_mix_ratio[p + final_np * t] * opac[ny*nx*(p + t*final_np):ny*nx*((p+1) + t*final_np)])

for y in range(ny):
weighted_opac = npy.array(weighted_opac)

weighted_opac = mass_mix_ratio * opac[y + ny*x + ny*nx*p + ny*nx*final_np*t]
combined_opacity += weighted_opac

combined_opacity[y + ny*x + ny*nx*p + ny*nx*final_np*t] += weighted_opac

def calc_h_minus_bf(self, conti, param):
""" calculates the H- bound-free continuum opacity """
Expand Down Expand Up @@ -968,7 +971,7 @@ def add_one_species(self, param, ray, conti, species, iter):
final_vmr_2,
species.weight,
self.mu,
nb.typed.List(interpol_opac),
interpol_opac,
self.final_nt,
self.final_np,
self.nx,
Expand Down

0 comments on commit d5e6237

Please sign in to comment.