Commit 24686558 authored by Kendrick, Coleman's avatar Kendrick, Coleman
Browse files

Hollow cylinder angled tests

parent 300285f7
......@@ -1005,6 +1005,67 @@ public:
TOLERANCE);
}
void testTracksForHollowCylinderAngle() {
// hollow cylinder at origin with symmetry along y axis
// using PAC06 dimensions: 2.95mm radius x 5.68cm height
// Beam is hitting surface at 30, 45, and 60 degrees from the y-z axis
constexpr double INNER_RADIUS{0.00295};
constexpr double OUTER_RADIUS{0.00315};
constexpr double HEIGHT{0.0568};
constexpr double TOLERANCE{1e-12};
V3D BOTTOM_CENTRE{0.0, -0.5 * HEIGHT, 0.0};
constexpr V3D AXIS_SYMM{0., 1., 0.};
auto cylinder = ComponentCreationHelper::createHollowCylinder(
INNER_RADIUS, OUTER_RADIUS, HEIGHT, BOTTOM_CENTRE, AXIS_SYMM, "cyl");
V3D BEAM_DIRECTION{0.0, sin(45.0 * (M_PI / 180.0)),
cos(45.0 * (M_PI / 180.0))};
BEAM_DIRECTION.normalize();
double ANGLE{atan((BEAM_DIRECTION.Y()) / BEAM_DIRECTION.Z())};
// centre of sample
Track origin(V3D{0., 0., 0.}, BEAM_DIRECTION);
int nsegments = cylinder->interceptSurface(origin);
TS_ASSERT_EQUALS(nsegments, 1);
// Treat pt where beam exits wall as triangle, so same case as
// solid cylinder, just with a smaller and shifted triangle
double base = origin.totalDistInsideObject() * (BEAM_DIRECTION.Z());
double height = base * tan(ANGLE);
double dist = sqrt(pow(height, 2) + pow(base, 2));
TS_ASSERT_DELTA(origin.totalDistInsideObject(),
dist, TOLERANCE);
// Test at same angle, but through entire cylinder:
Track bottom_right(V3D{0., -0.5 * HEIGHT, -OUTER_RADIUS}, BEAM_DIRECTION);
nsegments = cylinder->interceptSurface(bottom_right);
TS_ASSERT_EQUALS(nsegments, 2);
// Assuming the origin test above passed, this should technically be twice
// that distance due to symmetry
TS_ASSERT_DELTA(bottom_right.totalDistInsideObject(),
dist * 2.0, TOLERANCE);
// Test at 30 degrees
BEAM_DIRECTION = V3D{0.0, sin(30.0 * (M_PI / 180.0)),
cos(30.0 * (M_PI / 180.0))};
BEAM_DIRECTION.normalize();
ANGLE = double{atan((BEAM_DIRECTION.Y()) / BEAM_DIRECTION.Z())};
origin = Track(V3D{0., 0., 0.}, BEAM_DIRECTION);
nsegments = cylinder->interceptSurface(origin);
TS_ASSERT_EQUALS(nsegments, 1);
base = origin.totalDistInsideObject() * (BEAM_DIRECTION.Z());
height = base * tan(ANGLE);
dist = sqrt(pow(height, 2) + pow(base, 2));
TS_ASSERT_DELTA(origin.totalDistInsideObject(),
dist, TOLERANCE);
}
void testTracksForFlatPlate() {
// Flat plate centered at origin, 5 mm x 5 mm x 2 mm
// Thin side of plate (2mm) is facing the beam
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment