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
28 changes: 15 additions & 13 deletions mcstas-comps/optics/Absorber.comp
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,27 @@ DECLARE

INITIALIZE
%{
xw = xmax-xmin;
yh = ymax-ymin;
zt = zmax-zmin;
xm = (xmax+xmin)/2;
ym = (ymax+ymin)/2;
zm = (zmax+zmin)/2;
if (xw == 0 || yh == 0 || zt == 0)
{ fprintf(stderr,"Absorber: %s: Error: Slab volume is zero!\n", NAME_CURRENT_COMP); exit(-1); }
xw = xmax - xmin;
yh = ymax - ymin;
zt = zmax - zmin;
xm = (xmax + xmin) / 2;
ym = (ymax + ymin) / 2;
zm = (zmax + zmin) / 2;
if (xw == 0 || yh == 0 || zt == 0) {
fprintf (stderr, "Absorber: %s: Error: Slab volume is zero!\n", NAME_CURRENT_COMP);
exit (-1);
}
%}

TRACE
%{
double t0,t1,xp,yp,zp;
double t0, t1, xp, yp, zp;
xp = x - xm;
yp = y - ym;
zp = z - zm;
if (box_intersect(&t0, &t1, xp, yp, zp, vx, vy, vz, xw, yh, zt)) {
if (t1>=0) {
PROP_DT((t1+t0)/2);
if (box_intersect (&t0, &t1, xp, yp, zp, vx, vy, vz, xw, yh, zt)) {
if (t1 >= 0) {
PROP_DT ((t1 + t0) / 2);
SCATTER;
ABSORB;
}
Expand All @@ -77,7 +79,7 @@ TRACE

MCDISPLAY
%{
box(xm, ym, zm, xw, yh, zt,0, 0, 1, 0);
box (xm, ym, zm, xw, yh, zt, 0, 0, 1, 0);
%}

END
14 changes: 6 additions & 8 deletions mcstas-comps/optics/Arm.comp
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,14 @@ FINALLY
MCDISPLAY
%{
/* A bit ugly; hard-coded dimensions. */

line(0,0,0,0.2,0,0);
line(0,0,0,0,0.2,0);
line(0,0,0,0,0,0.2);

line (0, 0, 0, 0.2, 0, 0);
line (0, 0, 0, 0, 0.2, 0);
line (0, 0, 0, 0, 0, 0.2);

cone(0.2,0,0,0.01,0.02,1,0,0);
cone(0,0.2,0,0.01,0.02,0,1,0);
cone(0,0,0.2,0.01,0.02,0,0,1);

cone (0.2, 0, 0, 0.01, 0.02, 1, 0, 0);
cone (0, 0.2, 0, 0.01, 0.02, 0, 1, 0);
cone (0, 0, 0.2, 0.01, 0.02, 0, 0, 1);
%}

END
46 changes: 25 additions & 21 deletions mcstas-comps/optics/Beamstop.comp
Original file line number Diff line number Diff line change
Expand Up @@ -48,38 +48,42 @@ xwidth=0, yheight=0, radius=0)

INITIALIZE
%{
if (xwidth > 0) { xmax = xwidth/2; xmin = -xmax; }
if (yheight > 0) { ymax = yheight/2; ymin = -ymax; }
if (xwidth > 0) {
xmax = xwidth / 2;
xmin = -xmax;
}
if (yheight > 0) {
ymax = yheight / 2;
ymin = -ymax;
}

if (xmin == 0 && xmax == 0 && ymin == 0 & ymax == 0 && radius == 0)
{ fprintf(stderr,"Beamstop: %s: Error: give geometry\n", NAME_CURRENT_COMP); exit(-1); }
if (xmin == 0 && xmax == 0 && ymin == 0 & ymax == 0 && radius == 0) {
fprintf (stderr, "Beamstop: %s: Error: give geometry\n", NAME_CURRENT_COMP);
exit (-1);
}
%}

TRACE
%{
double Time = t;
ALLOW_BACKPROP;
PROP_Z0;
Time = t - Time;
if ((Time>=0) && ((radius!=0) && (x*x + y*y <= radius*radius))
|| ((Time>=0) && (radius==0) && (x>xmin && x<xmax && y>ymin && y<ymax))) {
SCATTER;
ABSORB;
} else {
RESTORE_NEUTRON(INDEX_CURRENT_COMP, x, y, z, vx, vy, vz, t, sx, sy, sz, p);
}
double Time = t;
ALLOW_BACKPROP;
PROP_Z0;
Time = t - Time;
if ((Time >= 0) && ((radius != 0) && (x * x + y * y <= radius * radius)) || ((Time >= 0) && (radius == 0) && (x > xmin && x < xmax && y > ymin && y < ymax))) {
SCATTER;
ABSORB;
} else {
RESTORE_NEUTRON (INDEX_CURRENT_COMP, x, y, z, vx, vy, vz, t, sx, sy, sz, p);
}
%}

MCDISPLAY
%{

if (radius != 0)
circle("xy", 0, 0, 0, radius);
circle ("xy", 0, 0, 0, radius);
else
multiline(5, (double)xmin, (double)ymin, 0.0,
(double)xmax, (double)ymin, 0.0,
(double)xmax, (double)ymax, 0.0,
(double)xmin, (double)ymax, 0.0,
multiline (5, (double)xmin, (double)ymin, 0.0, (double)xmax, (double)ymin, 0.0, (double)xmax, (double)ymax, 0.0, (double)xmin, (double)ymax, 0.0,
(double)xmin, (double)ymin, 0.0);
%}

Expand Down
Loading