arunavabasucom / radis-app

A web app for high-resolution infrared molecular spectra using RADIS
https://radis.app
GNU Lesser General Public License v3.0
11 stars 16 forks source link

Hack to improve performances in transmittance + slit mode #630

Closed erwanp closed 2 years ago

erwanp commented 2 years ago

Thinking about it : in Transmittance mode; when a slit will be applied (typically 1-10 cm-1) , we can degrade the step resolution (typically 0.01 cm-1 by default), as long as wstep remains ~10x lower than the slit size. This can increase computational speed by probably one or two orders of magnitude.

This is not true in Radiance mode; because of physics reasons (basically lines interact and don't just sum-up, so you need to know precisely where they are, and cannot use a degraded resolution.)

This could be added in Radis-app

erwanp commented 2 years ago

@dcmvdbekerom same can be added in Radis GPU-interactive-widget mode ; if computing a slit ;

@TranHuuNhatHuy same can be added in the fitting interface, also if using a slit, and computing a transmittance

dcmvdbekerom commented 2 years ago

This only works for low concentrations when exp(-x) ~ 1-x. In general it doesn't work becuase the transmittance spectrum where the instrument function is convolved, and the abscoeff spectrum where the molecular lineshapes are convolved are related through an exponential function. It's not a great explanation but I know from experience that it doesn't work unfortunately.

erwanp commented 2 years ago

My bad, you're right ! It would work, exactly (mathematically), to get low-resolution absorbance or cross-sections spectra ; but not to get low-resolution transmittance as the exponential is not linear --> transmittance([filtered absorbance]) != filtered[transmittance(absorbance)].

erwanp commented 2 years ago

We can still have it if we generalize the "apply_slit" option to "low-resolution" ; for instance to compute cross-sections on the fly.

dcmvdbekerom commented 2 years ago

So you leave it up to the user to decide whether concentration is low enough to enable this optimiziation, right?

In that case, you might as well model all molecular lines delta peaks and convolve only once with the instrumental function, which would be much faster still*

(*) if computation time is dominated by the convolution step

erwanp commented 2 years ago

Not exactly helping : ~same calc time for wstep of 10 and 0.029

import astropy.units as u
from radis import calc_spectrum

import matplotlib.pyplot as plt 

plt.figure()

for wstep in ["auto", 10]:

    s = calc_spectrum(
        wmin=0.5 * u.um,
        wmax=10 * u.um,  # cm-1
        mole_fraction={"CO2": 420e-6},
        isotope="1,2,3",
        pressure=1.01325,  # bar
        Tgas=300,  # K
        path_length=1e5,  # 1 km in cm
        verbose=2,
        databank="hitemp",
        cutoff=0,
        wstep=wstep,
        warnings={"AccuracyError":"ignore"}
    )
    s.name = f"wstep {s.c['wstep']}, t={s.c['calculation_time']:.1f}s"
    s.plot(yscale="log", nfig='same')
    print("Calculation time:", s.c["calculation_time"])<
    print("wstep:", s.c["wstep"])

plt.legend()

image

Dropping this idea. Your latest idea (drop physical broadening) is probably the only worth one !