I'm not sure this is entirely what I need.<br><br>The big questions are:<br><br>Does the virtual_output component store neutron data sequentially?<br>Does the virtual_input component read neutron data from the file sequentially?<br>
<br>Here's another question regarding SPLIT, because I'd like to use the method on a PowderN with SPLIT 10:<br><br>Does each of the 10 neutron events in the sample interact with the same sample area (i.e. would I get the same xp, yp, zp for the 10 neutrons coming from the split command), or is the selection of the interaction point calculated separately for each?<br>
<br>Would the current method work with the SPLIT keyword?<br><br>If each instance interacts with the same xp, yp, zp in the sample, could I simply add a counter (perhaps using another IF statement or a FOR loop) to then only store xp, yp, zp, IF it was scattered by the sample, IF is hit the detector and IF is a counter going from 1 to 10 was say 1.<br>
<br>Many thanks again, your help is greatly appreciated.<br><br>Aaron<br><br><div class="gmail_quote">On Fri, Mar 28, 2008 at 4:12 PM, 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>
I guess what you think of is quite close from what PreMonitor_nD can do.<br>
It stores neutron state at some point, and this can be used in any further<br>
instance of Monitor_nD. It thus makes a correlation between neutron state<br>
at some position, and the detection somewhere else, just as what you did<br>
with your EXTENDs. The Monitor_nD may store that state as well as a source<br>
with e.g. options="source" or "list all, x y z vx vy vz t sx sy sz", which<br>
is indeed a Virtual_output.<br>
<font color="#888888"><br>
Emmanuel.<br>
</font><div><div></div><div class="Wj3C7c"><br>
> 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<br>
> to<br>
> do is somehow "pass" the x, y, z variables of interaction position with<br>
> the<br>
> PowderN through a virtual_output component. I can immediately think of<br>
> two<br>
> ways to do this:<br>
><br>
> 1) Write x,y,z as a list in a file (much like the virtual_output output<br>
> file). Then when the virtual_input is used, add and EXTEND and make use<br>
> of<br>
> the read_table-lib to read from the x,y,z data file and once again attach<br>
> these variables to each neutron.<br>
><br>
> This would only work if the virtual_input picks neutrons from the<br>
> virtual_output file sequentially. Moreover, the virtual_out must also<br>
> store<br>
> 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<br>
> (giving each line in the . Then read these as neutron states are read by<br>
> the virtual_input.<br>
><br>
> I would be inclined to say that option 1 might be the easiest, but it<br>
> requires that neutron state are store and the read sequentially. Option 2<br>
> would make the output file larger and might not be as easy to employ.<br>
><br>
> Any insight?<br>
><br>
> Aaron<br>
><br>
> On Fri, Mar 28, 2008 at 3:26 AM, Emmanuel FARHI <<a href="mailto:farhi@ill.fr">farhi@ill.fr</a>> wrote:<br>
><br>
>> 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>
>><br>
>> E.<br>
>><br>
>><br>
>> > Hi Emmanuel,<br>
>> ><br>
>> > I used your suggestions; I hadn't realized that the x, y, z names<br>
>> 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<br>
>> 785<br>
>> > printf parameters and "monitor_N=202" output on similation end. I'm<br>
>> 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<br>
>> 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<br>
>> possible<br>
>> > that SCATTERED is allowing any rays that intersect the entire<br>
>> cylindrical<br>
>> > shell of the detector (i.e. as if on theta: limits = [0, 360])? I<br>
>> 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<br>
>> matches<br>
>> > the<br>
>> > number give by the printf.<br>
>> ><br>
>> > So it appears that SCATTERED it TRUE when a neutron intersects any<br>
>> part<br>
>> 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.<br>
>> 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<br>
>> entirely<br>
>> > confident on this until we fix the above problem and see what the<br>
>> 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<br>
>> 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<br>
>> the<br>
>> >> end of the User Manual). the 'A' in the name indicates this is in<br>
>> the<br>
>> >> absolute coordinate frame. Better use the 'R' label,<br>
>> POS_R_CURRENT_COMP.<br>
>> >> The 'x' 'y' 'z' fields of the structure can not be accessed as the<br>
>> 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<br>
>> 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<br>
>> 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<br>
>> EXTEND<br>
>> >> may<br>
>> >> get tricky as you are not sure to pass there. So, better make sure<br>
>> you<br>
>> >> control all variables, and this should be done at least at some<br>
>> 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<br>
>> 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<br>
>> 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<br>
>> x,<br>
>> >> y,<br>
>> >> > z<br>
>> >> > position of the scattering event in the sample and also create a<br>
>> 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<br>
>> 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<br>
>> the<br>
>> >> > scattering event in the PowderN component. I have been using<br>
>> 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<br>
>> hit<br>
>> >> the<br>
>> >> > detector. My speculation is that the SCATTERED macro does not work<br>
>> 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.<br>
>> I've<br>
>> >> > tried<br>
>> >> > using POS_A_CURRENT_COMP.x to get the x-component, but this does<br>
>> 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<br>
>> 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<br>
>> (using<br>
>> >> the<br>
>> >> > state parameters x, y, z) and then put that into the local<br>
>> 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<br>
>> 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<br>
>> 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>
>><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>*************************************************