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