MCSTAS(1)

πŸ“¦
version 3.5+3.5.19 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute

✨ 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 file FILE. that's it, that's the whole job ✨
  • -I DIR, –search-dir=DIR β€” append DIR to the component search list. feeding it more places to look πŸ”
  • -t, –trace β€” enable trace mode for instrument display πŸ‘€
  • -v, –version β€” prints the mcstas version. the classic "who am i" moment πŸ’
  • –no-main β€” do not create main(), 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.json
  • http://www.mcstas.org

⭐ EXAMPLES ⭐

Translate the Test_SX example (Single crystal diffraction) into C β€” watch and learn 🧚

  • mcstas Test_SX.instr
  • gcc 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