Running Optab example
February 15, 2026 ยท View on GitHub
CAUTION
It is advisable to begin with a minimal number of layers and closely observe the memory consumption before proceeding to full-scale calculations. For instance, in the sample execution below, the peak memory consumption can reach approximately 1.5GB or more, varying with the level of parallelization.
This section details the creation of opacity tables using a chemical abundance table from FastChem. Ensure FastChem is set up before proceeding. The variables $FASTCHEM and $OPTAB denote the root directories of FastChem and Optab, respectively.
-
Generate a Chemical Abundance Table with
FastChem
Follow the instructions inwork/FastChem-lnk_interpolate_dev/README.md. By default, the grid is 21 x 21 and evenly spaced in the log T - log P plane (see the image below). (If you plan to use an existing chemical-equilibrium dataset, see eos/README.md.)
Warning:FastChembuilt with quadruple precision does not run correctly on arm64 Macs due to ABI constraints. arm64 Mac users must runFastChemon a separate x86_64 platform; see Step 2 for a fallback. -
Convert
FastChemOutput to anoptab-compatible HDF5 Filecd $OPTAB/eos/FastChem ../src/convert_Fastchem $FASTCHEM/output/sample.datIf you do not have access to an x86_64 platform but still want to test
optab, a sampleFastChemoutput is available at$OPTAB/work/FastChem-lnk_interpolate_dev/output/sample.dat. In that case, run:../src/convert_Fastchem $OPTAB/work/FastChem-lnk_interpolate_dev/output/sample.datVisualize the converted HDF5 file sample.h5 using the following Python script:
python3 ../python/eos.py sample.h5 mmw --syms=100
-
Execute
optabwith thesample.shScriptcd $OPTAB/sample/ bash sample.shThis example takes approximately 68 minutes on a 3.3 GHz 12-Core Intel Xeon W processor using 12 MPI processes.
NOTE
Adjust the following parameters to align with your system before running the script:EOS: path to the chemical abundance table in the HDF5 format created in the above stepOPTAB: path to the top directory ofOptabDATABASE: path to the top directory ofOptabdatabaseMPIBIN: path to the directory wherempirunis installedjprc: number of MPI processes
Consider reviewing and modifying additional parameters within the script as shown below:
... ##### export EOS='/Volumes/Storage/optab/eos/FastChem/sample.h5' export OPTAB='/Volumes/Storage/optab/' export DATABASE='/Volumes/Storage/optab/database/' export MPIBIN='/opt/local/bin' ... ##### SELECT A SINGLE LINE-SOURCE FOR EACH MOLECULAR ISOTOPOLOGUE cat <<EOF > input/species_id.dat Species Isotopologue HITRAN HITEMP Exomol 1 H2O 1H2-16O 0 HITRAN 1 HITEMP 0 POKAZATEL 0 BT2 1 H2O 1H2-18O 0 HITRAN 1 HITEMP 0 HotWat78 1 H2O 1H2-17O 0 HITRAN 1 HITEMP 0 HotWat78 ... 56 H3+ 1H3_p 1 HITRAN 0 MiZATeP 56 H3+ 1H2-2H_p 0 ST 999 dummy dummy 0 dummy EOF ##### SELECT OPACITY SOURCES TO BE CONSIDERED (1: SELECTED, 0: NOT SELECTED) cat <<EOF > input/fort.5 &switches ! selection of opacity sources line_molecules = 1 ! molecular lines line_kurucz_gfpred = 1 ! Kurucz gfpred lines line_kurucz_gfall = 1 ! Kurucz gfall lines rayleigh_scattering_h2 = 1 ! Rayleigh scattering by H2 rayleigh_scattering_he = 1 ! Rayleigh scattering by He rayleigh_scattering_h = 1 ! Rayleigh scattering by H electron_scattering = 1 ! electron scattering cia = 0 ! Collision-induced absorption (EXPERIMENTAL) photoion_h2 = 1 ! Photoionization by H2 photoion_topbase = 1 ! TOPbase photoionization (exclusive with mathisen) photoion_mathisen = 0 ! Mathisen photoionization (exclusive with topbase) photoion_verner = 1 ! Verner photoionization photoion_h_minus = 1 ! Photoionization by H- brems_h_minus = 1 ! Bremsstrahlung by H- brems_h2_minus = 1 ! Bremsstrahlung by H2- brems_atomicions = 1 ! Bremsstrahlung by atomic ions / &cutoffs ! for line evaluation cutoff0_voigt = 1d2 ! cutoff for Voigt profile [in wavelenth(cm^-1)] cutoff0_gauss = 3d0 ! cutoff for Gaussian profile [in gaussian width] delta_crit = 1d-4 ! criteria for discarding weak lines delta_voigt = 1d0 ! criteria for adopting Voigt profile / &radtemp ! radiation temperature for 2-temp Planck-mean opacity temp2 = 6000d0 / &grid_log_const ! logarithmic wavenumber grid k_total = 100000 ! total number of grid points grd_min = 1d0 ! min value of wavenumber grid grd_max = 9d0 ! max value of wavenumber grid / &mpi_decomp ! total number of MPI processes = kprc * jprc * mprc * jprc kprc = 1 ! number of processes in wavenumber grid (EXPERIMENTAL) lprc = 1 ! number of processes in line loop (EXPERIMENTAL) mprc = 1 ! number of processes in reading line-block loop (EXPERIMENTAL) jprc = 8 ! number of processes in layer loop / ... EOF ... -
Visualize
optabOutput Files
For each set of (T, P, Ni),optabproduces an HDF5 file,mono_?????.h5in the directory$OPTAB/sample/sample/output/, containing:- Rosseland-mean opacity
- Planck-mean opacity
- two-temperature Planck-mean opacity
- monochromatic absorption and scattering opacities
Use the
opac.pyandmono.pyscripts within$OPTAB/sample/pythonto visualize the data as follows. To see the available script arguments, execute them without any arguments.python3 python/opac.py sample ross 150 python3 python/opac.py sample pla 150 python3 python/opac.py sample pla2 150 python3 python/mono.py sample 30 python3 python/mono.py sample 300



