Skip to content

Commit

Permalink
Merge pull request #1790 from McStasMcXtrace/comp-fixes-mcstas-antlr-…
Browse files Browse the repository at this point in the history
…support

ANTLR-support: Replace nasty type var[] in fact headers
  • Loading branch information
willend authored Dec 5, 2024
2 parents 6ecbbea + 7b9d2c9 commit c05366f
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 241 deletions.
6 changes: 3 additions & 3 deletions mcstas-comps/contrib/Fermi_chop2a.comp
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ SHARE

/*routine to calculate x and y positions of a neutron in a fermi chopper */
#pragma acc routine
void neutxypos(double *x, double *y, double phi, double inrad,double c[])
void neutxypos(double *x, double *y, double phi, double inrad, double* c)
{
*x=c[0]+inrad*cos(phi);
*y=c[1]+inrad*sin(phi);
}

/* routine to calculate the origin of a circle that describes the neutron path through the chopper */
#pragma acc routine
void calccenter(double c[],double zr[], double xr[]){
void calccenter(double* c, double* zr, double* xr){
double denom, A,B,C,D,a,b;
denom=2*(-zr[0]*xr[2] +zr[0]*xr[1]+ zr[1]*xr[2]+xr[0]*zr[2]-xr[0]*zr[1] - xr[1]*zr[2]);
A=xr[1]-xr[2];B=xr[0]-xr[1];C=zr[2]-zr[1];D=zr[1]-zr[0];
Expand All @@ -85,7 +85,7 @@ SHARE
* return 0 if neutron does not transmit return 1 with channel number if neutron will pass*/
#pragma acc routine
int checkabsorb(double phi,int *chan_num, double inrad,double inw, double insw,
double inbw, double blader, double off, double c[]){
double inbw, double blader, double off, double* c){
double xtmp,neuzr,neuxr;
neutxypos(&neuzr,&neuxr,phi,inrad,c);
// printf("xr:%g zr:%g phi: %g r: %g c[0]: %g c[1]: %g\n",neuxr,neuzr,phi,inrad,c[0],c[1]);
Expand Down
1 change: 0 additions & 1 deletion mcstas-comps/contrib/FlatEllipse_finite_mirror.comp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ DECLARE
//point structure
Point p1;
//Function to handle Conic-Neutron collisions with reflectivity from McStas Tables
void traceNeutronConicWithTables(_class_particle* p, ConicSurf c);
double *rfront_inner;//all r-distances at lStart for all mirror surfaces
int silicon; // +1: neutron in silicon, -1: neutron in air, 0: mirrorwidth is 0; neutron cannot be in silicon and also does not track mirror transitions
t_Table rsTable;
Expand Down
22 changes: 15 additions & 7 deletions mcstas-comps/contrib/GISANS_sample.comp
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ double complsqrt(double re, double im, double *imsqrt) {
};

double calclayers(double xiref, double bref, double vz, double vzi, double v,
double zt[8],
double xi[8], double beta[8],
double v2re[8], double v2im[8],
double Ot1[8], double Ot2[8],
double In1[8], double In2[8]
double* zt,
double* xi, double* beta,
double* v2re, double* v2im,
double* Ot1, double* Ot2,
double* In1, double* In2
) {
/* vz und vzi haben beide das Vorzeichen der Richtung */
int i;
Expand Down Expand Up @@ -540,8 +540,8 @@ return 0;

DECLARE
%{
double phase[10][10]; /* Table of different orientations in bulk phase */
double SigB[21][182]; /* Table of total cross sections from integral */
DArray2d phase; /* Table of different orientations in bulk phase */
DArray2d SigB; /* Table of total cross sections from integral */
double z1[8];
double z2[8];
double zt[8];
Expand Down Expand Up @@ -585,6 +585,9 @@ double phirrr;
double dvx,dvy,dvz,dvzi;
double Qx,Qy,Qz;

phase = create_darr2d(10,10);
SigB = create_darr2d(21,182);

Qmin = 1e-5; /* reasonable smallest SANS Q, should be close to zero, but finite */
Qminl= log10(1e-5); /* logarithm of Qmin */
l10 = log(10.0); /* constant ln(10) */
Expand Down Expand Up @@ -1716,6 +1719,11 @@ outsample:

%}

FINALLY %{
destroy_darr2d(phase);
destroy_darr2d(SigB);
%}

MCDISPLAY
%{
double radius = 0;
Expand Down
9 changes: 7 additions & 2 deletions mcstas-comps/contrib/SANS_benchmark2.comp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ return J1o;
};


double dSigdW(int sw, double Q, double Qtab[], double Itab[]) {
double dSigdW(int sw, double Q, double* Qtab, double* Itab) {

int i;

Expand Down Expand Up @@ -514,7 +514,7 @@ return out;

DECLARE
%{
double Idsdw[31][19];
DArray2d Idsdw;
double Qmind; /* AA-1 somehow SANS limit -- the total range should be reasonably large, so Qmind close enough to ZERO */
double Qmaxd; /* AA-1 approx. model Q-limit, where coh. scatt. becomes zero -- practical limit -- 1.0 for most SANS problems */

Expand All @@ -528,6 +528,7 @@ DECLARE

INITIALIZE
%{
Idsdw=create_darr2d(31,19);
Qmind = 0.0001;
Qmaxd = 2.1544346900319;

Expand Down Expand Up @@ -826,6 +827,10 @@ TRACE

%}

FINALLY %{
destroy_darr2d(Idsdw);
%}

MCDISPLAY
%{
double radius = 0;
Expand Down
2 changes: 1 addition & 1 deletion mcstas-comps/contrib/SNS_source.comp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ SHARE %{
/* ----------------------------------------------------------------
routine to load E, I and t I data from SNS source files
-----------------------------------------------------------------*/
void sns_source_load(char fname[], double *xvec, double *yvec, int xcol, int ycol,
void sns_source_load(char* fname, double *xvec, double *yvec, int xcol, int ycol,
int *veclenptr, double *tcol, double *Ecol, double **Imat,int *ntvals, int *nEvals)
{
FILE *fp;
Expand Down
6 changes: 3 additions & 3 deletions mcstas-comps/contrib/Vertical_T0a.comp
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ SHARE

/*routine to calculate x and y positions of a neutron in a fermi chopper */
#pragma acc routine
void neutxypos(double *x, double *y, double phi, double inrad,double c[])
void neutxypos(double *x, double *y, double phi, double inrad, double* c)
{
*x=c[0]+inrad*cos(phi);
*y=c[1]+inrad*sin(phi);
}

/* routine to calculate the origin of a circle that describes the neutron path through the chopper */
#pragma acc routine
void calccenter(double c[],double zr[], double xr[]){
void calccenter(double* c, double* zr, double* xr){
double denom, A,B,C,D,a,b;
denom=2*(-zr[0]*xr[2] +zr[0]*xr[1]+ zr[1]*xr[2]+xr[0]*zr[2]-xr[0]*zr[1] - xr[1]*zr[2]);
A=xr[1]-xr[2];B=xr[0]-xr[1];C=zr[2]-zr[1];D=zr[1]-zr[0];
Expand All @@ -65,7 +65,7 @@ SHARE
#endif
/* function to calculate if the neutron is in the channel or not
* return 0 if neutron does not transmit return 1 if neutron will pass*/
int t0checkabsorb(double phi, double inrad,double inw1, double inw2, double c[]){
int t0checkabsorb(double phi, double inrad,double inw1, double inw2, double* c){
double xtmp,neuzr,neuxr;
neutxypos(&neuzr,&neuxr,phi,inrad,c);
// printf("xr:%g zr:%g phi: %g r: %g c[0]: %g c[1]: %g\n",neuxr,neuzr,phi,inrad,c[0],c[1]);
Expand Down
15 changes: 2 additions & 13 deletions mcstas-comps/examples/SNS/SNS_ARCS/SNS_ARCS.instr
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,7 @@ COMPONENT mod=SNS_source(filename=filename,
Emin=Emin,
Emax=Emax)
AT(0,0,-13.61) ABSOLUTE
// COMPONENT mod=SNS_source(S_filename="source_sct521_bu_17_1.dat",
// width=0.1,
// height=0.12,
// dist=2.5,
// xw=0.1,
// yh=0.12,
// Emin=Emin,
// Emax=Emax)
// AT(0,0,0) ABSOLUTE

COMPONENT sourceMantid=Arm()
AT(0,0,0) RELATIVE mod
COMPONENT core_ves=Guide_channeled(w1=0.094285,h1=0.11323,w2=0.084684,h2=0.102362,l=1.2444,
Expand Down Expand Up @@ -186,8 +178,6 @@ COMPONENT Guide_1_3_3=Guide_channeled(w1=0.06440,h1=0.07609,w2=0.06342,h2=0.0744
W=Gu_W,nslit=1,d=0.0,alphax=Gu_alpha,alphay=Gu_alpha)
AT(0,0,8.04145) RELATIVE mod

/*COMPONENT T0_chopp=Arm()*/

COMPONENT t0_chopp=Vertical_T0a(len=0.474,w1=0.08,w2=0.101,nu=T0_nu,delta=0.0,tc=phase_T0,
ymin=-0.045,ymax=0.045)
AT(0,0,LT0)RELATIVE mod
Expand Down Expand Up @@ -219,10 +209,9 @@ COMPONENT Guide_2_1_5=Guide_channeled(w1=0.05745,h1=0.06417,w2=0.05637,h2=0.0622
W=Gu_W,nslit=1,d=0.0,alphax=Gu_alpha,alphay=Gu_alpha)
AT(0,0,11.08340) RELATIVE mod

COMPONENT fermi_chopp=Fermi_chop2a(len=0.10,w=0.06,ymin=-.0325,ymax=.0325,
COMPONENT fermi_chopp=Fermi_chop2a(len=0.10,w=0.06,ymin=-.0325,ymax=.0325,
nu=Fermi_nu,delta=0.0,tc=phasefc1
,nchan=nchans,bw=0.0005,blader=nrad)
/*COMPONENT fermi_chopp=Arm()*/
AT (0,0,LF) RELATIVE mod
/* COMPONENT Monitor1=TOF_monitor(xmin=-0.035,xmax=0.035,ymin=-0.035,ymax=0.035, */
/* tmin=tplotmin, */
Expand Down
Loading

0 comments on commit c05366f

Please sign in to comment.