kw_monitor

Farhi farhi at ill.fr
Tue Oct 5 11:39:51 CEST 1999


Hy Kristian,

Concerning the kw_monitor, I saw you installed it in the unofficial
additions to McStas. It's great, thanks. Anyway, I modified a line at
the begining in order to be able to use more than one of these monitors
in one instrument definition. Could you update this ?


OUTPUT PARAMETERS (Nsum, psum, p2sum,file,nlines)

I attach the total file as well.

I'm still on the optimizer. I got some problems in computing the adapted
'pi' probability.
For some neutrons, it becomes very big, that makes spikes on instruments
monitors.
The neutrons responsible for this are those whose efficiency is low (the
optimized source should emit few of those, thus their weight is high).
I'm thinking about suppresing them...

Cheers.

--
Emmanuel FARHI, http://www.ill.fr/tas/people/Farhi.html     \|/ ____ \|/
TAS-Group, Institut Laue-Langevin (ILL) Grenoble            ~@-/ oO \-@~
Avenue des Martyrs, BP 156, 38042 Grenoble Cedex 9,France   /_( \__/ )_\
Work :Tel (33/0) 4 76 20 71 83. Fax (33/0) 4 76 48 39 06       \__U_/
La Grande Arche, Chateau d'Uriage, 38410 Saint Martin d'Uriage 04 76 59 73 94


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman2.mcstas.org/pipermail/mcstas-users/attachments/19991005/f39a2a38/attachment.html>
-------------- next part --------------
/*******************************************************************************
*
* McStas, version 1.1, released 
*         Maintained by Kristian Nielsen and Kim Lefmann,
*         Risoe National Laboratory, Roskilde, Denmark
*
* Component: kw_monitor
*
* Written by: EF, 17 Sept 1999
*
* A monitor that list all neutron (k,w).
* Output is a 2D matrix of lines [ kx ky kz Omega Intensity DeltaIntensity ]
* stored if a file. The integrated flux is also measured.
*
* INPUT PARAMETERS:
*
* xmin:     Lower x bound of detector opening (m)
* xmax:     Upper x bound of detector opening (m)
* ymin:     Lower y bound of detector opening (m)
* ymax:     Upper y bound of detector opening (m)
* filename: Name of file in which to store the counts (text)
*
* OUTPUT PARAMETERS:
*
* Nsum:    Integrated neutron counts
* psum:    Integrated neutron weight counts
* p2sum:   Integrated second moments
*
*******************************************************************************/

DEFINE COMPONENT kw_monitor
DEFINITION PARAMETERS (xmin, xmax, ymin, ymax, filename)
SETTING PARAMETERS ()
OUTPUT PARAMETERS (Nsum, psum, p2sum,file,nlines)
STATE PARAMETERS (x,y,z,vx,vy,vz,t,s1,s2,p)
DECLARE
  %{
    int nlines;
    int Nsum;
    double psum, p2sum;
    FILE *file;
    double kx, ky, kz, E;
  %}
INITIALIZE
  %{
    psum = 0;
    p2sum = 0;
    Nsum = 0;
    nlines = 0;
    file = fopen(filename, "w");
    if(!file)
    {
       fprintf(stderr, "Error: %s : could not open output file '%s'\n", mccompcurname, filename);
       exit(-1);
    }
    else
    {
       fprintf(file,"# Instrument-source: %s\n", mcinstrument_source);
       mcruninfo_out("# ", file);
       fprintf(file,"# type: array_2d(-1,6) (See end of file for exact dimensions)\n");
       fprintf(file,"# component: %s\n", mccompcurname);
       fprintf(file,"# title: Resolution (\\vec{k},omega) Monitor\n");
       fprintf(file,"# filename: '%s'\n",filename);
       fprintf(file,"# variables: Kx Ky Kz E I I_err\n");
       fprintf(file,"# xvar: (Kx Ky Kz E)\n");
       fprintf(file,"# yvar: (I,I_err)\n");
       fprintf(file,"# xlabel: 'Wavevector [Angs-1], Energie [meV]'\n");
       fprintf(file,"# ylabel: 'Intensity'\n");
    }
  %}
TRACE
  %{
    PROP_Z0;
    if (x>xmin && x<xmax && y>ymin && y<ymax)
    {
      Nsum++;
      psum += p;
      p2sum += p*p;
      nlines++;
      
      kx = V2K*vx;
      ky = V2K*vy;
      kz = V2K*vz;
      E = VS2E*(vx*vx + vy*vy + vz*vz);
      
	fprintf(file, "%g %g %g %g %g %g\n",
		kx, ky, kz, E, p, p*p);
    }
  %}
FINALLY
  %{
    if (file)
    {
       fprintf(file,"# type: array_2d(%i,6)\n",nlines);
       fprintf(file,"# End of (k,omega) resolution block.\n");
       fclose(file);
    }
    DETECTOR_OUT_0D("Resolution_monitor (integrated)", Nsum, psum, p2sum);
  %}
  
MCDISPLAY
%{
  magnify("xy");
  multiline(5, (double)xmin, (double)ymin, 0.0,
               (double)xmax, (double)ymin, 0.0,
               (double)xmax, (double)ymax, 0.0,
               (double)xmin, (double)ymax, 0.0,
               (double)xmin, (double)ymin, 0.0);
%}
END


More information about the mcstas-users mailing list