/******************************************************************************* * * McStas, neutron ray-tracing package * Copyright 1997-2002, All rights reserved * Risoe National Laboratory, Roskilde, Denmark * Institut Laue Langevin, Grenoble, France * * Component: TOF_PSD_monitor_rad * * %Identification * Written by: Kim Lefmann * Modified from: PSD_monitor_rad by Henrich Frielinghaus, FZJuelich * Date: March 2012 * Origin: UCPH * Modified by: * * Position-sensitive TOF monitor with radially averaging. * * %D * TOF monitor that performs radial averaging. * Comment: The intensity is given as two 2D files: * 1) a radial sum vs. TOF * 2) a radial average (i.e. intensity per area) vs. TOF * * Example: TOF_PSD_monitor_rad(rmax=0.2, nr=100, filename="Output.psd", filename_av="Output_av.psd") * * %P * INPUT PARAMETERS: * * rmax: [m] Outer radius of detector * nr: [1] Number of concentric circles * filename: [string] Name of file in which to store the detector image * filename_av: [string] Name of file in which to store the averaged detector image * nt: [1] Number of time bins * tmin: [mu-s] Beginning of time window * tmax: [mu-s] End of time window * nowritefile: [1] If set, monitor will skip writing to disk * * OUTPUT PARAMETERS: * * PSDr_N: [] Array of neutron counts * PSDr_p: [] Array of neutron weight counts * PSDr_p2: [] Array of second moments * PSDr_av_N: [] Array of neutron counts, averaged * PSDr_av_p: [] Array of neutron weight counts, averaged * PSDr_av_p2: [] Array of second moments, averaged * * %E *******************************************************************************/ DEFINE COMPONENT TOF_PSD_monitor_rad DEFINITION PARAMETERS () SETTING PARAMETERS (nr=100, nt=100, int nowritefile=0, string filename=0, string filename_av=0, rmax=0.2, tmin, tmax, restore_neutron=0) OUTPUT PARAMETERS () DECLARE %{ double tt_0; double tt_1; DArray2d TOFPSDr_N; DArray2d TOFPSDr_p; DArray2d TOFPSDr_p2; DArray2d TOFPSDr_av_p; DArray2d TOFPSDr_av_p2; %} INITIALIZE %{ int i, j; TOFPSDr_N = create_darr2d(nt, nr); TOFPSDr_p = create_darr2d(nt, nr); TOFPSDr_p2 = create_darr2d(nt, nr); TOFPSDr_av_p = create_darr2d(nt, nr); TOFPSDr_av_p2 = create_darr2d(nt, nr); tt_0=tmin*1e-6; tt_1=tmax*1e-6; for (i=0; i=0 && i < nt) { double p2 = p*p; #pragma acc atomic TOFPSDr_N[i][j] = TOFPSDr_N[i][j]+1; #pragma acc atomic TOFPSDr_p[i][j] = TOFPSDr_p[i][j]+p; #pragma acc atomic TOFPSDr_p2[i][j] = TOFPSDr_p2[i][j]+p2; SCATTER; } if (restore_neutron) { RESTORE_NEUTRON(INDEX_CURRENT_COMP, x, y, z, vx, vy, vz, t, sx, sy, sz, p); } %} SAVE %{ if (!nowritefile) { int i, j; for(i=0; i