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

Create incompressible_viscous solver and lid-driven cavity test problem #138

Merged
merged 44 commits into from
Aug 9, 2023

Conversation

simonguichandut
Copy link
Contributor

Needed to change a few things in incompressible/simulation.py as well:

  • Neumann BC's on phi in the case of dirichlet BC's on v (and apply phi-specific BC's in the multigrid solves)
  • Allow user-defined BC's
  • Allow another method for the velocity update in the evolve loop

The latter two are then redefined in incompressible_viscous/simulation.py. The rest of the methods are inherited from the base class.

For the lid-driven cavity problem, the only free parameter is the viscosity. Since the velocity and length scales are =1, the Reynolds number is just 1/viscosity.

For Re=400, after 5 characteristic timescales, this is the result
cavity_Re400

@zingale
Copy link
Collaborator

zingale commented Mar 17, 2023

can you address those test failures (isort and flake8)

@zingale
Copy link
Collaborator

zingale commented Mar 24, 2023

can you add the name of the solver to the README.md in the list of solvers?

Also, we should add some description to the docs -- if you are comfortable with Sphinx you can do so, otherwise, we can address that in a separate PR

pyro_sim.py incompressible shear inputs.shear


.. image:: shear.png
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you need to git add all the images

Copy link
Collaborator

Choose a reason for hiding this comment

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

has this been resolved?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes! All the images are there, the page should load fine.

@simonguichandut
Copy link
Contributor Author

Not converging!!

incomp_viscous_converge

@simonguichandut
Copy link
Contributor Author

simonguichandut commented Apr 4, 2023

Here's the incompressible/shear problem, but run with the incompressible_viscous solver with viscosity=0, which should yield the same solution (link to original plot)

shear_viscous

But we get a different result! Something weird is going on at the boundaries...

@zingale
Copy link
Collaborator

zingale commented Apr 8, 2023

to be second-order accurate, when you do the interface state prediction, you'll need to add a viscous term to the predictor. This will come in as

0.5 dt * nu L U

and enter in the same place that gradp_x and gradp_y do now in states.

@simonguichandut
Copy link
Contributor Author

Now recovers the incompressible (viscosity=0) solution for the shear problem (at least qualitatively). However, there are still large divergences at the boundaries.
shear_viscous

@zingale
Copy link
Collaborator

zingale commented Apr 11, 2023

are you making that with plot.py? I think the issue at the boundaries is due to the ghost cells. Maybe we need to fill them in plot.py

@simonguichandut
Copy link
Contributor Author

are you making that with plot.py? I think the issue at the boundaries is due to the ghost cells. Maybe we need to fill them in plot.py

Yes I am, so maybe it's fine then

@zhichen3
Copy link
Collaborator

zhichen3 commented Aug 8, 2023

I basically split up the original get_interface_states into different functions to handle different source terms when evaluating the interface state. I think this way it's a lot clearer and allows us to reuse codes.

So I think you can create a function that takes in the left and right interface states and source_x and source_y, and put


u_xl.ip(1, buf=2)[:, :] += 0.5 * dt * source_x.v(buf=2)
u_xr.v(buf=2)[:, :] += 0.5 * dt * source_x.v(buf=2)
u_yl.jp(1, buf=2)[:, :] += 0.5 * dt * source_x.v(buf=2)
u_yr.v(buf=2)[:, :] += 0.5 * dt * source_x.v(buf=2)

v_xl.ip(1, buf=2)[:, :] += 0.5 * dt * source_y.v(buf=2)
v_xr.v(buf=2)[:, :] += 0.5 * dt * source_y.v(buf=2)
v_yl.jp(1, buf=2)[:, :] += 0.5 * dt * source_y.v(buf=2)
v_yr.v(buf=2)[:, :] += 0.5 * dt * source_y.v(buf=2)

into that function, something like apply_other_source_terms.

Then you would get the original get_interface_states as a sequence of calling burgers_interface.get_interface_states, burgers_interface.apply_transverse_correction, apply_gradp_corrections, and your apply_other_source_terms function.

@@ -36,6 +36,7 @@ pyro: a python hydro code
multigrid
diffusion_basics
incompressible_basics
incompressible_viscous_basics
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think incompressible_viscous_basics is really an extension of incompressible solver, so it might be better to just add subsections in incompressible_basics.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That might make the page a little cumbersome. An alternative is to combine the solvers into a single one, since incompressible_viscous perfectly reproduces incompressible when viscosity=0. But that would be another PR.

Thoughts @zhichen3 @zingale ?

pyro/incompressible/incomp_interface.py Outdated Show resolved Hide resolved
@zingale
Copy link
Collaborator

zingale commented Aug 9, 2023

if there are no conflicts and it works, let's merge this and then we can clean it up (by subclassing incompressible, e.g.) in a separate PR.

@zingale zingale merged commit 113a50d into python-hydro:main Aug 9, 2023
10 checks passed
@simonguichandut simonguichandut deleted the dev_incompressible_viscous branch August 11, 2023 16:14
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