Scattering kernels

Detectors

Counter (SCounter)

class mcramp.scat.SCounter(idx=0, ctx=None, filename=None, **kwargs)[source]

Scattering kernel for Counter detector. Marks a neutron as detected for usage alongside the ‘SRescal’ component, and outputs a floating point number equal to the sum of the weights of detected neutrons.

Parameters:
filename : str or None

Name of the file to which neutron counts will be saved. No file saved if filename is None

Methods

Data Returns the sum of detected neutron weights as a floating point number.
Plot None
Save Saves the sum of detected neutron weights as a npy file if the parameter filename is not None.

1D Detector (SDetector1D)

class mcramp.scat.SDetector1D(binning=(0, 0, 0), logscale=False, restore_neutron=False, idx=0, var='energy', ctx=None, filename=None, **kwargs)[source]

Scattering kernel for a one axis monitor supporting a variety of axis variables.

Parameters:
binning : 3-tuple of floats

Lower bin edge, bin size, and upper bin edge for axis variable

restore_neutron : Boolean

If False, neutron is terminated upon intersection with this component

var : { “energy”, “theta”, “tof” }

Quantity which defines the axis along which neutron weights are histogrammed

filename : str or None

Name of the file to which spectrum will be saved. No file saved if filename is None

Attributes:
binning

Methods

Data Returns a 2-tuple of numpy arrays, the first containing the generated binning axis and the second containing the histogrammed neutron weights in each bin.
Plot Displays a plot of histogrammed neutron weights as a function of neutron energy
Save Saves the histogram axis, histogrammed neutron weights, and error assosciated with those weights (calculated as the sum of the squared weights) in each bin to numpy files “filename_X”, “filename_Y” and “filename_E” if filename is not None.

2D Detector (SDetector2D)

class mcramp.scat.SDetector2D(shape='', axis1_binning=(0, 0, 0), axis2_binning=(0, 0, 0), axis1_var='theta', axis2_var='tof', restore_neutron=False, idx=0, ctx=None, filename=None, logscale=False, **kwargs)[source]

Scattering kernel for a two axis monitor supporting a variety of axis variables.

Parameters:
axis1_var, axis2_var : { “x”, “y”, “theta”, “alpha”, “tof”, “divX”, “divY” }
Chooses the variables of each axis. These correspond to:
  • “x” : x coordinate of intersection point with the detector
  • “y” : y coordinate of intersection point with the detector
  • “theta” : Angle made by intersection point in xz plane with z axis, typically the in-plane scattering angle
  • “alpha” : Angle made by intersection point in yz plane with z axis, typically the out-of-plane scattering angle
  • “divX” : Horizontal divergence of neutron velocity
  • “divY” : Vertical divergence of neutron velocity
axis1_binning : 3-tuple of floats

Lower bin edge, bin size, and upper bin edge for axis 1

axis2_binning : 3-tuple of floats

Lower bin edge, bin size, and upper bin edge for axis 2

restore_neutron : Boolean

If False, neutron is terminated upon intersection with this component

filename : str or None

Name of the file to which histogram will be saved. No file saved if filename is None

logscale : Boolean

If True, histogram intensity is plotted on a logarithmic scale

Attributes:
axis1_binning
axis2_binning
sample_pos

Methods

Data Returns a 3-tuple of numpy arrays, the first two containing the binning for axes 1 and 2, respectively, and the third containing the histogrammed neutron weights for each bin
Plot Displays a plot of the two dimensional histogram of neutron weights along the chosen axes.
Save Saves the binning along axes 1 and 2, the histogrammed neutron weights and assosciated error (calculated as the sum of the squared neutron weights) for each bin as filename_X, filename_Y, filename_Z, and filename_E respectively, if filename is not None.

Optics

Guide (SGuide)

class mcramp.scat.SGuide(w1=0, h1=0, w2=0, h2=0, l=0, R0=0, Qc=0, alpha=0, m=1, W=0, idx=0, ctx=0, max_bounces=50, **kwargs)[source]

Scattering kernel for tapered rectangular Guide. Recreates the functionality of the Guide component in McStas. The path of the neutron through the guide is numerically simulated and its weight adjusted according to the reflectivity function of the guide walls.

Intersection is taken as the point at which the neutron enters the guide and the guide geometry is taken to lie centered along the z axis.

Parameters:
w1 : float

Width of the guide entrance in meters

h1 : float

Height of the guide entrance in meters

w2 : float

Width of the guide exit in meters

h2 : float

Height of the guide exit in meters

l : float

Length of the guide in meters

R0 : float

Low-angle reflectivity of the guide

Qc : float

Critical scattering vector of the guide

alpha : float

Slope of the reflectivity

m : float

m-value of the guide coating

W : float

Width of the guide supermirror cutoff

max_bounces : float

Cutoff to prevent infinite scattering due to numerical error in the kernel

Methods

Data None
Plot None
Save None

Disk chopper (SChopper)

class mcramp.scat.SChopper(slit_width=0.0, radius=0.0, freq=0.0, n_slits=0, phase=0.0, jitter=0.0, idx=0, ctx=0, **kwargs)[source]

Scattering kernel for Chopper component. Replicates the functionality of the DiskChopper component in McStas. Neutrons with velocities that are not permitted by the chopper are terminated.

Parameters:
slit_width : float

Width of the chopper slits in meters

radius : float

Radius of the chopper disc in meters

freq : float

Angular frequency of the chopper in radians per second

n_slits : float

Number of chopper slits

phase : float

Initial phase of the chopper in radians

jitter : float

Jitter in the chopper phase in radians

Methods

Data None
Plot None
Save None

Monochromator (SMonochromator)

class mcramp.scat.SMonochromator(slab_width=0.0, slab_height=0.0, gap=0.0, n_horizontal=1, n_vertical=1, mosaic_horizontal=0.0, mosaic_vertical=0.0, r0=1.0, d_spacing=0.0, radius_vertical=0.0, radius_horizontal=0.0, idx=0, ctx=0, **kwargs)[source]

Scattering kernel for general curved Monochromator. Recreates the functionality of the Monochromator_curved component in McStas. Reflection takes place from the local yz plane, higher order scattering and anisotropic gaussian mosaic is simulated.

Parameters:
slab_width : float

Width of monochromator crystal slabs in meters

slab_height : float

Height of monochromator crystal slabs in meters

gap : float

Gap between monochromator crystal slabs in meters

n_horizontal : float

Number of monochromator crystal slabs in the z direction

n_vertical : float

Number of monochromator crystal slabs in the y direction

mosaic_horizontal : float

Crystal mosaic in the z direction in arc minutes

mosaic_vertical : float

Crystal mosaic in the y direction in arc minutes

r0 : float

Maximum reflectivity of the monochromator crystal

d_spacing : float

Lattice spacing of the monochromator crystal plane in AA

radius_vertical : float

Radius of curvature normal to the z direction in meters

radius_horizontal : float

Radius of curvature normal to the y direction in meters

Methods

Data None
Plot None
Save None

Linear collimator (SLinearCollimator)

class mcramp.scat.SLinearCollimator(length=0.0, divergence_H=0.0, divergence_V=0.0, transmission=1.0, idx=0, ctx=0, **kwargs)[source]

Scattering kernel for Linear Collimator component. Recreates the functionality of the Collimator_linear component in McStas. Neutrons with divergence exceeding that permitted by the collimator are terminated.

Parameters:
length : float

Flight path length of the collimator

divergence_H : float

Maximum horizontal divergence accepted by the collimator

divergence_V : float

Maximum vertical divergence accepted by the collimator

transmission : float

Transmission coefficient of the collimator

Methods

Data None
Plot None
Save None

Polarisation

Polariser (SPolariser)

class mcramp.scat.SPolariser(polarisation=[0, 0, 0], idx=0, ctx=None, filename=None, **kwargs)[source]

Scattering kernel for ideal polariser component. Sets neutron polarisation to value of polarisation parameter.

Parameters:
polarisation : 3-tuple of floats

Value to set neutron polarisation to

Methods

Data None
Plot None
Save None

Analyser (SAnalyser)

class mcramp.scat.SAnalyser(polarisation=[0, 0, 0], idx=0, ctx=None, filename=None, **kwargs)[source]

Scattering kernel for ideal analyser component. Adjusts neutron weight based on dot product between neutron polarisation and polarisation parameter, and sets neutron polarisation to the analysed direction.

Parameters:
polarisation : 3-tuple of floats

Vector against which neutron polarisation should be analysed

Methods

Data None
Plot None
Save None

Samples

Multi line powder (SPowderN)

class mcramp.scat.SPowderN(d_spacing=[0.0], pack=0.0, vc=0.0, sigma_abs=0.0, multiplicity=[0], DW=0.0, F2=[0.0], d_phi=180.0, transmit=1, idx=0, ctx=None, **kwargs)[source]

Scattering kernel for Bragg scattering powder sample. Recreates the functionality of the PowderN component in McStas. If a neutron satisfies the Bragg condition, it is scattered at an angle twotheta into a random angle on the Debye-Scherrer cone. Phi focusing is implemented to improve simulation performance.

WARNING: Neutron weights are NOT verified to be physically accurate for the scattering from this component, however the lineshape is correct.

Parameters:
d_spacing : float array

Lattice spacings corresponding to the Bragg powder lines in AA

pack : float in range [0, 1]

Packing fraction of the sample

vc : float

Volume of the sample unit cell in AA^3

sigma_abs : float

Absorption cross section of the sample at 2200 m/s in barns

multiplicity : int array

Multiplicity of the powder lines

DW : float in range [0, 1]

Debye-Waller factor

F2 : float array

Structure factors of the powder lines

d_phi : float in range [0.0, 180.0]

Max angle around Debye-Scherrer cone into which neutrons are scattered

Methods

Data None
Plot None
Save None

Single line powder (SPowder1)

class mcramp.scat.SPowder1(d_spacing=0.0, pack=0.0, vc=0.0, sigma_abs=0.0, multiplicity=0, DW=0.0, F2=0.0, d_phi=180.0, idx=0, ctx=None, **kwargs)[source]

Scattering kernel for single Bragg scattering powder sample. Recreates the functionality of the Powder1 component in McStas. If a neutron satisfies the Bragg condition, it is scattered at an angle twotheta into a random angle on the Debye-Scherrer cone. Phi focusing is implemented to improve simulation performance.

WARNING: Neutron weights are NOT verified to be physically accurate for the scattering from this component, however the lineshape is correct.

Parameters:
d_spacing : float

Lattice spacing corresponding to the Bragg powder line in AA

pack : float in range [0, 1]

Packing fraction of the sample

vc : float

Volume of the sample unit cell in AA^3

sigma_abs : float

Absorption cross section of the sample at 2200 m/s in barns

multiplicity : int

Multiplicity of the powder line

DW : float in range [0, 1]

Debye-Waller factor

F2 : float

Structure factor of the powder line

d_phi : float in range [0.0, 180.0]

Max angle around Debye-Scherrer cone into which neutrons are scattered

Methods

Data None
Plot None
Save None

TAS resolution sample (SRescal)

class mcramp.scat.SRescal(target=[0, 0, 0], E0=0, dE=0, focus_r=0, idx=0, ctx=None, **kwargs)[source]

Methods

data  
data_reduce  
lines  
plot  
save  
scatter_prg  

Isotropic powder (SIsotropic)

class mcramp.scat.SIsotropic(fn_coh='', fn_inc='', fn_mag='', temperature=0, transmit=1, idx=0, ctx=None, **kwargs)[source]

Scattering kernel for an isotropic scatterer which samples from a S(Q, w) distribution specified in a file format as set out by the corresponding McStas component.

Parameters:
fn_coh : str

Filename of S(Q, w) file specifying coherent scattering (no polarisation effect)

fn_inc : str

Filename of S(Q, w) file specifying incoherent scattering (2/3rd spin flip)

fn_mag : str

Filename of S(Q, w) file specifying magnetic scattering (Halpern-Johnson pol rule)

temperature : float

Temperature of scattering sample for detailed balance

transmit : int

Flag which specifies if transmitted beam should be retained (0 = off, 1 = on)

Methods

Data None
Plot None
Save None

Others

Arm (SArm)

class mcramp.scat.SArm(idx=0, ctx=None, **kwargs)[source]

Scattering kernel for Arm component - does not alter the neutron state.

Parameters:
None

Methods

Data None
Plot None
Save None

Beamstop (SBeamstop)

class mcramp.scat.SBeamstop(idx=0, ctx=None, filename=None, **kwargs)[source]

Scattering kernel for the beamstop component. Absorbs neutrons.

Parameters:
None

Methods

Data None
Plot None
Save None