-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8dc727e
commit 7605e3b
Showing
2 changed files
with
41 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# note: the AMReX frontend is broken in yt 4.3.0 | ||
import yt | ||
from yt.frontends.boxlib.data_structures import AMReXDataset | ||
|
||
def particle_dist(plotfiles): | ||
t_arr = [] | ||
err_arr = [] | ||
d0 = 2.0*3.125e12 | ||
|
||
for pltfile in plotfiles: | ||
ds = AMReXDataset(pltfile) | ||
ad = ds.all_data() | ||
x = ad["CIC_particles", "particle_position_x"] | ||
y = ad["CIC_particles", "particle_position_y"] | ||
z = ad["CIC_particles", "particle_position_z"] | ||
dx = x[0] - x[1] | ||
dy = y[0] - y[1] | ||
dz = z[0] - z[1] | ||
from math import sqrt | ||
d = sqrt(dx*dx + dy*dy + dz*dz) | ||
err = (d-d0)/d0 | ||
t_arr.append(float(ds.current_time) / 3.15e7) | ||
err_arr.append(err) | ||
|
||
return t_arr, err_arr | ||
|
||
import glob | ||
files = glob.glob("plt*") | ||
files = sorted(files) | ||
t, err = particle_dist(files) | ||
|
||
import matplotlib.pyplot as plt | ||
plt.figure(figsize=(6,4)) | ||
plt.plot(t, err) | ||
plt.xlabel("time (yr)") | ||
plt.ylabel(r"$(d-d_0)/d_0$") | ||
plt.tight_layout() | ||
plt.savefig("orbit.png", dpi=150) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters