Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/manuals/mcstas/kernelcalls.tex
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ \subsection{Neutron propagation}
\item \textbfMCRH{PROP\_GRAV\_DT}$(dt,Ax,Ay,Az)$. Like \textbf{PROP\_DT}, but it also
includes gravity using the acceleration $(Ax,Ay,Az)$. In addition
to adjusting $(x,y,z)$ and $t$, also $(vx,vy,vz)$ is modified.
\item \textbfMCRH{PROP\_NO\_G\_DT}$(dt)$. Propagates the neutron through the
time interval $dt$ using straight-line motion, regardless of the global
gravitation setting. The negative-time and back-propagation rules are the
same as for \textbf{PROP\_DT}.
\item \textbfMCRH{PROP\_NO\_G\_X0}, \textbfMCRH{PROP\_NO\_G\_Y0}, and
\textbfMCRH{PROP\_NO\_G\_Z0}. Propagate the neutron to the corresponding
local coordinate plane using straight-line motion, regardless of the global
gravitation setting.
\item \textbfMCRH{ALLOW\_BACKPROP}. Indicates that the next propagation routine
will not remove the neutron ray, even if negative propagation times
are found. Subsequent propagations are not affected.
Expand Down
24 changes: 24 additions & 0 deletions mccode/nlib/share/mcstas-r.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,30 @@ void SCATTER_func(_class_particle *_particle); /* provides function to SCATTER f
} while(0)


/* Propagation variants that always use straight-line motion. */
#define PROP_NO_G_DT(dt) \
do { \
if(dt < 0 && allow_backprop == 0) { RESTORE=1; ABSORB; }; \
mcPROP_DT(dt); \
DISALLOW_BACKPROP; \
} while(0)

#define PROP_NO_G_Z0 \
do { \
mcPROP_Z0; \
} while(0)

#define PROP_NO_G_X0 \
do { \
mcPROP_X0; \
} while(0)

#define PROP_NO_G_Y0 \
do { \
mcPROP_Y0; \
} while(0)


#ifdef DEBUG

#define DEBUG_STATE() if(!mcdotrace); else \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*******************************************************************************
* McStas, neutron ray-tracing package
*
* Instrument: Unittest_PROP_NO_G
*
* %Identification
* Written by: Mads Bertelsen
* Date: September 2026
* Origin: ESS
* %INSTRUMENT_SITE: Tests_grammar
*
* Test for the PROP_NO_G_DT propagation macro.
*
* %Description
* A long-wavelength beam is focused onto a small detector 10 m away. The
* intermediate Arm uses PROP_NO_G_DT, so the beam should remain focused even
* when gravity is enabled.
*
* %Example: -g Detector: PropNoGMonitor_I=7.95774e-8
*
* %End
*******************************************************************************/
DEFINE INSTRUMENT Unittest_PROP_NO_G()

TRACE

COMPONENT Origin = Progress_bar()
AT (0, 0, 0) ABSOLUTE

COMPONENT Source = Source_simple(
radius = 0.01,
dist = 10,
focus_xw = 0.01,
focus_yh = 0.01,
lambda0 = 30,
dlambda = 0,
flux = 0)
AT (0, 0, 0) RELATIVE Origin

COMPONENT PropNoG = Arm()
AT (0, 0, 0) RELATIVE Source
EXTEND %{
PROP_NO_G_DT(10/vz);
%}

COMPONENT PropNoGMonitor = Monitor(
xwidth = 0.01,
yheight = 0.01)
AT (0, 0, 10) RELATIVE PropNoG

END
4 changes: 4 additions & 0 deletions support/common/editors/mccode.lang
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,13 @@
<keyword>RESTORE_NEUTRON</keyword>
<keyword>PROP_GRAV_DT</keyword>
<keyword>PROP_DT</keyword>
<keyword>PROP_NO_G_DT</keyword>
<keyword>PROP_Z0</keyword>
<keyword>PROP_X0</keyword>
<keyword>PROP_Y0</keyword>
<keyword>PROP_NO_G_Z0</keyword>
<keyword>PROP_NO_G_X0</keyword>
<keyword>PROP_NO_G_Y0</keyword>
<keyword>vec_prod</keyword>
<keyword>scalar_prod</keyword>
<keyword>NORM</keyword>
Expand Down
4 changes: 4 additions & 0 deletions support/common/editors/mccode.vim
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,14 @@
\ RESTORE_NEUTRON
\ PROP_GRAV_DT
\ PROP_DT
\ PROP_NO_G_DT
\ PROP_DL
\ PROP_Z0
\ PROP_X0
\ PROP_Y0
\ PROP_NO_G_Z0
\ PROP_NO_G_X0
\ PROP_NO_G_Y0
\ vec_prod
\ scalar_prod
\ NORM
Expand Down
Loading