|
[Sponsors] |
March 28, 2016, 13:43 |
Implicit AD, where do I start?
|
#1 |
New Member
Join Date: Mar 2016
Posts: 4
Rep Power: 10 |
Hi all,
Newbie here. I am trying to write an innocent implement of the advection diffusion in 2-d using implicit method. I have some background on numerical methods for PDE (Leveque, Gochenback, ...) and have read some CFD (Chung, Pozrikidis). My impression is that Crank-Nicolson is the way to go. Before I take the plunge, I would appreciate any hint, advise, experience. Not to reinvent the wheel, I thought that I could find the relevant equations in matrix form for the C-N scheme, but fail to find these in the books that are available to me. Plenty in 1-D but not 2-D. Many thanks in advance, |
|
March 28, 2016, 13:49 |
|
#2 | |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,768
Rep Power: 71 |
Quote:
I suggest a prototypal of discretization useful since it is used for the momentum equation: CN for the diffusive terms and Adams-BAshforth for the convective term |
||
March 28, 2016, 15:34 |
|
#3 |
Senior Member
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,672
Rep Power: 65 |
It's actually not so straightforward, but I do recommend reinventing the wheel for this one (at least for a very simple case, with very innocent discretization schemes).
For diffusion problems, Crank-Nicolson becomes block tri-diagonal in 2D, requiring specialized matrix algorithms to solve (and to invert the coefficient matrix). C-N is appropriate for diffusion problems, but not advection problems (where you need backward/upwind schemes for stability and accuracy). Even for diffusion problems, C-N isn't the end all be all scheme either. There are fractional multi-step methods and operator splitting methods that give the same order of accuracy that are much faster. One of the reasons for the slowness of C-N is the block tri-diagonal structure. Restoring the matrix structure to a purely tri/bi/diagonal system makes it much faster to solve. Matrix equations for advection problems using an implicit scheme are more scarce because of the many many many possible ways the advective terms can be discretized. Another problem is the setup is somewhat implementation specific. |
|
March 28, 2016, 16:26 |
|
#4 |
Senior Member
Michael Prinkey
Join Date: Mar 2009
Location: Pittsburgh PA
Posts: 363
Rep Power: 25 |
If you want to get up to speed quickly, I don't think you can do better than this tutorial.
http://lorenabarba.com/blog/cfd-pyth...navier-stokes/ It leverages numpy and matplotlib to get you visible results quickly. There is not a pure advection/diffusion equation example. But steps (v) and steps (vii) are 2D advection and 2D diffusion separately, and you can merge the two very easily to build explicit advection diffusion to get started. There is also a full example for Poisson and Laplace equations using the sparse linear equation solvers in numpy. You can follow those as a easy way to step forward to an explicit advection/implicit diffusion scheme. The code is very easy to understand and visualization is built in. It may not lead you to production-level code, but it will get you up-to-speed on the algorithms faster than any other way I've seen. |
|
March 29, 2016, 12:39 |
|
#5 |
New Member
Join Date: Mar 2016
Posts: 4
Rep Power: 10 |
Hi Filippo,
Could you suggest some literature about the in/stability of the C-N/Adams-Bashforth methods for the convection equation. I seem to get the impression that C-N is inconditionally stable. Thanks, homh Last edited by homh; March 29, 2016 at 12:40. Reason: Wrong attribution |
|
March 29, 2016, 12:44 |
|
#6 | |
New Member
Join Date: Mar 2016
Posts: 4
Rep Power: 10 |
Quote:
Thanks for the link. I did come across this site and did some coding based on the examples. It turned out well except for the instability of the explicit scheme. Cheers, homh |
||
March 29, 2016, 12:56 |
|
#7 | |
Senior Member
Michael Prinkey
Join Date: Mar 2009
Location: Pittsburgh PA
Posts: 363
Rep Power: 25 |
Quote:
https://en.wikipedia.org/wiki/Crank%...icolson_method You should be able to modify the python code from the Poisson example based on the discrete formula in the above link. It will involve evaluating the diffusion operator "implicitly" by filling a sparse matrix in exactly the same way the Laplacian and Poisson examples do and then solving that linear system of equations for the new timestep solution. CN actually averages the diffusion operator applied to the old-time solution with the diffusion operator applied to the new-time solution and in doing so, makes linear diffusion 2nd-order accurate in time and unconditionally stable. Just to give you an overview. The new-time laplacian operator is loaded into the sparse linear matrix (and in the Poisson case), the old-time laplacian operator and the old-time advection operator are evaluated with data already on hand and are inserted into the right-hand-side of the linear system (like the source terms in the Poisson example). Then solving the linear system gives you the new time solution. |
||
March 29, 2016, 12:59 |
|
#8 | |
New Member
Join Date: Mar 2016
Posts: 4
Rep Power: 10 |
Quote:
Thanks for the tips. I did use Thomas tridiagonal algorithm for the C-N convection in 1-D. Do you have any reading suggestion for the operator splitting method? I found this (also semi Lagrangian) out in Spiegelman's "Myths and Methods in Modeling" but not as much detail as I wish. Cheers, homh |
||
March 29, 2016, 13:09 |
|
#9 | |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,768
Rep Power: 71 |
Quote:
hello, the structure of the CN scheme for the diffusion and AB for the convection is the basis of many codes for incompressible flows since 30-year ago (see http://www.ann.jussieu.fr/frey/paper...0equations.pdf). Tha stability analysis for a 2D discretization can be done by means of the Von Neumann analysis, as in the doc attached. |
||
March 29, 2016, 13:14 |
|
#10 | |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,768
Rep Power: 71 |
Quote:
using the second order discretization for diffusion, you get a five-entry diagonal matrix and a block Thomas-based algorithm can be used. However, since the matrix is well conditioned a simple iterative solver will rapidly converge. I suggest using the SOR since it has few sum/multiplication operations and it is very fast with thge correct forcing parameter. |
||
March 29, 2016, 15:03 |
|
#11 | |
Senior Member
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,672
Rep Power: 65 |
Quote:
https://en.wikipedia.org/wiki/Altern...mplicit_method Operator splitting method is a very broad field and very vague, so I don't mean to generalize it. For example, discretizing your diffusion terms using central differencing and advection terms using upwind differencing is technically also an operator splitting technique. the ADIM method is an operator splitting technique that splits the same spatial discretization for the diffusion term separately in x and y directions which is very different than splitting different phenomena separately. |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
TimeVaryingMappedFixedValue | irishdave | OpenFOAM Running, Solving & CFD | 32 | June 16, 2021 06:55 |
using chemkin | JMDag2004 | OpenFOAM Pre-Processing | 2 | March 8, 2016 22:38 |
Can anybody give a introduction of the term "point implicit" and 'line implicit' ? | Tommy Chen | Main CFD Forum | 2 | August 3, 2015 03:30 |
Sample not working correctly | sihaqqi | OpenFOAM Running, Solving & CFD | 1 | July 12, 2014 01:36 |
Lets start the public domain CFD-Project! | Heinz Wilkening | Main CFD Forum | 3 | March 11, 1999 22:55 |