[neutron-mc] Neutron parameters and EXTEND

Aaron M. Percival percival at physics.queensu.ca
Thu Mar 27 20:52:46 CET 2008

Hi all,

I've been working on a way to essentially visualize the gauge volume in a
sample.  I'll give a brief summary of my instrument and then the problems
that I've found:

It's a simple 2-axis instrument, with such components as: a
Source_Maxwell_3, a Monochromator_flat, a PowderN and a Monitor_nD.  I've
used a virtual_input/virtual_output to save neutron histories at the sample
incident slit.  I can then continue these histories through diffraction from
the sample and to the detector.

In order to visualize the gauge volume, I thought I could do the following:

1) Use EXTEND and if(SCATTERED) in the sample component to save the x, y, z
position of the scattering event in the sample and also create a flag if the
neutron was scattered at the sample (example flag = 1 if SCATTERED, ELSE
flag = 0)

2) Use EXTEND and if(flag==1 && SCATTERED) at the detector.  Then printf the
saved x, y, z positions of the scattering events in the sample from above.
(here I am using printf for debugging, eventually I would like to use the
DETECTOR OUT 3D(...) macro).

The problems that I'm having:

1) I cannot seem to find a variable(s) that define the location of the
scattering event in the PowderN component.  I have been using simple the
global variables 'x' 'y' 'z', but I don't think this is working correctly.

2) The printf is outputting many more neutron x,y,z than actually hit the
detector.  My speculation is that the SCATTERED macro does not work in

3) A smaller problem.  What I would like is the local x-y-z of the scattered
neutron in the sample.  To do this, I've tried using the POS_A_CURRENT_COMP,
but I can't seem to isolate the x,y,z components of this vector.  I've tried
using POS_A_CURRENT_COMP.x to get the x-component, but this does not seem to
work as I get the following error:

In function `mcraytrace':
87: error: structure has no member named `mcnlx'

Here is a sample of the EXTEND sections.  ** indicates a comment that I've
added for clarity:

COMPONENT sample = PowderN(
    reflections = "Ni.laz", format = Lazy, d_phi = 8,
    radius = 0.006, yheight = 0.06, pack = 1, sigma_abs = 0,
    sigma_inc = 0, Delta_d = 0, frac = 0, tfrac = 0, DW = 0,
    concentric = 0, barns = 1)
  AT (0, 0, 0) RELATIVE sample_arm
**here I'm trying to get the location of the scattering event (using the
state parameters x, y, z) and then put that into the local coordinates of
the sample using the POS_A_CURRENT_COMP ***
    xp = x - POS_A_CURRENT_COMP.x;
    yp = y - POS_A_CURRENT_COMP.y;
    zp = z - POS_A_CURRENT_COMP.z;

**the flag is later used in the detector to indicate that the neutron was
scattered from the sample**
    flag = 1;
    flag = 0;

COMPONENT monitor = Monitor_nD(
    yheight = 0.133, xwidth = 2.794,
    options = "banana, theta limits=[88.75, 91.25], bins = 32")
  AT (0, 0, 0) RELATIVE sample_arm
  ROTATED (0, 0, 0) RELATIVE origin

**Here the xp, yp, zp from above should only be printed if the neutron was
scattered from the sample and intersected the detector
if(flag==1 && SCATTERED)
       printf("%g,%g,%g\n", xp,yp,zp);
Aaron M. Percival
M.Sc. Candidate
Dept. of Physics, Engineering Physics & Astronomy
Queen's University
Kingston, Ontario, Canada, K7L 3N6
Office: 613-533-6000 ext. 74789
Fax: 613-533-6463
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman2.mcstas.org/pipermail/mcstas-users/attachments/20080327/ff245ae3/attachment.html>

More information about the mcstas-users mailing list