star-schiff

Library for estimating radiative properties
git clone git://git.meso-star.com/star-schiff.git
Log | Files | Refs | README | LICENSE

commit 9fe15422814b4717ef3445b33e0ec8736dcfa2ce
parent cfd01ee7e289d0f7d155c00833e079116e9103b2
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Mon,  4 Apr 2016 14:48:38 +0200

Use the volume scaling distribution in the rhodo test

Diffstat:
Msrc/test_sschiff_estimator_rhodo.c | 39++++++++++++++++++++++++++-------------
1 file changed, 26 insertions(+), 13 deletions(-)

diff --git a/src/test_sschiff_estimator_rhodo.c b/src/test_sschiff_estimator_rhodo.c @@ -2531,8 +2531,8 @@ static const double inverse_cumulative[] = { }; struct sampler_context { - struct geometry geometry; - double aspect_ratio; + struct s3d_shape* shape; + double cylinder_volume; double mean_radius; double sigma; }; @@ -2557,19 +2557,15 @@ sample_cylinder void* sampler_context) { struct sampler_context* sampler_ctx = sampler_context; - struct cylinder cylinder; + double sphere_volume; double sample; - (void)rng, (void)sampler_context; NCHECK(volume_scaling, NULL); sample = ssp_ran_lognormal(rng, log(sampler_ctx->mean_radius), log(sampler_ctx->sigma)); - cylinder.geometry = &sampler_ctx->geometry; - cylinder.radius = (float)(sample / pow(3.0 / (2.0*sampler_ctx->aspect_ratio), 1.0/3.0)); - cylinder.height = (float)(2.f * cylinder.radius / sampler_ctx->aspect_ratio); - *volume_scaling = 1.0; - - return cylinder_setup_s3d_shape(&cylinder, shape); + sphere_volume = 4.0*PI*sample*sample*sample / 3.0; + *volume_scaling = sphere_volume / sampler_ctx->cylinder_volume; + return s3d_mesh_copy(sampler_ctx->shape, shape); } struct cross_section_result { @@ -2585,6 +2581,8 @@ int main(int argc, char** argv) { struct mem_allocator allocator; + struct s3d_device* s3d = NULL; + struct s3d_shape* shape = NULL; struct sampler_context sampler_ctx; struct sschiff_device* dev; struct sschiff_geometry_distribution distrib = SSCHIFF_NULL_GEOMETRY_DISTRIBUTION; @@ -2592,6 +2590,8 @@ main(int argc, char** argv) struct sschiff_cross_section cross_section; struct ssp_rng* rng; struct sschiff_state result, result2; + struct geometry geometry; + struct cylinder cylinder; const struct sschiff_state* val; const struct sschiff_state* func = NULL; const struct sschiff_state* cumul = NULL; @@ -2599,7 +2599,9 @@ main(int argc, char** argv) double* thetas = NULL; double interval[2]; double n; + double cylinder_volume; const double* angles = NULL; + const double aspect_ratio = 0.263; const double wavelength = 0.5; /* In micron */ const size_t nscatt_angles = 1000; const size_t ngeoms = 1000; @@ -2610,11 +2612,18 @@ main(int argc, char** argv) (void)argc, (void)argv; mem_init_proxy_allocator(&allocator, &mem_default_allocator); + CHECK(s3d_device_create(NULL, &allocator, 0, &s3d), RES_OK); + CHECK(s3d_shape_create_mesh(s3d, &shape), RES_OK); CHECK(ssp_rng_create(&allocator, &ssp_rng_threefry, &rng), RES_OK); CHECK(sschiff_device_create (NULL, &allocator, SSCHIFF_NTHREADS_DEFAULT, 1, NULL, &dev), RES_OK); - geometry_init_cylinder(&sampler_ctx.geometry, 64); + geometry_init_cylinder(&geometry, 64); + cylinder.geometry = &geometry; + cylinder.radius = 1.f; + cylinder.height = (float)(cylinder.radius / aspect_ratio * 2.0); + cylinder_setup_s3d_shape(&cylinder, shape); + cylinder_volume = PI * cylinder.radius * cylinder.radius * cylinder.height; cross_section_result.extinction_E = 2.81307852441391; cross_section_result.extinction_SE = 7.86230094748024e-4; @@ -2623,9 +2632,10 @@ main(int argc, char** argv) cross_section_result.absorption_E = 1.78192486614360e-1; cross_section_result.absorption_SE = 3.44690633379987e-5; - sampler_ctx.aspect_ratio = 0.263; sampler_ctx.mean_radius = 0.983; sampler_ctx.sigma = 1.1374; + sampler_ctx.shape = shape; + sampler_ctx.cylinder_volume = cylinder_volume; distrib.characteristic_length = 0.38190884533484676025; distrib.material.get_property = get_material_property; @@ -2845,7 +2855,10 @@ main(int argc, char** argv) CHECK(sschiff_device_ref_put(dev), RES_OK); CHECK(ssp_rng_ref_put(rng), RES_OK); - geometry_release(&sampler_ctx.geometry); + CHECK(s3d_device_ref_put(s3d), RES_OK); + CHECK(s3d_shape_ref_put(shape), RES_OK); + + geometry_release(&geometry); check_memory_allocator(&allocator); mem_shutdown_proxy_allocator(&allocator); CHECK(mem_allocated_size(), 0);