- DMC McStas simulation working

SKIPPED:
	psi/amorstat.c
	psi/nxamor.c
	psi/pimotor.c
	psi/polterwrite.c
This commit is contained in:
koennecke
2005-07-05 07:06:15 +00:00
parent 9e0447b7dd
commit 96e8cdb2d5
22 changed files with 916 additions and 137 deletions

104
mcstas/dmc/MKMonitor.comp Normal file
View File

@ -0,0 +1,104 @@
/*******************************************************************************
*
* McStas, neutron ray-tracing package
* Copyright 1997-2002, All rights reserved
* Risoe National Laboratory, Roskilde, Denmark
* Institut Laue Langevin, Grenoble, France
*
* Component: Monitor
*
* %I
* Written by: Kim Lefmann
* Date: October 4, 1997
* Version: $Revision: 1.19 $
* Origin: Risoe
* Release: McStas 1.6
* Modified to write monitor file for SICS: Mark Koennecke, June 2005
*
* Simple single detector/monitor.
*
* %D
* Sums neutrons (0th, 1st, and 2nd moment of p) flying through
* the rectangular monitor opening. May also be used as detector.
*
* Example: Monitor(xmin=-0.1, xmax=0.1, ymin=-0.1, ymax=0.1)
*
* %P
* INPUT PARAMETERS:
*
* xmin: Lower x bound of opening [m]
* xmax: Upper x bound of opening [m]
* ymin: Lower y bound of opening [m]
* ymax: Upper y bound of opening [m]
*
* OUTPUT PARAMETERS:
*
* Nsum: Number of neutron hits
* psum: Sum of neutron weights
* p2sum: 2nd moment of neutron weights
*
* %E
*******************************************************************************/
DEFINE COMPONENT MKMonitor
DEFINITION PARAMETERS ()
SETTING PARAMETERS (xmin, xmax, ymin, ymax,char *controlfile="mon1.dat",int dumpCount=1000)
OUTPUT PARAMETERS (Nsum, psum, p2sum,currentCount)
STATE PARAMETERS (x,y,z,vx,vy,vz,t,s1,s2,p)
SHARE
%{
void dumpTotal(char *ffilename, long totalCounts){
FILE *fd = NULL;
fd = fopen(ffilename,"w");
if(fd != NULL){
fprintf(fd,"%ld\n",totalCounts);
fclose(fd);
}
}
%}
DECLARE
%{
long currentCount;
double Nsum;
double psum, p2sum;
%}
INITIALIZE
%{
psum = 0;
p2sum = 0;
Nsum = 0;
currentCount = 0;
%}
TRACE
%{
PROP_Z0;
if (x>xmin && x<xmax && y>ymin && y<ymax)
{
Nsum++;
psum += p;
p2sum += p*p;
currentCount++;
if(dumpCount > 0 && currentCount > dumpCount){
dumpTotal(controlfile,Nsum);
currentCount = 0;
}
SCATTER;
}
%}
SAVE
%{
DETECTOR_OUT_0D("Single monitor", 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