[mcstas-users] [EXTERNAL] Multiple samples in a single mcstas instrument?
Erik B Knudsen
erkn at fysik.dtu.dk
Thu Jul 11 20:23:24 CEST 2019
Dear Christoph,
In your instrument file there are two missing ; (line 186 and 194), a
switched %} line 187, and a double '==' where it should say '=' (line
187). Some of these were due to me being a bit too fast of the mark this
morning, so sorry for that. The attached version has these things fixed
- I can't test it completely since I lack your SANS-component but it
should get you a bit further. Good Luck!
cheers
Erik
On 11/07/2019 19:57, Wildgruber, Christoph U. wrote:
> Hi again,
>
> so I did try the basic ‘SPLIT 2’ approach but I end up with an unexpected compile time error (RHEL 7, mcstas 2.5, mpi enabled)…
> I must be missing something really basic…
>
> Here is the result:
> ==============
>
> Setting environment:
> MCSTAS_OVERRIDE=
> /usr/local/mcstas/2.5/tools/Python/mcgui/../mccodelib/../../..
>
> MCSTAS_CFLAGS_OVERRIDE=
> -g -O2 -lm
>
> MCSTAS_CC_OVERRIDE=
> gcc
>
> MCSTAS_MPICC_OVERRIDE=
> mpicc
>
> mcrun -c BER_SANS_guide_elliptical_optimize_2.1.instr -n0
>
> INFO: No output directory specified (--dir)
> INFO: Using directory: "BER_SANS_guide_elliptical_optimize_2.1_20190711_134948"
> INFO: Regenerating c-file: BER_SANS_guide_elliptical_optimize_2.1.c
> Reference to undefined component instance a1 at line BER_SANS_guide_elliptical_optimize_2.1.instr:246.
> Reference to undefined component instance a1 at line BER_SANS_guide_elliptical_optimize_2.1.instr:258.
> Reference to undefined component instance a1 at line BER_SANS_guide_elliptical_optimize_2.1.instr:266.
> Reference to undefined component instance a1 at line BER_SANS_guide_elliptical_optimize_2.1.instr:274.
> Reference to undefined component instance a1 at line BER_SANS_guide_elliptical_optimize_2.1.instr:284.
> Reference to undefined component instance a1 at line BER_SANS_guide_elliptical_optimize_2.1.instr:294.
> Reference to undefined component instance a1 at line BER_SANS_guide_elliptical_optimize_2.1.instr:304.
> Reference to undefined component instance a1 at line BER_SANS_guide_elliptical_optimize_2.1.instr:314.
> Info: 'PSD_monitor_rad' is a contributed component.
> Reference to undefined component instance a1 at line BER_SANS_guide_elliptical_optimize_2.1.instr:321.
> Reference to undefined component instance a1 at line BER_SANS_guide_elliptical_optimize_2.1.instr:328.
> Info: 'SANSQMonitor' is a contributed component.
> Reference to undefined component instance a1 at line BER_SANS_guide_elliptical_optimize_2.1.instr:338.
> Reference to undefined component instance a1 at line BER_SANS_guide_elliptical_optimize_2.1.instr:347.
> McStas: 12 Errors encountered during parse of BER_SANS_guide_elliptical_optimize_2.1.instr.
> compile thread done
>
>
> I attach the instr file in case you get a chance to try to compile it…
>
> So what is going on?
>
>
> Thanks so much,
>
>
> Uli
>
--
Erik Bergbäck Knudsen, Research Engineer | DTU | morituri
NEXMAP, DTU Fysik, DK-2800 Kgs. Lyngby, Denmark |<>-<>| te
phone: (+45) 2132 6655 |<>-<>| salutant
-------------- next part --------------
/**********************************************************************************************************************************************
*
* Basic SANS
*
* Trying to implement Erik Knudsens / Peter Willendrups suggestions
*
*********************************************************************************************************************************************
*/
DEFINE INSTRUMENT BER_Sans_optimize(lambda_max = 9.418,
opticsStart = 0.843,
apt_0_size = 0.0801,
guide_0_Start = 1.026, guide_0_End = 2.331,
guide_0_size_1 = 0.0331, guide_0_size_2 = 0.0507,
guide_0_m = 6.223,
apt_1_size = 0.0724,
guide_1_Start = 2.389, guide_1_End = 14.001,
guide_1_size = 0.0469,
guide_1_f1 = 2.298, guide_1_f2 = 1857.7,
guide_1_m = 3.04,
apt_2_size = 0.2838,
guide_2_Start = 14.35, guide_2_End = 29.21,
guide_2_size = 0.108,
guide_2_f1 = 3590.2, guide_2_f2 = 1.506,
guide_2_m = 6.549,
apt_3_size = 0.0930,
sample_pos = 30.0,
sample_size = 0.01,
detector_pos = 33.0)
DECLARE
%{
double taperLength;
double lambda_min;
double guide_1_length, guide_2_length, SD;
double detectorRadius = 1.0;
double E_low, E_high;
double apt_0_width, apt_0_height, apt_1_width, apt_1_height, apt_2_width, apt_2_height, apt_3_width, apt_3_height;
double apt_0_pos, apt_1_pos, apt_2_pos, apt_3_pos;
double sample_n;
%}
INITIALIZE
%{
// until otherwise required I use the smallest lambda_min conceivable...
// =========================================================================
lambda_min = (detector_pos * lambda_max - 3956.0 / 15.0) / detector_pos;
if (lambda_min < 0.1) lambda_min = 0.1;
taperLength = guide_0_End - guide_0_Start;
guide_1_length = guide_1_End - guide_1_Start;
guide_2_length = guide_2_End - guide_2_Start;
SD = detector_pos - sample_pos;
E_low = (9.045 / lambda_max) * (9.045 / lambda_max);
E_high = (9.045 / lambda_min) * (9.045 / lambda_min);
apt_0_width = apt_0_height = apt_0_size;
apt_0_pos = opticsStart;
apt_1_width = apt_1_height = apt_1_size;
apt_1_pos = guide_0_End + 0.001;
apt_2_width = apt_2_height = apt_2_size;
apt_2_pos = guide_1_End + 0.001;
apt_3_width = apt_3_height = apt_3_size;
apt_3_pos = guide_2_End + 0.001;
%}
TRACE
COMPONENT origin = Progress_bar()
AT (0, 0, 0) ABSOLUTE
COMPONENT arm_source = Arm( )
AT (0, 0, 0) RELATIVE origin
// Pin hole configuration: source 'focus' on sample...
// (source focussing on rectangle!)
// ===================================================
COMPONENT Source = SNS_source_mod(filename = "/home/cwl/McStas_projects/BER_SANS/source_rot_t3m-25_sp.dat",
radius = 0.015,
dist = guide_1_Start,
focus_xw = 1.01 * apt_0_width,
focus_yh = 1.01 * apt_0_height,
Emin = E_low,
Emax = E_high,
Anorm = 0.000707)
AT (0,0,0) RELATIVE origin
// Aperture at entrance to straight tapered section...
// =================================================================
COMPONENT Apt_0 = Slit(xwidth = apt_0_width, yheight = apt_0_height)
AT (0, 0, apt_0_pos) RELATIVE origin
// Tapered guide...
// =========================================================================================================================
COMPONENT taperedGuide = Guide(w1 = guide_0_size_1, h1 = guide_0_size_1,
w2 = guide_0_size_2, h2 = guide_0_size_2,
l = taperLength, m = guide_0_m)
AT (0, 0, guide_0_Start) RELATIVE origin
// Aperture at entrance to focusing section...
// =================================================================
COMPONENT Apt_1 = Slit(xwidth = apt_1_width, yheight = apt_1_height)
AT (0, 0, apt_1_pos) RELATIVE origin
// 1st half of elliptical guide...
// ===================================================================================================================
COMPONENT focussingGuide_1 = Guide_tapering(option = "elliptical",
w1 = guide_1_size, h1 = guide_1_size,
l = guide_1_length,
linw = guide_1_f1, loutw = guide_1_f2,
linh = guide_1_f1, louth = guide_1_f2,
mx = guide_1_m, my = guide_1_m)
AT (0, 0, guide_1_Start) RELATIVE origin
// Aperture at center to focusing section...
// =================================================================
COMPONENT Apt_2 = Slit(xwidth = apt_2_width, yheight = apt_2_height)
AT (0, 0, apt_2_pos) RELATIVE origin
//COMPONENT guide_center_psd = PSD_monitor(nx = 127, ny = 127,
// filename = "Guide_center.dat",
// xwidth = 1.05 * apt_width_2, yheight = 1.05 * apt_height_2,
// //xwidth = 0.06, yheight = 0.06,
// restore_neutron = 1)
//AT (0, 0, apt_pos_2 + 0.001) RELATIVE origin
// 2nd half of elliptical guide...
// ===============================
COMPONENT focussingGuide_2 = Guide_tapering(option = "elliptical",
w1 = guide_2_size, h1 = guide_2_size,
l = guide_2_length,
linw = guide_2_f1, loutw = guide_2_f2,
linh = guide_2_f1, louth = guide_2_f2,
mx = guide_2_m, my = guide_2_m)
AT (0, 0, guide_2_Start) RELATIVE origin
COMPONENT Apt_3 = Slit(xwidth = apt_3_width, yheight = apt_3_height)
AT (0, 0, apt_3_pos) RELATIVE origin
// Monitor beam divergence at sample position...
// (we want the sensitive area be identical to the sample area!)
// =============================================================
COMPONENT sample_Div = Divergence_monitor(nh = 127, nv = 127,
filename = "Sample_divergence.dat",
xwidth = sample_size, yheight = sample_size,
maxdiv_h = 0.25, maxdiv_v = 0.25,
restore_neutron = 1)
AT (0, 0, sample_pos - 0.01) RELATIVE origin
COMPONENT sample_Div_2 = Divergence_monitor(nh = 127, nv = 127,
filename = "Sample_divergence_2.dat",
xwidth = sample_size, yheight = sample_size,
maxdiv_h = 2.5, maxdiv_v = 2.5,
restore_neutron = 1)
AT (0, 0, sample_pos - 0.009) RELATIVE origin
COMPONENT sample_apt = Slit(xwidth = sample_size, yheight = sample_size)
AT (0, 0, sample_pos - 0.008) RELATIVE origin
COMPONENT sample_psd = PSD_monitor(nx = 127, ny = 127,
filename = "Sample_psd.dat",
xwidth = 1.05 * sample_size, yheight = 1.05 * sample_size,
restore_neutron = 1)
AT (0, 0, sample_pos - 0.007) RELATIVE origin
// Multiple samples...
// ===================
COMPONENT a0 = Arm()
AT (0, 0, sample_pos) RELATIVE origin
EXTEND
%{
sample_n = 0;
%}
COMPONENT a1 = Arm()
AT (0, 0, 0) RELATIVE a0
EXTEND
%{
sample_n++;
%}
// sample: flatline_1.dat
// =====================================================================================================
COMPONENT GK_MD_sim_1 = SANSCurve(DeltaRho = 1.0e-14, Volume = 1000.0,
Concentration = 0.01, AbsorptionCrosssection = 0.0,
xwidth = sample_size,
yheight = sample_size,
zdepth = 0.005,
SampleToDetectorDistance = SD,
DetectorRadius = 1.0,
FileWithCurve = "/home/cwl/McStas_projects/BER_SANS/BER_SANS_optimize_elliptical_discrimination/samples/flatLine_1.dat")
WHEN (sample_n == 1) AT (0, 0, 0) RELATIVE a1
// sample: 1_Apo_Guanylate_kinase_theoretical_SANS.dat
// =====================================================================================================
COMPONENT GK_MD_sim_2 = SANSCurve(DeltaRho = 1.0e-14, Volume = 1000.0,
Concentration = 0.01, AbsorptionCrosssection = 0.0,
xwidth = sample_size,
yheight = sample_size,
zdepth = 0.005,
SampleToDetectorDistance = SD,
DetectorRadius = 1.0,
FileWithCurve = "/home/cwl/McStas_projects/BER_SANS/BER_SANS_optimize_elliptical_discrimination/samples/1_Apo_Guanylate_kinase_theoretical_SANS.dat")
WHEN (sample_n == 2) AT (0, 0, 0) RELATIVE a1
// single 2D detector #1 at 'detector_pos'...
// ==========================================
COMPONENT psd_monitor_1 = PSD_monitor(nx = 127, ny = 127,
filename = "PSD_mon_1.dat",
xwidth = detectorRadius, yheight = detectorRadius,
restore_neutron = 1)
WHEN (sample_n == 1) AT (0, 0, (detector_pos - sample_pos)) RELATIVE a1
// single 2D detector #2 at 'detector_pos'...
// ==========================================
COMPONENT psd_monitor_2 = PSD_monitor(nx = 127, ny = 127,
filename = "PSD_mon_2.dat",
xwidth = detectorRadius, yheight = detectorRadius,
restore_neutron = 1)
WHEN (sample_n == 2) AT (0, 0, (detector_pos - sample_pos)) RELATIVE a1
// wavlength monitor #1...
// =======================
COMPONENT l_monitor_1 = L_monitor(nL = 257,
filename = "L_mon_1.dat",
xwidth = detectorRadius, yheight = detectorRadius,
Lmin = lambda_min - 0.5 * (lambda_max - lambda_min),
Lmax = lambda_max + 0.5 * (lambda_max - lambda_min),
restore_neutron = 1)
WHEN (sample_n == 1) AT (0, 0, (detector_pos - sample_pos + 0.001)) RELATIVE a1
// wavlength monitor #2...
// =======================
COMPONENT l_monitor_2 = L_monitor(nL = 257,
filename = "L_mon_2.dat",
xwidth = detectorRadius, yheight = detectorRadius,
Lmin = lambda_min - 0.5 * (lambda_max - lambda_min),
Lmax = lambda_max + 0.5 * (lambda_max - lambda_min),
restore_neutron = 1)
WHEN (sample_n == 2) AT (0, 0, (detector_pos - sample_pos + 0.001)) RELATIVE a1
// energy monitor #1...
// ====================
COMPONENT E_monitor_1 = E_monitor(nE = 257,
filename = "E_mon_1.dat",
xwidth = detectorRadius, yheight = detectorRadius,
Emin = E_low - 0.5 * (E_high - E_low),
Emax = E_high + 0.5 * (E_high - E_low),
restore_neutron = 1)
WHEN (sample_n == 1) AT (0, 0, (detector_pos - sample_pos + 0.002)) RELATIVE a1
// energy monitor #2...
// ====================
COMPONENT E_monitor_2 = E_monitor(nE = 257,
filename = "E_mon_2.dat",
xwidth = detectorRadius, yheight = detectorRadius,
Emin = E_low - 0.5 * (E_high - E_low),
Emax = E_high + 0.5 * (E_high - E_low),
restore_neutron = 1)
WHEN (sample_n == 2) AT (0, 0, (detector_pos - sample_pos + 0.002)) RELATIVE a1
// radial monitor #1 (1D detector)...
// (don't try to use 'restore_neutron'!)
// =====================================
COMPONENT psd_monitor_rad_1 = PSD_monitor_rad(rmax = detectorRadius, nr = 257,
filename = "PSD_rad_1.dat", filename_av = "PSD_rad_av_1.dat")
WHEN (sample_n == 1) AT (0, 0, (detector_pos -sample_pos + 0.003)) RELATIVE a1
// radial monitor #2 (1D detector)...
// (don't try to use 'restore_neutron'!)
// =====================================
COMPONENT psd_monitor_rad_2 = PSD_monitor_rad(rmax = detectorRadius, nr = 257,
filename = "PSD_rad_2.dat", filename_av = "PSD_rad_av_2.dat")
WHEN (sample_n == 2) AT (0, 0, (detector_pos - sample_pos + 0.003)) RELATIVE a1
// q monitor #1...
// ===============
COMPONENT sansqmonitor_1 = SANSQMonitor(LambdaMin = 1.9,
RFilename = "RDetector_1", qFilename = "QDetector_1",
NumberOfBins = 1025,
RadiusDetector = detectorRadius, DistanceFromSample = SD,
restore_neutron = 0)
WHEN (sample_n == 1) AT (0, 0, (detector_pos - sample_pos + 0.004)) RELATIVE a1
// q monitor #2...
// ===============
COMPONENT sansqmonitor_2 = SANSQMonitor(LambdaMin = 1.9,
RFilename = "RDetector_2", qFilename = "QDetector_2",
NumberOfBins = 1025,
RadiusDetector = detectorRadius, DistanceFromSample = SD,
restore_neutron = 0)
WHEN (sample_n == 2) AT (0, 0, (detector_pos - sample_pos + 0.004)) RELATIVE a1
FINALLY
%{
%}
END
More information about the mcstas-users
mailing list