schiff

Estimate the radiative properties of soft particless
git clone git://git.meso-star.com/schiff.git
Log | Files | Refs | README | LICENSE

commit 81d8ce44788de8a8b4fc45b5af9c82ce1e6e867f
parent cb39be62c3f8146ecb94c7b71f08fac8f965c57f
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Mon, 21 Mar 2016 16:33:54 +0100

Add the test_schiff_sphere test script

Diffstat:
Mcmake/CMakeLists.txt | 8+++++++-
Msrc/test_schiff_cylinder.sh | 3+--
Asrc/test_schiff_sphere.sh | 106+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 114 insertions(+), 3 deletions(-)

diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -108,8 +108,14 @@ else() add_test( NAME test_schiff_cylinder COMMAND + ${_env} PATH=$ENV{PATH}:$<TARGET_FILE_DIR:schiff> + ${_bash} ${SCHIFF_SOURCE_DIR}/test_schiff_cylinder.sh) + add_test( + NAME test_schiff_sphere + COMMAND ${_env} PATH=$ENV{PATH}:$<TARGET_FILE_DIR:schiff> - ${_bash} ${SCHIFF_SOURCE_DIR}/test_schiff_cylinder.sh) + ${_bash} ${SCHIFF_SOURCE_DIR}/test_schiff_sphere.sh + WORKING_DIRECTORY ${_test_sphere_path}) endif() ################################################################################ diff --git a/src/test_schiff_cylinder.sh b/src/test_schiff_cylinder.sh @@ -1,5 +1,4 @@ #!/bin/bash -# # Copyright (C) 2015-2016 CNRS # # This program is free software: you can redistribute it and/or modify @@ -381,7 +380,7 @@ then -A $nangles \ -l $mean_radius \ -i $tmppipe \ - -w ${wavelength} \ + -w $wavelength \ -g $nrealisations \ -d $ndirs >> $tmpfile \ || true # inhibit the "set -e" comportment on failure diff --git a/src/test_schiff_sphere.sh b/src/test_schiff_sphere.sh @@ -0,0 +1,106 @@ +#!/bin/bash +# Copyright (C) 2015-2016 CNRS +# +# 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +tmpfile=schiff_result +tmppipe=schiff_pipe +tmpprefix=xxschiff + +nrealisations=1000 +nangles=100 +ndirs=100 +wavelength=0.6 # in micron (in vacuum) +Nr=1.1 # Real relative refractive index +Kr=0.004 # Imaginary relative refractive index +Ne=1.33333 # Refractive index of the medium +sigma=1.18 +mean_radius=(1.0 3.22 5.44 7.67 9.89 12.1 14.3 16.6 19.0 21.0) + +# Extinction Absorption Scattering +references=( + "8.39 0.484 7.90" + "69.3 13.4 55.9" + "197 54.6 143" + "392 131 261" + "651 243 408" + "975 393 582" + "1370 578 787" + "1820 799 1020" + "2390 1080 1310" + "2930 1350 1580" +) + +# print whether or not the $1 is equal to $2 +/- 4*$3 +eq_eps(){ + echo -e\ + "scale=20\n"\ + "dst = $1 - $2\n"\ + "if(dst <0) dst = -dst\n"\ + "dst < 4*$3\n" | bc -l +} + +set -e +cd `mktemp -d` +pwd + +if [ ! -e $tmppipe ]; then mkfifo $tmppipe; fi + +if [ ! -f $tmpfile ] +then + for zeta in ${mean_radius[*]} + do + # Generate the geometry distribution into the pipe + echo -e \ + "sphere:\n" \ + " radius: { lognormal: { zeta: $zeta, sigma: $sigma } }" \ + > $tmppipe & + + # invoke the schiff command + echo $wavelength $Nr $Kr $Ne | \ + schiff -q \ + -A $nangles \ + -l $zeta \ + -i $tmppipe \ + -w $wavelength \ + -g $nrealisations \ + -d $ndirs >> $tmpfile \ + || true # inhibit the "set -e" comportment on failure + done +fi + +err=0 # error code + +for ((i=0; i < ${#mean_radius[@]}; ++i)) +do + xsection=(`sed -n "$(($i*($nangles+4)+1))p" $tmpfile | sed 's/^\S*\(.*\)$/\1/g'`) + reference=(`echo ${references[$i]}`) + + extinction=$(eq_eps ${reference[0]} ${xsection[0]} ${xsection[1]}) + absorption=$(eq_eps ${reference[1]} ${xsection[2]} ${xsection[3]}) + scattering=$(eq_eps ${reference[2]} ${xsection[4]} ${xsection[5]}) + + echo -n "${mean_radius[$i]} " + if [ $extinction -eq 0 -o $absorption -eq 0 -o $scattering -eq 0 ] + then + echo FAILURE + err=1 # notify the error + else + echo OK + fi +done + +rm $tmppipe + +exit 0