CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Writing a solver - heat equation - Solution diverges

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 30, 2013, 00:28
Unhappy Writing a solver - heat equation - Solution diverges
  #1
New Member
 
Dheepan Iyyampillai
Join Date: Jan 2013
Location: Bangalore, India
Posts: 3
Rep Power: 13
DheepanPillai is on a distinguished road
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.
DheepanPillai is offline   Reply With Quote

Old   February 1, 2013, 21:09
Default
  #2
Senior Member
 
fumiya's Avatar
 
Fumiya Nozaki
Join Date: Jun 2010
Location: Yokohama, Japan
Posts: 266
Blog Entries: 1
Rep Power: 18
fumiya is on a distinguished road
Hi,

You might want to try the following:

Code:
solve
(
    fvm::laplacian(T) - fvm::Sp(n, T) + n * Tatm
);
Fumiya
fumiya is offline   Reply With Quote

Reply

Tags
diverged, heat equation, laplace, programming, solver


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 Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Solver for an incompressible, turbulent flow with heat transfer tH3f0rC3 OpenFOAM Running, Solving & CFD 9 June 17, 2019 06:12
Neumann Boundary Condition for Poisson Equation solution in Polar Coordinates prapanj Main CFD Forum 2 July 30, 2011 19:07
Constant velocity of the material Sas CFX 15 July 13, 2010 08:56
IcoFoam parallel woes msrinath80 OpenFOAM Running, Solving & CFD 9 July 22, 2007 02:58
heat equation solution source code john Main CFD Forum 1 May 27, 2004 23:41


All times are GMT -4. The time now is 10:52.