3434* <b>Example 1, Elliptical definition using focal points:</b>
3535*
3636* Elliptic_guide_gravity(
37- *      l=50,
38- *      linxw=5,linyh=5,loutxw=10,loutyh=10,
39- *      xwidth=0.05,yheight=0.05,
40- *      R0=0.99,Qc=0.0219,alpha=6.07,m=1.0,W=0.003
37+ * l=50,
38+ * linxw=5,linyh=5,loutxw=10,loutyh=10,
39+ * xwidth=0.05,yheight=0.05,
40+ * R0=0.99,Qc=0.0219,alpha=6.07,m=1.0,W=0.003
4141* )
4242*
4343* <b>Example 2: Half elliptical definition:</b>
4444*
4545* Elliptic_guide_gravity(
46- *      l=50,
47- *      linxw=5,linyh=5,loutxw=10,loutyh=10,
48- *      xwidth=0.1,yheight=0.1,
49- *      R0=0.99,Qc=0.0219,alpha=6.07,m=1.0,W=0.003,
50- *      option = "halfEllipse",
51- *      dimensionsAt = "entrance"
46+ * l=50,
47+ * linxw=5,linyh=5,loutxw=10,loutyh=10,
48+ * xwidth=0.1,yheight=0.1,
49+ * R0=0.99,Qc=0.0219,alpha=6.07,m=1.0,W=0.003,
50+ * option = "halfEllipse",
51+ * dimensionsAt = "entrance"
5252* )
5353*
5454* <b>Example 3: Parabolic approximation:</b>
5555*
5656* Elliptic_guide_gravity(
57- *      l=50,
58- *      linxw=5,linyh=5,loutxw=1e6,loutyh=1e6, // values larger than 1e8 may cause erroneous results
59- *      xwidth=0.1,yheight=0.1,
60- *      R0 = 0.99,Qc=0.0219,alpha=6.07,m=1.0,W=0.003,
61- *      dimensionsAt = "exit"
57+ * l=50,
58+ * linxw=5,linyh=5,loutxw=1e6,loutyh=1e6, // values larger than 1e8 may cause erroneous results
59+ * xwidth=0.1,yheight=0.1,
60+ * R0 = 0.99,Qc=0.0219,alpha=6.07,m=1.0,W=0.003,
61+ * dimensionsAt = "exit"
6262* )
6363*
6464* <b>Example 4: Elliptical definition with varying m-values:</b>
6565*
6666* Elliptic_guide_gravity(
67- *      l=50,
68- *      linxw=5,linyh=5,loutxw=10,loutyh=10,
69- *      xwidth=0.1,yheight=0.1,
70- *      R0 = 0.99,Qc=0.0219,alpha=6.07,m=1.0,W=0.003,
71- *      mvaluesright=marray,mvaluesleft=marray,mvaluestop=marray,mvaluesbottom=marray
67+ * l=50,
68+ * linxw=5,linyh=5,loutxw=10,loutyh=10,
69+ * xwidth=0.1,yheight=0.1,
70+ * R0 = 0.99,Qc=0.0219,alpha=6.07,m=1.0,W=0.003,
71+ * mvaluesright=marray,mvaluesleft=marray,mvaluestop=marray,mvaluesbottom=marray
7272* )
7373*
7474* where marray is initialized as
@@ -244,7 +244,7 @@ struct SGI
244244 define geomtric of the guide or physical values for mirrors
245245 @param var is the input varible there the error occurred [text]
246246*/
247- int guide_elliptical_illegalInputLessThanZero(char var[] ,int verbose){
247+ int guide_elliptical_illegalInputLessThanZero(char* var,int verbose){
248248 if (verbose)
249249 printf("The user defined variable %s in %s has an illegal value"
250250 " less than zero\n",var,"Elliptic_guide_gravity");
@@ -258,7 +258,7 @@ int guide_elliptical_illegalInputLessThanZero(char var[],int verbose){
258258 @param in,out is the input varible there the error occurred [text]
259259*/
260260int guide_elliptical_illegalInputFocalPointsHyperbola(
261- char in[] ,char out[] ,
261+ char* in,char* out,
262262 double inValue,double outValue, int verbose){
263263 if (verbose){
264264 printf("The user defined length of the guide, length \
@@ -277,7 +277,7 @@ int guide_elliptical_illegalInputFocalPointsHyperbola(
277277 should not be accessible if the algoritmes are working correctly
278278 Most likely errors are floating points and ill-defined cases
279279*/
280- void guide_elliptical_callCriticalWarning(char func[] ,int verbose){
280+ void guide_elliptical_callCriticalWarning(char* func,int verbose){
281281 if (verbose)
282282 printf("A CRITICAL WARNING has been called inside %s by function %s."
283283 "This is most likely due to a programming error \
@@ -526,62 +526,6 @@ int guide_elliptical_handleGuideIntersection(
526526 return boolean;
527527}
528528
529- /**
530- Check if the neutron is within the guide using the sign
531- of the crossproduct between the two points,
532- on each of the enclosing box surface and neutrons position.
533-
534- @param x,y,z; position of the neutron. [m]
535- @param guideInfo; pointer to the guide infomation holding structure.
536- @return; return 1 if the neutron is inside the guide [boolean]
537- */
538-
539- /*
540- int guide_elliptical_InsideEnclosingBox(double x,double y,double z,struct SGI *guideInfo){
541- int guide_elliptical_IsPointInVolume(
542- double *x,double *y,double *z,
543- double px,double py,double pz){
544- int guide_elliptical_WhichSide( double p1x,double p1y,double p1z,
545- double p2x,double p2y,double p2z,
546- double p3x,double p3y,double p3z,
547- double px ,double py ,double pz ){
548-
549- double v1x = p1x - p2x, v1y = p1y-p2y, v1z = p1z-p2z;
550- double v2x = p3x - p2x, v2y = p3y-p2y, v2z = p3z-p2z;
551- double v3x = v2y*v1z-v2z*v1y;
552- double v3y = v2z*v1x-v2x*v1z;
553- double v3z = v2x*v1y-v2y*v1x;
554-
555- return 0 >= v3x*(px-p1x)+v3y*(py-p1y)+v3z*(pz-p1z);
556- }
557-
558- if( //front
559- guide_elliptical_WhichSide(x[3],y[3],z[3],x[2],y[2],z[2],x[1],y[1],z[1],px,py,pz) &&
560- guide_elliptical_WhichSide(x[1],y[1],z[1],x[0],y[0],z[0],x[3],y[3],z[3],px,py,pz) &&
561- //back
562- guide_elliptical_WhichSide(x[5],y[5],z[5],x[6],y[6],z[6],x[7],y[7],z[7],px,py,pz) &&
563- guide_elliptical_WhichSide(x[7],y[7],z[7],x[4],y[4],z[4],x[5],y[5],z[5],px,py,pz) &&
564- //right
565- guide_elliptical_WhichSide(x[7],y[7],z[7],x[3],y[3],z[3],x[0],y[0],z[0],px,py,pz) &&
566- guide_elliptical_WhichSide(x[0],y[0],z[0],x[4],y[4],z[4],x[7],y[7],z[7],px,py,pz) &&
567- //left
568- guide_elliptical_WhichSide(x[1],y[1],z[1],x[2],y[2],z[2],x[6],y[6],z[6],px,py,pz) &&
569- guide_elliptical_WhichSide(x[6],y[6],z[6],x[5],y[5],z[5],x[1],y[1],z[1],px,py,pz) &&
570- //top
571- guide_elliptical_WhichSide(x[0],y[0],z[0],x[1],y[1],z[1],x[5],y[5],z[5],px,py,pz) &&
572- guide_elliptical_WhichSide(x[5],y[5],z[5],x[4],y[4],z[4],x[0],y[0],z[0],px,py,pz) &&
573- //bottom
574- guide_elliptical_WhichSide(x[6],y[6],z[6],x[2],y[2],z[2],x[3],y[3],z[3],px,py,pz) &&
575- guide_elliptical_WhichSide(x[3],y[3],z[3],x[7],y[7],z[7],x[6],y[6],z[6],px,py,pz) )
576- return 1;
577- else return 0;
578- }
579- return guide_elliptical_IsPointInVolume(
580- guideInfo->xArray,guideInfo->yArray,guideInfo->zArray,x,y,z);
581- }
582- */
583-
584-
585529///////////////////////////////////////////////////////////////////////////
586530/////////////// reflection functions
587531///////////////////////////////////////////////////////////////////////////
@@ -1124,29 +1068,6 @@ INITIALIZE
11241068 // Applies the properties of the mirrors in the guide given by the user.
11251069 // These variables are used in the reflection functions.
11261070
1127-
1128- // Sets the mirror type of the guides mirrors
1129- // These variables are used in the collision functions
1130- // to find the type of collision
1131-
1132- // guideInfo.OuterSide[RightSide] =
1133- // guide_elliptical_getMirrorTypeFromInput(outer_right_side_mirror,guideInfo.verboseSetting);
1134- // guideInfo.OuterSide[TopSide] =
1135- // guide_elliptical_getMirrorTypeFromInput(outer_top_side_mirror,guideInfo.verboseSetting);
1136- // guideInfo.OuterSide[LeftSide] =
1137- // guide_elliptical_getMirrorTypeFromInput(outer_left_side_mirror,guideInfo.verboseSetting);
1138- // guideInfo.OuterSide[BottomSide] =
1139- // guide_elliptical_getMirrorTypeFromInput(outer_bottom_side_mirror,guideInfo.verboseSetting);
1140-
1141- // guideInfo.InnerSide[RightSide] =
1142- // guide_elliptical_getMirrorTypeFromInput(inner_right_side_mirror,guideInfo.verboseSetting);
1143- // guideInfo.InnerSide[TopSide] =
1144- // guide_elliptical_getMirrorTypeFromInput(inner_top_side_mirror,guideInfo.verboseSetting);
1145- // guideInfo.InnerSide[LeftSide] =
1146- // guide_elliptical_getMirrorTypeFromInput(inner_left_side_mirror,guideInfo.verboseSetting);
1147- // guideInfo.InnerSide[BottomSide] =
1148- // guide_elliptical_getMirrorTypeFromInput(inner_bottom_side_mirror,guideInfo.verboseSetting);
1149-
11501071 // Give a warning if all side of the guide is turned off,
11511072 // as the guide is essentially turned off
11521073 if( guideInfo.OuterSide[RightSide] == 1
@@ -1170,10 +1091,6 @@ INITIALIZE
11701091 MirrorTypeabsorption;
11711092 if(guideInfo.mArr[BottomSide] <= 0) guideInfo.InnerSide[BottomSide] =
11721093 MirrorTypeabsorption;
1173- /* if(directDefination == 0){ */
1174- /* guideInfo.entranceHorizontalWidth = xwidth; */
1175- /* guideInfo.entranceVerticalWidth = yheight; */
1176- /* } */
11771094
11781095 if( strcmp(option,"halfellipse") == 0 && directDefination == 0 ){
11791096 guideInfo.entranceHorizontalWidth =
@@ -1195,56 +1112,6 @@ INITIALIZE
11951112
11961113 guideInfo.EnclosingBoxOn = 0;
11971114
1198- /*
1199- double DefaultArray1[8] = { 1.0,-1.0,-1.0, 1.0, 1.0,-1.0,-1.0, 1.0};
1200- double DefaultArray2[8] = { 1.0, 1.0,-1.0,-1.0, 1.0, 1.0,-1.0,-1.0};
1201- double DefaultArray3[8] = {-1.0,-1.0,-1.0,-1.0, 1.0, 1.0, 1.0, 1.0};
1202-
1203- guideInfo.EnclosingBoxOn = 0;
1204- double *xinput;
1205- if ( xInput != NULL ){ xinput = xInput; guideInfo.EnclosingBoxOn = 1; }
1206- else { xinput = DefaultArray1; }
1207- double *yinput;
1208- if ( yInput != NULL ){ yinput = yInput; guideInfo.EnclosingBoxOn = 1;}
1209- else { yinput = DefaultArray2; }
1210- double *zinput;
1211- if ( zInput != NULL ){ zinput = zInput; guideInfo.EnclosingBoxOn = 1;}
1212- else { zinput = DefaultArray3; }
1213- */
1214-
1215- /*
1216- double xarray[8] ={ guideInfo.ellipseMinorAxis[0]*xinput[0],
1217- guideInfo.ellipseMinorAxis[2]*xinput[1],
1218- guideInfo.ellipseMinorAxis[2]*xinput[2],
1219- guideInfo.ellipseMinorAxis[0]*xinput[3],
1220- guideInfo.ellipseMinorAxis[0]*xinput[4],
1221- guideInfo.ellipseMinorAxis[2]*xinput[5],
1222- guideInfo.ellipseMinorAxis[2]*xinput[6],
1223- guideInfo.ellipseMinorAxis[0]*xinput[7] };
1224- double yarray[8] ={ guideInfo.ellipseMinorAxis[1]*yinput[0],
1225- guideInfo.ellipseMinorAxis[1]*yinput[1],
1226- guideInfo.ellipseMinorAxis[3]*yinput[2],
1227- guideInfo.ellipseMinorAxis[3]*yinput[3],
1228- guideInfo.ellipseMinorAxis[1]*yinput[4],
1229- guideInfo.ellipseMinorAxis[1]*yinput[5],
1230- guideInfo.ellipseMinorAxis[3]*yinput[6],
1231- guideInfo.ellipseMinorAxis[3]*yinput[7] };
1232- double zarray[8] ={ guideInfo.Length/2*zinput[0]+guideInfo.Length/2,
1233- guideInfo.Length/2*zinput[1]+guideInfo.Length/2,
1234- guideInfo.Length/2*zinput[2]+guideInfo.Length/2,
1235- guideInfo.Length/2*zinput[3]+guideInfo.Length/2,
1236- guideInfo.Length/2*zinput[4]+guideInfo.Length/2,
1237- guideInfo.Length/2*zinput[5]+guideInfo.Length/2,
1238- guideInfo.Length/2*zinput[6]+guideInfo.Length/2,
1239- guideInfo.Length/2*zinput[7]+guideInfo.Length/2 };
1240- int i = 0;
1241- for(i = 0; i < 8; i++){
1242- guideInfo.xArray[i] = xarray[i];
1243- guideInfo.yArray[i] = yarray[i];
1244- guideInfo.zArray[i] = zarray[i];
1245- }
1246- */
1247-
12481115 guideInfo.exitVerticalWidth =
12491116 2*sqrt(1 - ( (guideInfo.Length-guideInfo.ellipseMajorOffset[BottomSide])
12501117 *(guideInfo.Length-guideInfo.ellipseMajorOffset[BottomSide])
@@ -1295,61 +1162,6 @@ INITIALIZE
12951162 }
12961163 else guideInfo.segLength = seglength;
12971164
1298- /* if( guideInfo.numberOfSegments != sizeof(mvaluesright)/sizeof(mvaluesright[0]) */
1299- /* || guideInfo.numberOfSegments != sizeof(mvaluesleft)/sizeof(mvaluesleft[0]) */
1300- /* || guideInfo.numberOfSegments != sizeof(mvaluestop)/sizeof(mvaluestop[0]) */
1301- /* || guideInfo.numberOfSegments != sizeof(mvaluesbottom)/sizeof(mvaluesbottom[0]) */
1302- /* || (guideInfo.segLength == NULL */
1303- /* & guideInfo.numberOfSegments != sizeof(seglength)/sizeof(guideInfo.segLength[0]) */
1304- /* ) ) { */
1305-
1306- /* printf("Error in userinput inside %s, the length of the arrays" */
1307- /* " mvalues and seglength are not equal\n",NAME_CURRENT_COMP); */
1308- /* printf("The length of the arrays are: mValuesright is %lu," */
1309- /* " mvaluesleft is %lu, mvaluestop is %lu, mvaluesbottom is" */
1310- /* " %lu and seglength is %lu and should be %d \n; Above assume that the arrays are using double \n", */
1311- /* sizeof(mvaluesright)/sizeof(double), */
1312- /* sizeof(mvaluesleft)/sizeof(double), */
1313- /* sizeof(mvaluestop)/sizeof(double), */
1314- /* sizeof(mvaluesbottom)/sizeof(double), */
1315- /* sizeof(guideInfo.segLength)/sizeof(double), */
1316- /* guideInfo.numberOfSegments */
1317- /* ); */
1318-
1319- /* if ( guideInfo.verboseSetting ) { */
1320- /* int i; */
1321-
1322- /* printf("The Values of mvaluesright is: ["); */
1323- /* for(i=0; i < sizeof(mvaluesright)/sizeof(mvaluesright[0]); i++) */
1324- /* printf("%e,",guideInfo.mValuesright[i] ); */
1325- /* printf("]\n"); */
1326-
1327- /* printf("The Values of mvaluesleft is: ["); */
1328- /* for(i=0; i < sizeof(mvaluesleft)/sizeof(mvaluesleft[0]); i++) */
1329- /* printf("%e,",guideInfo.mValuesleft[i] ); */
1330- /* printf("]\n"); */
1331-
1332- /* printf("The Values of mvaluestop is: ["); */
1333- /* for(i=0; i < sizeof(mvaluestop)/sizeof(mvaluestop[0]); i++) */
1334- /* printf("%e,",guideInfo.mValuestop[i] ); */
1335- /* printf("]\n"); */
1336-
1337- /* printf("The Values of mvaluesbottom is: ["); */
1338- /* for(i=0; i < sizeof(mvaluesbottom)/sizeof(mvaluesbottom[0]); i++) */
1339- /* printf("%e,",guideInfo.mValuesbottom[i] ); */
1340- /* printf("]\n"); */
1341-
1342- /* printf("The Values of seglength is: ["); */
1343- /* for(i=0; i < sizeof(guideInfo.segLength)/sizeof(guideInfo.segLength[0]); i++) */
1344- /* printf("%e,",guideInfo.segLength[i]); */
1345- /* printf("]\n"); */
1346- /* } */
1347- /* exit( printf("Exit due to critical error in userinput for the" */
1348- /* " component %s, consider having a look at the input" */
1349- /* " for following: mvaluesright,mvaluesleft,mvaluestop," */
1350- /* "mvaluesbottom and/or seglength.",NAME_CURRENT_COMP) ); */
1351- /* } */
1352- //
13531165 double sumOfelements=0;
13541166 int i;
13551167 for(i=0;i< guideInfo.numberOfSegments; i++) {
0 commit comments