Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 75 additions & 25 deletions mcstas-comps/contrib/SNS_source_analytic.comp
Original file line number Diff line number Diff line change
Expand Up @@ -809,84 +809,124 @@ INITIALIZE
fprintf (stderr, "Error opening file\n");
exit (-1);
} else {
printf ("%s\n", "File opened...");
MPI_MASTER(
printf ("%s\n", "File opened...");
);
}
/* spectral parameters */
while ((fgets (line, linelength, fp) != NULL) && (strchr (line, '#') != NULL)) {
printf ("%s", line);
MPI_MASTER(
printf ("%s", line);
);
}
kk = sscanf (line, " %le %le %le %le %le %le %le %le %le %le %le %le %le %le", &para_sp[0], &para_sp[1], &para_sp[2], &para_sp[3], &para_sp[4], &para_sp[5],
&para_sp[6], &para_sp[7], &para_sp[8], &para_sp[9], &para_sp[10], &para_sp[11], &para_sp[12], &para_sp[13]);

/* a parameter of emission time distribuation */
while ((fgets (line, linelength, fp) != NULL) && (strchr (line, '#') != NULL)) {
printf ("%s", line);
MPI_MASTER(
printf ("%s", line);
);
}
kk = sscanf (line, " %le %le %le %le %le %le %le %le %le %le", &para_a[0], &para_a[1], &para_a[2], &para_a[3], &para_a[4], &para_a[5], &para_a[6], &para_a[7],
&para_a[8], &para_a[9]);
if (kk != 10) {
printf ("para_a: insufficient number of data entries read\n");
MPI_MASTER(
printf ("para_a: insufficient number of data entries read\n");
);
_ABORT ();
}

/* b parameter of emission time distribuation */
while ((fgets (line, linelength, fp) != NULL) && (strchr (line, '#') != NULL)) {
printf ("%s", line);
MPI_MASTER(
printf ("%s", line);
);
}
kk = sscanf (line, " %le %le %le %le %le %le %le %le %le %le", &para_b[0], &para_b[1], &para_b[2], &para_b[3], &para_b[4], &para_b[5], &para_b[6], &para_b[7],
&para_b[8], &para_b[9]);
if (kk != 10) {
printf ("para_b: insufficient number of data entries read\n");
MPI_MASTER(
printf ("para_b: insufficient number of data entries read\n");
);
_ABORT ();
}

/* R parameter of emission time distribuation */
while ((fgets (line, linelength, fp) != NULL) && (strchr (line, '#') != NULL)) {
printf ("%s", line);
MPI_MASTER(
printf ("%s", line);
);
}
kk = sscanf (line, " %le %le %le %le %le %le %le %le %le %le", &para_R[0], &para_R[1], &para_R[2], &para_R[3], &para_R[4], &para_R[5], &para_R[6], &para_R[7],
&para_R[8], &para_R[9]);
if (kk != 10) {
printf ("para_R: kk=%d insufficient number of data entries read\n", kk);
MPI_MASTER(
printf ("para_R: kk=%d insufficient number of data entries read\n", kk);
);
_ABORT ();
}

/* to parameter of emission time distribuation */
while ((fgets (line, linelength, fp) != NULL) && (strchr (line, '#') != NULL)) {
printf ("%s", line);
MPI_MASTER(
printf ("%s", line);
);
}
kk = sscanf (line, " %le %le %le %le %le %le %le %le %le %le", &para_to[0], &para_to[1], &para_to[2], &para_to[3], &para_to[4], &para_to[5], &para_to[6],
&para_to[7], &para_to[8], &para_to[9]);
if (kk != 10) {
printf ("para_R: insufficient number of data entries read\n");
MPI_MASTER(
printf ("para_R: insufficient number of data entries read\n");
);
_ABORT ();
}

printf ("\n");
for (k = 0; k < 14; k++) {
printf (" para_sp(%d)=%e\n", k, para_sp[k]);
MPI_MASTER(
printf (" para_sp(%d)=%e\n", k, para_sp[k]);
);
}
printf ("\n");
MPI_MASTER(
printf ("\n");
);
for (k = 0; k < 10; k++) {
printf (" para_a(%d)=%e\n", k, para_a[k]);
MPI_MASTER(
printf (" para_a(%d)=%e\n", k, para_a[k]);
);
}
printf ("\n");
MPI_MASTER(
printf ("\n");
);
for (k = 0; k < 10; k++) {
printf (" para_b(%d)=%e\n", k, para_b[k]);
MPI_MASTER(
printf (" para_b(%d)=%e\n", k, para_b[k]);
);
}
printf ("\n");
MPI_MASTER(
printf ("\n");
);
for (k = 0; k < 8; k++) {
printf (" para_R(%d)=%e\n", k, para_R[k]);
MPI_MASTER(
printf (" para_R(%d)=%e\n", k, para_R[k]);
);
}
printf ("\n");
MPI_MASTER(
printf ("\n");
);
for (k = 0; k < 10; k++) {
printf (" para_to(%d)=%e\n", k, para_to[k]);
MPI_MASTER(
printf (" para_to(%d)=%e\n", k, para_to[k]);
);
}

if (sample_E == 0) {
CItot = prepare_cumulative_spectral_function (csfE, Emin, Emax, para_sp);
if (CItot <= 0.0) {
printf (" choice of Emin and Emax gives zero neutron intensity\n");
MPI_MASTER(
printf (" choice of Emin and Emax gives zero neutron intensity\n");
);
_ABORT ();
}
// for(i=0;i<=1000;i++){
Expand All @@ -896,19 +936,29 @@ INITIALIZE

/* some checks */
if (dist <= 0.0) {
printf (" dist must be greater zero\n");
MPI_MASTER(
printf (" dist must be greater zero\n");
);
_ABORT ();
} else if (focus_xw <= 0.0) {
printf (" focus_xw must be greater zero\n");
MPI_MASTER(
printf (" focus_xw must be greater zero\n");
);
_ABORT ();
} else if (focus_yh <= 0.0) {
printf (" focus_yh must be greater zero\n");
MPI_MASTER(
printf (" focus_yh must be greater zero\n");
);
_ABORT ();
} else if (p_power <= 0) {
printf (" p_power must be greater zero\n");
MPI_MASTER(
printf (" p_power must be greater zero\n");
);
_ABORT ();
} else if (n_pulses <= 0) {
printf (" n_pulses must be greater zero\n");
MPI_MASTER(
printf (" n_pulses must be greater zero\n");
);
_ABORT ();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
* B. Fultz,"Design and operation of the wide angular-range chopper spectrometer ARCS at the
* Spallation Neutron Source", Review of Scientific Instruments, 83 , 015114 (2012)</ul>
*
* %Example: Fermi_nu=420 Detector: Full_cyl_I=235445
*
* %Parameters
* Fermi_nu: [Hz] Frequency of the Fermi chopper
* T0_nu: [Hz] Frequency of the T0 chopper
Expand Down Expand Up @@ -261,6 +263,10 @@ AT(0,0,LS) RELATIVE mod
COMPONENT sampleMantid = Spot_sample(radius_o=0.01, h=0.05, pack = 1,xwidth=0, yheight=0, zthick=0, Eideal=Edes,w=Et,two_theta=ttheta,n_spots=4)
AT (0.0,0.0,0.0) RELATIVE Sample_Arm

COMPONENT Full_cyl= Monitor_nD(xwidth=5.98,yheight=3.2,restore_neutron=1,
options="mantid banana, theta limits=[-28.0 135.38] bins=389 ,y limits=[-0.550 0.450] bins=128")
AT (0,0,0.00005) RELATIVE Sample_Arm

COMPONENT nD_Mantid_0= Monitor_nD(xwidth=5.9817,yheight=3.2,restore_neutron=1, filename="this",
options="mantid banana, theta limits=[-28.0 135.38] bins=389 ,y limits=[-0.550 0.450] bins=128, neutron pixel min=0 t, list all neutrons", restore_neutron=1)
AT (0,0,0.00005) RELATIVE Sample_Arm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
* Simple instrumentfile for estimating SNS brilliance, moderator is a the Granroth SNS_source applying linear interpolation in MCNPX tables.
*
* Example: filename=source_sct091_tu_02_1.dat Detector: Brillmon_I=7.11736e+12
* %Example: filename=source_sct091_tu_02_1.dat Detector: Brillmon_I=7.11736e+12
*
* %Parameters
* Lambda_min: [AA] Minimum wavelength produced at source
Expand Down
3 changes: 1 addition & 2 deletions mcstas-comps/examples/SNS/SNS_ARCS/SNS_ARCS.instr
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
* B. Fultz,"Design and operation of the wide angular-range chopper spectrometer ARCS at the
* Spallation Neutron Source", Review of Scientific Instruments, 83 , 015114 (2012)</ul>
*
* Example: -y Detector: Full_cyl_I=235445
* (temporarily disabled on nightly test...)
* %Example: -y Detector: Full_cyl_I=235445
*
* %Parameters
* Fermi_nu: [Hz] Frequency of the Fermi chopper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* Simple test instrument for the SNS_source component.
* Refer to SNS <A href="http://neutrons.ornl.gov/instrument_systems/components/moderators.shtml">Source files.</A>
*
* Example: filename=source_sct091_tu_02_1.dat Detector: det_I=7.09416e+09
* %Example: -y Detector: det_I=8.51297e+10
*
* %Parameters
* filename: [string] Source file
Expand Down Expand Up @@ -48,8 +48,9 @@ INITIALIZE %{

#define LOADPATH_ STR(LOADPATH)
sprintf(fullfile,"%s/%s",LOADPATH_,filename);
printf("Using the input file: %s\n", fullfile);

MPI_MASTER(
printf("Using the input file: %s\n", fullfile);
);
%}

TRACE
Expand Down
48 changes: 26 additions & 22 deletions tools/Python/mctest/mctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,26 +95,30 @@ def save(self, infolder):
text = json.dumps(self.get_json_repr(), indent=2)
f = open(join(infolder, self.get_display_name()) + ".json", 'w').write(text)
def load(self,testnb=0):
jsonfile=os.path.join(os.path.dirname(self.localfile),self.get_display_name()+'.json')
f = open(jsonfile, "r", encoding="utf-8")
obj = json.load(f)
# # Populate test
self.displayname=obj['displayname']
self.sourcefile=obj['sourcefile']
self.localfile=obj['localfile']
self.instrname=obj['instrname']
self.testnb=obj['testnb']
self.parvals=obj['parvals']
self.detector=obj['detector']
self.targetval=obj['targetval']
self.testval=obj['testval']
self.linted=obj['linted']
self.compiled=obj['compiled']
self.compiletime=obj['compiletime']
self.didrun=obj['didrun']
self.runtime=obj['runtime']
self.errmsg=obj['errmsg']

jsonfile=pathlib.Path(os.path.join(os.path.dirname(self.localfile),self.get_display_name()+'.json'))
if jsonfile.is_file():
f = open(jsonfile, "r", encoding="utf-8")
obj = json.load(f)
# # Populate test
self.displayname=obj['displayname']
self.sourcefile=obj['sourcefile']
self.localfile=obj['localfile']
self.instrname=obj['instrname']
self.testnb=obj['testnb']
self.parvals=obj['parvals']
self.detector=obj['detector']
self.targetval=obj['targetval']
self.testval=obj['testval']
self.linted=obj['linted']
self.compiled=obj['compiled']
self.compiletime=obj['compiletime']
self.didrun=obj['didrun']
self.runtime=obj['runtime']
self.errmsg=obj['errmsg']
return True
else:
return False

def get_display_name(self):
if self.testnb > 1:
return self.instrname + "_%d" % self.testnb
Expand Down Expand Up @@ -251,8 +255,8 @@ def mccode_test(branchdir, testdir, limitinstrs=None, instrfilter=None, compfilt
populated=[]
for t in instrtests:
if t.testnb >= 0:
t.load(t.testnb)
populated.append(t)
if t.load(t.testnb)==True:
populated.append(t)
tests = tests + populated
pass

Expand Down
Loading