test_atrstm_radcoefs.c (2732B)
1 /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) 2 * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 17 #include "atrstm_radcoefs.h" 18 19 int 20 main(int argc, char** argv) 21 { 22 const double ka_ref = 5.7382401729092799E-1; 23 const double ks_ref = 7.2169062018378995E-6; 24 25 struct radcoefs radcoefs = RADCOEFS_NULL; 26 struct radcoefs_compute_args args = RADCOEFS_COMPUTE_ARGS_NULL; 27 (void)argc, (void)argv; 28 29 args.lambda = 633; 30 args.n = 1.90; 31 args.kappa = 0.55; 32 args.fractal_prefactor = 1.70; 33 args.fractal_dimension = 1.75; 34 args.soot_volumic_fraction = 1.e-7; 35 args.soot_primary_particles_count = 100; 36 args.soot_primary_particles_diameter = 1; 37 args.radcoefs_mask = ATRSTM_RADCOEFS_MASK_ALL; 38 39 radcoefs_compute(&radcoefs, &args); 40 41 printf("ka = %g; ks = %g\n", radcoefs.ka, radcoefs.ks); 42 CHK(eq_eps(radcoefs.ka, ka_ref, ka_ref*1.e-6)); 43 CHK(eq_eps(radcoefs.ks, ks_ref, ks_ref*1.e-6)); 44 CHK(eq_eps(radcoefs.kext, ka_ref+ks_ref, (ka_ref+ks_ref)*1e-6)); 45 46 args.radcoefs_mask = ATRSTM_RADCOEF_FLAG_Ka; 47 radcoefs_compute(&radcoefs, &args); 48 CHK(eq_eps(radcoefs.ka, ka_ref, ka_ref*1.e-6)); 49 CHK(radcoefs.ks == 0); 50 CHK(radcoefs.kext == 0); 51 52 args.radcoefs_mask = ATRSTM_RADCOEF_FLAG_Ks; 53 radcoefs_compute(&radcoefs, &args); 54 CHK(radcoefs.ka == 0); 55 CHK(eq_eps(radcoefs.ks, ks_ref, ks_ref*1.e-6)); 56 CHK(radcoefs.kext == 0); 57 58 args.radcoefs_mask = ATRSTM_RADCOEF_FLAG_Kext; 59 /* Note that actually even though Ka and Ks are note required they are 60 * internally computed and thus are returned to the caller */ 61 radcoefs_compute(&radcoefs, &args); 62 CHK(eq_eps(radcoefs.kext, ka_ref+ks_ref, (ka_ref+ks_ref)*1e-6)); 63 64 args.radcoefs_mask = ATRSTM_RADCOEFS_MASK_ALL; 65 66 args.soot_primary_particles_count = 0; 67 radcoefs_compute(&radcoefs, &args); 68 CHK(radcoefs.ka == 0); 69 CHK(radcoefs.ks == 0); 70 CHK(radcoefs.kext == 0); 71 72 args.soot_primary_particles_count = 100; 73 args.soot_volumic_fraction = 0; 74 radcoefs_compute(&radcoefs, &args); 75 CHK(radcoefs.ka == 0); 76 CHK(radcoefs.ks == 0); 77 CHK(radcoefs.kext == 0); 78 79 return 0; 80 }