- DMC McStas simulation working
SKIPPED: psi/amorstat.c psi/nxamor.c psi/pimotor.c psi/polterwrite.c
This commit is contained in:
@ -1,3 +1,3 @@
|
||||
6
|
||||
71
|
||||
NEVER, EVER modify or delete this file
|
||||
You'll risk eternal damnation and a reincarnation as a cockroach!|n
|
104
mcstas/dmc/MKMonitor.comp
Normal file
104
mcstas/dmc/MKMonitor.comp
Normal 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
|
@ -10,7 +10,7 @@
|
||||
* %I
|
||||
* Written by: Kim Lefmann
|
||||
* Date: Feb 3, 1998
|
||||
* Version: $Revision: 1.1 $
|
||||
* Version: $Revision: 1.2 $
|
||||
* Origin: Risoe
|
||||
* Release: McStas 1.6
|
||||
*
|
||||
@ -118,24 +118,10 @@ TRACE
|
||||
%}
|
||||
SAVE
|
||||
%{
|
||||
DETECTOR_OUT_2D(
|
||||
"PSD monitor",
|
||||
"X position [cm]",
|
||||
"Y position [cm]",
|
||||
xmin*100.0, xmax*100.0, ymin*100.0, ymax*100.0,
|
||||
nx, ny,
|
||||
&PSD_N[0][0],&PSD_p[0][0],&PSD_p2[0][0],
|
||||
filename);
|
||||
%}
|
||||
|
||||
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
|
||||
|
62
mcstas/dmc/conv.tcl
Normal file
62
mcstas/dmc/conv.tcl
Normal file
@ -0,0 +1,62 @@
|
||||
#!/usr/bin/tclsh
|
||||
#--------------------------------------------------------------------------
|
||||
# script for extracting detector data with error bars from a simulation
|
||||
# XML file. The output can be used for plotting with gnuplot
|
||||
# The program reads from stdin and prints to stdout.
|
||||
#
|
||||
# Mark Koennecke, July 2005
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
#------- locate detector data
|
||||
while { [gets stdin line] >= 0} {
|
||||
if {[string first det9.dat $line] > 0} {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
#------- locate data record
|
||||
while { [gets stdin line] >= 0} {
|
||||
if {[string first "<data" $line] > 0} {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
#------ remove XML stuff
|
||||
set idx [string first > $line]
|
||||
set line [string range $line [expr $idx + 1] end]
|
||||
|
||||
set l [split $line]
|
||||
set count 0
|
||||
foreach e $l {
|
||||
set e [string trim $e]
|
||||
if { [string length $e] > 0} {
|
||||
set data($count) $e
|
||||
incr count
|
||||
}
|
||||
}
|
||||
set maxCount $count
|
||||
|
||||
#---- find errors line
|
||||
while { [gets stdin line] >= 0} {
|
||||
if {[string first "<errors" $line] > 0} {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
#------ remove XML stuff
|
||||
set idx [string first > $line]
|
||||
set line [string range $line [expr $idx + 1] end]
|
||||
|
||||
set l [split $line]
|
||||
set count 0
|
||||
foreach e $l {
|
||||
set e [string trim $e]
|
||||
if { [string length $e] > 0} {
|
||||
set err($count) $e
|
||||
incr count
|
||||
}
|
||||
}
|
||||
|
||||
for {set i 0} {$i < $maxCount} {incr i} {
|
||||
puts stdout "$i $data($i) $err($i)"
|
||||
}
|
@ -101,7 +101,7 @@ COMPONENT out2_slit = Slit(
|
||||
AT (0,0,0.65) RELATIVE msa ROTATED (0,0,0) RELATIVE msa
|
||||
|
||||
COMPONENT PSD_sample = PSD_monitor(
|
||||
xmin=-0.05, xmax=0.05, ymin=-0.07, ymax=0.07,
|
||||
xmin=-0.02, xmax=0.02, ymin=-0.065, ymax=0.065,
|
||||
nx=80, ny=80, filename="PSD_sample.dat",controlfile=monfile, dumpCount=500)
|
||||
AT ( 0, 0, 1.5) RELATIVE msa
|
||||
|
||||
@ -125,60 +125,3 @@ AT (0,0,0) RELATIVE sa_arm
|
||||
ROTATED (0, 0, 180) RELATIVE sa_arm
|
||||
|
||||
END
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
145
mcstas/dmc/dmc_sics05.instr
Normal file
145
mcstas/dmc/dmc_sics05.instr
Normal file
@ -0,0 +1,145 @@
|
||||
DEFINE INSTRUMENT DMC_diff(lambda,Det_start, char *samplefile, char *monfile)
|
||||
DECLARE
|
||||
%{
|
||||
double mono_q;
|
||||
double dm;
|
||||
double OMA;
|
||||
double RV;
|
||||
double NV = 5;
|
||||
double TKOFF;
|
||||
double sample_radius = 0.005;
|
||||
double sample_height = 0.03;
|
||||
double lambda;
|
||||
double ldiff=0.5;
|
||||
double Det_start;
|
||||
double Det_end;
|
||||
char option_list[150];
|
||||
%}
|
||||
|
||||
INITIALIZE
|
||||
%{
|
||||
dm = 3.3537;
|
||||
TKOFF = lambda/(2.*dm);
|
||||
TKOFF = 2.*asin(TKOFF)*57.29577951308232087679815481410517;
|
||||
printf("TKOFF = %f\n", TKOFF);
|
||||
OMA = TKOFF/2;
|
||||
RV = fabs(2*2.82*sin(DEG2RAD*OMA));
|
||||
Det_end= Det_start + 80;
|
||||
sprintf(option_list,"banana theta limits [%f %f] bins=400, file=det9.dat",Det_start,Det_end);
|
||||
printf("%s \n",option_list);
|
||||
%}
|
||||
|
||||
TRACE
|
||||
|
||||
COMPONENT source_arm = Arm()
|
||||
AT (0, 0, 0) ABSOLUTE
|
||||
|
||||
COMPONENT progress = Progress_bar(percent=5,flag_save=1)
|
||||
AT (0,0,0) ABSOLUTE
|
||||
|
||||
/* values for guide side window RNR12 */
|
||||
COMPONENT csource = Source_gen(
|
||||
radius = 0.08,xw = 0.02, yh = 0.12, dist = 1.5,
|
||||
Lambda0 = lambda, dLambda = ldiff,
|
||||
T1=150.42,I1=5.98e11,
|
||||
T2=37.23,I2=5.637e11,T3=14.9,I3=0.962e11)
|
||||
AT (0,0,0) RELATIVE source_arm ROTATED (0,0,0) RELATIVE source_arm
|
||||
|
||||
/* guide segment 1, m=2, 4.66 m */
|
||||
COMPONENT guide1 = Guide(w1=0.02, h1=0.12, w2=0.02, h2=0.12,
|
||||
l=4.66, R0=0.995, Qc=0.0217, alpha = 5.76,
|
||||
m = 2.0, W = 0.0033)
|
||||
AT (0,0,1.5) RELATIVE source_arm ROTATED (0,0,0) RELATIVE source_arm
|
||||
|
||||
/* guide segment 2, curved, m=2, 24.5 m */
|
||||
COMPONENT guide2 = Bender(
|
||||
w = 0.02, h = 0.12, r = 3612, R0a = 0.995, Qca = 0.0217,
|
||||
alphaa = 5.76, ma = 2, Wa = 0.0033, R0i = 0.995, Qci = 0.0217,
|
||||
alphai = 5.76, mi = 2, Wi = 0.0033, R0s = 0.995, Qcs = 0.0217,
|
||||
alphas = 5.76, ms = 2, Ws = 0.0033, l = 24.5)
|
||||
AT (0,0,6.16) RELATIVE source_arm ROTATED (0,0,0) RELATIVE source_arm
|
||||
|
||||
/* bunker wall, m=2, 3.0 m */
|
||||
COMPONENT bunker = Guide(
|
||||
w1=0.02, h1=.12, w2=0.02, h2=.12,
|
||||
l=3.0, R0=0.995, Qc=0.0217, alpha = 5.76,
|
||||
m = 2.0, W = 0.0033)
|
||||
AT (0,0,30.66) RELATIVE source_arm ROTATED (0,0,0) RELATIVE source_arm
|
||||
|
||||
/* guide segment 3, m=2, 8.84 m */
|
||||
|
||||
COMPONENT guide3 = Guide(
|
||||
w1=0.02, h1=.12, w2=0.02, h2=.12,
|
||||
l=8.84, R0=0.995,Qc=0.0217, alpha = 5.76,
|
||||
m = 2.0, W = 0.0033)
|
||||
AT (0,0,33.66) RELATIVE source_arm ROTATED (0,0,0) RELATIVE source_arm
|
||||
|
||||
/* guide exit at 42.5 m - measured flux 2.46 10e8 cm-2 s-1 mA-1 */
|
||||
|
||||
COMPONENT in_slit = Slit(
|
||||
xmin = -0.01, xmax=0.01 , ymin = -0.06, ymax = 0.06)
|
||||
AT (0,0,42.5) RELATIVE source_arm ROTATED (0,0,0) RELATIVE source_arm
|
||||
|
||||
/* Monochromator description */
|
||||
|
||||
COMPONENT sma = Arm() /* source - monochromator arm */
|
||||
AT (0, 0, 43.15) RELATIVE source_arm ROTATED (0,OMA,0) RELATIVE source_arm
|
||||
|
||||
|
||||
COMPONENT foc_mono = Monochromator_curved(
|
||||
zwidth = 0.05, yheight = 0.025, gap = 0.0005, NH = 1, NV = 5,
|
||||
mosaich = 38, mosaicv = 38, r0 = 0.7, DM=dm, RV = RV,
|
||||
RH = 0)
|
||||
AT (0, 0, 0) RELATIVE sma
|
||||
|
||||
COMPONENT msa = Arm() /* monochromator - sample arm */
|
||||
AT (0, 0, 0) RELATIVE sma ROTATED (0, TKOFF, 0) RELATIVE source_arm
|
||||
|
||||
COMPONENT out1_slit = Slit(
|
||||
xmin=-0.01, xmax=0.01, ymin=-0.06, ymax=0.06)
|
||||
AT (0,0,0.2) RELATIVE msa ROTATED (0,0,0) RELATIVE msa
|
||||
|
||||
COMPONENT Amoin_slit = Slit(
|
||||
xmin=-0.01, xmax=0.01, ymin=-0.06, ymax=0.06)
|
||||
AT (0,0,0.325) RELATIVE msa ROTATED (0,0,0) RELATIVE msa
|
||||
|
||||
COMPONENT Bmoin_slit = Slit(
|
||||
xmin=-0.01, xmax=0.01, ymin=-0.06, ymax=0.06)
|
||||
AT (0,0,0.525) RELATIVE msa ROTATED (0,0,0) RELATIVE msa
|
||||
|
||||
|
||||
COMPONENT out2_slit = Slit(
|
||||
xmin=-0.01, xmax=0.01, ymin=-0.06, ymax=0.06)
|
||||
AT (0,0,0.65) RELATIVE msa ROTATED (0,0,0) RELATIVE msa
|
||||
|
||||
COMPONENT PSD_sample = MKMonitor(
|
||||
xmin=-0.05, xmax=0.05, ymin=-0.07, ymax=0.07,controlfile=monfile)
|
||||
AT ( 0, 0, 1.5) RELATIVE msa
|
||||
|
||||
/*
|
||||
COMPONENT PSD_sample = PSD_monitor(
|
||||
xmin=-0.05, xmax=0.05, ymin=-0.07, ymax=0.07,
|
||||
nx=80, ny=80, filename="PSD_sample.dat",controlfile=monfile,dumpCount=1000)
|
||||
AT ( 0, 0, 1.5) RELATIVE msa
|
||||
COMPONENT PSD_sample = PSD_monitor(
|
||||
xmin=-0.05, xmax=0.05, ymin=-0.07, ymax=0.07,
|
||||
nx=80, ny=80, filename="PSD_sample.dat")
|
||||
AT ( 0, 0, 1.5) RELATIVE msa
|
||||
*/
|
||||
COMPONENT sa_arm = Arm()
|
||||
AT (0, 0, 2.82) RELATIVE msa
|
||||
ROTATED (0, 0, 0) RELATIVE msa
|
||||
|
||||
COMPONENT sample = PowderN (
|
||||
d_phi0=0, radius=sample_radius, h=sample_height,
|
||||
pack=1, Vc=1076.98, reflections = samplefile,
|
||||
sigma_a=0.2, focus_aw=80, focus_ah=3.5, target_index=+1)
|
||||
AT ( 0, 0, 0) RELATIVE sa_arm
|
||||
|
||||
COMPONENT Det9 = Monitor_nD(
|
||||
xwidth=3.0,yheight=0.09,
|
||||
options=option_list)
|
||||
AT (0,0,0.000001) RELATIVE sa_arm
|
||||
ROTATED (0, 0, 180) RELATIVE sa_arm
|
||||
|
||||
END
|
68
mcstas/dmc/dmcafter.instr
Normal file
68
mcstas/dmc/dmcafter.instr
Normal file
@ -0,0 +1,68 @@
|
||||
DEFINE INSTRUMENT DMC_diff(Det_start, char *samplefile, char *monfile,
|
||||
char *lambdafile,int repeat)
|
||||
DECLARE
|
||||
%{
|
||||
double sample_radius = 0.005;
|
||||
double sample_height = 0.03;
|
||||
double Det_start;
|
||||
double Det_end;
|
||||
char option_list[150];
|
||||
%}
|
||||
|
||||
INITIALIZE
|
||||
%{
|
||||
Det_end= Det_start + 80;
|
||||
sprintf(option_list,"banana theta limits [%f %f] bins=400, file=det9.dat",Det_start,Det_end);
|
||||
printf("%s \n",option_list);
|
||||
%}
|
||||
|
||||
|
||||
TRACE
|
||||
|
||||
COMPONENT msa = Arm() /* monochromator - sample arm */
|
||||
AT (0, 0, 0) ABSOLUTE
|
||||
|
||||
/*
|
||||
COMPONENT progress = Progress_bar(percent=5,flag_save=1)
|
||||
AT (0,0,.1) ABSOLUTE
|
||||
*/
|
||||
|
||||
COMPONENT in = Virtual_input(file=lambdafile,repeat_count=repeat)
|
||||
AT (0,0,0.64) RELATIVE msa ROTATED (0,0,0) RELATIVE msa
|
||||
|
||||
COMPONENT out2_slit = Slit(
|
||||
xmin=-0.01, xmax=0.01, ymin=-0.06, ymax=0.06)
|
||||
AT (0,0,0.65) RELATIVE msa ROTATED (0,0,0) RELATIVE msa
|
||||
|
||||
COMPONENT PSD_sample = MKMonitor(
|
||||
xmin=-0.05, xmax=0.05, ymin=-0.07, ymax=0.07,controlfile=monfile)
|
||||
AT ( 0, 0, 1.5) RELATIVE msa
|
||||
|
||||
/*
|
||||
COMPONENT PSD_sample = PSD_monitor(
|
||||
xmin=-0.05, xmax=0.05, ymin=-0.07, ymax=0.07,
|
||||
nx=80, ny=80, filename="PSD_sample.dat",controlfile=monfile,dumpCount=1000)
|
||||
AT ( 0, 0, 1.5) RELATIVE msa
|
||||
COMPONENT PSD_sample = PSD_monitor(
|
||||
xmin=-0.05, xmax=0.05, ymin=-0.07, ymax=0.07,
|
||||
nx=80, ny=80, filename="PSD_sample.dat")
|
||||
AT ( 0, 0, 1.5) RELATIVE msa
|
||||
*/
|
||||
COMPONENT sa_arm = Arm()
|
||||
AT (0, 0, 2.82) RELATIVE msa
|
||||
ROTATED (0, 0, 0) RELATIVE msa
|
||||
|
||||
COMPONENT sample = PowderN (
|
||||
d_phi0=0, radius=sample_radius, h=sample_height,
|
||||
pack=1, Vc=1076.98, reflections = samplefile,
|
||||
sigma_a=0.2, focus_aw=80, focus_ah=3.5, target_index=+1)
|
||||
AT ( 0, 0, 0) RELATIVE sa_arm
|
||||
|
||||
COMPONENT Det9 = Monitor_nD(
|
||||
xwidth=3.0,yheight=0.09,
|
||||
options=option_list)
|
||||
AT (0,0,0.000001) RELATIVE sa_arm
|
||||
ROTATED (0, 0, 180) RELATIVE sa_arm
|
||||
|
||||
|
||||
END
|
113
mcstas/dmc/dmcprecalc.instr
Normal file
113
mcstas/dmc/dmcprecalc.instr
Normal file
@ -0,0 +1,113 @@
|
||||
DEFINE INSTRUMENT DMC_diff(lambda,Det_start, char *samplefile, char *monfile,
|
||||
char *lambdafile)
|
||||
DECLARE
|
||||
%{
|
||||
double mono_q;
|
||||
double dm;
|
||||
double OMA;
|
||||
double RV;
|
||||
double NV = 5;
|
||||
double TKOFF;
|
||||
double sample_radius = 0.005;
|
||||
double sample_height = 0.03;
|
||||
double lambda;
|
||||
double ldiff=0.5;
|
||||
double Det_start;
|
||||
double Det_end;
|
||||
char option_list[150];
|
||||
%}
|
||||
|
||||
INITIALIZE
|
||||
%{
|
||||
dm = 3.3537;
|
||||
TKOFF = lambda/(2.*dm);
|
||||
TKOFF = 2.*asin(TKOFF)*57.29577951308232087679815481410517;
|
||||
printf("TKOFF = %f\n", TKOFF);
|
||||
OMA = TKOFF/2;
|
||||
RV = fabs(2*2.82*sin(DEG2RAD*OMA));
|
||||
Det_end= Det_start + 80;
|
||||
sprintf(option_list,"banana theta limits [%f %f] bins=400, file=det9.dat",Det_start,Det_end);
|
||||
printf("%s \n",option_list);
|
||||
%}
|
||||
|
||||
TRACE
|
||||
|
||||
COMPONENT source_arm = Arm()
|
||||
AT (0, 0, 0) ABSOLUTE
|
||||
|
||||
|
||||
/* values for guide side window RNR12 */
|
||||
COMPONENT csource = Source_gen(
|
||||
radius = 0.08,xw = 0.02, yh = 0.12, dist = 1.5,
|
||||
Lambda0 = lambda, dLambda = ldiff,
|
||||
T1=150.42,I1=5.98e11,
|
||||
T2=37.23,I2=5.637e11,T3=14.9,I3=0.962e11)
|
||||
AT (0,0,0) RELATIVE source_arm ROTATED (0,0,0) RELATIVE source_arm
|
||||
|
||||
/* guide segment 1, m=2, 4.66 m */
|
||||
COMPONENT guide1 = Guide(w1=0.02, h1=0.12, w2=0.02, h2=0.12,
|
||||
l=4.66, R0=0.995, Qc=0.0217, alpha = 5.76,
|
||||
m = 2.0, W = 0.0033)
|
||||
AT (0,0,1.5) RELATIVE source_arm ROTATED (0,0,0) RELATIVE source_arm
|
||||
|
||||
/* guide segment 2, curved, m=2, 24.5 m */
|
||||
COMPONENT guide2 = Bender(
|
||||
w = 0.02, h = 0.12, r = 3612, R0a = 0.995, Qca = 0.0217,
|
||||
alphaa = 5.76, ma = 2, Wa = 0.0033, R0i = 0.995, Qci = 0.0217,
|
||||
alphai = 5.76, mi = 2, Wi = 0.0033, R0s = 0.995, Qcs = 0.0217,
|
||||
alphas = 5.76, ms = 2, Ws = 0.0033, l = 24.5)
|
||||
AT (0,0,6.16) RELATIVE source_arm ROTATED (0,0,0) RELATIVE source_arm
|
||||
|
||||
/* bunker wall, m=2, 3.0 m */
|
||||
COMPONENT bunker = Guide(
|
||||
w1=0.02, h1=.12, w2=0.02, h2=.12,
|
||||
l=3.0, R0=0.995, Qc=0.0217, alpha = 5.76,
|
||||
m = 2.0, W = 0.0033)
|
||||
AT (0,0,30.66) RELATIVE source_arm ROTATED (0,0,0) RELATIVE source_arm
|
||||
|
||||
/* guide segment 3, m=2, 8.84 m */
|
||||
|
||||
COMPONENT guide3 = Guide(
|
||||
w1=0.02, h1=.12, w2=0.02, h2=.12,
|
||||
l=8.84, R0=0.995,Qc=0.0217, alpha = 5.76,
|
||||
m = 2.0, W = 0.0033)
|
||||
AT (0,0,33.66) RELATIVE source_arm ROTATED (0,0,0) RELATIVE source_arm
|
||||
|
||||
/* guide exit at 42.5 m - measured flux 2.46 10e8 cm-2 s-1 mA-1 */
|
||||
|
||||
COMPONENT in_slit = Slit(
|
||||
xmin = -0.01, xmax=0.01 , ymin = -0.06, ymax = 0.06)
|
||||
AT (0,0,42.5) RELATIVE source_arm ROTATED (0,0,0) RELATIVE source_arm
|
||||
|
||||
/* Monochromator description */
|
||||
|
||||
COMPONENT sma = Arm() /* source - monochromator arm */
|
||||
AT (0, 0, 43.15) RELATIVE source_arm ROTATED (0,OMA,0) RELATIVE source_arm
|
||||
|
||||
|
||||
COMPONENT foc_mono = Monochromator_curved(
|
||||
zwidth = 0.05, yheight = 0.025, gap = 0.0005, NH = 1, NV = 5,
|
||||
mosaich = 38, mosaicv = 38, r0 = 0.7, DM=dm, RV = RV,
|
||||
RH = 0)
|
||||
AT (0, 0, 0) RELATIVE sma
|
||||
|
||||
COMPONENT msa = Arm() /* monochromator - sample arm */
|
||||
AT (0, 0, 0) RELATIVE sma ROTATED (0, TKOFF, 0) RELATIVE source_arm
|
||||
|
||||
COMPONENT out1_slit = Slit(
|
||||
xmin=-0.01, xmax=0.01, ymin=-0.06, ymax=0.06)
|
||||
AT (0,0,0.2) RELATIVE msa ROTATED (0,0,0) RELATIVE msa
|
||||
|
||||
COMPONENT Amoin_slit = Slit(
|
||||
xmin=-0.01, xmax=0.01, ymin=-0.06, ymax=0.06)
|
||||
AT (0,0,0.325) RELATIVE msa ROTATED (0,0,0) RELATIVE msa
|
||||
|
||||
COMPONENT Bmoin_slit = Slit(
|
||||
xmin=-0.01, xmax=0.01, ymin=-0.06, ymax=0.06)
|
||||
AT (0,0,0.525) RELATIVE msa ROTATED (0,0,0) RELATIVE msa
|
||||
|
||||
|
||||
COMPONENT out = Virtual_output(file=lambdafile)
|
||||
AT(0,0,0.64) RELATIVE msa ROTATED (0,0,0) RELATIVE msa
|
||||
|
||||
END
|
4
mcstas/dmc/makelambda.sh
Normal file
4
mcstas/dmc/makelambda.sh
Normal file
@ -0,0 +1,4 @@
|
||||
dmcprecalc -n 1e9 lambda=2.56 Det_start=19. monfile=monfile samplefile=na2ca3al2f14.q lambdafile="dmc256.dat"
|
||||
dmcprecalc -n 1e9 lambda=4.2 Det_start=19. monfile=monfile samplefile=na2ca3al2f14.q lambdafile="dmc420.dat"
|
||||
dmcprecalc -n 1e9 lambda=2.45 Det_start=19. monfile=monfile samplefile=na2ca3al2f14.q lambdafile="dmc245.dat"
|
||||
dmcprecalc -n 1e9 lambda=3.8 Det_start=19. monfile=monfile samplefile=na2ca3al2f14.q lambdafile="dmc380.dat"
|
@ -34,23 +34,59 @@ set mcwaittime 7
|
||||
#----------------------------------------------------------------------
|
||||
proc mcstasdump {pid} {
|
||||
global mcwaittime
|
||||
if { $pid <= 0} {
|
||||
error "Trying to dump invalid PID: $pid"
|
||||
}
|
||||
clientput "Dumping ..."
|
||||
catch {eval exec /usr/bin/kill -USR2 $pid}
|
||||
wait $mcwaittime
|
||||
}
|
||||
#-----------------------------------------------------------------------
|
||||
# mcstasisrunning has to open a pipe to ps and to read the results of
|
||||
# the ps command. This is because a terminated McStas simulation turns
|
||||
# into a Zombie process which finishes never. This can only be cured
|
||||
# by checking for this in the STAT field of ps's output. According to
|
||||
# the Unix FAQ this is the best solution......
|
||||
#----------------------------------------------------------------------
|
||||
proc readPID {pid} {
|
||||
set f [ open "| /bin/ps -up $pid" r]
|
||||
set pstxt [read $f]
|
||||
close $f
|
||||
return $pstxt
|
||||
}
|
||||
#----------------------------------------------------------------------
|
||||
proc mcstasisrunning {pid} {
|
||||
set ret [catch {eval exec /bin/ps --pid $pid} msg]
|
||||
if {$ret == 0} {
|
||||
return 1
|
||||
} else {
|
||||
return 0;
|
||||
global runningCount runningLast
|
||||
|
||||
if { $pid <= 0} {
|
||||
return 0
|
||||
}
|
||||
set pstxt " "
|
||||
set ret [catch {set pstxt [readPID $pid]} msg]
|
||||
set pslist [split $pstxt "\n"]
|
||||
if { [llength $pslist] < 2} {
|
||||
return 0
|
||||
}
|
||||
set header [lindex $pslist 0]
|
||||
set idx [string first STAT $header]
|
||||
set stat [string trim [string range [lindex $pslist 1] $idx [expr $idx + 4]]]
|
||||
if { [string first Z $stat] >= 0 || [string first T $stat] >= 0} {
|
||||
mccontrol finish
|
||||
return 0
|
||||
} else {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
#-----------------------------------------------------------------------
|
||||
proc mcstaskill {pid} {
|
||||
global mcwaittime
|
||||
if { $pid <= 0} {
|
||||
error "Trying to kill invalid PID $pid"
|
||||
}
|
||||
clientput "Killing $pid"
|
||||
catch {eval exec /usr/bin/kill -TERM $pid}
|
||||
wait $mcwaittime
|
||||
# catch {mccontrol finish}
|
||||
wait 10
|
||||
}
|
||||
#-----------------------------------------------------------------------
|
||||
proc mcinstall {} {
|
||||
|
@ -10,8 +10,8 @@ set home $env(HOME)/src/workspace/sics/mcstas/dmc
|
||||
|
||||
#--------------------------------- first all the server options are set
|
||||
#ServerOption RedirectFile $home/stdcdmc
|
||||
ServerOption ReadTimeOut 0
|
||||
ServerOption AcceptTimeOut 0
|
||||
ServerOption ReadTimeOut 1
|
||||
ServerOption AcceptTimeOut 1
|
||||
ServerOption ReadUserPasswdTimeout 500000
|
||||
ServerOption LogFileBaseName "$home/vdmclog"
|
||||
ServerOption LogFileDir $home/
|
||||
@ -57,7 +57,8 @@ MakeWaveLength lambda Mono
|
||||
#--------------------------------------------------------------------------
|
||||
MakeMcStasReader
|
||||
MakeMcStasController
|
||||
allowexec $home/dmc_sics01
|
||||
allowexec $home/dmcafter
|
||||
allowexec $home/dmc_sics05
|
||||
|
||||
ClientPut "Installing counter"
|
||||
MakeCounter counter mcstas
|
||||
@ -107,8 +108,8 @@ Instrument lock
|
||||
VarMake Title Text User
|
||||
VarMake User Text User
|
||||
VarMake Collimation Text User
|
||||
VarMake Sample Text User
|
||||
Sample Kellerit
|
||||
VarMake SampleIntern Text User
|
||||
SampleIntern Kellerit
|
||||
VarMake comment1 Text User
|
||||
VarMake comment2 Text User
|
||||
VarMake comment3 Text User
|
||||
|
@ -13,6 +13,7 @@ if { [info exists vdmcinit] == 0 } {
|
||||
Publish storedmcdata User
|
||||
Publish rundmcsim User
|
||||
Publish copydmcdata User
|
||||
Publish sample User
|
||||
mcinstall
|
||||
}
|
||||
source $home/log.tcl
|
||||
@ -23,19 +24,85 @@ proc SplitReply { text } {
|
||||
set l [split $text =]
|
||||
return [lindex $l 1]
|
||||
}
|
||||
#---------------------------------------------------------------------
|
||||
# load a lazy pulverix file
|
||||
#---------------------------------------------------------------------
|
||||
proc washlazy {name} {
|
||||
global home
|
||||
set newNam [file rootname [file tail $name]]
|
||||
set in [open $name r]
|
||||
set out [open $home/$newNam.q w]
|
||||
#------- proceed to first header line
|
||||
while { [gets $in line] >= 0} {
|
||||
if { [string first "H K L THETA 2THETA D VALUE" $line] > 0} {
|
||||
break
|
||||
}
|
||||
}
|
||||
#------- process data lines
|
||||
puts $out "// mult Q(hkl) F2 DW w"
|
||||
while { [gets $in line] >= 0} {
|
||||
set num [scan $line "%d %d %d %f %f %f %f %f %d %d %d %f %f %f %f %f %d"\
|
||||
h k l th th2 d di sin h2 k2 l2 I F A B ang mul]
|
||||
if { $num == 17} {
|
||||
set q [expr (2.*3.14159265358979323846)/$d]
|
||||
set f2 [expr $F * $F]
|
||||
puts $out [format "%d %f %f 1 0" $mul $q $f2]
|
||||
}
|
||||
}
|
||||
close $in
|
||||
close $out
|
||||
}
|
||||
#----------------------------------------------------------------------
|
||||
# script for setting the sample. We only allow samples for which
|
||||
# there is a corresponing q data file
|
||||
#------------------------------------------------------------------------
|
||||
proc sample args {
|
||||
global home
|
||||
if { [llength $args] < 1} {
|
||||
set sa [SplitReply [sampleintern]]
|
||||
return "sample = $sa"
|
||||
}
|
||||
set txt [lindex $args 0]
|
||||
#-------- list
|
||||
if { [string compare $txt list] == 0} {
|
||||
set l [glob $home/*.q]
|
||||
foreach f $l {
|
||||
append out [file rootname [file tail $f]] "\n"
|
||||
}
|
||||
return $out
|
||||
}
|
||||
#--------- load
|
||||
if { [string compare $txt load] == 0} {
|
||||
if { [llength $args] < 2} {
|
||||
error "Need path to lazy pulverix output file to load"
|
||||
}
|
||||
set nam [lindex $args 1]
|
||||
washlazy $nam
|
||||
set nam2 [file rootname [file tail $nam]]
|
||||
eval sampleintern $nam2
|
||||
return OK
|
||||
}
|
||||
if { ![file exists $home/$txt.q] } {
|
||||
error "No Q data for sample $txt"
|
||||
} else {
|
||||
eval sampleintern $txt
|
||||
return OK
|
||||
}
|
||||
}
|
||||
#-----------------------------------------------------------------------
|
||||
# Scripts required for controlling McStas simulations
|
||||
#-----------------------------------------------------------------------
|
||||
proc rundmcsim {mode preset} {
|
||||
global home
|
||||
append command $home/dmc_sics01 " -f $home/dmc.xml --format=\"XML\""
|
||||
append command " -n 9e15 "
|
||||
append command $home/dmc_sics05 " -f $home/dmc.xml --format=\"XML\""
|
||||
append command " -n 1e10 "
|
||||
append command " lambda=[string trim [SplitReply [lambda]]]"
|
||||
append command " TKOFF=[string trim [SplitReply [TwoThetaM]]]"
|
||||
append command " samplefile=$home/[string trim [SplitReply [sample]]].q"
|
||||
append command " Det_start=[string trim [SplitReply [TwoThetaD]]]"
|
||||
append command " samplefile=$home/[string trim [SplitReply [sampleintern]]].q"
|
||||
append command " monfile=$home/monfile "
|
||||
append command " >& $home/dmc.log &"
|
||||
clientput "Starting McStas.. "
|
||||
# clientput $command
|
||||
set ret [catch {eval exec $command} msg]
|
||||
if {$ret != 0} {
|
||||
error $msg
|
||||
@ -44,23 +111,85 @@ proc rundmcsim {mode preset} {
|
||||
}
|
||||
}
|
||||
#------------------------------------------------------------------------
|
||||
# Run the DMC simulation in an optimized mode with neutrons
|
||||
# precalculated for various wave length until the sample slit
|
||||
#------------------------------------------------------------------------
|
||||
set dmcdata(2.56) dmc256.dat
|
||||
set dmcdata(4.2) dmc420.dat
|
||||
set dmcdata(2.45) dmc245.dat
|
||||
set dmcdata(3.8) dmc380.dat
|
||||
#-------------------------------------------------------------------------
|
||||
proc rundmcoptsim {mode preset } {
|
||||
global home dmcdata
|
||||
#--------- locate closest precalculated neutron data file
|
||||
set lambda [SplitReply [lambda]]
|
||||
set myLambda $lambda
|
||||
set wv [array names dmcdata]
|
||||
set diff 999999.99
|
||||
set lambdafile $dmcdata(2.56)
|
||||
foreach w $wv {
|
||||
set tmp [expr abs($w - $lambda)]
|
||||
if { $tmp < $diff} {
|
||||
set diff $tmp
|
||||
set lambdafile $dmcdata($w)
|
||||
set myLambda $w
|
||||
}
|
||||
}
|
||||
#-------- build McStas command line
|
||||
append command $home/dmcafter " -f $home/dmc.xml --format=\"XML\""
|
||||
append command " -n 1e10 "
|
||||
append command " lambdafile=$home/$lambdafile"
|
||||
append command " Det_start=[string trim [SplitReply [TwoThetaD]]]"
|
||||
append command " samplefile=$home/[string trim [SplitReply [sampleintern]]].q"
|
||||
append command " monfile=$home/monfile "
|
||||
append command " repeat=1000000000 "
|
||||
append command " >& $home/dmc.log &"
|
||||
#--------- start McStas
|
||||
clientput "Starting McStas.. "
|
||||
clientput "Coercing $lambda to precalculated $myLambda"
|
||||
# clientput $command
|
||||
set ret [catch {eval exec $command} msg]
|
||||
if {$ret != 0} {
|
||||
error "ERROR: $msg"
|
||||
} else {
|
||||
return $msg
|
||||
}
|
||||
}
|
||||
#------------------------------------------------------------------------
|
||||
proc copydmcdata { } {
|
||||
global home
|
||||
set mcversion "McStas 1.8 - Mar. 05, 2004"
|
||||
washsimfile $home/dmc.xml
|
||||
mcreader open $home/dmc.xml
|
||||
mcreader insertmon \
|
||||
"/$mcversion/DMC_diff/dmc.xml/PSD_sample/PSD_sample.dat/values" \
|
||||
counter 1
|
||||
"/$mcversion/DMC_diff/dmc.xml/PSD_sample/values" \
|
||||
counter 1 [expr 1./10000]
|
||||
mcreader insertmon \
|
||||
"/$mcversion/DMC_diff/dmc.xml/Det9/det9.dat/values" \
|
||||
counter 5
|
||||
set hmScale [SplitReply [counter getmonitor 5]]
|
||||
if { $hmScale <= 0} {
|
||||
set hmScale 1e9
|
||||
} else {
|
||||
set hmScale [expr $hmScale * 1e9]
|
||||
}
|
||||
clientput "HM scale = $hmScale"
|
||||
mcreader inserthm \
|
||||
"/$mcversion/DMC_diff/dmc.xml/Det9/det9.dat/data" banana
|
||||
"/$mcversion/DMC_diff/dmc.xml/Det9/det9.dat/data" banana $hmScale
|
||||
mcreader close
|
||||
}
|
||||
#-------------------------------------------------------------------------
|
||||
proc dmcdump {pid} {
|
||||
#--do nothing: progress is doing it for us
|
||||
}
|
||||
#--------------------------------------------------------------------------
|
||||
mccontrol configure mcstart rundmcsim
|
||||
#mccontrol configure mcstart rundmcsim
|
||||
mccontrol configure mcstart rundmcoptsim
|
||||
mccontrol configure mccopydata copydmcdata
|
||||
mccontrol configure update 60
|
||||
mccontrol configure mcmonfile $home/monfile
|
||||
mccontrol configure monitorscale [expr 1. /10000]
|
||||
mccontrol configure mcdump mcstasdump
|
||||
#--------------------------------------------------------------------------
|
||||
# A count command for VDMC
|
||||
# All arguments are optional. The current values will be used if not
|
||||
|
@ -14,7 +14,7 @@ sicsdatapostfix .hdf
|
||||
sicsdatapostfix setAccess 0
|
||||
sicsdataprefix powder
|
||||
sicsdataprefix setAccess 0
|
||||
starttime 2005-06-21 14:21:44
|
||||
starttime 2005-07-01 16:19:39
|
||||
starttime setAccess 2
|
||||
comment3 UNKNOWN
|
||||
comment3 setAccess 2
|
||||
@ -22,8 +22,8 @@ comment2 UNKNOWN
|
||||
comment2 setAccess 2
|
||||
comment1 UNKNOWN
|
||||
comment1 setAccess 2
|
||||
sample na2ca3al2f14
|
||||
sample setAccess 2
|
||||
sampleintern na2ca3al2f14
|
||||
sampleintern setAccess 2
|
||||
collimation UNKNOWN
|
||||
collimation setAccess 2
|
||||
user UNKNOWN
|
||||
@ -120,11 +120,11 @@ a1 InterruptMode 0.000000
|
||||
a1 precision 0.010000
|
||||
a1 AccessCode 2.000000
|
||||
a1 movecount 10.000000
|
||||
banana CountMode timer
|
||||
banana preset 180.000000
|
||||
banana CountMode monitor
|
||||
banana preset 5.000000
|
||||
# Counter counter
|
||||
counter SetPreset 180.000000
|
||||
counter SetMode Timer
|
||||
counter SetPreset 5000.000000
|
||||
counter SetMode Monitor
|
||||
# Motor twothetad
|
||||
twothetad sign 1.000000
|
||||
twothetad SoftZero 0.000000
|
||||
|
Reference in New Issue
Block a user