Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Put the CoM back as the reference frame for the fragmentation movies
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Jan 13, 2023
1 parent 2236488 commit 5329a89
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions examples/Fragmentation/Fragmentation_Movie.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
available_movie_styles = ["disruption_headon", "disruption_off_axis", "supercatastrophic_headon", "supercatastrophic_off_axis","hitandrun_disrupt", "hitandrun_pure", "merge"]
movie_title_list = ["Head-on Disruption", "Off-axis Disruption", "Head-on Supercatastrophic", "Off-axis Supercatastrophic", "Hit and Run w/ Runner Disruption", "Pure Hit and Run", "Merge"]
movie_titles = dict(zip(available_movie_styles, movie_title_list))
num_movie_frames = 1200
num_movie_frames = 1000

# These initial conditions were generated by trial and error
names = ["Target","Projectile"]
Expand Down Expand Up @@ -206,9 +206,17 @@ def update_plot(self, frame):
def reference_frame(r_ref, v_ref, t):
coord_pos = r_ref + v_ref * t
return coord_pos.values[0], coord_pos.values[1]

def center(Gmass, x, y):
x = x[~np.isnan(x)]
y = y[~np.isnan(y)]
Gmass = Gmass[~np.isnan(Gmass)]
x_com = np.sum(Gmass * x) / np.sum(Gmass)
y_com = np.sum(Gmass * y) / np.sum(Gmass)
return x_com, y_com

t, Gmass, rh, point_rad = next(self.data_stream(frame))
x_ref, y_ref = reference_frame(self.r_ref,self.v_ref, t)
x_ref, y_ref = center(Gmass, rh[:,0], rh[:,1])
self.scatter_artist.set_offsets(np.c_[rh[:,0] - x_ref, rh[:,1] - y_ref])
self.scatter_artist.set_sizes(point_rad**2)
return self.scatter_artist,
Expand Down

0 comments on commit 5329a89

Please sign in to comment.