Skip to content

Commit 113a50d

Browse files
Create incompressible_viscous solver and lid-driven cavity test problem (#138)
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.
1 parent 70445dc commit 113a50d

43 files changed

Lines changed: 1306 additions & 50 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ inputs.auto
2222

2323
__pycache__/
2424

25+
.DS_Store
26+
2527

2628
pyro/_version.py
2729
pyro.egg-info/
30+
pyro_hydro.egg-info/
2831
.eggs/

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ pyro provides the following solvers (all in 2-d):
157157
projection method for the incompressible equations of
158158
hydrodynamics.
159159
160+
- `incompressible_viscous`: an extension of the incompressible solver
161+
including a diffusion term for viscosity.
162+
160163
- `lm_atm`: a solver for the equations of low Mach number
161164
hydrodynamics for atmospheric flows.
162165

docs/source/cavity_Re100.png

577 KB
Loading

docs/source/cavity_Re1000.png

670 KB
Loading

docs/source/cavity_Re400.png

627 KB
Loading
22.1 KB
Loading
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
Incompressible viscous hydrodynamics solver
2+
===========================================
3+
4+
pyro's incompressible viscous solver solves:
5+
6+
.. math::
7+
8+
\frac{\partial U}{\partial t} + U \cdot \nabla U + \nabla p &= \nu \nabla^2 U \\
9+
\nabla \cdot U &= 0
10+
11+
This solver is based on pyro's incompressible solver, but modifies the
12+
velocity update step to take viscosity into account.
13+
14+
The main parameters that affect this solver are:
15+
16+
.. include:: incompressible_viscous_defaults.inc
17+
18+
Examples
19+
--------
20+
21+
shear
22+
^^^^^
23+
24+
The same shear problem as in incompressible solver, here with viscosity
25+
added.
26+
27+
.. prompt:: bash
28+
29+
pyro_sim.py incompressible_viscous shear inputs.shear
30+
31+
.. image:: shear_viscous.png
32+
:align: center
33+
34+
Compare this with the inviscid result. Notice how the velocities have
35+
diffused in all directions.
36+
37+
cavity
38+
^^^^^^
39+
40+
The lid-driven cavity is a well-known benchmark problem for hydro codes
41+
(see e.g. :cite:t:`ghia1982`, :cite:t:`Kuhlmann2019`). In a unit square box
42+
with initially static fluid, motion is initiated by a "lid" at the top
43+
boundary, moving to the right with unit velocity. The basic command is:
44+
45+
.. prompt:: bash
46+
47+
pyro_sim.py incompressible_viscous cavity inputs.cavity
48+
49+
It is interesting to observe what happens when varying the viscosity, or,
50+
equivalently the Reynolds number (in this case :math:`\rm{Re}=1/\nu` since
51+
the characteristic length and velocity scales are 1 by default).
52+
53+
|pic1| |pic2| |pic3|
54+
55+
.. |pic1| image:: cavity_Re100.png
56+
:width: 32%
57+
58+
.. |pic2| image:: cavity_Re400.png
59+
:width: 32%
60+
61+
.. |pic3| image:: cavity_Re1000.png
62+
:width: 32%
63+
64+
These plots were made by allowing the code to run for longer and approach a
65+
steady-state with the option ``driver.max_steps=1000``, then running
66+
(e.g. for the Re=100 case):
67+
68+
.. prompt:: bash
69+
70+
python incompressible_viscous/problems/plot_cavity.py cavity_n64_Re100_0406.h5 -Re 100 -o cavity_Re100.png
71+
72+
convergence
73+
^^^^^^^^^^^
74+
75+
This is the same test as in the incompressible solver. With viscosity,
76+
an exponential term is added to the solution. Limiting can again be
77+
disabled by adding ``incompressible.limiter=0`` to the run command.
78+
The basic set of tests shown below are run as:
79+
80+
.. prompt:: bash
81+
82+
pyro_sim.py incompressible_viscous converge inputs.converge.32 vis.dovis=0
83+
pyro_sim.py incompressible_viscous converge inputs.converge.64 vis.dovis=0
84+
pyro_sim.py incompressible_viscous converge inputs.converge.128 vis.dovis=0
85+
86+
The error is measured by comparing with the analytic solution using
87+
the routine ``incomp_viscous_converge_error.py`` in ``analysis/``. To
88+
generate the plot below, run
89+
90+
.. prompt:: bash
91+
92+
python incompressible_viscous/tests/convergence_errors.py convergence_errors.txt
93+
94+
or ``convergence_errors_no_limiter.txt`` after running with that option. Then:
95+
96+
.. prompt:: bash
97+
98+
python incompressible_viscous/tests/convergence_plot.py
99+
100+
.. image:: incomp_viscous_converge.png
101+
:align: center
102+
103+
The solver is converging but below second-order, unlike the inviscid case. Limiting
104+
does not seem to make a difference here.
105+
106+
Exercises
107+
---------
108+
109+
Explorations
110+
^^^^^^^^^^^^
111+
112+
* In the lid-driven cavity problem, when does the solution reach a steady-state?
113+
114+
* :cite:`ghia1982` give benchmark velocities at different Reynolds number for the
115+
lid-driven cavity problem (see their Table I). Do we agree with their results?
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
* section: [driver]
2+
3+
+----------------------------------+----------------+----------------------------------------------------+
4+
| option | value | description |
5+
+==================================+================+====================================================+
6+
| cfl | ``0.8`` | |
7+
+----------------------------------+----------------+----------------------------------------------------+
8+
9+
* section: [incompressible]
10+
11+
+----------------------------------+----------------+----------------------------------------------------+
12+
| option | value | description |
13+
+==================================+================+====================================================+
14+
| limiter | ``2`` | limiter (0 = none, 1 = 2nd order, 2 = 4th order) |
15+
+----------------------------------+----------------+----------------------------------------------------+
16+
| proj_type | ``2`` | what are we projecting? 1 includes -Gp term in U* |
17+
+----------------------------------+----------------+----------------------------------------------------+
18+
19+
* section: [incompressible_viscous]
20+
21+
+----------------------------------+----------------+----------------------------------------------------+
22+
| option | value | description |
23+
+==================================+================+====================================================+
24+
| viscosity | ``0.1`` | kinematic viscosity of the fluid (units L^2/T) |
25+
+----------------------------------+----------------+----------------------------------------------------+
26+
27+
* section: [particles]
28+
29+
+----------------------------------+----------------+----------------------------------------------------+
30+
| option | value | description |
31+
+==================================+================+====================================================+
32+
| do_particles | ``0`` | |
33+
+----------------------------------+----------------+----------------------------------------------------+
34+
| particle_generator | ``grid`` | |
35+
+----------------------------------+----------------+----------------------------------------------------+
36+

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pyro: a python hydro code
3636
multigrid
3737
diffusion_basics
3838
incompressible_basics
39+
incompressible_viscous_basics
3940
lowmach_basics
4041
swe_basics
4142
particles_basics
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
pyro.incompressible\_viscous.problems package
2+
=============================================
3+
4+
.. automodule:: pyro.incompressible_viscous.problems
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:
8+
9+
Submodules
10+
----------
11+
12+
pyro.incompressible\_viscous.problems.cavity module
13+
---------------------------------------------------
14+
15+
.. automodule:: pyro.incompressible_viscous.problems.cavity
16+
:members:
17+
:undoc-members:
18+
:show-inheritance:
19+
20+
pyro.incompressible\_viscous.problems.converge module
21+
-----------------------------------------------------
22+
23+
.. automodule:: pyro.incompressible_viscous.problems.converge
24+
:members:
25+
:undoc-members:
26+
:show-inheritance:
27+
28+
pyro.incompressible\_viscous.problems.plot\_cavity module
29+
---------------------------------------------------------
30+
31+
.. automodule:: pyro.incompressible_viscous.problems.plot_cavity
32+
:members:
33+
:undoc-members:
34+
:show-inheritance:
35+
36+
pyro.incompressible\_viscous.problems.shear module
37+
--------------------------------------------------
38+
39+
.. automodule:: pyro.incompressible_viscous.problems.shear
40+
:members:
41+
:undoc-members:
42+
:show-inheritance:

0 commit comments

Comments
 (0)