athenapk icon indicating copy to clipboard operation
athenapk copied to clipboard

WIP tracers

Open pgrete opened this issue 11 months ago • 0 comments

Python analysis/plotting example:

import matplotlib.pyplot as plt
import numpy as np
import sys
sys.path.insert(
    1,
    "/home/pgrete/src/athenapk/external/parthenon"
    + "/scripts/python/packages/parthenon_tools/parthenon_tools",
)

try:
    import phdf
except ModuleNotFoundError:
    print("Couldn't find module to read Parthenon hdf5 files.")

data = phdf.phdf("../run-turbulence/parthenon.prim.00010.phdf")
tracers = data.GetSwarm("tracers")
xs = tracers.x
ys = tracers.y
zs = tracers.z
ids = tracers.Get("id")

fig = plt.figure()
ax = fig.add_subplot(projection='3d')

ax.scatter(xs, ys, zs,s=1,c=ids)#,cmap="plasma")

results in image

with lookback times available in

data.Params["tracers/t_lookback"]

from parameters in an output block like

<parthenon/output2>
file_type  = hdf5       # Binary data dump
variables   = prim   # variables to be output
dt         = 0.1        # time increment between outputs
id         = prim
single_precision_output = true

swarms = tracers
tracers_variables = id, x, y, z, rho, s, sdot

and tracers enabled by an additional block as

<tracers>
enabled = true
num_tracers_per_cell = 0.125

pgrete avatar Mar 04 '24 19:03 pgrete