EGSnrc
EGSnrc copied to clipboard
Add dynamic motion for shapes using egs_dynamic_shape
This builds on PR #1022 by adding similar support of motion for shapes. This is useful if you're using a shape to define a source shape (e.g. a collimated source target shape), and that shape is meant to be aimed at a geometry that's in motion.
@rtownson, I've been running a couple of tests using egs_dynamic_shape to collimate a source and, for some reason, I'm not seeing the evolution of source particles I would expect. I've attached a tutor7pp example in which a parallel beam is collimated using egs_rectangle inside egs_dynamic_shape so that the rectangle rotates 10 degrees about the Z-axis every 1/4*ncase histories, but I don't see evidence of this in egs_view or any rotational smearing in a phase space file scored beneath the source. I feel like there's some issue with my input or with my understanding of what I should be seeing. Could you please take a look when you get the chance? Thanks! source_dyn_shape_test.txt
@blakewalters with that input file you should be seeing this warning (actually causes an infinite loop, I'll fix that):
Time index of control point 3 < time index of control point 2
If you're not, then something hasn't been compiled. Recompile in HEN_HOUSE/egs++, HEN_HOUSE/egs++/view, and egs_home/tutor7pp. My guess is that you didn't recompile tutor7pp. Also make sure that you're using the freshly compiled egs_view, not the one that comes with the installation.
Edit: After fixing that issue, you're right that I'm still not seeing any shape motion for this case.
Thanks, @rtownson!
Edit2: I had a typo elsewhere in the input file, you can disregard this.
Correct me if I'm wrong, but it seems like egs_rectangle
doesn't accept transformations! This looks to be the case for a number of shapes. This will also stop egs_dynamic_shape from working. It has the line shape->setTransformation(input);
but then never uses the transformation, as far as I can tell. So this is a wider problem to solve.
E.g. the following seems to do nothing:
:start shape:
library = egs_rectangle
rectangle = -1 -1 1 1
:start transformation:
translation = 10 0 0
:stop transformation:
:stop shape:
Edit: In this case you could just use a dynamic_source or source transformation instead.
@rtownson, oh now I think I see: getPointSourceDirection applies the transformation when a new source particle is chosen. Just looking over the logic for a parallel beam with a rectangular shape, though, we use EGS_BaseShape::getRandomPoint which then applies T to EGS_RectangularRing::getPoint before returning the incident position, so I'm not sure where the chain is breaking down. Let me know if you'd like me to do more digging!
@blakewalters I believe I fixed the issue, let me know if you can find any other bugs :)
The RectangleShape derives from SurfaceShape, which derives from BaseShape, and I have transformed rectangle shapes before if I remember correctly.
Unless I have only transformed the source itself?
The RectangleShape derives from SurfaceShape, which derives from BaseShape, and I have transformed rectangle shapes before if I remember correctly.
You're right, I just had a typo in my input file! It's all resolved now.
Looks good, @rtownson! I've run a couple of other tests and source output is consistent with the (albeit simplistic) dynamic motion of their shapes.
One lingering questions concerns the viewing of dynamic particle track files (.syncptracks) using egs_view: What is the "Time window" input in the "Particle tracks" window? Does this control the (max.) fraction of the particle tracks displayed in a given time frame? The default value on launching egs_view is 2.0, which doesn't show any evolution of tracks at all, just the cumulative result.
Thanks @blakewalters, I changed the default time window to be 0.01, instead of defaulting to showing all of the tracks. I also added a new feature to adjust the number of steps to animate, something I was wanting while making videos for a talk.
Rebased on the new add-egs-dynamic-geometry
.
Adjusted the commit titles, reordered and squashed a couple. Clean git diff
compared to origin/
.
Adjusted one commit message, clean diff
.