Skip to content

Commit

Permalink
do not mix for single composition
Browse files Browse the repository at this point in the history
  • Loading branch information
mlietzow committed Aug 26, 2024
1 parent 1256dcb commit a098505
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions miex_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,6 @@ def interp1d_log(xx, yy, kind="linear", fill_value=np.nan):
log_interp = lambda zz: np.power(10.0, lin_interp(np.log10(zz)))
return log_interp


with placeholder.container():
progress_text = "Mixing materials ..."
progress_bar = st.progress(0, text=progress_text)

eps_comp = np.zeros((ncomp, nlam), dtype=complex)
# read lambda/n/k database
for icomp in range(ncomp):
Expand Down Expand Up @@ -344,18 +339,25 @@ def interp1d_log(xx, yy, kind="linear", fill_value=np.nan):
)
eps_comp[icomp] = (real_interp(wavelength) + 1j * imag_interp(wavelength))**2

from mpmath import findroot
eps_mean = np.zeros(nlam, dtype=complex)
counter = 0
for ilam in range(nlam):
def bruggeman_mix(x):
return np.sum(abun * ((eps_comp[:,ilam] - x) / (eps_comp[:,ilam] + 2 * x)))
if ncomp > 1:
with placeholder.container():
progress_text = "Mixing materials ..."
progress_bar = st.progress(0, text=progress_text)

counter += 1
if int(counter % (nlam / 10)) == 0:
progress_bar.progress(int(counter / nlam * 100), text=progress_text)
from mpmath import findroot
eps_mean = np.zeros(nlam, dtype=complex)
counter = 0
for ilam in range(nlam):
def bruggeman_mix(x):
return np.sum(abun * ((eps_comp[:,ilam] - x) / (eps_comp[:,ilam] + 2 * x)))

counter += 1
if int(counter % (nlam / 10)) == 0:
progress_bar.progress(int(counter / nlam * 100), text=progress_text)

eps_mean[ilam] = complex(findroot(bruggeman_mix, complex(1.0, 0.1)))
eps_mean[ilam] = complex(findroot(bruggeman_mix, complex(1.0, 0.1)))
else:
eps_mean = eps_comp[0]

ri_real = np.real(np.sqrt(eps_mean))
ri_imag = np.imag(np.sqrt(eps_mean))
Expand Down

0 comments on commit a098505

Please sign in to comment.