First tries using McStas

Kristian Nielsen kristian.nielsen at risoe.dk
Thu Nov 12 15:13:27 CET 1998


Hi Georg,

> using your component Guide2 for different coatings for left/right and
> top/bottom faces of a guide I have now a first set up which could be
> compared to a calculation with the program Beamline written by Jeremy Cook.

Great!

> Beamline is able to compute absolute fluxes. Is there any possibility
> to calculate absolute fluxes with McStas?

Yes, computing absolute fluxes is possible. The tricky part is to get
the units right.Ian Anderson from ILL was here a couple of days before
the Workshop. Together we set up a simple simulation of the in14
instrument at ILL and computed the absolute flux at the sample position.

As the unit of measure for the flux at the source we use

  number of neutrons per square cm per solid angle in
  steradians per wavelength in Aangstroem: n/(cm*cm*st*AA).

The component Source_flat models a source that emits N neutrons in the
full 4PI solid angle, where N is the number of neutron histories
simulated. Therefore, if delta_lambda is the range of wavelengths
emitted from the source in AA and r is the radius of the source in cm,
we can compute the total flux of the source simulated by McStas as
follows:

    flux = N / (PI*r*r * 4PI * delta_lambda)

To compare with another source of flux flux', the intensities in the
detector computed by McStas should be multiplied by the factor
(flux'/flux). Together with Ian I modified the Source_flat component to
compute this factor, but it still needs some polishing. I will look at
it and send it to you when it is ready.

Note that the intensity in detectors in McStas is the sum of the
statistical weights of incident neutrons. The actual number of neutron
histories that reach the detector is not very meaningfull because of
inportance sampling etc.

> Another possible comparison is the transmission. Within Beamline, 
> the transmission is the number of neutrons detected divided by the
> number of neutrons entering the first guide section. To calculate an
> "equivalent" transmission with the output of McStas I divided the
> value mon_I by the solid angle at the source and divided the resulting 
> value by the number of started neutrons. Is that correct?

It would probably be simpler to place one monitor at the guide entrance
and one at the exit. The transmission is then the ratio between the
intensities in the two monitors, mon2_I/mon1_I. The monitor at the
entrance must have the same dimensions as the guide opening, of course.

You will probably also want to compare the formula for mirror
reflectivity that McStas uses (page 30 in the manual) with the one used
in your program. If they are different it might be difficult to compare
results directly.

> At the moment I'm trying to compare the profiles. Unfortunately we
> don't have MATLAB so I need a workaround. The spatial distribution of
> neutrons at the detector is no problem. How can I get the angular
> distribution with McStas?

You can use the angular divergence detector that Kim Lefmann just wrote
today (for a simulation of our RITA spectrometer). It computes the
intensity as a function of angular divergence. I have put it on our Web
Page at the URL

http://elu-alf-2.risoe.dk/~elu-krni/mcstas/support/misc/Divergence_monitor.comp


> missing. I've installed all packages (from the CD: PGPLOT, PDL,

I am a bit confused here. You say that you installed PGPLOT. Did you
install both pgplot5.2.tar.gz and PGPLOT-2.11.tar.gz? Both are needed
for mcdisplay to work.

Btw, for pgplot5.2.tar.gz, the optional C bindings must also be
installed. There should be a file "cpgdemo" that correctly displays a
few graphs when run.

When you install PGPLOT-2.11.tar.gz, after running "make", running
"make test" should correctly display some simple examples in a window.

> Unquoted string "pgend" may clash with future reserved word at /usr/local/bin/mcdisplay line 293.
> Useless use of a constant in void context at /usr/local/bin/mcdisplay line 293.
> Undefined subroutine &main::pgbegin called at /usr/local/bin/mcdisplay line 261.
> artus at obiwan:/home/artus/mcstas/example > 

This looks as if the PGPLOT calls (pgend, pgbegin and so on) are not
recognized by perl. This is a bit strange, given that perl apparently
now does find the pgplot <-> perl interface file "PGPLOT.pm". In your
first mail, you wrote that perl failed to find this file:

> 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.

I assume that installing the PGPLOT-2.11.tar.gz package fixed this?
Anyway, it appears that it did not install properly. When you installed
PGPLOT-2.11.tar.gz, did the "make test" command run correctly and
display a window?

If I remove the "use PGPLOT;" line at the top of the mcdisplay file, I
get the exact same error messages you do. Did you by any chance modify
the mcdisplay file?

It is a bit unfortunate that getting the graphics runnig is so
difficult. Especially since future versions of McStas will have much
better graphics. If you are able to give me a login account on your
machine and want me to help, I can log in remotely and try to find out
what the problem is.

Hope this helps,

 - Kristian.






More information about the mcstas-users mailing list