This example was originally provided by fred2 <at> qnet.com in http://thread.gmane.org/gmane.comp.python.fipy/911
The model problem of a (compressible) gas confined between two infinite plates is a useful test case for a Navier-Stokes solver. For stationary walls maintained at fixed (but different) temperatures, and assuming continuum no-slip boundary conditions, the the Navier-Stokes equations can be solved analytically.
The energy equation simplifies to the (1D) heat equation (i.e., a DiffusionTerm) to be solved for the temperature profile.
from fipy import * nx = 401 dx = 1. / nx mesh = Grid1D(nx=nx, dx=dx) x, = mesh.getCellCenters() x = CellVariable(mesh=mesh, value=x) temperature = CellVariable(name="$T / T_L$", mesh=mesh)
is the exponent of the "variable hard sphere (VHS)" viscosity/temperature relationship (i.e., )
omega = 0.657 kappa = temperature.getArithmeticFaceValue()**omega energy_eqn = DiffusionTerm(coeff=kappa)
which is solved with no-slip boundary conditions (strictly applicable only for Knudsen number ) such that
with a wall temperature ratio .chi = 3.72 BCs = (FixedValue(faces=mesh.getFacesLeft(), value=1.), FixedValue(faces=mesh.getFacesRight(), value=chi))
The normal momentum equation simplifies to from which the density profile can be obtained.
rho_dimensional = 1. / temperature rho = rho_dimensional / rho_dimensional[nx / 2] rho.name = r"$\rho / \rho_0$"
The exact steady-state temperature profile is
where and is the plate separation distance.temperature_analytical = ((chi**(omega+1) - 1.)*x + 1.)**(1./(omega+1)) temperature_analytical.name = temperature.name + " analytical" rho_dimensional_analytical = 1. / temperature_analytical rho_analytical = rho_dimensional_analytical / rho_dimensional_analytical[nx / 2] rho_analytical.name = rho.name + " analytical" viewer = Viewer(vars=(temperature, temperature_analytical, rho, rho_analytical), title=r'''gas between heated plates (Navier-Stokes, no-slip) $T_{left}/T_{right} = %g$, $\omega = %4.3f$''' % (chi, omega))
Starting from a linear profile, it takes only a few sweeps to reach convergence.
temperature.setValue(1 + (chi - 1.)*x) res = 1e10 while res > 1.e-6: res = energy_eqn.sweep(var=temperature, boundaryConditions=BCs) viewer.plot() print temperature.allclose(temperature_analytical, atol=1.e-4) print rho.allclose(rho_analytical, atol=1.e-4)
Reference Wadsworth:1993 compares finite difference Navier-Stokes and particle simulation method predictions in the rarefied flow (i.e., slip) regime for which some experimental data are available.
@article{Wadsworth:1993, author = {D. C. Wadsworth}, title = {Slip effects in a confined rarefied gas. I: Temperature slip}, journal = {Phys Fluids A}, volume = 5, year = 1993, pages = {1831-1839} }
Attachments (1)
- 1dht.png (40.0 KB) - added by guyer 5 years ago.
Download all attachments as: .zip