commit 65a3822c6775678ee5e84adf9b78f58e583f9a29 parent bcf123293f1446c3c9c393348dc4f0741b94afc2 Author: Vincent Forest <vincent.forest@meso-star.com> Date: Tue, 4 Jun 2019 16:03:03 +0200 Merge branch 'release_0.8' Diffstat:
75 files changed, 307 insertions(+), 151 deletions(-)
diff --git a/README.md b/README.md @@ -29,6 +29,12 @@ variable the install directories of its dependencies. ## Release notes +### Version 0.8 + +- Register into the estimator the final state of the RNG used during the + simulation. Add the `ssol_estimator_get_rng_state` function that returns this + state. + ### Version 0.7.3 - Update the version of the RSys and StarSP dependencies. @@ -125,8 +131,8 @@ variable the install directories of its dependencies. Solstice-Solver is developed by [|Meso|Star>](http://www.meso-star.com) for the [National Center for Scientific Research](http://www.cnrs.fr/index.php) (CNRS). -It is a free software copyright (C) CNRS 2016-2017 and it is released under the -[OSI](http://opensource.org)-approved GPL v3+ license. You are welcome to -redistribute it under certain conditions; refer to the COPYING file for -details. +Copyright (C) 2016-2018 CNRS, 2018-2019 +[|Meso|Star>](http://www.meso-star.com). It is free software released under the +GPL v3+ license: GNU GPL version 3 or later. You are welcome to redistribute it +under certain conditions; refer to the COPYING file for details. diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) CNRS 2016-2017 +# Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -54,8 +54,8 @@ rcmake_append_runtime_dirs(_runtime_dirs RSys Star3D Star3DUT StarCPR StarSF Sta # Configure and define targets ################################################################################ set(VERSION_MAJOR 0) -set(VERSION_MINOR 7) -set(VERSION_PATCH 3) +set(VERSION_MINOR 8) +set(VERSION_PATCH 0) set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) set(SSOL_FILES_SRC diff --git a/src/ssol.h b/src/ssol.h @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1140,6 +1140,12 @@ ssol_estimator_get_mc_sampled const struct ssol_instance* samp_instance, struct ssol_mc_sampled* sampled); +/* Retrieve the RNG state at the end of the simulation */ +SSOL_API res_T +ssol_estimator_get_rng_state + (const struct ssol_estimator* estimator, + const struct ssp_rng** rng_state); + /******************************************************************************* * Tracked paths ******************************************************************************/ @@ -1198,7 +1204,7 @@ ssol_mc_shape_get_mc_primitive SSOL_API res_T ssol_solve (struct ssol_scene* scn, - struct ssp_rng* rng, + const struct ssp_rng* rng, const size_t realisations_count, const size_t max_failed_count, const struct ssol_path_tracker* tracker, /* NULL<=>Do not record the paths */ diff --git a/src/ssol_atmosphere.c b/src/ssol_atmosphere.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_atmosphere_c.h b/src/ssol_atmosphere_c.h @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_c.h b/src/ssol_c.h @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_camera.c b/src/ssol_camera.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_camera.h b/src/ssol_camera.h @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_data.c b/src/ssol_data.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_device.c b/src/ssol_device.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_device_c.h b/src/ssol_device_c.h @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_draw.c b/src/ssol_draw.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_draw.h b/src/ssol_draw.h @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_draw_draft.c b/src/ssol_draw_draft.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_draw_pt.c b/src/ssol_draw_pt.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_estimator.c b/src/ssol_estimator.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,6 +25,8 @@ #include <rsys/ref_count.h> #include <rsys/rsys.h> +#include <star/ssp.h> + #include <math.h> /******************************************************************************* @@ -81,6 +83,7 @@ estimator_release(ref_T* ref) htable_receiver_release(&estimator->mc_receivers); htable_sampled_release(&estimator->mc_sampled); darray_path_release(&estimator->paths); + if(estimator->rng) SSP(rng_ref_put(estimator->rng)); ASSERT(dev && dev->allocator); MEM_RM(dev->allocator, estimator); SSOL(device_ref_put(dev)); @@ -255,6 +258,15 @@ ssol_estimator_get_mc_sampled } res_T +ssol_estimator_get_rng_state + (const struct ssol_estimator* estimator, const struct ssp_rng** rng_state) +{ + if(!estimator || !rng_state) return RES_BAD_ARG; + *rng_state = estimator->rng; + return RES_OK; +} + +res_T ssol_estimator_get_tracked_paths_count (const struct ssol_estimator* estimator, size_t* npaths) { @@ -344,7 +356,6 @@ estimator_create exit: if(out_estimator) *out_estimator = estimator; return res; - error: if(estimator) { SSOL(estimator_ref_put(estimator)); @@ -353,3 +364,55 @@ error: goto exit; } +res_T +estimator_save_rng_state + (struct ssol_estimator* estimator, const struct ssp_rng_proxy* proxy) +{ + struct ssp_rng_type rng_type; + FILE* stream = NULL; + res_T res = RES_OK; + ASSERT(estimator && proxy); + + /* Release the previous rng state */ + if(estimator->rng) { + SSP(rng_ref_put(estimator->rng)); + estimator->rng = NULL; + } + + stream = tmpfile(); + if(!stream) { + log_error(estimator->dev, + "Could not open a stream to store the proxy RNG state.\n"); + res = RES_IO_ERR; + goto error; + } + + SSP(rng_proxy_get_type(proxy, &rng_type)); + res = ssp_rng_create(estimator->dev->allocator, &rng_type, &estimator->rng); + if(res != RES_OK) { + log_error(estimator->dev, + "Could not create the RNG to save the proxy RNG state.\n"); + goto error; + } + + res = ssp_rng_proxy_write(proxy, stream); + if(res != RES_OK) { + log_error(estimator->dev, "Could not serialize the proxy RNG state.\n"); + goto error; + } + + rewind(stream); + res = ssp_rng_read(estimator->rng, stream); + if(res != RES_OK) { + log_error(estimator->dev, "Could not save the proxy RNG state.\n"); + goto error; + } + +exit: + if(stream) fclose(stream); + return res; +error: + if(estimator->rng) SSP(rng_ref_put(estimator->rng)); + goto exit; +} + diff --git a/src/ssol_estimator_c.h b/src/ssol_estimator_c.h @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,6 +26,7 @@ /* Forward declaration */ struct mem_allocator; struct ssol_instance; +struct ssp_rng_proxy; /* Monte carlo data */ struct mc_data { @@ -569,6 +570,9 @@ struct ssol_estimator { * geometry */ double sampled_area; + /* State of the RNG after the simulation */ + struct ssp_rng* rng; + struct ssol_device* dev; ref_T ref; }; @@ -579,6 +583,11 @@ estimator_create struct ssol_scene* scene, struct ssol_estimator** estimator); +extern LOCAL_SYM res_T +estimator_save_rng_state + (struct ssol_estimator* estimator, + const struct ssp_rng_proxy* proxy); + static FINLINE res_T get_mc_receiver_1side (struct htable_receiver* receivers, diff --git a/src/ssol_image.c b/src/ssol_image.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_image_c.h b/src/ssol_image_c.h @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_instance.c b/src/ssol_instance.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_instance_c.h b/src/ssol_instance_c.h @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_material.c b/src/ssol_material.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_material_c.h b/src/ssol_material_c.h @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_mc_receiver.c b/src/ssol_mc_receiver.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_object.c b/src/ssol_object.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_object_c.h b/src/ssol_object_c.h @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_param_buffer.c b/src/ssol_param_buffer.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_ranst_sun_dir.c b/src/ssol_ranst_sun_dir.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_ranst_sun_dir.h b/src/ssol_ranst_sun_dir.h @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_ranst_sun_wl.c b/src/ssol_ranst_sun_wl.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_ranst_sun_wl.h b/src/ssol_ranst_sun_wl.h @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_scene.c b/src/ssol_scene.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_scene_c.h b/src/ssol_scene_c.h @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_shape.c b/src/ssol_shape.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_shape_c.h b/src/ssol_shape_c.h @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_solver.c b/src/ssol_solver.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1086,7 +1086,7 @@ trace_radiative_path #undef ACCUM_WEIGHT /* Check conservation of energy at the realisation level */ - ASSERT((double)depth*DBL_EPSILON*pt.initial_flux >= fabs(pt.energy_loss)); + ASSERT(((double)depth*DBL_EPSILON*10)*pt.initial_flux >= fabs(pt.energy_loss)); /* this realisation accounts for many that where canceled */ if(pt.survivor_score) { @@ -1119,7 +1119,7 @@ error: res_T ssol_solve (struct ssol_scene* scn, - struct ssp_rng* rng_state, + const struct ssp_rng* rng_state, const size_t realisations_count, const size_t max_failed_count, const struct ssol_path_tracker* path_tracker, @@ -1320,6 +1320,10 @@ ssol_solve } estimator->sampled_area = scn->sampled_area; + + res = estimator_save_rng_state(estimator, rng_proxy); + if(res != RES_OK) goto error; + if(mt_res != RES_OK) res = (res_T)mt_res; #ifndef NDEBUG diff --git a/src/ssol_spectrum.c b/src/ssol_spectrum.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_spectrum_c.h b/src/ssol_spectrum_c.h @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_sun.c b/src/ssol_sun.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/ssol_sun_c.h b/src/ssol_sun_c.h @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_ssol_atmosphere.c b/src/test_ssol_atmosphere.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_ssol_by_receiver_integration.c b/src/test_ssol_by_receiver_integration.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_ssol_camera.c b/src/test_ssol_camera.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_ssol_circ2D_geometry.h b/src/test_ssol_circ2D_geometry.h @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_ssol_cube_geometry.h b/src/test_ssol_cube_geometry.h @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_ssol_data.c b/src/test_ssol_data.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_ssol_device.c b/src/test_ssol_device.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_ssol_draw.c b/src/test_ssol_draw.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_ssol_geometries.h b/src/test_ssol_geometries.h @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_ssol_image.c b/src/test_ssol_image.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_ssol_instance.c b/src/test_ssol_instance.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_ssol_material.c b/src/test_ssol_material.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_ssol_materials.h b/src/test_ssol_materials.h @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_ssol_object.c b/src/test_ssol_object.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_ssol_param_buffer.c b/src/test_ssol_param_buffer.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_ssol_rect2D_geometry.h b/src/test_ssol_rect2D_geometry.h @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_ssol_rect_geometry.h b/src/test_ssol_rect_geometry.h @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_ssol_scene.c b/src/test_ssol_scene.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_ssol_shape.c b/src/test_ssol_shape.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_ssol_solver1.c b/src/test_ssol_solver1.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -49,8 +49,13 @@ main(int argc, char** argv) { struct spectrum_desc desc = {0}; struct mem_allocator allocator; + FILE* stream; struct ssol_device* dev; struct ssp_rng* rng; + struct ssp_rng* rng2; + const struct ssp_rng* rng_state; + struct ssp_rng_type rng_type0; + struct ssp_rng_type rng_type1; struct ssol_scene* scene; struct ssol_shape* dummy; struct ssol_shape* square; @@ -237,6 +242,23 @@ main(int argc, char** argv) CHK(ssol_estimator_get_mc_global(estimator, NULL) == RES_BAD_ARG); CHK(ssol_estimator_get_mc_global(estimator, &mc_global) == RES_OK); + CHK(ssol_estimator_get_rng_state(NULL, &rng_state) == RES_BAD_ARG); + CHK(ssol_estimator_get_rng_state(estimator, NULL) == RES_BAD_ARG); + CHK(ssol_estimator_get_rng_state(estimator, &rng_state) == RES_OK); + CHK(ssp_rng_get_type(rng_state, &rng_type0) == RES_OK); + CHK(ssp_rng_get_type(rng, &rng_type1) == RES_OK); + CHK(ssp_rng_type_eq(&rng_type0, &rng_type1)); + + /* Clone the rng_state */ + CHK(stream = tmpfile()); + CHK(ssp_rng_create(&allocator, &ssp_rng_threefry, &rng2) == RES_OK); + CHK(ssp_rng_write(rng_state, stream) == RES_OK); + rewind(stream); + CHK(ssp_rng_read(rng2, stream) == RES_OK); + CHK(fclose(stream) == 0); + CHK(ssp_rng_get(rng2) != ssp_rng_get(rng)); + CHK(ssp_rng_ref_put(rng2) == RES_OK); + CHK(ssol_estimator_ref_get(NULL) == RES_BAD_ARG); CHK(ssol_estimator_ref_get(estimator) == RES_OK); CHK(ssol_estimator_ref_put(NULL) == RES_BAD_ARG); @@ -303,7 +325,7 @@ main(int argc, char** argv) std = dbl; /* Target was sampled but shadowed by secondary */ CHK(ssol_estimator_get_mc_global(estimator, &mc_global) == RES_OK); - PRINT_GLOBAL(mc_global); + print_global(&mc_global); CHK(eq_eps(mc_global.shadowed.E, m, 2 * dbl) == 1); CHK(eq_eps(mc_global.missing.E, 2*m, 2*mc_global.missing.SE) == 1); CHK(GET_MC_RCV(NULL, NULL, SSOL_BACK, NULL) == RES_BAD_ARG); @@ -324,8 +346,8 @@ main(int argc, char** argv) CHK(GET_MC_RCV(estimator, target, SSOL_FRONT, &mc_rcv) == RES_OK); printf("Ir(target) = %g +/- %g\n", mc_rcv.incoming_flux.E, mc_rcv.incoming_flux.SE); - CHK(eq_eps(mc_rcv.incoming_flux.E, m, 2 * std) == 1); - CHK(eq_eps(mc_rcv.incoming_flux.SE, std, 1e-1) == 1); + CHK(eq_eps(mc_rcv.incoming_flux.E, m, 3 * std) == 1); + CHK(eq_eps(mc_rcv.incoming_flux.SE, std, std*1e-2) == 1); CHK(ssol_estimator_ref_put(estimator) == RES_OK); /* Sample primary mirror only; variance is low */ @@ -338,7 +360,7 @@ main(int argc, char** argv) m = 4 * DNI_cos; std = 0; CHK(ssol_estimator_get_mc_global(estimator, &mc_global) == RES_OK); - PRINT_GLOBAL(mc_global); + print_global(&mc_global); CHK(eq_eps(mc_global.shadowed.E, 0, 1e-4) == 1); CHK(eq_eps(mc_global.missing.E, m, 1e-4) == 1); CHK(eq_eps(mc_global.cos_factor.E, COS, 1e-4) == 1); @@ -364,7 +386,7 @@ main(int argc, char** argv) CHK(ssol_scene_detach_atmosphere(scene, atm) == RES_OK); CHK(ssol_atmosphere_ref_put(atm) == RES_OK); CHK(ssol_estimator_get_mc_global(estimator, &mc_global) == RES_OK); - PRINT_GLOBAL(mc_global); + print_global(&mc_global); CHK(eq_eps(mc_global.shadowed.E, 0, 1e-4) == 1); CHK(eq_eps(mc_global.missing.E, m, 1e-4) == 1); CHK(eq_eps(mc_global.cos_factor.E, COS, 1e-4) == 1); @@ -407,7 +429,7 @@ main(int argc, char** argv) a_m = REFLECTIVITY * 4 * K * DNI_cos; a_std = 0; CHK(ssol_estimator_get_mc_global(estimator, &mc_global) == RES_OK); - PRINT_GLOBAL(mc_global); + print_global(&mc_global); CHK(eq_eps(mc_global.shadowed.E, 0, 1e-4) == 1); CHK(eq_eps( mc_global.missing.E + mc_global.shadowed.E + mc_global.absorbed_by_receivers.E @@ -415,7 +437,7 @@ main(int argc, char** argv) m, 1e-4)); CHK(eq_eps(mc_global.cos_factor.E, COS, 1e-4) == 1); CHK(GET_MC_RCV(estimator, target, SSOL_FRONT, &mc_rcv) == RES_OK); - PRINT_RCV(mc_rcv); + print_rcv(&mc_rcv); CHK(ssol_estimator_get_sampled_count(estimator, &scount) == RES_OK); CHK(ssol_estimator_get_mc_sampled(estimator, heliostat, &sampled) == RES_BAD_ARG); CHK(ssol_estimator_get_mc_sampled(estimator, heliostat2, &sampled) == RES_OK); @@ -493,14 +515,14 @@ main(int argc, char** argv) m = 4 * K2 * DNI_cos; std = 0; CHK(ssol_estimator_get_mc_global(estimator, &mc_global) == RES_OK); - PRINT_GLOBAL(mc_global); + print_global(&mc_global); CHK(eq_eps(mc_global.shadowed.E, 0, 1e-4) == 1); CHK(eq_eps(mc_global.missing.E, m, 1e-4) == 1); CHK(eq_eps(mc_global.cos_factor.E, COS, 1e-4) == 1); CHK(GET_MC_RCV(estimator, target, SSOL_FRONT, &mc_rcv) == RES_OK); printf("Ir(target) = %g +/- %g\n", mc_rcv.incoming_flux.E, mc_rcv.incoming_flux.SE); - PRINT_RCV(mc_rcv); + print_rcv(&mc_rcv); CHK(eq_eps(mc_rcv.incoming_flux.E, m, 1e-4) == 1); CHK(eq_eps(mc_rcv.incoming_flux.SE, std, 1e-4) == 1); diff --git a/src/test_ssol_solver10.c b/src/test_ssol_solver10.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -135,8 +135,8 @@ main(int argc, char** argv) CHK(ssol_estimator_get_mc_global(estimator, &mc_global1) == RES_OK); CHK(GET_MC_RCV(estimator, geom1, SSOL_FRONT, &mc_rcv1) == RES_OK); - PRINT_GLOBAL(mc_global1); - PRINT_RCV(mc_rcv1); + print_global(&mc_global1); + print_rcv(&mc_rcv1); CHK(mc_global1.cos_factor.E == 1); CHK(mc_global1.cos_factor.SE == 0); CHK(mc_global1.absorbed_by_receivers.E == DNI_S); @@ -175,8 +175,8 @@ main(int argc, char** argv) CHK(ssol_estimator_get_mc_global(estimator, &mc_global2) == RES_OK); CHK(GET_MC_RCV(estimator, geom2, SSOL_FRONT, &mc_rcv2) == RES_OK); - PRINT_GLOBAL(mc_global2); - PRINT_RCV(mc_rcv2); + print_global(&mc_global2); + print_rcv(&mc_rcv2); CHK(eq_eps(mc_global2.absorbed_by_receivers.E, DNI_S, 3 * mc_global2.absorbed_by_receivers.SE) == 1); /* Free data */ diff --git a/src/test_ssol_solver11.c b/src/test_ssol_solver11.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -135,8 +135,8 @@ main(int argc, char** argv) CHK(ssol_estimator_get_mc_global(estimator, &mc_global1) == RES_OK); CHK(GET_MC_RCV(estimator, geom1, SSOL_FRONT, &mc_rcv1) == RES_OK); - PRINT_GLOBAL(mc_global1); - PRINT_RCV(mc_rcv1); + print_global(&mc_global1); + print_rcv(&mc_rcv1); CHK(mc_global1.cos_factor.E == 1); CHK(mc_global1.cos_factor.SE == 0); CHK(mc_global1.absorbed_by_receivers.E == DNI_S); @@ -175,8 +175,8 @@ main(int argc, char** argv) CHK(ssol_estimator_get_mc_global(estimator, &mc_global2) == RES_OK); CHK(GET_MC_RCV(estimator, geom2, SSOL_FRONT, &mc_rcv2) == RES_OK); - PRINT_GLOBAL(mc_global2); - PRINT_RCV(mc_rcv2); + print_global(&mc_global2); + print_rcv(&mc_rcv2); CHK(eq_eps(mc_global2.absorbed_by_receivers.E, DNI_S, 3 * mc_global2.absorbed_by_receivers.SE) == 1); /* Free data */ diff --git a/src/test_ssol_solver12.c b/src/test_ssol_solver12.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -135,8 +135,8 @@ main(int argc, char** argv) CHK(ssol_estimator_get_mc_global(estimator, &mc_global1) == RES_OK); CHK(GET_MC_RCV(estimator, geom1, SSOL_FRONT, &mc_rcv1) == RES_OK); - PRINT_GLOBAL(mc_global1); - PRINT_RCV(mc_rcv1); + print_global(&mc_global1); + print_rcv(&mc_rcv1); CHK(mc_global1.cos_factor.E == 1); CHK(mc_global1.cos_factor.SE == 0); CHK(mc_global1.absorbed_by_receivers.E == DNI_S); @@ -175,8 +175,8 @@ main(int argc, char** argv) CHK(ssol_estimator_get_mc_global(estimator, &mc_global2) == RES_OK); CHK(GET_MC_RCV(estimator, geom2, SSOL_FRONT, &mc_rcv2) == RES_OK); - PRINT_GLOBAL(mc_global2); - PRINT_RCV(mc_rcv2); + print_global(&mc_global2); + print_rcv(&mc_rcv2); CHK(eq_eps(mc_global2.absorbed_by_receivers.E, DNI_S, 3 * mc_global2.absorbed_by_receivers.SE) == 1); /* Free data */ diff --git a/src/test_ssol_solver2.c b/src/test_ssol_solver2.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_ssol_solver2b.c b/src/test_ssol_solver2b.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_ssol_solver3.c b/src/test_ssol_solver3.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_ssol_solver4.c b/src/test_ssol_solver4.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -154,7 +154,7 @@ main(int argc, char** argv) m2 = m1; std2 = std1; CHK(ssol_estimator_get_mc_global(estimator, &mc_global) == RES_OK); - PRINT_GLOBAL(mc_global); + print_global(&mc_global); CHK(eq_eps(mc_global.shadowed.E, 0, 1e-4) == 1); CHK(eq_eps(mc_global.missing.E, 400 * DNI_cos, 1e-2) == 1); /* virtual => 100 % missing */ CHK(GET_MC_RCV(estimator, target1, SSOL_FRONT, &mc_rcv) == RES_OK); diff --git a/src/test_ssol_solver5.c b/src/test_ssol_solver5.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_ssol_solver6.c b/src/test_ssol_solver6.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -51,6 +51,7 @@ main(int argc, char** argv) struct mem_allocator allocator; struct ssol_device* dev; struct ssp_rng* rng; + const struct ssp_rng* rng_state; struct ssol_object *m_object1; struct ssol_object *m_object2; struct ssol_object* t_object1; @@ -74,11 +75,14 @@ main(int argc, char** argv) struct ssol_sun* sun; struct ssol_spectrum* spectrum; struct ssol_estimator* estimator; + struct ssol_estimator* estimator2; struct ssol_mc_global mc_global; + struct ssol_mc_global mc_global2; struct ssol_mc_receiver mc_rcv; double dir[3]; double transform[12]; /* 3x4 column major matrix */ - + double sum_w, sum_w2, E, V, SE; + size_t count; (void) argc, (void) argv; mem_init_proxy_allocator(&allocator, &mem_default_allocator); @@ -177,8 +181,10 @@ main(int argc, char** argv) #define N__ 10000 #define GET_MC_RCV ssol_estimator_get_mc_receiver CHK(ssol_solve(scene, rng, N__, 0, NULL, &estimator) == RES_OK); + CHK(ssol_estimator_get_realisation_count(estimator, &count) == RES_OK); + CHK(count == N__); CHK(ssol_estimator_get_mc_global(estimator, &mc_global) == RES_OK); - PRINT_GLOBAL(mc_global); + print_global(&mc_global); CHK(eq_eps(mc_global.shadowed.E, 100000, 2 * 100000/sqrt(N__)) == 1); CHK(eq_eps(mc_global.missing.E, 0, 0) == 1); @@ -194,6 +200,39 @@ main(int argc, char** argv) CHK(eq_eps(mc_rcv.incoming_flux.E, 0, 1) == 1); CHK(mc_rcv.incoming_flux.E == mc_rcv.absorbed_flux.E); + /* Launch another run that is statistically independent of the first one and + * that uses 3 more times samples */ + CHK(ssol_estimator_get_rng_state(estimator, &rng_state) == RES_OK); + CHK(ssol_solve(scene, rng_state, N__*3, 0, NULL, &estimator2) == RES_OK); + + /* Check the estimator result */ + CHK(ssol_estimator_get_realisation_count(estimator2, &count) == RES_OK); + CHK(count == N__*3); + CHK(ssol_estimator_get_mc_global(estimator2, &mc_global2) == RES_OK); + CHK(eq_eps(mc_global2.shadowed.E, 100000, 2 * 100000/sqrt(N__)) == 1); + CHK(eq_eps(mc_global.shadowed.SE/sqrt(3), mc_global2.shadowed.SE, 1.e-1)); + + CHK(mc_global.shadowed.E != mc_global2.shadowed.E); + CHK(mc_global.shadowed.SE != mc_global2.shadowed.SE); + + /* Merge the 2 estimations */ + sum_w = mc_global.shadowed.E * N__; + sum_w += mc_global2.shadowed.E * N__*3; + V = mc_global.shadowed.SE * mc_global.shadowed.SE * N__; + sum_w2 = (V + mc_global.shadowed.E * mc_global.shadowed.E) * N__; + V = mc_global2.shadowed.SE * mc_global2.shadowed.SE * N__*3; + sum_w2 += (V + mc_global2.shadowed.E * mc_global2.shadowed.E) * N__*3; + E = sum_w / (4*N__); + V = sum_w2 / (4*N__) - E*E; + SE = sqrt(V/(4*N__)); + + /* Check that the 2 runs are effectively independent, i.e. check the + * convergence ratio. By combining the 2 runs we have 4 more times samples, + * the standard deviation must be thus devided by 2 while the estimate must + * be compatible with the right value regarding the new error */ + CHK(eq_eps(E, 100000, 3*SE)); + CHK(eq_eps(SE, mc_global.shadowed.SE / 2, SE*1.e-2)); + /* Free data */ CHK(ssol_instance_ref_put(heliostat1) == RES_OK); CHK(ssol_instance_ref_put(target1) == RES_OK); @@ -210,6 +249,7 @@ main(int argc, char** argv) CHK(ssol_material_ref_put(v_mtl) == RES_OK); CHK(ssol_device_ref_put(dev) == RES_OK); CHK(ssol_estimator_ref_put(estimator) == RES_OK); + CHK(ssol_estimator_ref_put(estimator2) == RES_OK); CHK(ssol_scene_ref_put(scene) == RES_OK); CHK(ssp_rng_ref_put(rng) == RES_OK); CHK(ssol_spectrum_ref_put(spectrum) == RES_OK); diff --git a/src/test_ssol_solver7.c b/src/test_ssol_solver7.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -196,7 +196,7 @@ main(int argc, char** argv) CHK(ssol_estimator_get_sampled_area(estimator, &area) == RES_OK); printf("Total = %g\n", area * DNI_cos); CHK(eq_eps(area * DNI_cos, TOTAL, TOTAL * 1e-4) == 1); - PRINT_GLOBAL(mc_global); + print_global(&mc_global); CHK(GET_MC_RCV(estimator, target, SSOL_FRONT, &mc_rcv) == RES_OK); printf("Abs(target1) = %g +/- %g\n", diff --git a/src/test_ssol_solver8.c b/src/test_ssol_solver8.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_ssol_solver9.c b/src/test_ssol_solver9.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -141,7 +141,7 @@ main(int argc, char** argv) #define DNI_TGT_S (DNI * TGT_X * TGT_Y) #define DNI_S (DNI * SZ * SZ) CHK(ssol_estimator_get_mc_global(estimator, &mc_global) == RES_OK); - PRINT_GLOBAL(mc_global); + print_global(&mc_global); CHK(eq_eps(mc_global.cos_factor.E, 1./3., 3 * mc_global.cos_factor.SE)); CHK(eq_eps(mc_global.shadowed.E, DNI_S, 3 * mc_global.shadowed.SE)); CHK(eq_eps(mc_global.missing.E, MMAX(DNI_S, DNI_TGT_S), diff --git a/src/test_ssol_spectrum.c b/src/test_ssol_spectrum.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_ssol_sun.c b/src/test_ssol_sun.c @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_ssol_utils.h b/src/test_ssol_utils.h @@ -1,4 +1,4 @@ -/* Copyright (C) CNRS 2016-2017 +/* Copyright (C) 2016-2018 CNRS, 2018-2019 |Meso|Star> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,47 +30,53 @@ check_memory_allocator(struct mem_allocator* allocator) } } -#define PRINT_GLOBAL(Mc) { \ - printf("Shadows = %g +/- %g; ", (Mc).shadowed.E, (Mc).shadowed.SE); \ - printf("Missing = %g +/- %g; ", (Mc).missing.E, (Mc).missing.SE); \ - printf("Receivers = %g +/- %g; ", \ - (Mc).absorbed_by_receivers.E, (Mc).absorbed_by_receivers.SE); \ - printf("Atmosphere = %g +/- %g; ", \ - (Mc).extinguished_by_atmosphere.E, (Mc).extinguished_by_atmosphere.SE); \ - printf("Other absorbed = %g +/- %g; ", \ - (Mc).other_absorbed.E, (Mc).other_absorbed.SE); \ - printf("Cos = %g +/- %g\n", (Mc).cos_factor.E, (Mc).cos_factor.SE); \ -} (void)0 +static INLINE void +print_global(const struct ssol_mc_global* mc) +{ + ASSERT(mc); + printf("Shadows = %g +/- %g; ", mc->shadowed.E, mc->shadowed.SE); + printf("Missing = %g +/- %g; ", mc->missing.E, mc->missing.SE); + printf("Receivers = %g +/- %g; ", + mc->absorbed_by_receivers.E, mc->absorbed_by_receivers.SE); + printf("Atmosphere = %g +/- %g; ", + mc->extinguished_by_atmosphere.E, mc->extinguished_by_atmosphere.SE); + printf("Other absorbed = %g +/- %g; ", + mc->other_absorbed.E, mc->other_absorbed.SE); + printf("Cos = %g +/- %g\n", mc->cos_factor.E, mc->cos_factor.SE); +} -#define PRINT_RCV(Rcv) { \ - printf("\tIncoming flux(target) = %g +/- %g \n", \ - (Rcv).incoming_flux.E, (Rcv).incoming_flux.SE); \ - printf("\tIncoming flux wo Atmosphere(target) = %g +/- %g (%.2g %%)\n", \ - (Rcv).incoming_if_no_atm_loss.E, (Rcv).incoming_if_no_atm_loss.SE, \ - 100 * (Rcv).incoming_if_no_atm_loss.E / (Rcv).incoming_flux.E); \ - printf("\tIncoming flux wo Field Loss(target) = %g +/- %g (%.2g %%)\n", \ - (Rcv).incoming_if_no_field_loss.E, (Rcv).incoming_if_no_field_loss.SE, \ - 100 * (Rcv).incoming_if_no_field_loss.E / (Rcv).incoming_flux.E); \ - printf("\tAtmospheric Loss on Incoming(target) = %g +/- %g (%.2g %%)\n", \ - (Rcv).incoming_lost_in_atmosphere.E, (Rcv).incoming_lost_in_atmosphere.SE, \ - 100 * (Rcv).incoming_lost_in_atmosphere.E / (Rcv).incoming_flux.E); \ - printf("\tOptical Field Loss(target) on Incoming = %g +/- %g (%.2g %%)\n", \ - (Rcv).incoming_lost_in_field.E, (Rcv).incoming_lost_in_field.SE, \ - 100 * (Rcv).incoming_lost_in_field.E / (Rcv).incoming_flux.E); \ - printf("\tAbsorbed flux(target) = %g +/- %g \n", \ - (Rcv).absorbed_flux.E, (Rcv).absorbed_flux.SE); \ - printf("\tAbsorbed flux wo Atmosphere(target) = %g +/- %g (%.2g %%)\n", \ - (Rcv).absorbed_if_no_atm_loss.E, (Rcv).absorbed_if_no_atm_loss.SE, \ - 100 * (Rcv).absorbed_if_no_atm_loss.E / (Rcv).absorbed_flux.E); \ - printf("\tAbsorbed flux wo Field Loss(target) = %g +/- %g (%.2g %%)\n", \ - (Rcv).absorbed_if_no_field_loss.E, (Rcv).absorbed_if_no_field_loss.SE, \ - 100 * (Rcv).absorbed_if_no_field_loss.E / (Rcv).absorbed_flux.E); \ - printf("\tAtmospheric Loss(target) on Absorbed = %g +/- %g (%.2g %%)\n", \ - (Rcv).absorbed_lost_in_atmosphere.E, (Rcv).absorbed_lost_in_atmosphere.SE, \ - 100 * (Rcv).absorbed_lost_in_atmosphere.E / (Rcv).absorbed_flux.E); \ - printf("\tOptical Field Loss(target) on Absorbed = %g +/- %g (%.2g %%)\n", \ - (Rcv).absorbed_lost_in_field.E, (Rcv).absorbed_lost_in_field.SE, \ - 100 * (Rcv).absorbed_lost_in_field.E / (Rcv).absorbed_flux.E); \ -} (void)0 +static INLINE void +print_rcv(const struct ssol_mc_receiver* rcv) +{ + ASSERT(rcv); + printf("\tIncoming flux(target) = %g +/- %g \n", + rcv->incoming_flux.E, rcv->incoming_flux.SE); + printf("\tIncoming flux wo Atmosphere(target) = %g +/- %g (%.2g %%)\n", + rcv->incoming_if_no_atm_loss.E, rcv->incoming_if_no_atm_loss.SE, + 100 * rcv->incoming_if_no_atm_loss.E / rcv->incoming_flux.E); + printf("\tIncoming flux wo Field Loss(target) = %g +/- %g (%.2g %%)\n", + rcv->incoming_if_no_field_loss.E, rcv->incoming_if_no_field_loss.SE, + 100 * rcv->incoming_if_no_field_loss.E / rcv->incoming_flux.E); + printf("\tAtmospheric Loss on Incoming(target) = %g +/- %g (%.2g %%)\n", + rcv->incoming_lost_in_atmosphere.E, rcv->incoming_lost_in_atmosphere.SE, + 100 * rcv->incoming_lost_in_atmosphere.E / rcv->incoming_flux.E); + printf("\tOptical Field Loss(target) on Incoming = %g +/- %g (%.2g %%)\n", + rcv->incoming_lost_in_field.E, rcv->incoming_lost_in_field.SE, + 100 * rcv->incoming_lost_in_field.E / rcv->incoming_flux.E); + printf("\tAbsorbed flux(target) = %g +/- %g \n", + rcv->absorbed_flux.E, rcv->absorbed_flux.SE); + printf("\tAbsorbed flux wo Atmosphere(target) = %g +/- %g (%.2g %%)\n", + rcv->absorbed_if_no_atm_loss.E, rcv->absorbed_if_no_atm_loss.SE, + 100 * rcv->absorbed_if_no_atm_loss.E / rcv->absorbed_flux.E); + printf("\tAbsorbed flux wo Field Loss(target) = %g +/- %g (%.2g %%)\n", + rcv->absorbed_if_no_field_loss.E, rcv->absorbed_if_no_field_loss.SE, + 100 * rcv->absorbed_if_no_field_loss.E / rcv->absorbed_flux.E); + printf("\tAtmospheric Loss(target) on Absorbed = %g +/- %g (%.2g %%)\n", + rcv->absorbed_lost_in_atmosphere.E, rcv->absorbed_lost_in_atmosphere.SE, + 100 * rcv->absorbed_lost_in_atmosphere.E / rcv->absorbed_flux.E); + printf("\tOptical Field Loss(target) on Absorbed = %g +/- %g (%.2g %%)\n", + rcv->absorbed_lost_in_field.E, rcv->absorbed_lost_in_field.SE, + 100 * rcv->absorbed_lost_in_field.E / rcv->absorbed_flux.E); +} #endif /* TEST_SSOL_UTILS_H */