MCSTAS(1)
β¨ NAME β¨
mcstas β the compiler of the mcstas neutron ray-trace simulation package π (yes bestie, that whole mouthful, it's the translator of your instrument dreams)
π SYNOPSIS π
mcstas [-o file] [-I dir1 ...] [-t] [-p] [-v] [βno-main] [βno-runtime]
[βverbose] file
π¦ DESCRIPTION π¦
okay so here's the vibe: the compiler for the mcstas instrument definition gets summoned when you type a command of the form mcstas name.instr in a shell or command prompt. simple as.
It reads the beamline definition name.instr β which is written in the mcstas meta-language β and translates that instrument definition into a Monte Carlo simulation program, provided in ISO-C. slay.
Where does the output go? By default it lands in a file in the current directory with the same name as the instrument file, except the extension is .c rather than .instr. iconic. You can override that with the -o option like this:
mcstas -o code.c name.instr
β¦which gives you the output in the file code.c π
A single dash - may be used for both the input and the output filename, to represent standard input and standard output, respectively. no cap.
The default component search list is usually defined by the environment variable MCSTAS β and its default is /usr/share/mcstas/resources. noted π
Also, real talk: often it will be way more convenient to use the front-end program mcgui or mcrun. These front-ends will compile and run the simulations automatically. main character energy honestly π«Ά
The usual instrument syntax is:
DEFINE INSTRUMENT name(parameters)
DECLARE %{
// C_code
%}
INITIALIZE %{
// C_code
%}
TRACE
COMPONENT name = comp(parameters)
WHEN (condition)
AT (...) [RELATIVE reference
{ROTATED {RELATIVE reference }
EXTEND %{
// C_code
%}
FINALLY %{
// C_code
%}
END
π OPTIONS π
-o FILE,βoutput-file=FILEβ place the C output in fileFILE. that's it, that's the whole job β¨-I DIR,βsearch-dir=DIRβ appendDIRto the component search list. feeding it more places to look π-t,βtraceβ enabletracemode for instrument display π-v,βversionβ prints the mcstas version. the classic "who am i" moment πβno-mainβ do not createmain(), for external embedding. you're the main character here, not it πβno-runtimeβ do not embed run-time libraries. keep it lean, bestieβverboseβ display compilation process steps. narrate the whole journey fr fr ποΈβsourceβ embed the instrument source code in the executable π¦
πΈ FILES πΈ
/usr/share/mcstas/resources/usr/share/mcstas/tools/Python/mccodelib/mccode_config.json~/.mcstas/mccode_config.jsonhttp://www.mcstas.org
β EXAMPLES β
Translate the Test_SX example (Single crystal diffraction) into C β watch and learn π§
mcstas Test_SX.instrgcc Test_SX.instr -o Test_SX.out -lm
π AUTHORS π
mcstas Team (mcstas.org)
π SEE ALSO π
mcstas(1), mcdoc(1), mcplot(1), mcrun(1), mcgui(1), mcdisplay(1) β the whole friend group, go say hi π
π AUTHORS π
MCSTAS neutron Ray Tracing Team. (they ate, and they left no crumbs π)
and that's the tea, bestie β this little masterpiece is served to you straight from source/version git, under the manual name MCSTAS(1). go compile something gorgeous π β¨
π¦ where this page comes from
- debian trixie: mcstas 3.5+3.5.19+ds5-2 Β· GPL-3.0-only
- ubuntu questing: mcstas 3.5+3.5.19+ds5-2
- ubuntu resolute: mcstas 3.5+3.5.19+ds5-2build1 Β· GPL-3.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms