Skip to content
Merged
102 changes: 26 additions & 76 deletions mcstas-comps/contrib/SNS_source_analytic.comp
Original file line number Diff line number Diff line change
Expand Up @@ -802,131 +802,91 @@ INITIALIZE
int linelength = 1000;
int k, kk;

FILE *fp, *fopen ();
FILE* fp;

fp = fopen (filename, "r");
if (fp == NULL) {
fprintf (stderr, "Error opening file\n");
exit (-1);
} else {
MPI_MASTER(
printf ("%s\n", "File opened...");
);
MPI_MASTER (printf ("%s\n", "File opened..."););
}
/* spectral parameters */
while ((fgets (line, linelength, fp) != NULL) && (strchr (line, '#') != NULL)) {
MPI_MASTER(
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)) {
MPI_MASTER(
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) {
MPI_MASTER(
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)) {
MPI_MASTER(
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) {
MPI_MASTER(
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)) {
MPI_MASTER(
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) {
MPI_MASTER(
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)) {
MPI_MASTER(
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) {
MPI_MASTER(
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++) {
MPI_MASTER(
printf (" para_sp(%d)=%e\n", k, para_sp[k]);
);
MPI_MASTER (printf (" para_sp(%d)=%e\n", k, para_sp[k]););
}
MPI_MASTER(
printf ("\n");
);
MPI_MASTER (printf ("\n"););
for (k = 0; k < 10; k++) {
MPI_MASTER(
printf (" para_a(%d)=%e\n", k, para_a[k]);
);
MPI_MASTER (printf (" para_a(%d)=%e\n", k, para_a[k]););
}
MPI_MASTER(
printf ("\n");
);
MPI_MASTER (printf ("\n"););
for (k = 0; k < 10; k++) {
MPI_MASTER(
printf (" para_b(%d)=%e\n", k, para_b[k]);
);
MPI_MASTER (printf (" para_b(%d)=%e\n", k, para_b[k]););
}
MPI_MASTER(
printf ("\n");
);
MPI_MASTER (printf ("\n"););
for (k = 0; k < 8; k++) {
MPI_MASTER(
printf (" para_R(%d)=%e\n", k, para_R[k]);
);
MPI_MASTER (printf (" para_R(%d)=%e\n", k, para_R[k]););
}
MPI_MASTER(
printf ("\n");
);
MPI_MASTER (printf ("\n"););
for (k = 0; k < 10; k++) {
MPI_MASTER(
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) {
MPI_MASTER(
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 @@ -936,29 +896,19 @@ INITIALIZE

/* some checks */
if (dist <= 0.0) {
MPI_MASTER(
printf (" dist must be greater zero\n");
);
MPI_MASTER (printf (" dist must be greater zero\n"););
_ABORT ();
} else if (focus_xw <= 0.0) {
MPI_MASTER(
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) {
MPI_MASTER(
printf (" focus_yh must be greater zero\n");
);
MPI_MASTER (printf (" focus_yh must be greater zero\n"););
_ABORT ();
} else if (p_power <= 0) {
MPI_MASTER(
printf (" p_power must be greater zero\n");
);
MPI_MASTER (printf (" p_power must be greater zero\n"););
_ABORT ();
} else if (n_pulses <= 0) {
MPI_MASTER(
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 @@ -75,7 +75,6 @@
DEFINE INSTRUMENT ESS_BEER_MCPL(string input="BEER_MR.mcpl", int repetition=50, string pwdfile="duplex.laz",
lc=6.65, lam0=2.0, dlam=1.8, omega=45, chi=90, colw=1, modul=0, mod_frq=2240, mod_twidth=0.0029, mod_shift=0,
only_event=-1, pinc=0.1, ptra=0.0, strain=0, ustrain=0)
DEPENDENCY "-DMCPLPATH=GETPATH(data)"

DECLARE
%{
Expand Down
14 changes: 2 additions & 12 deletions mcstas-comps/examples/Mantid/Tools_ONION/Tools_ONION.instr
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* %End
*******************************************************************************/
DEFINE INSTRUMENT Tools_ONION (double divergence=0.4, double distance=32, string filename="source_sct521_bu_08_1.dat")
DEPENDENCY " -DLOADPATH=GETPATH(data) @NEXUSFLAGS@ "
DEPENDENCY " @NEXUSFLAGS@ "

DECLARE
%{
Expand All @@ -53,16 +53,6 @@ sourcewidth = 2*distance*tan(div_rad);
sourceheight = 0.01;
samplewidth = 0.01;
sampleheight = sourceheight;
#define QUOTE(name) #name
#define STR(macro) QUOTE(macro)

#ifndef LOADPATH
#define LOADPATH=/usr/share/mcstas/3.1/data
#endif

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

TRACE
Expand All @@ -77,7 +67,7 @@ COMPONENT Origin = Progress_bar()


COMPONENT sourceMantid = SNS_source(
filename = fullfile,
filename = filename,
xwidth = sourcewidth, yheight = sourceheight,
dist = distance, focus_xw = samplewidth, focus_yh = sampleheight,
Emin = 0.001, Emax = 1000)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,17 @@
* %End
*******************************************************************************/
DEFINE INSTRUMENT Gallmeier_SNS_decoupled_poisoned(Lambda_min=0.5,Lambda_max=20, string filename="a1Gw2-2-f5_fit_fit.dat")

DEPENDENCY " -DLOADPATH=GETPATH(data) "

DECLARE
%{
double E_min;
double E_max;
char fullfile[256];
%}

INITIALIZE
%{
E_min=81.82/(Lambda_max*Lambda_max);
E_max=81.82/(Lambda_min*Lambda_min);

#define QUOTE(x) #x
#define STR(macro) QUOTE(macro)

#ifndef LOADPATH
#define LOADPATH /usr/share/mcstas/data
#endif

#define LOADPATH_ STR(LOADPATH)

sprintf(fullfile,"%s/%s",LOADPATH_,filename);

%}

/* Here comes the TRACE section, where the actual */
Expand All @@ -63,7 +48,7 @@ TRACE
COMPONENT Origin = Progress_bar()
AT (0,0,0) ABSOLUTE

COMPONENT Source = SNS_source_analytic(filename=fullfile,
COMPONENT Source = SNS_source_analytic(filename=filename,
xwidth=0.01, yheight=0.01,
dist=1, focus_xw=0.01, focus_yh=0.01, Emin=E_min,Emax=E_max,sample_E=2, p_power=2)
AT (0,0,0) ABSOLUTE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,17 @@
* %End
*******************************************************************************/
DEFINE INSTRUMENT Granroth_SNS_decoupled_poisoned(Lambda_min=0.5,Lambda_max=20, string filename="source_sct091_tu_02_1.dat")

DEPENDENCY " -DLOADPATH=GETPATH(data) "

DECLARE
%{
double E_min;
double E_max;
char fullfile[256];
%}

INITIALIZE
%{
E_min=81.82/(Lambda_max*Lambda_max);
E_max=81.82/(Lambda_min*Lambda_min);

#define QUOTE(x) #x
#define STR(macro) QUOTE(macro)

#ifndef LOADPATH
#define LOADPATH /usr/share/mcstas/data
#endif

#define LOADPATH_ STR(LOADPATH)

sprintf(fullfile,"%s/%s",LOADPATH_,filename);

%}

/* Here comes the TRACE section, where the actual */
Expand All @@ -63,7 +48,7 @@ TRACE
COMPONENT Origin = Progress_bar()
AT (0,0,0) ABSOLUTE

COMPONENT Source = SNS_source(filename=fullfile,
COMPONENT Source = SNS_source(filename=filename,
xwidth=0.01, yheight=0.01,
dist=1, focus_xw=0.01, focus_yh=0.01, Emin=E_min,Emax=E_max)//,sample_E=samp, p_power=0.5)
AT (0,0,0) ABSOLUTE
Expand Down
Loading
Loading