DheepanPillai |
January 30, 2013 00:28 |
Writing a solver - heat equation - Solution diverges
Hi,
I'm new to CFD and OpenFOAM. I was able to write a solver for 1-D heat equation with and without source and run it easily. The numerical solution matched with analytical solution. But when Convection is included in the code, it diverges, and temperature becomes infinity.
Code:
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "simpleControl.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"
#include "createFields.H"
simpleControl simple(mesh);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nCalculating temperature distribution\n" << endl;
while (simple.loop())
{
Info<< "Time = " << runTime.timeName() << nl << endl;
while (simple.correctNonOrthogonal())
{
solve //Solves thermal diffusion in a solid with convective heat transfer along its length
(
fvm::laplacian(T) - n* (T-Tatm) //where n = hP/kA
);
}
#include "write.H"
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //
Mesh is just a 1 m long rod with 5 elements. Tried different number of nodes and different time steps. Still diverges. :confused: I tried upwind and central differencing for laplacian.
|