Commit b5f721bd authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Provide a BASH example script for convergence tests

parent 61dcf9ec
Loading
Loading
Loading
Loading
+51 −0
Original line number Diff line number Diff line
#!/bin/bash

# Script settings
l_start=2 # first order to test
l_end=40 # last order to test
wavelength="1.000E-06" # wavelength to test (use your shortest one)
dielec_real="2.6015926E+00" # real part of dielectric function
dielec_imag="3.8710688E-04" # imaginary part of dielectric function
radius=$1 # radius is read from command line
ompthreads="" # OMP threads to use (default is "1,NPROC")

# Script execution starts here
if [ "x${ompthreads}" = "x" ]; then
    NPROC=$(nproc)
    ompthreads="1,${NPROC}" # OMP threads settings
fi
li=${l_start}
echo "#Wavelength,ScaSec,AbsSec,ExtSec,LI" > convergence.csv
while [ $((li)) -le ${l_end} ]
do
    fold_index=$(python -c "print('{0:02d}'.format($li))")
    str_index=$(python -c "print('{0:2d}'.format($li))")
    folder="li_${fold_index}"
    echo $li
    mkdir -p $folder
    cd $folder
    cat > DEDFB <<EOF
   1  0
 1.0000000E+00 3.0000000E+08 1.0000000E+00  0    1    0   3
1.000E-06
    1
  1     ${radius}
 1.00000E+00
(${dielec_real},${dielec_imag})
0
EOF
    cat > DSPH <<EOF
    1   ${str_index}    0  149  300    0
 0.00E+00  0.00E+00  0.00E+00  0.00E+00  0.00E+00  0.00E+00
 0.00E+00  0.00E+00  0.00E+00  0.00E+00  0.00E+00  0.00E+00
 1
0
USE_DYN_ORDERS=0
EOF
    OMP_NUM_THREADS=${ompthreads} /home/lamura/Programming/gits/np_tmcode/build/sphere/np_sphere DEDFB DSPH .
    /home/lamura/Programming/gits/np_tmcode/src/scripts/parse_output.py --app=SPH --in c_OSPH --out convergence
    cd ..
    str_line=$(tail -1 ${folder}/convergence_ics.csv)
    echo "${str_line},${fold_index}" >> convergence.csv
    li=$((li+1))
done