[mcstas-users] Spin random

Петр Коник 104pet104 at gmail.com
Thu Apr 24 16:21:55 CEST 2025


Thanks for the details!

I think I understood now.

Best,
PK

> On 2025. Apr 24., at 16:16, Peter Kjær Willendrup <pkwi at dtu.dk> wrote:
> 
> Hi again Peter,
> 
> 
> Think of the component as mostly intended for “unit-testing” - with an “arbitrary” definition of the polarisation, e.g. with a partly polarised set of neutron rays arrive from another simulation package.
> ( I’ve taken the liberty of adding Erik in cc: - he might have other insights or thoughts to add - pol in McStas was mostly his work in fact. ;-) )
> 
> And I absolutely agree that most polarised simulations would start by introduction of e.g. Pol_guide_vmirror, Pol_mirror or some other polariser. In that sense there is no other reason to include such a the Set_pol component other than showing that  “this description in fact also works”.
> 
> To illustrate that both models of describing an unpolarised beam is indeed working, please have a look at the test instrument Test_Pol_mirror.instr. (I think Pol_mirror received the same edit a longer time ago and should be in functional order in your 3.5.24.)
> 
> By running a scan:
> mcrun -c Test_Pol_Mirror.instr polarize=0,1 -N2
> 
> you can check that the net polarisation after the mirror is the same if “rays start unpolarised” (polarize=0) and “rays start polarised, but with average polarisation 0” (polarize=1), see attached screenshots comparing reflected and transmitted polarisation between the two cases. 
> 
> 
> Best and hope this makes better sense?
> 
> Peter
> 
> <Transmitted_ beams.png><Reflected_beams.png>
> 
> 
>> On 24 Apr 2025, at 15.46, Петр Коник <104pet104 at gmail.com> wrote:
>> 
>> Dear Peter,
>> 
>> Thanks for quick answer! 
>> 
>> Can you elaborate a bit more on a situation where this component is useful? I understand what you are saying, but still can’t get why would I want this? For example, if I have an ideal polarizer, normally it would just set P=1 for every trajectory in the unpolarized beam. With spin_random I would lose half of all trajectories after such a polarizer.
>> 
>> My general feeling is that trajectories were never meant to be identified as real neutrons, so I’m struggling to understand the rationale behind this component.
>> 
>> I’m running 3.5.24, I will check the fix, thanks!
>> 
>> Best regards,
>> PK
>> 
>>> On 2025. Apr 24., at 15:37, Peter Kjær Willendrup <pkwi at dtu.dk> wrote:
>>> 
>>> Hi Peter,
>>> 
>>> 
>>>> On 24 Apr 2025, at 13.55, Петр Коник via mcstas-users <mcstas-users at mcstas.org> wrote:
>>>> 
>>>> Can you explain me the intended use of Spin_random component? What are the benefits of assigning polarization to trajectories before the polarizer?
>>> 
>>> The component was mainly added to allow defining an “unpolarised beam” at the “full beam level” (i.e. with a set polarisation pr. ray but a net 0 polarisation) to allow comparing with all rays having sx=sy=sz=0 (i.e. with each ray unpolarised).
>>> 
>>>> Moreover, when used in combination with Pol_Vmirror component it results in polarization over 1 if two components are rotated 90 degrees relative to each other.
>>> 
>>> We have recently made a fix to that component (i.e. ~ 1 month ago) that I would think rectifies this problem - see https://github.com/mccode-dev/McCode/commit/55e3989eb05150a7671523749f30dd462e19b266. 
>>> The logic is that a given polariser / analyser defines a definition of “up/down”, meaning post to “measurement” the other components should be put to zero.
>>> 
>>> How recent a version are you running? Chances are that 3.5.25 (which is only on conda-forge at the moment) would fix this.
>>> 
>>> Otherwise stay tuned for 3.5.26 that I can promote to become a “full” release including .deb packages, Windows installer etc.
>>> 
>>> 
>>> Best,
>>> Peter W
>>> 
>>> 
>>> 
>>> Peter Kjær Willendrup
>>> Forskningsingeniør, Specialkonsulent
>>> 
>>> DTU Physics
>>> 
>>> <image001.gif>
>>> 
>>> 
>>> Technical University of Denmark
>>> 
>>> 
>>> <image002.gif>
>>> 
>>> 
>>> Department of Physics
>>> Fysikvej
>>> Building 307
>>> DK-2800 Kongens Lyngby
>>> 
>>> Main office at 
>>> ESS DMSC
>>> Building 305
>>> DK-2800 Kongens Lyngby
>>> 
>>> Direct +45 2125 4612
>>> Mobil +45 2125 4612
>>> Fax +45 4593 2399
>>> pkwi at fysik.dtu.dk
>>> 
>> 
> 
> 
> Peter Kjær Willendrup
> Forskningsingeniør, Specialkonsulent
> 
> DTU Physics
> 
> <image001.gif>
> 
> 
> Technical University of Denmark
> 
> 
> <image002.gif>
> 
> 
> Department of Physics
> Fysikvej
> Building 307
> DK-2800 Kongens Lyngby
> 
> Main office at 
> ESS DMSC
> Building 305
> DK-2800 Kongens Lyngby
> 
> Direct +45 2125 4612
> Mobil +45 2125 4612
> Fax +45 4593 2399
> pkwi at fysik.dtu.dk
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman2.mcstas.org/pipermail/mcstas-users/attachments/20250424/d64f16cf/attachment-0001.htm>


More information about the mcstas-users mailing list