# Writing a solver - heat equation - Solution diverges

 Register Blogs Members List Search Today's Posts Mark Forums Read

 January 30, 2013, 01:28 Writing a solver - heat equation - Solution diverges #1 New Member   Dheepan Iyyampillai Join Date: Jan 2013 Location: Bangalore, India Posts: 3 Rep Power: 4 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. I tried upwind and central differencing for laplacian.

 February 1, 2013, 22:09 #2 Senior Member   Fumiya Nozaki Join Date: Jun 2010 Location: Yokohama, Japan Posts: 168 Rep Power: 7 Hi, You might want to try the following: Code: ```solve ( fvm::laplacian(T) - fvm::Sp(n, T) + n * Tatm );``` Fumiya

 Tags diverged, heat equation, laplace, programming, solver

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post prapanj Main CFD Forum 2 July 30, 2011 19:07 tH3f0rC3 OpenFOAM Running, Solving & CFD 6 March 24, 2011 06:41 Sas CFX 15 July 13, 2010 08:56 msrinath80 OpenFOAM Running, Solving & CFD 9 July 22, 2007 02:58 john Main CFD Forum 1 May 27, 2004 23:41

All times are GMT -4. The time now is 17:56.