Skip to content

Commit d5e6237

Browse files
author
matejmalik
committed
faster k table combination of opacities
1 parent d901b56 commit d5e6237

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

ktable/source_ktable/combination.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -651,24 +651,27 @@ def include_rayleigh_cross_section(self, param, ray, species, vol_mix_ratio):
651651
else:
652652
print("WARNING WARNING WARNING: Rayleigh scattering cross sections for species", species.name, "not found. Please double-check! Continuing without those... ")
653653

654+
654655
@staticmethod
655-
@nb.njit
656656
def weight_and_include_opacity(vol_mix_ratio, vol_mix_ratio2, weight, mu, opac, final_nt, final_np, nx, ny, combined_opacity):
657657
""" weights opacity and adds to total, combined opacity array """
658658

659+
opac = npy.array(opac)
660+
661+
weighted_opac = []
662+
663+
mass_mix_ratio = vol_mix_ratio * vol_mix_ratio2 * weight / mu
664+
659665
for t in range(final_nt):
660666

661667
for p in range(final_np):
662668

663-
mass_mix_ratio = vol_mix_ratio[p + final_np * t] * vol_mix_ratio2[p + final_np * t] * weight / mu[p + final_np * t]
664-
665-
for x in range(nx):
669+
weighted_opac.extend(mass_mix_ratio[p + final_np * t] * opac[ny*nx*(p + t*final_np):ny*nx*((p+1) + t*final_np)])
666670

667-
for y in range(ny):
671+
weighted_opac = npy.array(weighted_opac)
668672

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

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

673676
def calc_h_minus_bf(self, conti, param):
674677
""" calculates the H- bound-free continuum opacity """
@@ -968,7 +971,7 @@ def add_one_species(self, param, ray, conti, species, iter):
968971
final_vmr_2,
969972
species.weight,
970973
self.mu,
971-
nb.typed.List(interpol_opac),
974+
interpol_opac,
972975
self.final_nt,
973976
self.final_np,
974977
self.nx,

0 commit comments

Comments
 (0)