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

WIP tracers #102

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open

WIP tracers #102

wants to merge 33 commits into from

Conversation

pgrete
Copy link
Contributor

@pgrete pgrete commented Mar 4, 2024

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 pgrete changed the title Pgrete/tracer WIP tracers Mar 4, 2024

const auto &prim_pack = mbd->PackVariables(std::vector<std::string>{"prim"});

// update loop. RK2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think leapfrog should give much better accuracy for particle trajectories than RK2. It can be implemented (at second order accuracy) by doing a update that looks like forward Euler, but with velocities averaged over the timestep.

src/tracers/tracers.cpp Outdated Show resolved Hide resolved
@pgrete pgrete mentioned this pull request Aug 26, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants