Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dynamic motion for shapes using egs_dynamic_shape #1092

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from

Conversation

rtownson
Copy link
Collaborator

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.

Alex Demelo and others added 5 commits June 2, 2023 13:05
Added saving time index to the base source for all simulation objects
Added support to visualize simulations in time in egsview
Now if user pushes the play button while the simulation is playing it will pause the simulation at the current time index. Pushing play again causes the simulation to restart from paused position. Also, simulations will now play from current time index instead of defaulting to starting at zero. If the current time index is the last one it will set time to zero and start from the beginning
@rtownson rtownson added this to the Release 2024 milestone Jan 22, 2024
@rtownson rtownson self-assigned this Jan 22, 2024
@rtownson rtownson requested a review from a team as a code owner January 22, 2024 01:03
@blakewalters
Copy link
Contributor

@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

@rtownson
Copy link
Collaborator Author

rtownson commented Jun 17, 2024

@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.

@blakewalters
Copy link
Contributor

Thanks, @rtownson!

@rtownson
Copy link
Collaborator Author

rtownson commented Jun 17, 2024

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.

@blakewalters
Copy link
Contributor

blakewalters commented Jun 17, 2024

@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!

@rtownson
Copy link
Collaborator Author

@blakewalters I believe I fixed the issue, let me know if you can find any other bugs :)

@ftessier
Copy link
Member

The RectangleShape derives from SurfaceShape, which derives from BaseShape, and I have transformed rectangle shapes before if I remember correctly.

@ftessier
Copy link
Member

Unless I have only transformed the source itself?

@rtownson
Copy link
Collaborator Author

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.

@blakewalters
Copy link
Contributor

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.

@rtownson
Copy link
Collaborator Author

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.

Add a shape that handles dynamic motion, synchronized with the motion
of geometries and sources.
Fix flickering that occurred when dragging the time with your mouse.
Particle tracks would flash on the screen from a longer time range than
the selected window.
Change the time window default to 1% of the simulation duration for
tracks visualization. Also add a new input in egs_view for the number of
time steps to take in the animation. This allows for better control of
the visual speed of the motion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants