|
[Sponsors] |
June 25, 2013, 10:25 |
transient convergence criteria
|
#1 |
Member
Join Date: Sep 2012
Posts: 51
Rep Power: 14 |
Hi,
I'm working on a periodic simulation and I'd like to set up a temporal convergence criteria. It would be something like if variable(t+T)=variable(t) then stop simulation In the swak4foam library there are tools to stop a simulation if a criteria is reached, something like (in controlDict) : Code:
stopHighVel { type panicDump ; fieldName Q ; minimum -1; maximum 0.001; verbose true; } Regards, Florian |
|
June 25, 2013, 14:42 |
|
#2 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
||
June 25, 2013, 15:28 |
|
#3 |
Member
Join Date: Sep 2012
Posts: 51
Rep Power: 14 |
Thank you for writeAndEndSwakExpression, I didn't know this one. I'm still wondering how to access data at a specified time. oldTime only works for one timeStep in the past...
Any idea ? Regards, Florian |
|
June 25, 2013, 16:00 |
|
#4 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Yep. Delayed variable
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
|
June 28, 2013, 12:14 |
|
#5 |
Member
Join Date: Sep 2012
Posts: 51
Rep Power: 14 |
Thank you very much, a mix of delayedVariables and writeAndEndSwakExpression works perfectly !
Regards, Florian. |
|
June 28, 2013, 14:16 |
|
#6 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Thank YOU. Without you I wouldn't have thought that delayed variables can be used for convergence-checking
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
|
June 29, 2013, 08:14 |
|
#7 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
Can you post the code? Might be useful for people in the future.
__________________
*On twitter @akidTwit *Spend as much time formulating your questions as you expect people to spend on their answer. |
|
June 29, 2013, 09:13 |
|
#8 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
||
July 2, 2013, 11:41 |
|
#9 | |
Member
Join Date: Sep 2012
Posts: 51
Rep Power: 14 |
Quote:
Test case : one intlet with a sinusoidal pressure, 2 free outlets. Code:
stopIfCrit { type writeAndEndSwakExpression; valueType internalField; logicalExpression "(maxU1 < threshold) && (maxU2 < threshold) && (tt >= 1.5) && (test > 0.5) "; /* In this case 2 outlets are considered and tested. The (very basic) criteria used is the maximum velocity at the outlet patches. The flow is periodic and supposed physically converged if the criteria values are the same at t and t+T. The two first tests are the velocities comparison. The third one is a delay because of the unphysical behaviour that can appear at the beginning of the simulation. The fourth is used to keep the simulation running for one period after the convergence is reached.*/ logicalAccumulation and; variables ( "UA1fter{patch'outlet1}=max(mag(U));" //delayed criteria on outlet1 "Ub41{patch'outlet1}=max(mag(U));" // criteria on outlet1 "UA2fter{patch'outlet2}=max(mag(U));" "Ub42{patch'outlet2}=max(mag(U));" "maxU1=100*mag(UA1fter-Ub41)/mag(UA1fter);" "maxU2=100*mag(UA2fter-Ub42)/mag(UA2fter);" "threshold=5;" // 5% of difference accepted "tt=time();" "test=((maxU1 < threshold) && (maxU2 < threshold) && (tt >= 1.5))? 1 : 0;" // test done with a delay of T. ); delayedVariables ( { name UA1fter; delay 0.7; storeInterval 0.001; startupValue "100"; } { name UA2fter; delay 0.7; storeInterval 0.001; startupValue "100"; } { name test; delay 0.7; storeInterval 0.001; startupValue "0"; } ); verbose true; outputControlMode timestep; outputInterval 1; } With : blue = p(inlet), pink = 5% threshold, red and green : convergence criteria on both outlets. I was wondering : how can I add the period as a parameter ? Florian Last edited by Hiroshiman; July 2, 2013 at 15:31. |
||
July 2, 2013, 16:20 |
|
#10 | ||
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Quote:
Code:
defaultDelay 0.7; Code:
delay $defaultDelay;
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
|||
July 4, 2013, 12:21 |
|
#11 | ||
Member
Join Date: Sep 2012
Posts: 51
Rep Power: 14 |
Quote:
Code:
convcrit1 { type swakExpression; valueType patch; patchName outlet1; variables ( //"dummy=p-mag(U);" "UA1fter{patch'outlet1}=mag(U);" "Ub41{patch'outlet1}=mag(U);" ); delayedVariables ( { name UA1fter; delay 0.7; storeInterval 0.001; startupValue "100"; }); accumulations ( max ); expression "100*mag(UA1fter-Ub41)/mag(UA1fter)"; verbose true; autoInterpolate true; warnAutoInterpolate false; outputControlMode timestep; outputInterval 1; } Quote:
Florian |
|||
July 8, 2013, 15:59 |
|
#12 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
||
April 8, 2015, 13:34 |
|
#13 |
Member
Liam
Join Date: Aug 2013
Posts: 40
Rep Power: 13 |
Hi everyone,
I am not understanding well the use of this wonderful tool. I would like to stop my (steady) simulation when Residuals are below a given threshold (let's say 1e-4) and outlet velocity remains unchanged with iterations, so, I have included this in my controDict file: velocity_outlet { type patchExpression; accumulations ( average ); patches ( out ); expression "mag(U)"; verbose true; outputControl timeStep; outputInterval 1; } This computes averaged outlet velocity as I desired. But now I am not sure how to compare old and present values. I would like to: if |uaveraged(iteration n)-uaveraged(iteration n-1)|<0.1 and Residuals<1e-4 then STOP Based on the code I have seen here, I have tried something like this( forget about the Residuals in this first try) stopIfCrit { type writeAndEndSwakExpression; valueType internalField; logicalExpression "(tol < threshold)"; logicalAccumulation and; variables ( "UA1fter=velocity_outlet;" //delayed criteria on outlet1 "Ub41=velocity_outlet;" "tol=mag(UA1fter-Ub41);" "threshold=0.5;" "test=((tol < threshold) )? 1 : 0;" ); delayedVariables ( { name UA1fter; delay 1; storeInterval 1; startupValue "1"; } { name test; delay 1; storeInterval 1; startupValue "0"; } ); verbose true; outputControlMode timestep; outputInterval 1; } But nothing happens. It seems that I am not telling OpenFOAM when it has to stop .This definition I have tried looks so weird: "UA1fter=velocity_outlet;" //delayed criteria on outlet1 "Ub41=velocity_outlet;" Does anybody know how I have to proceed to compare a computed value in the previous iteration with this value in the current iteration? Thanks in advance! |
|
April 8, 2015, 14:03 |
|
#14 | |
Member
Join Date: Sep 2012
Posts: 51
Rep Power: 14 |
Quote:
Hi, you can look at the variables values that are stored during the simulation to check if they are what you expect (in the swak4Foam folder at each timeStep). You can use the [CODE ] [/CODE ] bracket to make the code readable. |
||
April 8, 2015, 14:45 |
|
#15 |
Member
Liam
Join Date: Aug 2013
Posts: 40
Rep Power: 13 |
Hi Hiroshiman,
The values of: velocity_outlet { type patchExpression; accumulations ( average ); patches ( out ); expression "mag(U)"; verbose true; outputControl timeStep; outputInterval 1; } are written in postProcessing folder (no swak4foam folder in my case) The problem is I don't know how to use this values to stop my simulation when differences between consecutive iterations is small. Some more help will be much aprecciated. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
transient convergence | mohsen.samie | CFX | 8 | September 15, 2015 11:18 |
What is the criteria for convergence in transient problems? | abcd | ANSYS | 0 | July 26, 2015 13:03 |
SIMPLE algorithm, convergence criteria | bbasal | Main CFD Forum | 3 | December 3, 2011 00:24 |
What value shall I set for the Convergence criteria? | steventay | CFX | 7 | May 14, 2010 13:44 |
Convergence Criteria | edwin | FLUENT | 1 | February 14, 2008 20:24 |