3 Commits

Author SHA1 Message Date
glavic_a c14f216216 WFM simulation analysis helpers 2018-09-16 15:46:16 +02:00
glavic_a a73791a813 fix sbatch script for mcc 2018-09-16 14:36:08 +02:00
glavic_a d92e071e10 Add Estia Rapid Subdivision Addon (ERSA) WFM device 2018-09-16 14:12:01 +02:00
5 changed files with 373 additions and 2 deletions
+93
View File
@@ -0,0 +1,93 @@
#!/usr/bin/env python
from numpy import *
import mcstas_reader as mr
l=arange(3,11,0.01)
lp=(l[1:]+l[:-1])/2.
t=arange(0.0, 0.18, 0.0001)
tp=(t[1:]+t[:-1])/2.
def get_pulses(fn, freq, offset=0.002):
det=mr.McSim(fn)['tof_detector']
pulses=[]
for i in range(int(freq/7)):
li, Ii=det.project1d('L', bins=l, newcols=[('tc', 't-L*0.00406-%f'%offset)],
fltr='(tc>%f)&(tc<%f)'%(i*1./freq, (i+1)*1./freq))
ti, Iti=det.project1d('t', bins=t, newcols=[('tc', 't-L*0.00406-%f'%offset)],
fltr='(tc>%f)&(tc<%f)'%(i*1./freq, (i+1)*1./freq))
pulses.append(((li[1:]+li[:-1])/2., Ii, (ti[1:]+ti[:-1])/2., Iti))
return det, pulses
def get_filtered_pulses(det, pulses, freq, offset=0.0001, threashold=0.01):
Is=array([pi[3] for pi in pulses])
fpulses=[]
for i in range(1,int(freq/7)-1):
fltr=(Is[:i].sum(axis=0)+Is[i+1:].sum(axis=0))<(threashold*Is[i])
tf=tp[fltr]
if len(tf)<2:
continue
li, Ii=det.project1d('L', bins=l, fltr='(t>%f)&(t<%f)'%(tf[0], tf[-1]))
ti, Iti=det.project1d('t', bins=t, fltr='(t>%f)&(t<%f)'%(tf[0], tf[-1]))
fpulses.append(((li[1:]+li[:-1])/2., Ii, (ti[1:]+ti[:-1])/2., Iti))
return fpulses
def calc_usable(pulses, threashold=0.01):
Is=array([pi[3] for pi in pulses])
sI=0.
for i in range(1,Is.shape[0]):
sI+=Is[i][(Is[:i].sum(axis=0)+Is[i+1:].sum(axis=0))<(threashold*Is[i])].sum()
return sI
def calc_sum(pulses):
Is=array([pi[3] for pi in pulses])
return Is.sum(axis=0)
def tof_plot(det, pulses):
figure(figsize=(18,10))
for i, pi in enumerate(pulses):
semilogy(tp, pi[3], label='%i'%i)
ylim(100,1e5)
def tof_th_plot(det, pulses, threashold=0.01):
figure(figsize=(18,10))
Is=array([pi[3] for pi in pulses])
for i, pi in enumerate(pulses):
fltr=(Is[:i].sum(axis=0)+Is[i+1:].sum(axis=0))<(threashold*Is[i])
semilogy(tp[fltr], pi[3][fltr], label='%i'%i)
ylim(100,1e5)
def lambda_plot(det, pulses):
figure(figsize=(18,10))
for i, pi in enumerate(pulses):
semilogy(lp, pi[1])
semilogy(lp, det.project1d('L', bins=l)[1])
semilogy(lp, Ir)
ylim(100,1e6)
xlim(3,11)
def export(fn, pulses):
It=calc_sum(pulses)
savetxt(fn+'_lpulses.dat', array([pules[0][0], It, Ir]+[pi[1] for pi in pulses]).T)
savetxt(fn+'_tpulses.dat', array([pules[0][2]]+[pi[3] for pi in pulses]).T)
ref=mr.McSim('../results/ersa_ref/')['tof_detector']
Ir=ref.project1d('L', bins=l)[1]
freq_offsets={245: 0.00007, 280: 0.002, 308: 0.0015, 350: 0.003}
rfreq_offsets={245: 0.0000, 280: 0.0002, 308: 0.0015, 350: 0.0007}
results={}
for key,val in freq_offsets.items():
results['%i'%key]=get_pulses('../results/ersa_%iHz/'%key, 2.*key, val)
try:
results['r300-%i'%key]=get_pulses('../results/ersa_r300_%iHz/'%key, 2.*key, val)
except:
continue
for key,val in rfreq_offsets.items():
results['rev-%i'%key]=get_pulses('../results/ersa_reverse_%iHz/'%key, 2.*key, val)
+3 -2
View File
@@ -52,8 +52,9 @@ DEFINE INSTRUMENT ESS_reflectometer_Estia
(double omegaa = 1.2, int sample = 0, double sample_length = 0.01, double sample_height = 0.01,
int operationmode = 0, double over_illumination = 0.0, double theta_resolution = 0.04,
double lambda_min = 3.75, double lambda_start = 3.0, double lambda_end = 12.0,
int enable_chopper = 0, int enable_gravity=0, int enable_windows=1,
int enable_polarizer = 0, int enable_analyzer = 0,
int enable_chopper = 0, int enable_gravity=0, int enable_windows=1,
double wfm_freq=0.0, double wfm_shift=0.0, double wfm_radius=0.15,
int enable_polarizer = 0, int enable_analyzer = 0,
double source_power = 2,
double selene1_foot1y =0.0, double selene1_foot2y = 0.0
)
+76
View File
@@ -63,6 +63,10 @@ REMOVABLE COMPONENT source = Moderator(radius = 0.001, focus_xw = selene_entry+0
AT (0,0,0) RELATIVE ISCS
ROTATED (-1.25, 1.25, 0) RELATIVE ISCS
COMPONENT arm_ersa = Arm()
AT (0, 0, 0) RELATIVE arm_selene2
ROTATED (0, -selene_theta, 0) RELATIVE arm_selene2
/**************************************
* Middle focus between Selene guides *
@@ -78,6 +82,78 @@ COMPONENT polarizer1 = Polariser(nIncRefr=1, d_substrate = 5e-4, reflect_d=0, re
ROTATED (0,0,90.0) RELATIVE arm_polarizer
COMPONENT ersa_01 = DiskChopper(radius=wfm_radius, yheight=0.05,
theta_0=120, phase=60+wfm_shift*180,
nu=wfm_freq, nslit=2)
WHEN wfm_freq>0
AT (0, 0, -0.08) RELATIVE arm_ersa
COMPONENT ersa_02 = DiskChopper(radius=wfm_radius, yheight=0.05,
theta_0=120, phase=75+wfm_shift*180,
nu=wfm_freq, nslit=2)
WHEN wfm_freq>0
AT (0, 0, -0.07) RELATIVE arm_ersa
COMPONENT ersa_03 = DiskChopper(radius=wfm_radius, yheight=0.05,
theta_0=120, phase=90+wfm_shift*180,
nu=wfm_freq, nslit=2)
WHEN wfm_freq>0
AT (0, 0, -0.06) RELATIVE arm_ersa
COMPONENT ersa_04 = DiskChopper(radius=wfm_radius, yheight=0.05,
theta_0=120, phase=105+wfm_shift*180,
nu=wfm_freq, nslit=2)
WHEN wfm_freq>0
AT (0, 0, -0.05) RELATIVE arm_ersa
COMPONENT ersa_05 = DiskChopper(radius=wfm_radius, yheight=0.05,
theta_0=120, phase=120+wfm_shift*180,
nu=wfm_freq, nslit=2)
WHEN wfm_freq>0
AT (0, 0, -0.04) RELATIVE arm_ersa
COMPONENT ersa_05b = DiskChopper(radius=wfm_radius, yheight=0.05,
theta_0=45, phase=-22.5+wfm_shift*180,
nu=wfm_freq, nslit=2)
WHEN wfm_freq<0
AT (0, 0, -0.04) RELATIVE arm_ersa
COMPONENT ersa_11b = DiskChopper(radius=wfm_radius, yheight=0.05,
theta_0=45, phase=22.5+wfm_shift*180,
nu=wfm_freq, nslit=2)
WHEN wfm_freq<0
AT (0, 0, 0.04) RELATIVE arm_ersa
COMPONENT ersa_11 = DiskChopper(radius=wfm_radius, yheight=0.05,
theta_0=120, phase=120+wfm_shift*180,
nu=wfm_freq, nslit=2)
WHEN wfm_freq>0
AT (0, 0, 0.04) RELATIVE arm_ersa
COMPONENT ersa_12 = DiskChopper(radius=wfm_radius, yheight=0.05,
theta_0=120, phase=135+wfm_shift*180,
nu=wfm_freq, nslit=2)
WHEN wfm_freq>0
AT (0, 0, 0.05) RELATIVE arm_ersa
COMPONENT ersa_13 = DiskChopper(radius=wfm_radius, yheight=0.05,
theta_0=120, phase=150+wfm_shift*180,
nu=wfm_freq, nslit=2)
WHEN wfm_freq>0
AT (0, 0, 0.06) RELATIVE arm_ersa
COMPONENT ersa_14 = DiskChopper(radius=wfm_radius, yheight=0.05,
theta_0=120, phase=165+wfm_shift*180,
nu=wfm_freq, nslit=2)
WHEN wfm_freq>0
AT (0, 0, 0.07) RELATIVE arm_ersa
COMPONENT ersa_15 = DiskChopper(radius=wfm_radius, yheight=0.05,
theta_0=120, phase=180+wfm_shift*180,
nu=wfm_freq, nslit=2)
WHEN wfm_freq>0
AT (0, 0, 0.08) RELATIVE arm_ersa
/* The proximal polariser comes next */
COMPONENT polarizer2 = Polariser(nIncRefr=1, d_substrate = 5e-4, reflect_d=0, reflect_u=0, lin=polarizer_start, length=polarizer_length,
delta_theta=(Theta1_polarizer+Theta2_polarizer)*PI/180.0, h2=0.1, h1=0.05, abs_ref=1, m_u=4.0, m_d=0.65, both_coated=1, alpha=2.3, W = 0.0014)
+177
View File
@@ -0,0 +1,177 @@
#!/bin/bash
DEST=../results
ncount=2e10
use_cores=$SLURM_NPROCS
sample=1
omega=5.0
sample_length=0.01
sample_height=0.01
lambda_start=3.00
lambda_end=15.0
######################## 1% WFM for 30cm and 60cm device #######################
DESTi=$DEST/ersa_245Hz
if [ -e "$DESTi" ]; then
rm -r "$DESTi"
fi
mpirun -np $use_cores Estia_baseline.out \
--dir="$DESTi" --format=NeXuS --ncount=$ncount --gravitation \
omegaa=$omega operationmode=0 theta_resolution=0.04 over_illumination=0.001 \
sample=$sample sample_length=$sample_length sample_height=$sample_height \
enable_windows=0 wfm_freq=245 wfm_shift=0.0 \
lambda_start=$lambda_start lambda_end=$lambda_end enable_gravity=1 enable_chopper=1
DESTi=$DEST/ersa_280Hz
if [ -e "$DESTi" ]; then
rm -r "$DESTi"
fi
mpirun -np $use_cores Estia_baseline.out \
--dir="$DESTi" --format=NeXuS --ncount=$ncount --gravitation \
omegaa=$omega operationmode=0 theta_resolution=0.04 over_illumination=0.001 \
sample=$sample sample_length=$sample_length sample_height=$sample_height \
enable_windows=0 wfm_freq=280 wfm_shift=0.0 \
lambda_start=$lambda_start lambda_end=$lambda_end enable_gravity=1 enable_chopper=1
DESTi=$DEST/ersa_308Hz
if [ -e "$DESTi" ]; then
rm -r "$DESTi"
fi
mpirun -np $use_cores Estia_baseline.out \
--dir="$DESTi" --format=NeXuS --ncount=$ncount --gravitation \
omegaa=$omega operationmode=0 theta_resolution=0.04 over_illumination=0.001 \
sample=$sample sample_length=$sample_length sample_height=$sample_height \
enable_windows=0 wfm_freq=308 wfm_shift=0.0 \
lambda_start=$lambda_start lambda_end=$lambda_end enable_gravity=1 enable_chopper=1
DESTi=$DEST/ersa_350Hz
if [ -e "$DESTi" ]; then
rm -r "$DESTi"
fi
mpirun -np $use_cores Estia_baseline.out \
--dir="$DESTi" --format=NeXuS --ncount=$ncount --gravitation \
omegaa=$omega operationmode=0 theta_resolution=0.04 over_illumination=0.001 \
sample=$sample sample_length=$sample_length sample_height=$sample_height \
enable_windows=0 wfm_freq=350 wfm_shift=0.0 \
lambda_start=$lambda_start lambda_end=$lambda_end enable_gravity=1 enable_chopper=1
DESTi=$DEST/ersa_r300_245Hz
if [ -e "$DESTi" ]; then
rm -r "$DESTi"
fi
mpirun -np $use_cores Estia_baseline.out \
--dir="$DESTi" --format=NeXuS --ncount=$ncount --gravitation \
omegaa=$omega operationmode=0 theta_resolution=0.04 over_illumination=0.001 \
sample=$sample sample_length=$sample_length sample_height=$sample_height \
enable_windows=0 wfm_freq=245 wfm_shift=0.0 wfm_radius=0.3 \
lambda_start=$lambda_start lambda_end=$lambda_end enable_gravity=1 enable_chopper=1
DESTi=$DEST/ersa_r300_280Hz
if [ -e "$DESTi" ]; then
rm -r "$DESTi"
fi
mpirun -np $use_cores Estia_baseline.out \
--dir="$DESTi" --format=NeXuS --ncount=$ncount --gravitation \
omegaa=$omega operationmode=0 theta_resolution=0.04 over_illumination=0.001 \
sample=$sample sample_length=$sample_length sample_height=$sample_height \
enable_windows=0 wfm_freq=280 wfm_shift=0.0 wfm_radius=0.3 \
lambda_start=$lambda_start lambda_end=$lambda_end enable_gravity=1 enable_chopper=1
DESTi=$DEST/ersa_r300_308Hz
if [ -e "$DESTi" ]; then
rm -r "$DESTi"
fi
mpirun -np $use_cores Estia_baseline.out \
--dir="$DESTi" --format=NeXuS --ncount=$ncount --gravitation \
omegaa=$omega operationmode=0 theta_resolution=0.04 over_illumination=0.001 \
sample=$sample sample_length=$sample_length sample_height=$sample_height \
enable_windows=0 wfm_freq=308 wfm_shift=0.0 wfm_radius=0.3 \
lambda_start=$lambda_start lambda_end=$lambda_end enable_gravity=1 enable_chopper=1
DESTi=$DEST/ersa_r300_350Hz
if [ -e "$DESTi" ]; then
rm -r "$DESTi"
fi
mpirun -np $use_cores Estia_baseline.out \
--dir="$DESTi" --format=NeXuS --ncount=$ncount --gravitation \
omegaa=$omega operationmode=0 theta_resolution=0.04 over_illumination=0.001 \
sample=$sample sample_length=$sample_length sample_height=$sample_height \
enable_windows=0 wfm_freq=350 wfm_shift=0.0 wfm_radius=0.3 \
lambda_start=$lambda_start lambda_end=$lambda_end enable_gravity=1 enable_chopper=1
###################### 0.5% WFM ########################
ncount=4e10
DESTi=$DEST/ersa_reverse_280Hz
if [ -e "$DESTi" ]; then
rm -r "$DESTi"
fi
mpirun -np $use_cores Estia_baseline.out \
--dir="$DESTi" --format=NeXuS --ncount=$ncount \
omegaa=$omega operationmode=0 theta_resolution=0.04 over_illumination=0.001 \
sample=$sample sample_length=$sample_length sample_height=$sample_height \
enable_windows=0 wfm_freq=-280 wfm_shift=0.0 \
lambda_start=$lambda_start lambda_end=$lambda_end enable_gravity=0 enable_chopper=1
DESTi=$DEST/ersa_reverse_308Hz
if [ -e "$DESTi" ]; then
rm -r "$DESTi"
fi
mpirun -np $use_cores Estia_baseline.out \
--dir="$DESTi" --format=NeXuS --ncount=$ncount \
omegaa=$omega operationmode=0 theta_resolution=0.04 over_illumination=0.001 \
sample=$sample sample_length=$sample_length sample_height=$sample_height \
enable_windows=0 wfm_freq=-308 wfm_shift=0.0 \
lambda_start=$lambda_start lambda_end=$lambda_end enable_gravity=0 enable_chopper=1
DESTi=$DEST/ersa_reverse_350Hz
if [ -e "$DESTi" ]; then
rm -r "$DESTi"
fi
mpirun -np $use_cores Estia_baseline.out \
--dir="$DESTi" --format=NeXuS --ncount=$ncount \
omegaa=$omega operationmode=0 theta_resolution=0.04 over_illumination=0.001 \
sample=$sample sample_length=$sample_length sample_height=$sample_height \
enable_windows=0 wfm_freq=-350 wfm_shift=0.0 \
lambda_start=$lambda_start lambda_end=$lambda_end enable_gravity=0 enable_chopper=1
##################### Reference run ###############################
ncount=1e10
DESTi=$DEST/ersa_ref
if [ -e "$DESTi" ]; then
rm -r "$DESTi"
fi
mpirun -np $use_cores Estia_baseline.out \
--dir="$DESTi" --format=NeXuS --ncount=$ncount --gravitation \
omegaa=$omega operationmode=0 theta_resolution=0.04 over_illumination=0.001 \
sample=$sample sample_length=$sample_length sample_height=$sample_height \
enable_windows=0 wfm_freq=0 \
lambda_start=$lambda_start lambda_end=$lambda_end enable_gravity=1 enable_chopper=1
+24
View File
@@ -0,0 +1,24 @@
#!/bin/tcsh
#SBATCH -J wfm_McEstia
#SBATCH -N 2
#SBATCH --ntasks-per-node=24
#SBATCH --time=1-00:00:00
#SBATCH --mail-type=fail
#SBATCH --mail-user=artur.glavic@psi.ch
#SBATCH -o stdout.log
#SBATCH -e stderr.log
#SBATCH --partition=ll_long
echo "Starting at `date`"
echo "Running on hosts: $SLURM_NODELIST"
echo "Running on $SLURM_NNODES nodes."
echo "Running on $SLURM_NPROCS processors."
echo "Current working directory is `pwd`"
module load mcstas
bash compile_if_needed.sh
bash run_wfm.sh