McStas logo McStas - A neutron ray-trace simulation package ILL; PSI; ESS Niels Bohr Institute DTU Physics

McStas

About McStas
 Conditions of use
 Authors/Contacts
 Project funding

Download
 Components

Mailing list

Search web/mailinglist

Documentation
 Wiki (GitHub)
 McStas manual
 Publications

Links

Report bugs (GitHub)

Code-repository (GitHub)


McStas: MCPL_input

[ Identification | Description | Input parameters | Links ]

The MCPL_input Component

Source-like component that reads neutron state parameters from an mcpl-file.

Identification

  • Author: Erik B Knudsen, Gregory S Tucker and Peter Willendrup
  • Origin: DTU Physics / European Spallation Source ERIC
  • Date: Mar 2016, consolidated with MCPL_input_once Oct 2026

Description

Source-like component that reads neutron state parameters from a binary mcpl-file.

MCPL is short for Monte Carlo Particle List, and is a format for sharing events
between e.g. MCNP(X), Geant4 and McStas.

The --ncount given on the commandline is overwritten by
(#particles in the file) x repeat_count. Particles that are not neutrons, or are
outside [Emin, Emax], are counted but ABSORBed.

The rays form a stream that runs through the file repeat_count times. As in KDSource,
this stream is split into one contiguous chunk per MPI process: each process seeks once
to its start and reads on, wrapping around to the start of the file (with preload=1 it
loads only the part of the file its chunk covers). Every event is thus used
repeat_count times across the whole run, and its weight is divided by repeat_count.
All passes after the first are smeared using v_smear, pos_smear and dir_smear (the first
pass is too if always_smear is set), so repeat_count > 1 MUST be combined with at least
one *_smear option; if all are 0, repeat_count is reset to 1.

With replicate_across_processes=0 (the default, as in MCPL_input_once) the file is shared
between the MPI processes and --mpi=N does not change the number of rays.
replicate_across_processes=1 restores the pre-Oct 2026 MPI behaviour: repeat_count is
rounded up to a multiple of the number of MPI processes, so that every process runs
through the whole file at least once, and all but the first pass on the master are
smeared (or, with all *_smear=0, are identical copies).

Example: MCPL_input(filename=voutput,verbose=1,repeat_count=1,v_smear=0.1,pos_smear=0.001,dir_smear=0.01)

Input parameters

Parameters in boldface are required; the others are optional.
NameUnitDescriptionDefault
filenamestrName of neutron mcpl file to read0
polarisationuse If !=0 read polarisation vectors from file1
verbose Print debugging information for the first 10 neutrons read (on the master process)0
EminmeVLower energy bound. Particles found in the MCPL-file below the limit are skipped0
EmaxmeVUpper energy bound. Particles found in the MCPL-file above the limit are skippedFLT_MAX
repeat_count1Replay the contents of the MCPL file this number of times, dividing the event weights by the same number. MUST be combined with _smear options!1
v_smear1When replaying events, make a flat MC choice within v_smear*V around particle velocity V0
pos_smearmWhen replaying events, make a flat MC choice of position within pos_smear around particle starting position0
dir_smeardegWhen replaying events, make an MC choice of direction within dir_smear around particle direction0
preload Load particles during INITIALIZE. On GPU preload is forced0
always_smear If !=0, also smear the events on their first pass through the file0
replicate_across_processes If !=0, with MPI round repeat_count up to a multiple of the number of processes, so that each process runs through the whole file0
AT ( , , ) RELATIVE
ROTATED ( , , ) RELATIVE

Links


[ Identification | Description | Examples | Input parameters | Links ]

Generated on mcstas 3.10.0


Last Modified: Friday, 23-Oct-2026 18:32:10 CEST
Search website mailinglist archive GitHub repos