OpenFOAM (Open-source Field Operation And Manipulation) is a powerful open-source software used for simulating fluid dynamics, heat transfer, and other physical phenomena. One of the most fundamental heat transfer problems is 1D transient heat conduction, which is commonly solved using numerical methods like Finite Volume Method (FVM), the foundation of OpenFOAM’s numerical solvers.

This article will walk you through the steps of setting up a 1D transient heat conduction problem in OpenFOAM.

Problem Definition

Consider a 1D rod of length L, initially at a uniform temperature, T0. The boundaries of the rod are maintained at different constant temperatures, and heat conduction occurs along the length of the rod. We want to simulate the temperature distribution in the rod over time.

The governing equation for transient heat conduction is the 1D heat diffusion equation:

where:

  • T is the temperature.
  • t is time.
  • x is the spatial coordinate along the length of the rod.
  • α is the thermal diffusivity of the material.

This is example of the solver header to write the equation for OpenFOAM:

#include "fvCFD.H"
// Main program
int main(int argc, char *argv[])
{
    // Set up the time, mesh, and fields
    #include "setRootCase.H"
    #include "createTime.H"
    #include "createMesh.H"
   
 volScalarField T //define temperature
    (
        IOobject
        (
            "T",
            runTime.timeName(),
            mesh,
            IOobject::READ_IF_PRESENT,
            IOobject::AUTO_WRITE
        ),
        mesh
    );

//define diffusion coefficient
const dimensionedScalar alpha ("alpha", dimensionSet(0, 2, -1, 0, 0, 0,0) , 1e-5);

    // Time-stepping loop
    while (runTime.loop())
    {
        //solving the equation
        solve
        (
           fvm::ddt(T) - fvm::laplacian(alpha,T)
        );
        // Write results for each time step
        runTime.write();
    }
    return 0;
}

Conclusion

Setting up a 1D transient heat conduction problem in OpenFOAM is a relatively straightforward process involving mesh generation, defining initial and boundary conditions, specifying material properties, and configuring time control and solver settings. By following the steps above, you can simulate heat conduction through a rod and analyze the temperature distribution over time.

This basic problem can be extended to more complex scenarios involving multi-dimensional geometries, non-linear materials, and additional physical effects such as convection and radiation. OpenFOAM’s flexibility makes it a powerful tool for solving heat transfer problems in various engineering applications.

Need help to finish your OpenFOAM project/assignment?