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

Pressure difference as an input to simpleFoam

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

Like Tree4Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 5, 2022, 07:01
Default
  #21
New Member
 
Zhen Liao
Join Date: Apr 2022
Posts: 16
Rep Power: 2
zyliao is on a distinguished road
I used the fvSchemes that is the same as the tutorials case pitzDaily.
And I haven't simulated a more complex geometry yet. I'm now simulated a channel/fracture with some roughness, the newest result seems good to me.
I'll try to model some fracture network later.

Maybe you can try Tobermory's advice, i.e., adjust the tolerances, residualControls, and add a minIter?
zyliao is offline   Reply With Quote

Old   June 7, 2022, 00:58
Exclamation Encountered a problem: Final residual = nan
  #22
New Member
 
Zhen Liao
Join Date: Apr 2022
Posts: 16
Rep Power: 2
zyliao is on a distinguished road
Quote:
Originally Posted by Tobermory View Post
In fvSolution, just add a line for each variable you want to apply it to, eg.:
Code:
    p
    {
        solver          GAMG;
        tolerance       1e-08;
        relTol          0.01;
        smoother        GaussSeidel;
        minIter         1;
    }


The log file is showing you how many inner iterations the linear systems solver is taking to reach the tolerances you have set in the fvSolution file. This should generally be nonzero (an exception is a diagonal solver that does not have to iterate to solve), else the solver is not doing any work. In your case that you shared above, the Ux and p equations showed 0 inner iterations, which is a sign that your tolerances needed to be lowered.


You need to do some homework on this - see the user guide, and perhaps have a read of https://doc.cfd.direct/notes/cfd-gen...iples/contents. Suffice it to say that tolerance and relTol controls the inner iterations, and determine when the linear solver has "converged" sufficiently, whilst residualControl controls when the whole simulation has "converged".
Hi Tobermory,

These days I'm simulating water flow through a 2D rough fracture under a pressure gradient by simpleFoam.

The setting for the fvSolution is as follows:
Code:
solvers
{
    p
    {
        solver          GAMG;
        tolerance     1e-8;
        relTol           0;
        smoother     GaussSeidel;
	minIter        1;
    }

    U
    {
        solver           smoothSolver;
        smoother      symGaussSeidel;
        tolerance      1e-8;
        relTol            0;
	minIter         1;
    }
}

SIMPLE
{
    nNonOrthogonalCorrectors 0;
    consistent      yes;

    residualControl
    {
        p               1e-6;
        U               1e-6;
    }
}

relaxationFactors
{
    fields
	{
	    p               0.3;
	}
    equations
    {
        U               0.7; 
    }
}
And I think it works well when the pressure gradient is small, but for some cases that pressure gradient is bigger, the Final residual in log file becomes to equal to nan, like:
Code:
Time = 1000

smoothSolver:  Solving for Ux, Initial residual = 0.000291035, Final residual = 9.60557e-09, No Iterations 10
smoothSolver:  Solving for Uy, Initial residual = 0.000322102, Final residual = 7.96566e-09, No Iterations 10
GAMG:  Solving for p, Initial residual = 0.00108005, Final residual = 8.47719e-09, No Iterations 56
time step continuity errors : sum local = 1.84608e-06, global = 7.58599e-09, cumulative = 4.27814e-05
ExecutionTime = 20234.6 s  ClockTime = 20234 s

Time = 2000

smoothSolver:  Solving for Ux, Initial residual = 6.59773e-05, Final residual = 6.16032e-09, No Iterations 9
smoothSolver:  Solving for Uy, Initial residual = 7.23523e-05, Final residual = 5.38957e-09, No Iterations 9
GAMG:  Solving for p, Initial residual = 0.000254187, Final residual = 8.27609e-09, No Iterations 33
time step continuity errors : sum local = 1.97593e-06, global = -1.4394e-07, cumulative = 3.39222e-05
ExecutionTime = 36473.9 s  ClockTime = 36474 s

Time = 4000

smoothSolver:  Solving for Ux, Initial residual = 0.0163418, Final residual = 6.67672e-09, No Iterations 17
smoothSolver:  Solving for Uy, Initial residual = 0.017233, Final residual = 9.55891e-09, No Iterations 16
GAMG:  Solving for p, Initial residual = 0.0172172, Final residual = 7.92271e-09, No Iterations 71
time step continuity errors : sum local = 3.07673e-05, global = -2.52422e-07, cumulative = -3.41828e-05
ExecutionTime = 60182 s  ClockTime = 60182 s

Time = 4702

smoothSolver:  Solving for Ux, Initial residual = 0.992508, Final residual = 5.36214e+08, No Iterations 1000
smoothSolver:  Solving for Uy, Initial residual = 0.996478, Final residual = 1.43153e+09, No Iterations 1000
GAMG:  Solving for p, Initial residual = 1, Final residual = nan, No Iterations 1000
time step continuity errors : sum local = nan, global = nan, cumulative = nan
ExecutionTime = 84536.6 s  ClockTime = 84536 s

Time = 4703

smoothSolver:  Solving for Ux, Initial residual = nan, Final residual = nan, No Iterations 1000
smoothSolver:  Solving for Uy, Initial residual = nan, Final residual = nan, No Iterations 1000
GAMG:  Solving for p, Initial residual = nan, Final residual = nan, No Iterations 1000
time step continuity errors : sum local = nan, global = nan, cumulative = nan
ExecutionTime = 84926.2 s  ClockTime = 84926 s
I wonder why it'll become like that? Does it mean it diverged and I need to modify the settings in the fvSolution? How should I change the tolerance, residualControl, relaxationFactors, etc.?
Can you give me some advice?
Thank you very much!

PS, though the fracture is pretty rough, the perssure gradient is relative small so that the Re is small and the flow should not get to turbulence.
zyliao is offline   Reply With Quote

Old   June 7, 2022, 03:45
Default
  #23
Member
 
Josh Williams
Join Date: Feb 2021
Location: Scotland
Posts: 87
Rep Power: 3
joshwilliams is on a distinguished road
Quote:
I wonder why it'll become like that? Does it mean it diverged and I need to modify the settings in the fvSolution? How should I change the tolerance, residualControl, relaxationFactors, etc.?
Can you give me some advice?
It seems your timeContinuity error is quite large (cumulative error is around 1e-5). It is best for this ideally not larger than 1e-10. As this is a steady simulation, I would suggest switching to a transient solver (pimpleFoam) with max Courant number initally set at 0.9 and then perhaps lowered down to 0.2 (if it needs to be any lower, I think it would show that the error is elsewhere).


Quote:
fracture is pretty rough, the perssure gradient is relative small so that the Re is small and the flow should not get to turbulence.
We should not confuse transient effects with "turbulence". Turbulence is chaotic, irregular and definitely transient. However, the flow could still show transient effects in the laminar regime (think Karmaan vortex streets). Also another thing to consider is the pressure-driven flow: pressure-driven simulations are inherently less stable than flow-driven ones. Therefore, if there is some re-circulation at the outlet caused by your complex geometry, it could diverge.
joshwilliams is offline   Reply With Quote

Old   June 7, 2022, 10:05
Default
  #24
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 462
Rep Power: 11
Tobermory will become famous soon enough
Just to add to Josh's excellent suggestions - the "nan" value for continuity residual is indeed a sign that your solution has blown up, and I would also suggest checking your mesh quality, boundary conditions and reducing the relaxation factors slightly.

Moving to a transient solver will probably be more stable, but will likely take longer to get to your steady solution, so worth trying a little longer to get the steady solver to work.

Of course, a slow approach to a correct solution is better than a fast approach to a junk solution, so take my advice with a pinch of salt! Good luck.
Tobermory is offline   Reply With Quote

Old   June 9, 2022, 23:39
Thumbs up
  #25
New Member
 
Zhen Liao
Join Date: Apr 2022
Posts: 16
Rep Power: 2
zyliao is on a distinguished road
Quote:
Originally Posted by joshwilliams View Post
It seems your timeContinuity error is quite large (cumulative error is around 1e-5). It is best for this ideally not larger than 1e-10. As this is a steady simulation, I would suggest switching to a transient solver (pimpleFoam) with max Courant number initally set at 0.9 and then perhaps lowered down to 0.2 (if it needs to be any lower, I think it would show that the error is elsewhere).



We should not confuse transient effects with "turbulence". Turbulence is chaotic, irregular and definitely transient. However, the flow could still show transient effects in the laminar regime (think Karmaan vortex streets). Also another thing to consider is the pressure-driven flow: pressure-driven simulations are inherently less stable than flow-driven ones. Therefore, if there is some re-circulation at the outlet caused by your complex geometry, it could diverge.
Thank you, joshwilliams.

I'll try the pimpleFoam later.
And, I used the pressure-driven type according to me research objective, but maybe I'll consider the flow-driven ones later.

Best!
zyliao is offline   Reply With Quote

Old   June 9, 2022, 23:47
Thumbs up
  #26
New Member
 
Zhen Liao
Join Date: Apr 2022
Posts: 16
Rep Power: 2
zyliao is on a distinguished road
Quote:
Originally Posted by Tobermory View Post
Just to add to Josh's excellent suggestions - the "nan" value for continuity residual is indeed a sign that your solution has blown up, and I would also suggest checking your mesh quality, boundary conditions and reducing the relaxation factors slightly.

Moving to a transient solver will probably be more stable, but will likely take longer to get to your steady solution, so worth trying a little longer to get the steady solver to work.

Of course, a slow approach to a correct solution is better than a fast approach to a junk solution, so take my advice with a pinch of salt! Good luck.
Hi Tobermory,

Thank you for your advice.

The boundary conditions should be no problem, as it got a good solution when the pressure gradient was small, and there is not any quite skewed mesh. And I tried reducing the relaxation factor to 0.5 & 0.3, both of them encountered the same problem.

I think I'll try the pimpleFoam.

Best,
zyliao is offline   Reply With Quote

Old   July 2, 2022, 13:07
Exclamation pimpleFoam didn't converged, encountered "core dumped" problem
  #27
New Member
 
Zhen Liao
Join Date: Apr 2022
Posts: 16
Rep Power: 2
zyliao is on a distinguished road
Quote:
Originally Posted by Tobermory View Post
Just to add to Josh's excellent suggestions - the "nan" value for continuity residual is indeed a sign that your solution has blown up, and I would also suggest checking your mesh quality, boundary conditions and reducing the relaxation factors slightly.

Moving to a transient solver will probably be more stable, but will likely take longer to get to your steady solution, so worth trying a little longer to get the steady solver to work.

Of course, a slow approach to a correct solution is better than a fast approach to a junk solution, so take my advice with a pinch of salt! Good luck.
Hi Tobermory and joshwilliams,

These days I have tried the pimpleFoam based on the tutorials cases under the folder ď/tutorials/incompressible/pimpleFoam/laminarĒ.

Iím not sure how much time itíll cost for my case, and I want the solver stops when the tolerance conditions are reached, so I add the residualControl as follows:
Code:
PIMPLE
{
    nCorrectors         2;
	nNonOrthogonalCorrectors 0; //
	//nOuterCorrectore 2;  //
	//momentumPredictor   off; //
	
	residualControl
    {
        p               1e-5;
        U               1e-5;
    }
}
And it works when I simulated the simple case, plane-Poiseuille flow (plane-parallel plates with pressure gradient). The log file likes:
Code:
Courant Number mean: 0.446783 max: 0.669648
deltaT = 1e-05
Time = 0.28842

smoothSolver:  Solving for Ux, Initial residual = 6.23778e-09, Final residual = 4.37402e-10, No Iterations 1
smoothSolver:  Solving for Uy, Initial residual = 9.99837e-07, Final residual = 4.41101e-09, No Iterations 2
GAMG:  Solving for p, Initial residual = 1.55179e-10, Final residual = 8.75098e-12, No Iterations 1
time step continuity errors : sum local = 4.11461e-15, global = -2.19722e-15, cumulative = -1.15507e-08
GAMG:  Solving for p, Initial residual = 1.54756e-10, Final residual = 8.86012e-12, No Iterations 1
time step continuity errors : sum local = 4.16583e-15, global = 1.83124e-15, cumulative = -1.15507e-08
ExecutionTime = 8412.92 s  ClockTime = 8413 s

PIMPLE solution converged in 0.28842 iterations

End
However, when I simulated a more complicate case, pressure-driven flow in a fracture network (see attached figure), it encountered problems:
According to the log file, the solver didnít stop until it got the endTime (1.5), even though the residuals were much smaller than I set in the residualControl (1e-5).
Code:
Courant Number mean: 0.00192971 max: 0.0112378
Time = 1.5

smoothSolver:  Solving for Ux, Initial residual = 7.56505e-07, Final residual = 2.84178e-11, No Iterations 1
smoothSolver:  Solving for Uy, Initial residual = 7.75426e-07, Final residual = 2.8357e-11, No Iterations 1
GAMG:  Solving for p, Initial residual = 6.71212e-08, Final residual = 1.28297e-08, No Iterations 1
time step continuity errors : sum local = 2.6825e-15, global = -5.42384e-16, cumulative = -1.31311e-10
GAMG:  Solving for p, Initial residual = 3.53864e-08, Final residual = 1.1966e-08, No Iterations 1
time step continuity errors : sum local = 2.50191e-15, global = -3.23207e-18, cumulative = -1.31311e-10
ExecutionTime = 68419.4 s  ClockTime = 71020 s

End

Finalising parallel run
When I changed the endTime to 3, and rerun the simulation, it finally encountered an error:
Code:
Courant Number mean: 1.2346e+102 max: 4.57473e+103
Time = 2.08499

smoothSolver:  Solving for Ux, Initial residual = 0.730531, Final residual = 6.64896e-05, No Iterations 1000
smoothSolver:  Solving for Uy, Initial residual = 0.738381, Final residual = 8.22353e-05, No Iterations 1000
GAMG:  Solving for p, Initial residual = 0.989074, Final residual = 8.75592e-08, No Iterations 53
time step continuity errors : sum local = 1.26262e+95, global = 7.77481e+93, cumulative = 1.23051e+94
GAMG:  Solving for p, Initial residual = 0.262815, Final residual = 9.00335e-08, No Iterations 45
time step continuity errors : sum local = 1.59688e+96, global = -5.21253e+94, cumulative = -3.98202e+94
ExecutionTime = 40376.8 s  ClockTime = 40934 s

Courant Number mean: 1.17916e+103 max: 5.25875e+104
Time = 2.085

smoothSolver:  Solving for Ux, Initial residual = 0.71156, Final residual = 0.00334101, No Iterations 1000
smoothSolver:  Solving for Uy, Initial residual = 0.720883, Final residual = 0.00112397, No Iterations 1000
srun: error: n0045: tasks 1-2: Floating point exception (core dumped)
srun: error: n0045: tasks 0,3: Floating point exception (core dumped)
I have tried to change the deltaT, tolerance settings, they all encountered the same ďcore dumpedĒ problem.
Iím not sure if there are some settings are wrong. I attached the fvSolution, fvSchemes, controlDict files, maybe you can have a look. Thank you!
Attached Images
File Type: jpg 2D_fra_net_disk_note.jpg (71.1 KB, 1 views)
zyliao is offline   Reply With Quote

Old   July 2, 2022, 13:18
Exclamation
  #28
New Member
 
Zhen Liao
Join Date: Apr 2022
Posts: 16
Rep Power: 2
zyliao is on a distinguished road
Quote:
Originally Posted by zyliao View Post
Hi Tobermory and joshwilliams,

These days I have tried the pimpleFoam based on the tutorials cases under the folder ď/tutorials/incompressible/pimpleFoam/laminarĒ.

Iím not sure how much time itíll cost for my case, and I want the solver stops when the tolerance conditions are reached, so I add the residualControl as follows:

However, when I simulated a more complicate case, pressure-driven flow in a fracture network (see attached figure), it encountered problems:
According to the log file, the solver didnít stop until it got the endTime (1.5), even though the residuals were much smaller than I set in the residualControl (1e-5).

When I changed the endTime to 3, and rerun the simulation, it finally encountered an error:

I have tried to change the deltaT, tolerance settings, they all encountered the same ďcore dumpedĒ problem.
Iím not sure if there are some settings are wrong. I attached the fvSolution, fvSchemes, controlDict files, maybe you can have a look. Thank you!

Hi everyone, these are my files:

p:
Code:
dimensions      [0 2 -2 0 0 0 0];

internalField   uniform 0;

boundaryField
{
    "(INLET_1|INLET_2|INLET_3|INLET_4|INLET_5|INLET_6|INLET_7|INLET_8)"
    {
        type            fixedValue;
        value           uniform 0.01;
    }
    "(OUTLET_1|OUTLET_2|OUTLET_3|OUTLET_4|OUTLET_5|OUTLET_6|OUTLET_7|OUTLET_8)"
    {
        type            fixedValue;
        value           uniform 0;
    }
    WALL
    {
        type            zeroGradient;
    }
    "(TOP|BOTTOM)"
    {
        type            empty;
    }
}
U:
Code:
dimensions      [0 1 -1 0 0 0 0];

internalField   uniform (0 0 0);

boundaryField
{
    "(INLET_1|INLET_2|INLET_3|INLET_4|INLET_5|INLET_6|INLET_7|INLET_8)"
    {
        type            pressureInletVelocity;
        phi             phi;
        rho             rho;
        value           uniform (0 0 0);
    }

    "(OUTLET_1|OUTLET_2|OUTLET_3|OUTLET_4|OUTLET_5|OUTLET_6|OUTLET_7|OUTLET_8)"
    {
        type            zeroGradient;
    }

    WALL
    {
        type            noSlip;
    }

    "(TOP|BOTTOM)"
    {
        type            empty;
    }
}
fvSolution:
Code:
solvers
{
    p
    {
        solver           GAMG;
        tolerance        1e-7;
        relTol           0;
        smoother         DICGaussSeidel;
		minIter          5;  //

    }

    pFinal
    {
        $p;
        relTol          0;
    }

    U
    {
        solver          smoothSolver;
        smoother        symGaussSeidel;
        tolerance       1e-07;
        relTol          0;
		minIter         5; //
    }

    UFinal
    {
        $U;
        relTol          0;
    }
}

PIMPLE
{
    nCorrectors         2;
	nNonOrthogonalCorrectors 0; //
	//nOuterCorrectore 2;  //
	//momentumPredictor   off; //
	
	residualControl
    {
        p               1e-5;
        U               1e-5;
    }
}

relaxationFactors
{
    equations
    {
        ".*"   1;
    }
}
fvSchemes:
Code:
ddtSchemes
{
    default          Euler;
}

gradSchemes
{
    default         Gauss linear;
}

divSchemes
{
    default             none;

    div(phi,U)          Gauss linearUpwind grad(U);

    div((nuEff*dev2(T(grad(U))))) Gauss linear;
}

laplacianSchemes
{
    default         Gauss linear corrected;
}

interpolationSchemes
{
    default         linear;
}

snGradSchemes
{
    default         corrected;
}
controlDict:
Code:
application     pimpleFoam;

startFrom       latestTime;

startTime       0;

stopAt          endTime;

endTime         3;

deltaT          0.00001;

writeControl    adjustableRunTime;

writeInterval   0.1;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable yes;

adjustTimeStep  no; //

maxCo           3;

functions
{
#includeFunc flowRatePatch(name=INLET_1)

	#includeFunc flowRatePatch(name=OUTLET_1)

	#includeFunc patchAverage(name=INLET_1,p)
	
	#includeFunc patchAverage(name=OUTLET_1,p)
}
checkMesh.log:
Code:
Create time

Create polyMesh for time = 0

Time = 0

Mesh stats
    points:           1461944
    internal points:  0
    faces:            2854285
    internal faces:   1392335
    cells:            707770
    faces per cell:   6
    boundary patches: 19
    point zones:      0
    face zones:       5
    cell zones:       1

Overall number of cells of each type:
    hexahedra:     707770
    prisms:        0
    wedges:        0
    pyramids:      0
    tet wedges:    0
    tetrahedra:    0
    polyhedra:     0

Checking topology...
    Boundary definition OK.
    Cell to face addressing OK.
    Point usage OK.
    Upper triangular ordering OK.
    Face vertices OK.
    Number of regions: 1 (OK).

Checking patch topology for multiply connected surfaces...
    Patch               Faces    Points   Surface topology                  
    INLET_1             35       72       ok (non-closed singly connected)  
    INLET_2             21       44       ok (non-closed singly connected)  
    INLET_3             24       50       ok (non-closed singly connected)  
    INLET_4             29       60       ok (non-closed singly connected)  
    INLET_5             23       48       ok (non-closed singly connected)  
    INLET_6             55       112      ok (non-closed singly connected)  
    INLET_7             23       48       ok (non-closed singly connected)  
    INLET_8             26       54       ok (non-closed singly connected)  
    OUTLET_1            26       54       ok (non-closed singly connected)  
    OUTLET_2            21       44       ok (non-closed singly connected)  
    OUTLET_3            24       50       ok (non-closed singly connected)  
    OUTLET_4            28       58       ok (non-closed singly connected)  
    OUTLET_5            23       48       ok (non-closed singly connected)  
    OUTLET_6            24       50       ok (non-closed singly connected)  
    OUTLET_7            23       48       ok (non-closed singly connected)  
    OUTLET_8            16       34       ok (non-closed singly connected)  
    WALL                45989    92010    ok (non-closed singly connected)  
    TOP                 707770   730972   ok (non-closed singly connected)  
    BOTTOM              707770   730972   ok (non-closed singly connected)  

Checking geometry...
    Overall domain bounding box (1.05767 -1.34728 -5e-06) (1.3494 -1.05778 0)
    Mesh has 2 geometric (non-empty/wedge) directions (1 1 0)
    Mesh has 2 solution (non-empty) directions (1 1 0)
    All edges aligned with or perpendicular to non-empty directions.
    Boundary openness (3.20635e-18 3.0694e-19 2.91732e-17) OK.
    Max cell openness = 2.54883e-16 OK.
    Max aspect ratio = 2.74176 OK.
    Minimum face area = 1.28173e-10. Maximum face area = 7.11969e-09.  Face area magnitudes OK.
    Min volume = 5.61444e-15. Max volume = 3.55984e-14.  Total volume = 1.87478e-08.  Cell volumes OK.
    Mesh non-orthogonality Max: 59.1436 average: 20.7321
    Non-orthogonality check OK.
    Face pyramids OK.
    Max skewness = 1.82248 OK.
    Coupled point location match (average 0) OK.

Mesh OK.

End
zyliao is offline   Reply With Quote

Reply

Tags
boundary condition, internal flow, pipe flow, simplefoam convergence, simplefoam pressure bc

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Difference between p (pressure) and static pressure PeterShi OpenFOAM Post-Processing 2 March 19, 2019 17:23
pressure in incompressible solvers e.g. simpleFoam chrizzl OpenFOAM Running, Solving & CFD 13 March 28, 2017 06:49
Pressure difference at INLET and OUTLET. lovegne FLUENT 2 January 27, 2017 08:28
Neumann pressure BC and velocity field Antech Main CFD Forum 0 April 25, 2006 03:15
Hydrostatic pressure in 2-phase flow modeling (CFX4.2) HB &DS CFX 0 January 9, 2000 14:19


All times are GMT -4. The time now is 16:41.