Real-time GPU Accelerated Spectra (Interactive)¶
Example using GPU sliders and GPU calculation with eq_spectrum_gpu_intereactive()
Note
In some cases matplotlib immediately closes the window and returns; this is solved
by running python in interactive mode as follows: python -i plot_gpu_widgets.py.
Systems with a dedicated GPU often have multiple devices available, because they also have an integrated GPU in the main processor. This can be selected by chosing a different device_id (e.g. ‘nvidia’ or ‘intel’). The device id could be a string or an integer. The integer is the device number, starting from 0. Look at the device overview printed when running the GPU spectrum to see what options are available.
s.gpu_exit() does not have to be called explicitly because it is called when the interactive window is closed.

--------------------------------------------------------------------------------
CO2 - HITRAN - Downloading database
--------------------------------------------------------------------------------
Download:
- All files already downloaded.
Caching to HDF5/H5 format:
- All files already cached.
/home/docs/checkouts/readthedocs.org/user_builds/radis/checkouts/master/radis/misc/warning.py:427: HighTemperatureWarning: HITRAN is valid for low temperatures (typically < 700 K). For higher temperatures you may need HITEMP or CDSD. See the 'databank=' parameter
warnings.warn(WarningType(message))
Vulkan version: 1.3.275.1
Selected device (device_id = 0):
[X] 0: llvmpipe (LLVM 15.0.7, 256 bits)
Finished calculating spectrum!
0.77s - Spectrum calculated
Slice 1/1
from radis import SpectrumFactory
from radis.tools.plot_tools import ParamRange
sf = SpectrumFactory(
2150,
2450, # cm-1
molecule="CO2",
isotope="1,2,3",
wstep=0.002,
)
sf.fetch_databank("hitran")
s = sf.eq_spectrum_gpu_interactive(
var="radiance",
Tgas=ParamRange(300.0, 2500.0, 1500.0), # K
pressure=ParamRange(0.1, 2, 1), # bar
mole_fraction=ParamRange(0, 1, 0.8),
path_length=ParamRange(0, 1, 0.2), # cm
slit_function=ParamRange(0, 1.5, 0.5), # cm-1
# device_id='nvidia',
plotkwargs={"wunit": "nm"}, # "nfig": "same",
)
Total running time of the script: (0 minutes 1.781 seconds)