How to verify your codes
Hi all:
I am new in CFD area and try to write my own codes. Right now, I try to verify my 1D NavierStokes code but I barely can find a existing case to compare with. I want to ask you guys where to find these resources? Thanks. Another question is that is there a method called finite differencecontrol volume method? I just know finite difference or finite volume methods. But the book I am reading uses "finite differencecontrol volume method" to discretize the governing eqs. I want to ask this is finite difference method or finite volume method or neither? Thanks. 
Re: How to verify your codes
This reference provides a fantastic perspective. Just pick a velocity field (I assume you are doing compressible flow since 1D incompressible flow is boring) and differentiate it to get the distributed load required for an exact solution. Choose the boundary conditions by the exact solution (any type works) and check for convergence rates.
@article{roache2002cvm, title={{Code Verification by the Method of Manufactured Solutions}}, author={Roache, P.J.}, journal={Journal of Fluids Engineering}, volume={124}, pages={4}, year={2002}, publisher={ASME} } In 1D, it is both (and finite element while we're at it). 
Re: How to verify your codes
Thanks Jed. I have checked this article. It's a good article, but do you have any idea about 1D NavierStokes verification. I think I can verify Burger eq. but for coupling pressure gradient term, I am not sure whether I applied SIMPLE correct or not. Thanks

Re: How to verify your codes
what is coupling pressure gradient term? can you email me your SIMPLE please!

Re: How to verify your codes
Incompressible flow in 1D is boring because all flows are constant, therefore I'll assume we can have a mass source term. This example is a steady state flow, but you can add time dependence.
Choose solutions u and p. They can be almost anything, but preferably with nontrivial derivatives: u = atan(x) p = tanh(x) differentiate to get a distributed force: f = rho * u * u_x  eta * u_xx + p_x f = sech^2(x) + rho*atan(x)/(1+x^2) + 2*eta*x/(1+x^2)^2 differentiate to get a mass source: g = rho*u_x g = rho / (1+x^2) You now have an exact solution to a completely nontrivial 1D flow. For boundary conditions, use the manufactured solutions (Dirichlet) or differentiate them (Neumann). If you want to satisfy incompressibility, then just choose u to be a divergence free field. A canonical source of such fields is the curl of an arbitrary vector field. So pick a vector potential A arbitrarily and use u=curl(A) as a solution function. Then pick pressure arbitrarily (some calculus will tell you how to choose p so as to minimize the forcing term if that is of concern to you. 
Re: How to verify your codes
The simplest way to verify your solution is to increase the number of elements (or points or unknowns) and compare the two solutions. If there is a good agreement then your code has converged to the correct solution.

Re: How to verify your codes
No it says nothing about the correctness of a solution.
The beauty of Roache's work is that it is so fundamental. If your code is based on a second order in space scheme (O(h^2), or second order in time, or third order whatever) then by increasing the number of cells/elements the solution has to approach the final value linearly when plotting against h^2 (and the "final value" is simple the extrapolated result when h=0). If the code doesnot exhibit this behaviour than something is wrong somewhere. If it does than you'll have "verified" the code (it does what you planned when solving the equations). A different question is if these were the "correct equations"; that's called "validation". But there's a catch, several actually: when the mesh is too coarse then the solution will not approach a result asymptotically (or you are not fine enough). When using schemes which switch according to a Peclet number, Courant number or any other flow state, then, again, there's no asymptotical behaviour. Finally when your mesh is very, very fine, and your Reynolds number is increased than you'll have the danger of natural instability and then a converged steadystate solution is not possible anymore. 
All times are GMT 4. The time now is 04:32. 