From 2e9581b9619d2e7ada68c72167a1b160b71b94a4 Mon Sep 17 00:00:00 2001 From: David Minton Date: Fri, 11 Jun 2021 16:24:19 -0400 Subject: [PATCH 1/2] Fixed rotation visualization bug --- .../symba_energy_momentum/collision_movie.py | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/examples/symba_energy_momentum/collision_movie.py b/examples/symba_energy_momentum/collision_movie.py index 2cf98a46d..9001f8983 100644 --- a/examples/symba_energy_momentum/collision_movie.py +++ b/examples/symba_energy_momentum/collision_movie.py @@ -169,14 +169,12 @@ def spin_arrows(self, pl, id, len): py = pl[:, 1] sarrowend = [] sarrowtip = [] - idxactive = np.arange(id.size)[self.mask] for i in range(pl.shape[0]): - endrel = np.array([0.0, len[i], 0.0]) - tiprel = np.array([0.0, -len[i], 0.0]) + endrel = np.array([len[i], 0.0, 0.0]) + tiprel = np.array([-len[i], 0.0, 0.0]) r = R.from_rotvec(self.rot_angle[id[i]]) - if i in idxactive: - endrel = r.apply(endrel) - tiprel = r.apply(tiprel) + endrel = r.apply(endrel) + tiprel = r.apply(tiprel) send = (px[i] + endrel[0], py[i] + endrel[1]) stip = (px[i] + tiprel[0], py[i] + tiprel[1]) sarrowend.append(send) @@ -268,6 +266,7 @@ def data_stream(self, frame=0): roty = np.nan_to_num(roty, copy=False) rotz = np.nan_to_num(rotz, copy=False) rotvec = np.array([rotx, roty, rotz]) + self.rotvec = dict(zip(id, zip(*rotvec))) if frame == 0: tmp = np.zeros_like(rotvec) @@ -275,13 +274,9 @@ def data_stream(self, frame=0): else: t0 = self.ds.coords['time'].values[frame-1] dt = t - t0 - for i in np.arange(npl): - if id[i] in self.rot_angle: - self.rot_angle[id[i]] = self.rot_angle[id[i]] + dt * rotvec[:,i] - self.rot_angle[id[i]] = self.rot_angle[id[i]] % (2 * np.pi) - else: - self.rot_angle[id[i]] = np.zeros(3) - + idxactive = np.arange(id.size)[self.mask] + for i in id[idxactive]: + self.rot_angle[i] = self.rot_angle[i] + dt * np.array(self.rotvec[i]) frame += 1 yield t, name, mass, radius, npl, np.c_[x, y, vx, vy], radmarker, origin From f68942aa63591e4773aeb0c5053818ec65768c09 Mon Sep 17 00:00:00 2001 From: David Minton Date: Fri, 11 Jun 2021 16:26:48 -0400 Subject: [PATCH 2/2] Added rotation to head-on cases --- examples/symba_energy_momentum/collision_movie.py | 4 ++-- examples/symba_energy_momentum/disruption_headon.in | 4 ++-- examples/symba_energy_momentum/supercatastrophic_headon.in | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/symba_energy_momentum/collision_movie.py b/examples/symba_energy_momentum/collision_movie.py index 9001f8983..efc62ab86 100644 --- a/examples/symba_energy_momentum/collision_movie.py +++ b/examples/symba_energy_momentum/collision_movie.py @@ -10,8 +10,8 @@ ymin = -20.0 ymax = 20.0 -#cases = ['supercat_head', 'supercat_off', 'disruption_head', 'disruption_off'] -cases = ['disruption_off', 'supercat_off'] +cases = ['supercat_head', 'supercat_off', 'disruption_head', 'disruption_off'] +#cases = ['disruption_off', 'supercat_off'] def scale_sim(ds, config): diff --git a/examples/symba_energy_momentum/disruption_headon.in b/examples/symba_energy_momentum/disruption_headon.in index 34688822c..fe81f1641 100644 --- a/examples/symba_energy_momentum/disruption_headon.in +++ b/examples/symba_energy_momentum/disruption_headon.in @@ -9,10 +9,10 @@ 1.0 -4.20E-05 0.0 0.00 6.28 0.0 0.4 0.4 0.4 !Ip -0.0 0.0 0.0 !rot +0.0 0.0 6.0e4 !rot 3 7e-10 0.0004 3.25e-06 1.0 4.20E-05 0.0 0.00 -6.28 0.0 0.4 0.4 0.4 !Ip -0.0 0.0 0.0 !rot +0.0 0.0 1.0e5 !rot diff --git a/examples/symba_energy_momentum/supercatastrophic_headon.in b/examples/symba_energy_momentum/supercatastrophic_headon.in index 1ffbeacc5..b87fbba05 100644 --- a/examples/symba_energy_momentum/supercatastrophic_headon.in +++ b/examples/symba_energy_momentum/supercatastrophic_headon.in @@ -9,10 +9,10 @@ 1.0 -4.20E-05 0.0 0.00 6.28 0.0 0.4 0.4 0.4 !Ip -0.0 0.0 0.0 !rot +0.0 0.0 -6.0e4 !rot 3 1e-08 0.0004 3.25e-06 1.0 4.20E-05 0.0 0.00 -6.28 0.0 0.4 0.4 0.4 !Ip -0.0 0.0 0.0 !rot +0.0 0.0 1.0e5 !rot