Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fixes in monitors #1533

Merged
merged 3 commits into from
Dec 7, 2023
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
4 changes: 3 additions & 1 deletion mcstas-comps/monitors/Monitor_4PI.comp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ TRACE

SAVE
%{
DETECTOR_OUT_0D("4PI monitor " NAME_CURRENT_COMP, Nsum, psum, p2sum);
char full_name[1024];
sprintf(full_name, "4PI monitor %s", NAME_CURRENT_COMP);
DETECTOR_OUT_0D(full_name, Nsum, psum, p2sum);
%}

MCDISPLAY
Expand Down
12 changes: 0 additions & 12 deletions mcstas-comps/monitors/PSD_monitor_psf.comp
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ SETTING PARAMETERS (

OUTPUT PARAMETERS ()

STATE PARAMETERS (x, y, z, vx, vy, vz, t, s1, s2, p)

POLARISATION PARAMETERS (sx, sy, sz)

DECLARE
%{
DArray2d PSD_N;
Expand All @@ -87,14 +83,6 @@ INITIALIZE
PSD_p = create_darr2d(nx, ny);
PSD_p2 = create_darr2d(nx, ny);

for (i=0; i<nx; i++){
for (j=0; j<ny; j++){
PSD_N[i][j] = 0;
PSD_p[i][j] = 0;
PSD_p2[i][j] = 0;
}
}

// Use instance name for monitor output if no input was given
if (!strcmp(filename,"\0")) sprintf(filename,"%s",NAME_CURRENT_COMP);
%}
Expand Down
40 changes: 27 additions & 13 deletions mcstas-comps/monitors/TOFlog_monitor.comp
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,10 @@ OUTPUT PARAMETERS ()

DECLARE
%{
#define LARGENUMBER
int nchan;
double TOF_N[LARGENUMBER];
double TOF_p[LARGENUMBER];
double TOF_p2[LARGENUMBER];
DArray1d TOF_N;
DArray1d TOF_p;
DArray1d TOF_p2;
%}

INITIALIZE
Expand All @@ -76,17 +75,23 @@ INITIALIZE
NAME_CURRENT_COMP);
exit(0);
}

if (tmin <= 0 || tmax <= 0) {
printf("TOFlog_mon: %s: Only supports positive tmin and tmax !\n"
"ERROR (tmin, tmax). Exiting", NAME_CURRENT_COMP);
exit(0);
}

if (tmin >= tmax) {
printf("TOFlog_mon: %s: tmin should be smaller than tmax !\n"
"ERROR (tmin, tmax). Exiting", NAME_CURRENT_COMP);
exit(0);
}

nchan=(int)ceil(ndec*log(tmax/tmin)/log(10.0));
if (nchan>LARGENUMBER)
printf("FATAL ERROR, too many time channels \n");

for (i=0; i<nchan; i++)
{
TOF_N[i] = 0;
TOF_p[i] = 0;
TOF_p2[i] = 0;
}
TOF_N = create_darr1d(nchan);
TOF_p = create_darr1d(nchan);
TOF_p2 = create_darr1d(nchan);

// Use instance name for monitor output if no input was given
if (!strcmp(filename,"\0")) sprintf(filename,"%s",NAME_CURRENT_COMP);
Expand All @@ -108,6 +113,7 @@ TRACE
TOF_p[i] = TOF_p[i]+p;
#pragma acc atomic
TOF_p2[i] = TOF_p2[i]+p2;
SCATTER;
}
}
if (restore_neutron) {
Expand All @@ -128,6 +134,14 @@ if (!nowritefile) {
}
%}

FINALLY
%{
destroy_darr1d(TOF_N);
destroy_darr1d(TOF_p);
destroy_darr1d(TOF_p2);
%}


MCDISPLAY
%{
multiline(5, (double)xmin, (double)ymin, 0.0,
Expand Down