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

Simulating two different fluids #33

Open
cdelv opened this issue May 5, 2022 · 4 comments
Open

Simulating two different fluids #33

cdelv opened this issue May 5, 2022 · 4 comments

Comments

@cdelv
Copy link

cdelv commented May 5, 2022

Hi, I found this repo and love the library. I think that adding moving objects this easily is great. I have been using WaterLily for some time.

My new project involves a smoke simulation with a moving object. Therefore I was wondering, can WaterLily simulate 2 different fluids? especially because densities become variable on the domain and buoyancy forces become important.

The details of the simulation: Imagine a pipe full of smoke, then a piston accelerates the smoke out of the pipe into the air forming a smoke ring. Like in the donut example. I want to study how the ring changes with the simulation parameters. Smoke is much denser than air, that's my biggest problem.

Another approach I thought of was to add a lot of very small particles and update their position using the get force function and then add the buoyancy force but I don't know how good this approach is.

What do you recommend?

I could of course just study the vorticity of the air and don't mess with two different fluids, but I was wondering if WaterLily could do the job.

Thanks.

@weymouth
Copy link
Collaborator

weymouth commented May 6, 2022

If you don't care about the density/buoyancy effect, you can either use tracer particles, or (better) a scalar transport equation. The passive scalar transport equation is already implemented, but there isn't a good UI for the user yet: see #29.

Once you have the scalar equation going, it is fairly easy to add a Boussinesq approximation to capture the effect of buoyancy. This would be a cool feature to add!

If you want to model the inertia difference, then you need to model the density as a tracked variable. The pressure solver would then supply the real local buoyancy force as well. I've added this before for free surface flows, but it's not a "quick" fix. It'll change the momentum step quite a bit.

@cdelv
Copy link
Author

cdelv commented May 7, 2022

I see thanks, I have a couple of questions.

  1. What numerical method do you use to solve the Navier Stokes equations?
  2. Would it be possible to couple the passive transport equation to the Navier Stokes to add variable density and forcing terms? If so, I would like to help.
  3. Is it possible to run a WaterLily simulation step by step? For example, perform a time step, calculate forces over the particles, update positions and perform a time step. I have only seen examples where the movement of the solid object is already known.
  4. Is there already a function implemented for tracer particles?
  5. How do you cite WaterLily?

Thanks.

@weymouth
Copy link
Collaborator

weymouth commented May 8, 2022

  1. The Navier-Stokes solution method is a standard projection update.
    This function calculates the right-hand-side of the update other than pressure:
    https://github.com/weymouth/WaterLily.jl/blob/8132c5a2dbdee51ca90a20f7d75f29708ad85553/src/Flow.jl#L19-L28
    The velocity is updated, and then it's projected into a divergence-free field:
    https://github.com/weymouth/WaterLily.jl/blob/8132c5a2dbdee51ca90a20f7d75f29708ad85553/src/Flow.jl#L78-L84

  2. Yes, it's possible, but there are a few steps. The passive transport equation is here:
    https://github.com/weymouth/WaterLily.jl/blob/8132c5a2dbdee51ca90a20f7d75f29708ad85553/src/Flow.jl#L9-L17
    This could transport the "amount of smoke". But you'll also need to initialize this new variable, and you'll probably also want to set up some source terms (where smoke is being pumped into the fluid). Once you have that tested, you can define a variable density rho = rho_0+f * delta_rho. Finally, the variable density needs to be used in the projection and update step. So you'll need to include it in the Possion coefficient update:
    https://github.com/weymouth/WaterLily.jl/blob/8132c5a2dbdee51ca90a20f7d75f29708ad85553/src/WaterLily.jl#L105

  3. Sure, but idealized tracer particles don't require a momentum update. You can just have them passively follow the local velocity vectors.

  4. No, but they are easy to add as a visualization tool if you are interested.

  5. I need to submit the code to JOSS. @b-fg was suggesting that last year...

@cdelv
Copy link
Author

cdelv commented May 11, 2022

I see, thanks a lot. I will evaluate what to do.

Nevertheless, I love this protect, I would love to see this library do complete fluid dynamics simulations, including variable density, viscosity, compressible, etc.

After I finish this semester and get some time, I'll try to work on this.

I'm a physics student and I'm pretty busy with exams and research. But would love to get involved with this project in the future.

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

No branches or pull requests

2 participants