Hello again,<br><br>Excellent. Glad the source of the problem was found.<br><br>I would like to extend this ability one step further. What I would like to do is somehow "pass" the x, y, z variables of interaction position with the PowderN through a virtual_output component. I can immediately think of two ways to do this:<br>
<br>1) Write x,y,z as a list in a file (much like the virtual_output output file). Then when the virtual_input is used, add and EXTEND and make use of the read_table-lib to read from the x,y,z data file and once again attach these variables to each neutron.<br>
<br>This would only work if the virtual_input picks neutrons from the virtual_output file sequentially. Moreover, the virtual_out must also store the neutron data sequentially (but I think this is the case).<br><br>2) Append the x,y,z variables to each neutron stored by the virtual_out (giving each line in the . Then read these as neutron states are read by the virtual_input.<br>
<br>I would be inclined to say that option 1 might be the easiest, but it requires that neutron state are store and the read sequentially. Option 2 would make the output file larger and might not be as easy to employ.<br>
<br>Any insight?<br><br>Aaron<br><br><div class="gmail_quote">On Fri, Mar 28, 2008 at 3:26 AM, Emmanuel FARHI <<a href="mailto:farhi@ill.fr">farhi@ill.fr</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Aaron,<br>
<br>
you are right, the intersection test is with the whole cylinder, and so<br>
does the SCATTERED flag. I may fix that today in the CVS<br>
<font color="#888888"><br>
E.<br>
</font><div><div></div><div class="Wj3C7c"><br>
<br>
> Hi Emmanuel,<br>
><br>
> I used your suggestions; I hadn't realized that the x, y, z names referred<br>
> to local coordinates, which is exactly what I needed.<br>
><br>
> Still, for some reason I am getting many more printf neutron x,y,z<br>
> parameters than are recorded in the detector. In a recent run I had 785<br>
> printf parameters and "monitor_N=202" output on similation end. I'm not<br>
> clear as to why this might be happening. It seems as though both<br>
> conditions<br>
> in the IF statement in the EXTEND of the detector should only allow printf<br>
> for neutrons that are scattered and intersect the detector. On second<br>
> thought, this might not be the case. I recall seeing "intersect" as a<br>
> flag<br>
> in the component definition for Monitor_nD. However, could it be possible<br>
> that SCATTERED is allowing any rays that intersect the entire cylindrical<br>
> shell of the detector (i.e. as if on theta: limits = [0, 360])? I changed<br>
> the limits to [10, 170] to see if this would change the results. This<br>
> worked! The number of neutrons intersected in the detector now matches<br>
> the<br>
> number give by the printf.<br>
><br>
> So it appears that SCATTERED it TRUE when a neutron intersects any part of<br>
> the cylinder and not just the part defined by limits on theta.<br>
><br>
> As a side note, the gauge volume that I am seeing looks strange. However,<br>
> it is arranged in such a way that might explain the problems I've been<br>
> having with divergences from the PowderN component. I won't be entirely<br>
> confident on this until we fix the above problem and see what the proper<br>
> gauge volume is.<br>
><br>
> Here are the source, sample and detector components:<br>
><br>
> COMPONENT source = Virtual_input(<br>
> file = file, type = "text", verbose = 0, repeat_count = repeat,<br>
> smooth = 1)<br>
> AT (0, 0, 0) RELATIVE origin<br>
> EXTEND<br>
> %{<br>
> flag=0;<br>
> %}<br>
><br>
> COMPONENT sample = PowderN(<br>
> reflections = "Ni.laz", format = Lazy, d_phi = 8,<br>
> radius = 0.006, yheight = 0.06, pack = 1, sigma_abs = 0,<br>
> sigma_inc = 0, Delta_d = 0, frac = 0, tfrac = 0, DW = 0,<br>
> concentric = 0, barns = 1)<br>
> AT (0, 0, 0) RELATIVE sample_arm<br>
> EXTEND<br>
> %{<br>
> flag=0;<br>
> if(SCATTERED)<br>
> {<br>
> xp = x;<br>
> yp = y;<br>
> zp = z;<br>
> flag = 1;<br>
> }<br>
> %}<br>
><br>
> COMPONENT monitor = Monitor_nD(<br>
> yheight = 0.133, xwidth = 2.794,<br>
> options = "banana, theta limits=[10, 170], bins = 32")<br>
> AT (0, 0, 0) RELATIVE sample_arm<br>
> ROTATED (0, 0, 0) RELATIVE origin<br>
> EXTEND<br>
> %{<br>
> if(flag==1 && SCATTERED)<br>
> {<br>
> printf("%g,%g,%g\n", xp,yp,zp);<br>
> }<br>
> %}<br>
><br>
><br>
> On Thu, Mar 27, 2008 at 5:00 PM, Emmanuel FARHI <<a href="mailto:farhi@ill.fr">farhi@ill.fr</a>> wrote:<br>
><br>
>> Hi Aaron,<br>
>><br>
>> I can see a few comments to improve and understand the possible problems<br>
>> you face.<br>
>><br>
>> 1- to extract the neutron stte parameters, you can not indeed refer<br>
>> explicitely to the 'x','y' and 'z' names as these are only defined in<br>
>> the<br>
>> TRACE of each component. However, they should also be defined in the<br>
>> EXTEND, and they are already in the local component coordinate frame.<br>
>><br>
>> 2- if you want to extract coordinates from e.g. POS_A_CURRENT_COMP<br>
>> (which<br>
>> is a Coord structure), use the coords_get function (see Appendix at the<br>
>> end of the User Manual). the 'A' in the name indicates this is in the<br>
>> absolute coordinate frame. Better use the 'R' label, POS_R_CURRENT_COMP.<br>
>> The 'x' 'y' 'z' fields of the structure can not be accessed as the names<br>
>> xyz are redefined to point to the real name of the neutron coordinate<br>
>> which is e.g. 'mcnlx'.<br>
>><br>
>> 3- I would rather write your code as follow.<br>
>> At the source level (or virtual output), make an EXTEND that sets the<br>
>> flag<br>
>> to 0. Suppose you have first a neutron that interacts with the PowderN.<br>
>> It<br>
>> sets the flag. But now, let's say a second neutron misses the sample.<br>
>> The<br>
>> extend block is NOT evaluated as the component is skipped (e.g. no<br>
>> intersection with volume), and the flag value is the one from the<br>
>> previous<br>
>> neutron. You use a wrong flag value if that neutron reaches the<br>
>> detector!<br>
>><br>
>> Source=blah( ... )<br>
>> EXTEND %{<br>
>> flag=0;<br>
>> %}<br>
>><br>
>> Then you can have you sample extension, and use directly the xyz values.<br>
>> COMPONENT sample = PowderN( ... ) AT (0, 0, 0) RELATIVE sample_arm<br>
>> EXTEND<br>
>> %{<br>
>> flag=0; // make sure we always define it when reaching sample<br>
>> if(SCATTERED) {<br>
>> xp = x; // local coords<br>
>> yp = y;<br>
>> zp = z;<br>
>> flag = 1;<br>
>> }<br>
>> %}<br>
>><br>
>> Try these modifications, and tell me. Using global variables in EXTEND<br>
>> may<br>
>> get tricky as you are not sure to pass there. So, better make sure you<br>
>> control all variables, and this should be done at least at some position<br>
>> were all neutrons pass. There is a similar difficulty with the SPLIT<br>
>> keyword.<br>
>><br>
>> Emmanuel.<br>
>><br>
>><br>
>> > Hi all,<br>
>> ><br>
>> > I've been working on a way to essentially visualize the gauge volume<br>
>> in<br>
>> a<br>
>> > sample. I'll give a brief summary of my instrument and then the<br>
>> problems<br>
>> > that I've found:<br>
>> ><br>
>> > It's a simple 2-axis instrument, with such components as: a<br>
>> > Source_Maxwell_3, a Monochromator_flat, a PowderN and a Monitor_nD.<br>
>> I've<br>
>> > used a virtual_input/virtual_output to save neutron histories at the<br>
>> > sample<br>
>> > incident slit. I can then continue these histories through<br>
>> diffraction<br>
>> > from<br>
>> > the sample and to the detector.<br>
>> ><br>
>> > In order to visualize the gauge volume, I thought I could do the<br>
>> > following:<br>
>> ><br>
>> > 1) Use EXTEND and if(SCATTERED) in the sample component to save the x,<br>
>> y,<br>
>> > z<br>
>> > position of the scattering event in the sample and also create a flag<br>
>> if<br>
>> > the<br>
>> > neutron was scattered at the sample (example flag = 1 if SCATTERED,<br>
>> ELSE<br>
>> > flag = 0)<br>
>> ><br>
>> > 2) Use EXTEND and if(flag==1 && SCATTERED) at the detector. Then<br>
>> printf<br>
>> > the<br>
>> > saved x, y, z positions of the scattering events in the sample from<br>
>> above.<br>
>> > (here I am using printf for debugging, eventually I would like to use<br>
>> the<br>
>> > DETECTOR OUT 3D(...) macro).<br>
>> ><br>
>> > The problems that I'm having:<br>
>> ><br>
>> > 1) I cannot seem to find a variable(s) that define the location of the<br>
>> > scattering event in the PowderN component. I have been using simple<br>
>> the<br>
>> > global variables 'x' 'y' 'z', but I don't think this is working<br>
>> correctly.<br>
>> ><br>
>> > 2) The printf is outputting many more neutron x,y,z than actually hit<br>
>> the<br>
>> > detector. My speculation is that the SCATTERED macro does not work in<br>
>> > detectors?<br>
>> ><br>
>> > 3) A smaller problem. What I would like is the local x-y-z of the<br>
>> > scattered<br>
>> > neutron in the sample. To do this, I've tried using the<br>
>> > POS_A_CURRENT_COMP,<br>
>> > but I can't seem to isolate the x,y,z components of this vector. I've<br>
>> > tried<br>
>> > using POS_A_CURRENT_COMP.x to get the x-component, but this does not<br>
>> seem<br>
>> > to<br>
>> > work as I get the following error:<br>
>> ><br>
>> > In function `mcraytrace':<br>
>> > 87: error: structure has no member named `mcnlx'<br>
>> ><br>
>> > Here is a sample of the EXTEND sections. ** indicates a comment that<br>
>> I've<br>
>> > added for clarity:<br>
>> ><br>
>> > COMPONENT sample = PowderN(<br>
>> > reflections = "Ni.laz", format = Lazy, d_phi = 8,<br>
>> > radius = 0.006, yheight = 0.06, pack = 1, sigma_abs = 0,<br>
>> > sigma_inc = 0, Delta_d = 0, frac = 0, tfrac = 0, DW = 0,<br>
>> > concentric = 0, barns = 1)<br>
>> > AT (0, 0, 0) RELATIVE sample_arm<br>
>> > EXTEND<br>
>> > %{<br>
>> > if(SCATTERED)<br>
>> > {<br>
>> > **here I'm trying to get the location of the scattering event (using<br>
>> the<br>
>> > state parameters x, y, z) and then put that into the local coordinates<br>
>> of<br>
>> > the sample using the POS_A_CURRENT_COMP ***<br>
>> > xp = x - POS_A_CURRENT_COMP.x;<br>
>> > yp = y - POS_A_CURRENT_COMP.y;<br>
>> > zp = z - POS_A_CURRENT_COMP.z;<br>
>> ><br>
>> > **the flag is later used in the detector to indicate that the neutron<br>
>> was<br>
>> > scattered from the sample**<br>
>> > flag = 1;<br>
>> > }<br>
>> > else<br>
>> > {<br>
>> > flag = 0;<br>
>> > }<br>
>> > %}<br>
>> ><br>
>> > COMPONENT monitor = Monitor_nD(<br>
>> > yheight = 0.133, xwidth = 2.794,<br>
>> > options = "banana, theta limits=[88.75, 91.25], bins = 32")<br>
>> > AT (0, 0, 0) RELATIVE sample_arm<br>
>> > ROTATED (0, 0, 0) RELATIVE origin<br>
>> > EXTEND<br>
>> > %{<br>
>> ><br>
>> > **Here the xp, yp, zp from above should only be printed if the neutron<br>
>> was<br>
>> > scattered from the sample and intersected the detector<br>
>> > if(flag==1 && SCATTERED)<br>
>> > {<br>
>> > printf("%g,%g,%g\n", xp,yp,zp);<br>
>> > }<br>
>> > %}<br>
>> > --<br>
>> > *************************************************<br>
>> > Aaron M. Percival<br>
>> > M.Sc. Candidate<br>
>> > Dept. of Physics, Engineering Physics & Astronomy<br>
>> > Queen's University<br>
>> > Kingston, Ontario, Canada, K7L 3N6<br>
>> > Office: 613-533-6000 ext. 74789<br>
>> > Fax: 613-533-6463<br>
>> > *************************************************<br>
>> > _______________________________________________<br>
>> > neutron-mc mailing list<br>
>> > <a href="mailto:neutron-mc@risoe.dk">neutron-mc@risoe.dk</a><br>
>> > <a href="http://mailman.risoe.dk/mailman/listinfo/neutron-mc" target="_blank">http://mailman.risoe.dk/mailman/listinfo/neutron-mc</a><br>
>> ><br>
>><br>
>><br>
>> --<br>
>> FARHI Emmanuel <<a href="mailto:farhi@ill.fr">farhi@ill.fr</a>><br>
>> Groupe DS/CS, ILL4/156, Tel 04 76 20 71 35<br>
>> ILL, Grenoble<br>
>><br>
>> _______________________________________________<br>
>> neutron-mc mailing list<br>
>> <a href="mailto:neutron-mc@risoe.dk">neutron-mc@risoe.dk</a><br>
>> <a href="http://mailman.risoe.dk/mailman/listinfo/neutron-mc" target="_blank">http://mailman.risoe.dk/mailman/listinfo/neutron-mc</a><br>
>><br>
><br>
><br>
><br>
> --<br>
> *************************************************<br>
> Aaron M. Percival<br>
> M.Sc. Candidate<br>
> Dept. of Physics, Engineering Physics & Astronomy<br>
> Queen's University<br>
> Kingston, Ontario, Canada, K7L 3N6<br>
> Office: 613-533-6000 ext. 74789<br>
> Fax: 613-533-6463<br>
> *************************************************<br>
> _______________________________________________<br>
> neutron-mc mailing list<br>
> <a href="mailto:neutron-mc@risoe.dk">neutron-mc@risoe.dk</a><br>
> <a href="http://mailman.risoe.dk/mailman/listinfo/neutron-mc" target="_blank">http://mailman.risoe.dk/mailman/listinfo/neutron-mc</a><br>
><br>
<br>
<br>
--<br>
FARHI Emmanuel <<a href="mailto:farhi@ill.fr">farhi@ill.fr</a>><br>
Groupe DS/CS, ILL4/156, Tel 04 76 20 71 35<br>
ILL, Grenoble<br>
<br>
_______________________________________________<br>
neutron-mc mailing list<br>
<a href="mailto:neutron-mc@risoe.dk">neutron-mc@risoe.dk</a><br>
<a href="http://mailman.risoe.dk/mailman/listinfo/neutron-mc" target="_blank">http://mailman.risoe.dk/mailman/listinfo/neutron-mc</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>*************************************************<br>Aaron M. Percival<br>M.Sc. Candidate<br>Dept. of Physics, Engineering Physics & Astronomy<br>Queen's University<br>
Kingston, Ontario, Canada, K7L 3N6<br>Office: 613-533-6000 ext. 74789<br>Fax: 613-533-6463<br>*************************************************