test_ssol_utils.h (3782B)
1 /* Copyright (C) 2018-2026 |Meso|Star> (contact@meso-star.com) 2 * Copyright (C) 2016, 2018 CNRS 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 #ifndef TEST_SSOL_UTILS_H 18 #define TEST_SSOL_UTILS_H 19 20 #include <rsys/mem_allocator.h> 21 #include <stdio.h> 22 23 static INLINE void 24 check_memory_allocator(struct mem_allocator* allocator) 25 { 26 if(MEM_ALLOCATED_SIZE(allocator)) { 27 char dump[512]; 28 MEM_DUMP(allocator, dump, sizeof(dump)/sizeof(char)); 29 fprintf(stderr, "%s\n", dump); 30 FATAL("Memory leaks\n"); 31 } 32 } 33 34 static INLINE void 35 print_global(const struct ssol_mc_global* mc) 36 { 37 ASSERT(mc); 38 printf("Shadows = %g +/- %g; ", mc->shadowed.E, mc->shadowed.SE); 39 printf("Missing = %g +/- %g; ", mc->missing.E, mc->missing.SE); 40 printf("Receivers = %g +/- %g; ", 41 mc->absorbed_by_receivers.E, mc->absorbed_by_receivers.SE); 42 printf("Atmosphere = %g +/- %g; ", 43 mc->extinguished_by_atmosphere.E, mc->extinguished_by_atmosphere.SE); 44 printf("Other absorbed = %g +/- %g; ", 45 mc->other_absorbed.E, mc->other_absorbed.SE); 46 printf("Cos = %g +/- %g\n", mc->cos_factor.E, mc->cos_factor.SE); 47 } 48 49 static INLINE void 50 print_rcv(const struct ssol_mc_receiver* rcv) 51 { 52 ASSERT(rcv); 53 printf("\tIncoming flux(target) = %g +/- %g \n", 54 rcv->incoming_flux.E, rcv->incoming_flux.SE); 55 printf("\tIncoming flux wo Atmosphere(target) = %g +/- %g (%.2g %%)\n", 56 rcv->incoming_if_no_atm_loss.E, rcv->incoming_if_no_atm_loss.SE, 57 100 * rcv->incoming_if_no_atm_loss.E / rcv->incoming_flux.E); 58 printf("\tIncoming flux wo Field Loss(target) = %g +/- %g (%.2g %%)\n", 59 rcv->incoming_if_no_field_loss.E, rcv->incoming_if_no_field_loss.SE, 60 100 * rcv->incoming_if_no_field_loss.E / rcv->incoming_flux.E); 61 printf("\tAtmospheric Loss on Incoming(target) = %g +/- %g (%.2g %%)\n", 62 rcv->incoming_lost_in_atmosphere.E, rcv->incoming_lost_in_atmosphere.SE, 63 100 * rcv->incoming_lost_in_atmosphere.E / rcv->incoming_flux.E); 64 printf("\tOptical Field Loss(target) on Incoming = %g +/- %g (%.2g %%)\n", 65 rcv->incoming_lost_in_field.E, rcv->incoming_lost_in_field.SE, 66 100 * rcv->incoming_lost_in_field.E / rcv->incoming_flux.E); 67 printf("\tAbsorbed flux(target) = %g +/- %g \n", 68 rcv->absorbed_flux.E, rcv->absorbed_flux.SE); 69 printf("\tAbsorbed flux wo Atmosphere(target) = %g +/- %g (%.2g %%)\n", 70 rcv->absorbed_if_no_atm_loss.E, rcv->absorbed_if_no_atm_loss.SE, 71 100 * rcv->absorbed_if_no_atm_loss.E / rcv->absorbed_flux.E); 72 printf("\tAbsorbed flux wo Field Loss(target) = %g +/- %g (%.2g %%)\n", 73 rcv->absorbed_if_no_field_loss.E, rcv->absorbed_if_no_field_loss.SE, 74 100 * rcv->absorbed_if_no_field_loss.E / rcv->absorbed_flux.E); 75 printf("\tAtmospheric Loss(target) on Absorbed = %g +/- %g (%.2g %%)\n", 76 rcv->absorbed_lost_in_atmosphere.E, rcv->absorbed_lost_in_atmosphere.SE, 77 100 * rcv->absorbed_lost_in_atmosphere.E / rcv->absorbed_flux.E); 78 printf("\tOptical Field Loss(target) on Absorbed = %g +/- %g (%.2g %%)\n", 79 rcv->absorbed_lost_in_field.E, rcv->absorbed_lost_in_field.SE, 80 100 * rcv->absorbed_lost_in_field.E / rcv->absorbed_flux.E); 81 } 82 83 #endif /* TEST_SSOL_UTILS_H */