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

Add passive tracer advection-diffusion in 2D flows #279

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

Conversation

BrodiePearson
Copy link
Collaborator

I added a passive tracer to the 2D module for some personal experiments, and I wondered if this would be a useful addition for others. This is related, but not identical, to Issue #20. I wasn't sure whether this module fit in GeophysicalFlows.jl, PassiveTracersFlows.jl, or another project (I want to expand to reacting tracers in the future).

I approached this problem using the multi-layer QG module's framework of a 3D solution (where the top layer is dynamics, and other layers are tracers).

  • A rough overview of the structural differences between the new tracer 2D module and the original no-tracer 2D module can be seen in commit Adds tracer to new 2D dynamics module. There were also numerous small modifications to the code after this commit.

The general properties of the module are:

  • It solves advection-diffusion equations for tracers in a two-dimensional flow.
  • It can advect an arbitrary number of tracers (ntracers). The examples I have in this PR use 3 tracers.
  • There is a user-specified tracer diffusivity κ with order .
  • The tracers can be initialized alongside the initial vorticity field through a new set_ζ_and_tracers! function.
  • The new module (twodnavierstokeswithtracer.jl) frames the solution (sol) as a nk x nl x nlayers array, where nlayers = ntracers +1. The first layer (sol[:,:,1]) is the vorticity and the lower layers are each of the tracers.
  • The module is kind of slow (adding 3 tracers almost quadruples the simulation time). I think this is because of the calcN! step, and this could probably be made more efficient.
  • It is not monotonic, it creates some small negative tracer concentrations from an initially positive/zero tracer field. I think this might be a common feature of spectral tracer advection schemes. Adding diffusion reduces the occurence of these negative values.
  • I have added example setups (see videos below) for both decaying and stochastically-forced 2D turbulence, each with 3 tracers (2 initialized with Gaussians of varying shape, and a third initialized as a straight band of tracer). In both cases, the simulation dynamics are identical to the examples without tracers that already exist.

Decaying 2D turbulence (upper left two panels are identical to existing example)

twodturbtracer.mp4

Stochastically-Forced 2D turbulence (upper left two panels are identical to existing example)

twodturb_forced_tracer.mp4

Benchmarking on an Apple M1 chip

Decaying 2D example without tracers

2D_Decaying_NoTracer

Decaying 2D example with 3 tracers

2D_Decaying_Tracer

Stochastically-forced 2D example without tracers

2D_Stochastic_NoTracer

Stochastically-forced 2D example with 3 tracers

2D_Stochastic_Tracer

@navidcy
Copy link
Member

navidcy commented Jul 1, 2022

OMG! I totally forgot about this PR!

@navidcy
Copy link
Member

navidcy commented Jul 1, 2022

Really, really sorry!

@navidcy
Copy link
Member

navidcy commented Jul 1, 2022

This is very related with what's @jbisits been up to lately over in PassiveTracerFlows.jl, e.g., FourierFlows/PassiveTracerFlows.jl#53

@navidcy
Copy link
Member

navidcy commented Jul 4, 2022

So @BrodiePearson this is great! The nice thing about this implementation compared to that done in FourierFlows/PassiveTracerFlows.jl#53 is that here both tracers and flow are evolved simultaneously with the same time-stepping scheme and thus time-stepping can have the same accuracy.

I'm debating what's the best way forward here. There is a fair bit of overlap between modules TwoDNavierStokes and TwoDNavierStokesTracer. I think (but I'm not settled on this yet) that the best way forward is that this module belongs in PassiveTracerFlows.jl. Or perhaps we combine the two modules (TwoDNavierStokes and TwoDNavierStokesTracer)?

@glwagner would be keen to hear your opinion on this.

@jbisits
Copy link
Collaborator

jbisits commented Jul 4, 2022

Sorry to jump into the thread here but I agree this is great!

@navidcy navidcy mentioned this pull request Jul 4, 2022
@BrodiePearson
Copy link
Collaborator Author

@navidcy No problem, I had forgotten about it too so thank you for reviving it (I was going to pick it up again over summer).

I will be back at work next week and will take a look at @jbisits PR & think a bit more about your comments!

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.

None yet

3 participants