star-line

Structure for accelerating line importance sampling
git clone git://git.meso-star.com/star-line.git
Log | Files | Refs | README | LICENSE

test_sln_lines.h (9193B)


      1 /* Copyright (C) 2022, 2026 |Méso|Star> (contact@meso-star.com)
      2  * Copyright (C) 2026 Université de Lorraine
      3  * Copyright (C) 2022 Centre National de la Recherche Scientifique
      4  * Copyright (C) 2022 Université Paul Sabatier
      5  *
      6  * This file is part of Star-Line.
      7  *
      8  * This program is free software: you can redistribute it and/or modify
      9  * it under the terms of the GNU General Public License as published by
     10  * the Free Software Foundation, either version 3 of the License, or
     11  * (at your option) any later version.
     12  *
     13  * This program is distributed in the hope that it will be useful,
     14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     16  * GNU General Public License for more details.
     17  *
     18  * You should have received a copy of the GNU General Public License
     19  * along with this program. If not, see <http://www.gnu.org/licenses/>. */
     20 
     21 #ifndef TEST_SLN_LINES_H
     22 #define TEST_SLN_LINES_H
     23 
     24 #include <star/shtr.h>
     25 #include <rsys/rsys.h>
     26 #include <stdio.h>
     27 
     28 static const struct shtr_isotope g_H2O_isotopes[] = {
     29   {9.97317E-01, 1.7458E+02, 18.010565, 0, 1, 161},
     30   {1.99983E-03, 1.7605E+02, 20.014811, 0, 1, 181},
     31   {3.71884E-04, 1.0521E+03, 19.014780, 0, 6, 171},
     32   {3.10693E-04, 8.6474E+02, 19.016740, 0, 6, 162},
     33   {6.23003E-07, 8.7557E+02, 21.020985, 0, 6, 182},
     34   {1.15853E-07, 5.2268E+03, 20.020956, 0, 36, 172},
     35   {2.41974E-08, 1.0278E+03, 20.022915, 0, 1, 262}
     36 };
     37 static const struct shtr_molecule g_H2O = {
     38   "H2O", sizeof(g_H2O_isotopes)/sizeof(struct shtr_isotope), g_H2O_isotopes, 1,
     39 };
     40 
     41 static const struct shtr_isotope g_CO2_isotopes[] = {
     42   {9.84204E-01, 2.8609E+02, 43.989830, 1, 1, 626},
     43   {1.10574E-02, 5.7664E+02, 44.993185, 1, 2, 636},
     44   {3.94707E-03, 6.0781E+02, 45.994076, 1, 1, 628},
     45   {7.33989E-04, 3.5426E+03, 44.994045, 1, 6, 627},
     46   {4.43446E-05, 1.2255E+03, 46.997431, 1, 2, 638},
     47   {8.24623E-06, 7.1413E+03, 45.997400, 1, 12, 637},
     48   {3.95734E-06, 3.2342E+02, 47.998320, 1, 1, 828},
     49   {1.47180E-06, 3.7666E+03, 46.998291, 1, 6, 827},
     50   {1.36847E-07, 1.0972E+04, 45.998262, 1, 1, 727},
     51   {4.44600E-08, 6.5224E+02, 49.001675, 1, 2, 838},
     52   {1.65354E-08, 7.5950E+03, 48.001646, 1, 12, 837},
     53   {1.53745E-09, 2.2120E+04, 47.001618, 1, 2, 737}
     54 };
     55 static const struct shtr_molecule g_CO2 = {
     56   "CO2", sizeof(g_CO2_isotopes)/sizeof(struct shtr_isotope), g_CO2_isotopes, 2,
     57 };
     58 
     59 static const struct shtr_isotope g_O3_isotopes[] = {
     60   {9.92901E-01, 3.4750E+03, 47.984745, 2, 1, 666},
     61   {3.98194E-03, 7.5846E+03, 49.988991, 2, 1, 668},
     62   {1.99097E-03, 3.7030E+03, 49.988991, 2, 1, 686},
     63   {7.40475E-04, 4.4044E+04, 48.988960, 2, 6, 667},
     64   {3.70237E-04, 2.1742E+04, 48.988960, 2, 6, 676}
     65 };
     66 static const struct shtr_molecule g_O3 = {
     67   "O3", sizeof(g_O3_isotopes)/sizeof(struct shtr_isotope), g_O3_isotopes, 3
     68 };
     69 
     70 static const struct shtr_line g_lines[] = {
     71   {0.00156, 2.685e-36, 0.0695, 0.428,  399.7263, 0.79, 0.000240, 1, 5},
     72   {0.03406, 5.898e-37, 0.0883, 0.410, 1711.6192, 0.79, 0.000000, 1, 5},
     73   {0.03445, 5.263e-33, 0.0504, 0.329, 1570.0616, 0.79, 0.001940, 1, 3},
     74   {0.03628, 9.296e-29, 0.0704, 0.095,  522.5576, 0.81, 0.000000, 3, 0},
     75   {0.03671, 2.555e-37, 0.0389, 0.304, 2337.5190, 0.79, 0.002660, 1, 4},
     76   {0.08403, 8.190e-33, 0.0753, 0.394,  568.0017, 0.79, 0.002180, 1, 4},
     77   {0.08653, 5.376e-29, 0.0691, 0.083, 1061.6864, 0.76, 0.000000, 3, 0},
     78   {0.09642, 6.675e-37, 0.0570, 0.351, 2516.3150, 0.79, 0.000000, 1, 4},
     79   {0.16772, 2.456e-28, 0.0823, 0.105,  751.2922, 0.77, 0.000000, 3, 0},
     80   {0.18582, 5.338e-32, 0.0925, 0.428, 1717.3356, 0.79, 0.004100, 1, 3},
     81   {0.19368, 2.553e-32, 0.0901, 0.428,  293.8010, 0.79, 0.001260, 1, 5},
     82   {0.19688, 1.447e-31, 0.0901, 0.428,  292.3093, 0.79, 0.001260, 1, 4},
     83   {0.19757, 6.063e-29, 0.0681, 0.078, 1401.6146, 0.76, 0.000000, 3, 0},
     84   {0.21281, 8.238e-31, 0.0780, 0.103,  127.4733, 0.78, 0.000000, 3, 4},
     85   {0.21282, 5.999e-31, 0.0780, 0.103,  127.4733, 0.78, 0.000000, 3, 4},
     86   {0.21283, 7.737e-31, 0.0780, 0.103,  127.4733, 0.78, 0.000000, 3, 4},
     87   {0.21283, 6.394e-31, 0.0780, 0.103,  127.4733, 0.78, 0.000000, 3, 4},
     88   {0.21284, 7.260e-31, 0.0780, 0.103,  127.4732, 0.78, 0.000000, 3, 4},
     89   {0.21284, 6.813e-31, 0.0780, 0.103,  127.4733, 0.78, 0.000000, 3, 4},
     90   {0.21728, 5.928e-29, 0.0823, 0.105, 1153.4099, 0.77, 0.000000, 3, 0},
     91   {0.25818, 3.110e-32, 0.0539, 0.311, 1958.1248, 0.79, 0.008600, 1, 3},
     92   {0.26618, 1.468e-32, 0.0801, 0.378, 2118.9452, 0.79, 0.003100, 1, 3},
     93   {0.27091, 1.362e-35, 0.0539, 0.311, 1949.2032, 0.79, 0.008600, 1, 5},
     94   {0.28910, 2.058e-30, 0.0878, 0.106,    7.8611, 0.76, 0.000000, 3, 3},
     95   {0.29412, 8.666e-33, 0.0795, 0.378,  679.8760, 0.79, 0.004170, 1, 5},
     96   {0.29477, 1.457e-30, 0.0660, 0.340, 1238.7943, 0.79, 0.007260, 1, 3},
     97   {0.29673, 1.609e-30, 0.0773, 0.103,  138.7916, 0.78, 0.000000, 3, 3},
     98   {0.29673, 1.195e-30, 0.0773, 0.103,  138.7916, 0.78, 0.000000, 3, 3},
     99   {0.29676, 1.268e-30, 0.0773, 0.103,  138.7916, 0.78, 0.000000, 3, 3},
    100   {1.46280, 7.205e-26, 0.0696, 0.090,  702.3167, 0.82, 0.000000, 3, 0},
    101   {1.46899, 7.847e-28, 0.0704, 0.095, 1557.6290, 0.81, 0.000000, 3, 0},
    102   {1.47237, 1.700e-34, 0.0633, 0.297, 2389.2994, 0.79, 0.013980, 1, 4},
    103   {1.47273, 1.131e-32, 0.0903, 0.123,    0.7753, 0.69, 0.000814, 2, 2},
    104   {1.47863, 5.318e-33, 0.0925, 0.428, 2877.6872, 0.79, 0.006200, 1, 3},
    105   {1.48860, 1.058e-27, 0.0760, 0.102,  163.7760, 0.78, 0.000000, 3, 1},
    106   {1.49043, 4.787e-31, 0.0773, 0.103,  139.7879, 0.78, 0.000000, 3, 4},
    107   {1.49044, 3.139e-29, 0.0773, 0.103,  139.7879, 0.78, 0.000000, 3, 4},
    108   {1.49044, 3.332e-29, 0.0773, 0.103,  139.7880, 0.78, 0.000000, 3, 4},
    109   {1.49045, 2.785e-29, 0.0773, 0.103,  139.7880, 0.78, 0.000000, 3, 4},
    110   {1.49045, 2.625e-29, 0.0773, 0.103,  139.7880, 0.78, 0.000000, 3, 4},
    111   {1.49057, 5.941e-27, 0.0909, 0.106,  703.4398, 0.76, 0.000000, 3, 0},
    112   {1.49110, 1.537e-29, 0.0714, 0.098,  381.8992, 0.80, 0.000000, 3, 3},
    113   {1.49111, 1.828e-29, 0.0714, 0.098,  381.8992, 0.80, 0.000000, 3, 3},
    114   {1.49111, 1.648e-29, 0.0714, 0.098,  381.8992, 0.80, 0.000000, 3, 3},
    115   {1.49111, 1.766e-29, 0.0714, 0.098,  381.8991, 0.80, 0.000000, 3, 3},
    116   {1.49111, 1.706e-29, 0.0714, 0.098,  381.8991, 0.80, 0.000000, 3, 3},
    117   {1.49674, 1.208e-25, 0.0719, 0.102,  190.2125, 0.79, 0.000000, 3, 0},
    118   {1.50216, 4.971e-28, 0.0696, 0.090, 1734.9796, 0.82, 0.000000, 3, 0},
    119   {1.51178, 3.047e-27, 0.0766, 0.103, 1195.5580, 0.78, 0.000000, 3, 0},
    120   {1.51399, 1.986e-27, 0.0765, 0.104, 1129.0675, 0.77, 0.000000, 3, 0},
    121   {1.51442, 2.601e-34, 0.0903, 0.123,    0.7572, 0.69, 0.000814, 2, 3},
    122   {1.51443, 3.981e-34, 0.0903, 0.123,    0.7572, 0.69, 0.000814, 2, 3},
    123   {1.51443, 6.637e-35, 0.0903, 0.123,    0.7572, 0.69, 0.000814, 2, 3},
    124   {1.51444, 3.902e-34, 0.0903, 0.123,    0.7572, 0.69, 0.000814, 2, 3},
    125   {1.51445, 1.394e-33, 0.0903, 0.123,    0.7572, 0.69, 0.000814, 2, 3},
    126   {1.51446, 7.166e-34, 0.0903, 0.123,    0.7572, 0.69, 0.000814, 2, 3},
    127   {1.51446, 2.787e-34, 0.0903, 0.123,    0.7572, 0.69, 0.000814, 2, 3},
    128   {1.51446, 5.096e-34, 0.0903, 0.123,    0.7572, 0.69, 0.000814, 2, 3},
    129   {1.51448, 1.672e-34, 0.0903, 0.123,    0.7572, 0.69, 0.000814, 2, 3},
    130   {1.51597, 4.443e-30, 0.0704, 0.097,  463.6953, 0.81, 0.000000, 3, 3},
    131   {1.51600, 5.172e-30, 0.0704, 0.097,  463.6952, 0.81, 0.000000, 3, 3},
    132   {1.51603, 4.580e-30, 0.0704, 0.097,  463.6952, 0.81, 0.000000, 3, 3},
    133   {1.51605, 5.019e-30, 0.0704, 0.097,  463.6951, 0.81, 0.000000, 3, 3}
    134 };
    135 const size_t g_nlines = sizeof(g_lines) / sizeof(struct shtr_line);
    136 
    137 /*******************************************************************************
    138  * Helper functions
    139  ******************************************************************************/
    140 static INLINE void
    141 write_shtr_isotope(FILE* fp, const struct shtr_isotope* isotope)
    142 {
    143   CHK(fp && isotope);
    144   fprintf(fp, "    %d %.5E %.4E %d %.6f\n",
    145     isotope->id,
    146     isotope->abundance,
    147     isotope->Q296K,
    148     isotope->gj,
    149     isotope->molar_mass);
    150 }
    151 
    152 static INLINE void
    153 write_shtr_molecule(FILE* fp, const struct shtr_molecule* molecule)
    154 {
    155   size_t i;
    156   CHK(fp && molecule);
    157 
    158   fprintf(fp, "  %s (%d)\n", molecule->name, molecule->id);
    159   FOR_EACH(i, 0, molecule->nisotopes) {
    160     write_shtr_isotope(fp, molecule->isotopes+i);
    161   }
    162 }
    163 
    164 static INLINE void
    165 write_shtr_lines
    166   (FILE* fp,
    167    const struct shtr_line* lines,
    168    const size_t nlines)
    169 {
    170   size_t i;
    171 
    172   CHK(fp && (!nlines || lines));
    173   FOR_EACH(i, 0, nlines) {
    174     fprintf(fp,
    175       "%2d%1d%12.6f%10.3e 0.000E-00.%04d%5.3f%10.4f%4.2f%8.6f"
    176       /* Dummy remaining data */
    177       "          0 0 0" /* Global upper quanta */
    178       "          0 0 0" /* Global upper quanta */
    179       "  5  5  0      " /* Local upper quanta */
    180       "  5  5  1      " /* Local lower quanta */
    181       "562220" /* Error indices */
    182       "5041 7833348" /* References */
    183       " " /* Line mixing flag */
    184       "   66.0" /* g' */
    185       "   66.0" /* g'' */
    186       "\n",
    187       lines[i].molecule_id,
    188       lines[i].isotope_id_local == 9 ? 0 : lines[i].isotope_id_local+1,
    189       lines[i].wavenumber,
    190       lines[i].intensity,
    191       (int)(lines[i].gamma_air*10000+0.5/*round*/),
    192       lines[i].gamma_self,
    193       lines[i].lower_state_energy,
    194       lines[i].n_air,
    195       lines[i].delta_air);
    196   }
    197 }
    198 
    199 #endif /* TEST_SLN_LINES_H */