First tries using McStas
Kristian Nielsen
kristian.nielsen at risoe.dk
Fri Nov 6 09:36:17 CET 1998
> Dear Kristian,
>
> in the last days since our return from Denmark I've installed your
> program McStas on my machine here. Right now I'm trying to get my
> first "instrument" running. I have some 'beginners problems' and now allow
> myself to ask for help.
> I wanted to simulate a simple straight neutron guide with m=2 for left
> and right faces and m=3 for top and bottom faces. But the component
> Guide only allows one kind of coating. It is not quite clear to me
> from the manual how to build such a guide out of four Mirror
> components. The manual says that Mirrors can be used to assemble a
> guide but it says also that a Mirror lies in the xy-plane. Wouldn't
> one need Mirrors lying parallel to the z-axis to build a guide? May be
You need to rotate the mirror appropriately. For the top and bottom,
rotate around the X axis. For the sides, rotate around the Y axis. (And
I need to add this info to the manual!). You must take care to use
mirrors that are short enough that each neutron cannot hit a single
mirror more than once.
This is a simple example (not fully tested):
------------------------------------------------------------------------
/* 4cm by 10cm, 1m long guide build from mirrors. */
COMPONENT guide = Axis()
AT (0,0,1.5) RELATIVE source
COMPONENT mirrorh1 = Mirror(xlength = 0.04, yheight = 1.00, m = 3,
Qc=0.02, W=0.0033, alpha=6.49, R0=1)
AT (-0.02,-0.05,0) RELATIVE guide
ROTATED (90,0,0) RELATIVE guide
COMPONENT mirrorh2 = Mirror(xlength = 0.04, yheight = 1.00, m = 3,
Qc=0.02, W=0.0033, alpha=6.49, R0=1)
AT (-0.02,0.05,0) RELATIVE guide
ROTATED (90,0,0) RELATIVE guide
COMPONENT mirrorv1 = Mirror(xlength = 1.00, yheight = 0.1, m = 2,
Qc=0.02, W=0.0033, alpha=6.49, R0=1)
AT (-0.02,-0.05,0) RELATIVE guide
ROTATED (0,90,0) RELATIVE guide
COMPONENT mirrorv2 = Mirror(xlength = 1.00, yheight = 0.1, m = 2,
Qc=0.02, W=0.0033, alpha=6.49, R0=1)
AT (0.02,-0.05,0) RELATIVE guide
ROTATED (0,90,0) RELATIVE guide
------------------------------------------------------------------------
> the use of different coatings within the same guide can be implemented
> within the Guide component in some future release?
I have added it on my "ToDo" list. You might want to try modifying the
guide component yourself, it should not be difficult. What you need to
do is:
1. Copy the file "Guide.comp" into your directory as "Guide2.comp" and
edit the new file as follows:
2. Change the name of the component from "Guide" to "Guide2":
DEFINE COMPONENT Guide2
3. Replace the "m" definition parameter with two others, "mh" and
"mv":
DEFINITION PARAMETERS (w1, h1, w2, h2, l, R0, Qc, alpha, mh, mv, W)
4. Look in the calculations to see that the variable "i" is set to 1 or
2 for intersection with vertical mirrors, and 3 or 4 for horizontal
mirrors. Now find the calculation of the reflectivity and change it to
use mv if i <= 2, and mh otherwise:
double arg = (q - (i <= 2 ? mv : mh)*Qc)/W;
That should be all! You can now use "Guide2" instead of "Guide" using
"mh" and "mv" for horizontal and vertical m-value. I have put up a
version of Guide with these modifications on the Web server that you may
download from
http://elu-alf-2.risoe.dk/~elu-krni/mcstas/support/misc/Guide2.comp
> To make things easier I tried to set up the instrument with m=2 for
> all faces. But trying to compile it with McStas ends with:
>
> artus at obiwan:/home/artus/mcstas/resi1 > mcstas resi1.instr
> parse error, expecting `"AT"' at line 37.
> Errors encountered during parse.
> artus at obiwan:/home/artus/mcstas/resi1 >
>
> The AT is expected in the END line?
> I cannot find any error in resi1.instr:
The reason for the strange error message is that you have an
unterminated comment:
> dE = 1.0) /* =0.99394A - 1.00617A
here -> ^^^
So the rest of the file is just a comment as far as McStas is
concerned :-(
Once you fix this, you also need to separate the arguments to "Guide"
with commas:
> COMPONENT guide1 = Guide(
> w1 = 0.020
> h1 = 0.060
> w2 = 0.020
> h2 = 0.060
> l = 11.500
> R0 = 1.0
> Qc = 0.0214
> alpha = 5.617
> m = 2
> W = 0.0033)
> AT (0,0,2) RELATIVE a1
This should be
COMPONENT guide1 = Guide(
w1 = 0.020,
h1 = 0.060,
w2 = 0.020,
h2 = 0.060,
l = 11.500,
R0 = 1.0,
Qc = 0.0214,
alpha = 5.617,
m = 2,
W = 0.0033)
AT (0,0,2) RELATIVE a1
> Furthermore I've tried to use mcdisplay on the example files but this
> also ends with an error:
>
> artus at obiwan:/home/artus/mcstas/example > mcdisplay linup-1.instr
> Can't locate PGPLOT.pm in @INC (@INC contains: /usr/lib/perl5/i586-linux/5.00404 /usr/lib/perl5 /usr/lib/perl5/site_perl/i586-linux /usr/lib/perl5/site_perl .) at /usr/local/bin/mcdisplay line 6.
> BEGIN failed--compilation aborted at /usr/local/bin/mcdisplay line 6.
> artus at obiwan:/home/artus/mcstas/example >
You need to also install PgPerl, which is an interface that allows perl
programs to use pgplot. PgPerl is included on the CD in the file
external/PGPLOT-2.11.tar.gz
> Thank you very much for your help and
You are welcome! If you have any further questions, just mail me again
and I will do my best to help.
- Kristian.
More information about the mcstas-users
mailing list