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

Speeding up CHT Heatsink simulation

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 13, 2024, 10:35
Default Speeding up CHT Heatsink simulation
  #1
New Member
 
anonymous
Join Date: Nov 2024
Location: Germany
Posts: 2
Rep Power: 0
OpenFoamer_24 is on a distinguished road
Hello all,

I'm new to OpenFoam, but have been able to run a few cases successfully using the tutorials and this forum.

Basically the case is a simple Blower-Heatsink-Heater case, which I'm trying to simulate using a chtMultiRegionFoam in a OpenFoam v2112 Linux engine.

The fluid domain has a patch for the mouth of the blower (inlet), an outlet for air to escape and all the walls surrounding the fluid domain.

My question:
My first case is the one with the blower off(0 velocity at the inlet boundary) and it works well. with a run time of 17s per second of simulation.
Here are the boundary conditions for the fluid region:

Code:
/*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  dev                                   |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      changeDictionaryDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

U
{
    internalField   uniform (0 0 0);

    boundaryField
    {
        airwalls
    {
            type            noSlip;
    }
        inlet
    {
            type            fixedValue;
            inletValue      uniform (0 0 0);
    }
        outlet
    {
        type            pressureInletOutletVelocity;
        value           uniform (0 0 0);
    }
    air_to_pla
    {
            type            noSlip;
    }
    air_to_res
    {
            type            noSlip;
    }
    air_to_fin
    {
            type            noSlip;
    }
    }
}

T
{
    internalField   uniform 294;

    boundaryField
    {
        airwalls
    {
            type            fixedValue;
            inletValue      uniform 294;
    }
        inlet
    {
            type            inletOutlet;
            inletValue      uniform 294;
    }
        outlet
    {
            type            inletOutlet;
            inletValue      uniform 294;
    }
    air_to_pla
    {
            type            compressible::turbulentTemperatureCoupledBaffleMixed;
            Tnbr            T;
            kappaMethod     fluidThermo;
            value           uniform 294;
    }
    air_to_res
    {
            type            compressible::turbulentTemperatureCoupledBaffleMixed;
            Tnbr            T;
            kappaMethod     fluidThermo;
            value           uniform 294;
    }
    air_to_fin
    {
            type            compressible::turbulentTemperatureCoupledBaffleMixed;
            Tnbr            T;
            kappaMethod     fluidThermo;
            value           uniform 294;
    }
    }
}

p_rgh
{
    internalField   uniform 0;

    boundaryField
    {
        airwalls
        {
        type            fixedFluxPressure;
        value           uniform 0;
        }
        inlet
        {
        type            fixedFluxPressure;
        value           uniform 0;
        }
        outlet
        {
        type            totalPressure;
        p0              uniform 0;
        }
        air_to_pla
        {
        type            fixedFluxPressure;
        value           uniform 0;
        }
        air_to_res
        {
        type            fixedFluxPressure;
        value           uniform 0;
        }
        air_to_fin
        {
        type            fixedFluxPressure;
        value           uniform 0;
        }
    }
}

p
{
    internalField   uniform 0;

    boundaryField
    {
        airwalls
        {
        type            fixedValue;
        value           uniform 0;
        }
        inlet
        {
        type            zeroGradient;
        value           uniform 0;
        }
        outlet
        {
        type            totalPressure;
        p0              uniform 0;
        }
        air_to_pla
        {
        type            fixedValue;
        value           uniform 0;
        }
        air_to_res
        {
        type            fixedValue;
        value           uniform 0;
        }
        air_to_fin
        {
        type            fixedValue;
        value           uniform 0;
        }
    }
}

// ************************************************************************* //
Here's the residuals:
Code:
diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
DILUPBiCGStab:  Solving for h, Initial residual = 0.0007659, Final residual = 5.29e-09, No Iterations 1
Min/max T:294 294.8

Solving for fluid region air
GAMG:  Solving for p_rgh, Initial residual = 0.0004052, Final residual = 1.994e-06, No Iterations 3
diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
time step continuity errors (air): sum local = 9.467e-14, global = -5.288e-15, cumulative = -4.651e-08
GAMG:  Solving for p_rgh, Initial residual = 0.0001121, Final residual = 4.75e-08, No Iterations 7
diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
time step continuity errors (air): sum local = 2.269e-15, global = -2.194e-16, cumulative = -4.651e-08

Solving for solid region res
DICPCG:  Solving for h, Initial residual = 0.002468, Final residual = 7.609e-09, No Iterations 2
limitTemperature limitTemperature Lower limited 0 (0%) of cells
limitTemperature limitTemperature Upper limited 0 (0%) of cells
limitTemperature limitTemperature Unlimited Tmax 294.8
Unlimited Tmin 294.2
Min/max T:294.1 294.8

Solving for solid region pla
DICPCG:  Solving for h, Initial residual = 0.002341, Final residual = 2.106e-07, No Iterations 3
Min/max T:294 294.3

Solving for solid region fin
DICPCG:  Solving for h, Initial residual = 0.001642, Final residual = 4.425e-07, No Iterations 3
Min/max T:294 294.2
ExecutionTime = 37.09 s  ClockTime = 37 s

Region: air Courant Number mean: 7.986e-05 max: 0.005518
Region: res Diffusion Number mean: 0.003037 max: 0.226
Region: pla Diffusion Number mean: 0.05351 max: 2.3
Region: fin Diffusion Number mean: 0.07386 max: 10
deltaT = 0.003142
 Time = 2.13
For my application, this is workable and good.


But when I turn the blower on (a velocity at the inlet boundary) like prescribed below
Code:
/*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  dev                                   |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      changeDictionaryDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

U
{
    internalField   uniform (0 0 0);

    boundaryField
    {
        airwalls
    {
            type            noSlip;
    }
        inlet
    {
            type            fixedValue;
            inletValue      uniform (3.9 0 0);
    }
        outlet
    {
        type            pressureInletOutletVelocity;
        value           uniform (0 0 0);
    }
    air_to_pla
    {
            type            noSlip;
    }
    air_to_res
    {
            type            noSlip;
    }
    air_to_fin
    {
            type            noSlip;
    }
    }
}

T
{
    internalField   uniform 294;

    boundaryField
    {
        airwalls
    {
            type            fixedValue;
            inletValue      uniform 294;
    }
        inlet
    {
            type            inletOutlet;
            inletValue      uniform 294;
    }
        outlet
    {
            type            inletOutlet;
            inletValue      uniform 294;
    }
    air_to_pla
    {
            type            compressible::turbulentTemperatureCoupledBaffleMixed;
            Tnbr            T;
            kappaMethod     fluidThermo;
            value           uniform 294;
    }
    air_to_res
    {
            type            compressible::turbulentTemperatureCoupledBaffleMixed;
            Tnbr            T;
            kappaMethod     fluidThermo;
            value           uniform 294;
    }
    air_to_fin
    {
            type            compressible::turbulentTemperatureCoupledBaffleMixed;
            Tnbr            T;
            kappaMethod     fluidThermo;
            value           uniform 294;
    }
    }
}

p_rgh
{
    internalField   uniform 0;

    boundaryField
    {
        airwalls
        {
        type            fixedFluxPressure;
        value           uniform 0;
        }
        inlet
        {
        type            fixedFluxPressure;
        value           uniform 0;
        }
        outlet
        {
        type            totalPressure;
        p0              uniform 0;
        }
        air_to_pla
        {
        type            fixedFluxPressure;
        value           uniform 0;
        }
        air_to_res
        {
        type            fixedFluxPressure;
        value           uniform 0;
        }
        air_to_fin
        {
        type            fixedFluxPressure;
        value           uniform 0;
        }
    }
}

p
{
    internalField   uniform 0;

    boundaryField
    {
        airwalls
        {
        type            fixedValue;
        value           uniform 0;
        }
        inlet
        {
        type            zeroGradient;
        value           uniform 0;
        }
        outlet
        {
        type            totalPressure;
        p0              uniform 0;
        }
        air_to_pla
        {
        type            fixedValue;
        value           uniform 0;
        }
        air_to_res
        {
        type            fixedValue;
        value           uniform 0;
        }
        air_to_fin
        {
        type            fixedValue;
        value           uniform 0;
        }
    }
}

// ************************************************************************* //
And this takes 20.5 mins for 1 second of simulation, which is not workable for me.


Here are the residuals:
Code:
diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
DILUPBiCGStab:  Solving for h, Initial residual = 0.03133, Final residual = 4.604e-08, No Iterations 2
Min/max T:293.6 295

Solving for fluid region air
GAMG:  Solving for p_rgh, Initial residual = 0.0004678, Final residual = 2.737e-06, No Iterations 8
diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
time step continuity errors (air): sum local = 1.755e-10, global = 5.574e-11, cumulative = 7.951e-06
GAMG:  Solving for p_rgh, Initial residual = 0.002553, Final residual = 9.803e-08, No Iterations 11
diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
time step continuity errors (air): sum local = 6.243e-12, global = -1.666e-12, cumulative = 7.951e-06

Solving for solid region res
DICPCG:  Solving for h, Initial residual = 9.365e-06, Final residual = 1.143e-10, No Iterations 1
limitTemperature limitTemperature Lower limited 0 (0%) of cells
limitTemperature limitTemperature Upper limited 0 (0%) of cells
limitTemperature limitTemperature Unlimited Tmax 295
Unlimited Tmin 294.3
Min/max T:294.2 295

Solving for solid region pla
DICPCG:  Solving for h, Initial residual = 8.941e-06, Final residual = 2.439e-09, No Iterations 1
Min/max T:294 294.6

Solving for solid region fin
DICPCG:  Solving for h, Initial residual = 5.987e-06, Final residual = 1.301e-09, No Iterations 1
Min/max T:294 294.5
ExecutionTime = 320.6 s  ClockTime = 320 s

Region: air Courant Number mean: 0.02751 max: 1
Region: res Diffusion Number mean: 2.701e-05 max: 0.00201
Region: pla Diffusion Number mean: 0.0004759 max: 0.02046
Region: fin Diffusion Number mean: 0.000657 max: 0.08895
deltaT = 2.794e-05
Time = 5.18
I have tried increasing the MaxCo and MaxDi, but it blows up and results in negative temperatures.
I tried frozenFlow also but it has very less impact.


I need to simulate every case for a realtime of 30mins, which I cannot do at this rate.
So, I kindly request for some assistance here, so I can maybe do a work-around to make the simulation faster. I am not very particular on the accuracy. I just need to compare a few cases and I can do that with a fairly rough model as well. Thank you for reading and I highly appreciate any suggestion or advice to speed up my case.


TL;DR:
My chtMultiRegionFoam case is fairly fast with 0 inlet velocity but gets 75 times slower whin I give a 3.9 m/s inlet velocity. Is there a work-around to make the simulation faster? Thank you!
OpenFoamer_24 is offline   Reply With Quote

Old   November 14, 2024, 06:27
Default
  #2
Senior Member
 
Join Date: Dec 2021
Posts: 248
Rep Power: 5
Alczem is on a distinguished road
Hey!


A few possible workarounds:
  1. Use more PIMPLE loops to allow for larger Courant numbers. I managed a maxCo of 50 with 3 nOuterCorrectors and some relaxation for the first 2 loops(maxDi was set to a very large number so maxCo would be the most restrictive setting). The results were okay for my case, but it was natural convection, also for cooling applications. For forced convection, not sure how stable it will be.
  2. Coarser mesh which will result in larger timesteps for the same maxCo.
  3. If it is really forced convection, frozenFlow should work pretty well. You may have to increase maxDi to see any gain.


Last but not least, patience is key I remember spending several days trying to tweak my case so it would run faster, just to eventually bite the bullet and use my usual settings, and realize that I wasted days that could have been used for the computation. Are you sure you cannot let the simulation run for a few days? Instead of spending them scratching your head.
Alczem is offline   Reply With Quote

Old   November 14, 2024, 12:14
Default
  #3
New Member
 
anonymous
Join Date: Nov 2024
Location: Germany
Posts: 2
Rep Power: 0
OpenFoamer_24 is on a distinguished road
Quote:
Originally Posted by Alczem View Post
Last but not least, patience is key I remember spending several days trying to tweak my case so it would run faster, just to eventually bite the bullet and use my usual settings, and realize that I wasted days that could have been used for the computation. Are you sure you cannot let the simulation run for a few days? Instead of spending them scratching your head.

Thanks a lot for your response, Alczem. I agree with you. I was just trying to see if there is anything that I can do, that pros like yourself have tried before, that I can try to make my work more efficient. And it worked!!



Quote:
Originally Posted by Alczem View Post
  1. If it is really forced convection, frozenFlow should work pretty well. You may have to increase maxDi to see any gain.
I tried this and it worked like a charm.
I had tried frozenFlow and increasing MaxCo separately but when I put them together, it really speeds up the simulation. And the results are so good, that I'm a little skeptical about my procedure. So, I'd be even more grateful if you can comment on my procedure:

1. I run a normal simulation with the blower on (with the following fvSolution in 'air' region). In this simulation I give a MaxCo of 1.0 and a MaxDi of 100.0.
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  dev                                   |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

solvers
{
    rho
    {
        solver          GAMG;
        //preconditioner  DIC;
        tolerance       1e-7;
        relTol          0.1;
        smoother         GaussSeidel;
    }

    rhoFinal
    {
        $rho;
        tolerance       1e-7;
        relTol          0;
    }

    p_rgh
    {
        solver           GAMG;
        tolerance        1e-7;
        relTol           0.01;

        smoother         GaussSeidel;

    }

    p_rghFinal
    {
        $p_rgh;
        tolerance        1e-7;
        relTol           0;
    }

    "(U|h|k|epsilon|R)"
    {
        solver           PBiCGStab;
        preconditioner   DILU;
        tolerance        1e-7;
        relTol           0.1;
    }

    "(U|h|k|epsilon|R)Final"
    {
        $U;
        tolerance        1e-7;
        relTol           0;
    }
}

PIMPLE
{
    //momentumPredictor   yes;
    momentumPredictor false;
    //frozenFlow    yes;
    nOuterCorrectors 40;
    nCorrectors     3;
    consistent      true;
    nCorrectors         2;
    nNonOrthogonalCorrectors 0;
    residualControl
    {
        p_rgh
        {
            tolerance 1e-3;
            relTol 0;
        }
    }
    pRefCell    0;
    pRefValue    0;
}

relaxationFactors
{
    equations
    {
        "h.*"           1;
        "U.*"           1;
    }
}
2. I let this simulation run for a realtime of 3 seconds (I'm assuming that is enough for the flow to develop completely)
3. Now I take the p, T and p_rgh files from ./3/air/* (basically the air flow field values) and paste them in the ./0/air/* (the initial values) in a different case(my main simulation case). Please note that I'm only doing this for the air region and nothing else
4. In this main simulation case, I give frozenFlow = yes (in the fvSolution) and change MaxCo to 50. And I run the main simulation.

Please correct me if I'm doing something wrong here or if it can be done in a more efficient way.


But regardless, I really appreciate your support and suggestion, made my life easy. Thank You!!
OpenFoamer_24 is offline   Reply With Quote

Old   November 15, 2024, 04:57
Default
  #4
Senior Member
 
Join Date: Dec 2021
Posts: 248
Rep Power: 5
Alczem is on a distinguished road
Hey!


Glad you found a satisfactory way


Regarding results quality, unfortunately, you will have to trust those if you don't have any experimental data to compare against. Just make sure every timestep is properly converged.


For the setup, I mostly agree with what you did. A couple remarks:
  • To initialize your flow, you could have run a steady state simulation instead of a transient for 3 seconds. It would probably be faster, but I cannot say if it would be better for capturing the flow features. Depending on your case, 3 seconds might be too little or too much.
  • The relaxation factors seem a little odd to me, since they are all set to 1. For the final PIMPLE loop, it is ok, but the previous loops should have some relaxation IMO. Again, we can find many diverging opinions about the proper use of PIMPLE, so use whatever works
  • I tend to use a fixed number of PIMPLE loops instead of using residualControl. I know it is supposed to allow for more loops in case of a slighty unstable simulation, but I have found that if it gets rough, the solver reaches the max allowed loops anyway and eventually diverges most of the time. So I usually set nOuterCorrectors to 3-10 and make sure that it is enough to converge each timestep. Again, very case dependent.
I would be happy to hear about the accuracy of your results once you finish your project, especially considering the longer runtime.
Alczem is offline   Reply With Quote

Reply

Tags
chtmulitregionfoam, speed up


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
Question on steady and unsteady simulation Stargazer Main CFD Forum 33 December 19, 2023 02:45
CFG file Set Up Nicola_Fontana SU2 5 November 16, 2021 13:48
write bc data and read it for other simulation jdp810 SU2 1 May 8, 2021 18:04
Transient simulation gives worse results than steady state simulation jgross CFX 12 January 21, 2021 13:21
Transient CHT Simulation slow variable increase marcel_jay CFX 8 May 2, 2016 18:11


All times are GMT -4. The time now is 00:28.