CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   CFX (https://www.cfd-online.com/Forums/cfx/)
-   -   Change accumulated time step (https://www.cfd-online.com/Forums/cfx/151958-change-accumulated-time-step.html)

boubou April 21, 2015 03:00

Change accumulated time step
 
Hi,

In a junction box called at the end of each coefficient loop, i have to change the accumulated time step when i reach 50 iterations :

IF (ATSTEP.EQ.10) THEN
CALL MESAGE('WRITE','ATTENTION')
CALL PSHDIR ('/FLOW/SOLUTION', 'STOP', CRESLT)
CALL POKEI ('ATSTEP', IONE, 100, 'STOP', CRESLT, IZ)
CALL POPDIR ('STOP', CRESLT)
END IF

At the 101 iteration, i have an error message :

Error detected by routine PSHDRH
CDRNAM = /FLOW/MESH/TSTEP100 /LAST
CRESLT = NONE

Do you know why ?

Thanks

Opaque April 21, 2015 06:54

The accumulated time step is an internal feature of the software, and overriding w/o updating any related variables and/or data structures is ill-advised.

What are you trying to achieve by faking the accumulated timestep instead of ?

boubou April 21, 2015 07:35

Thanks for your answer.
I agree, in fact i don't know to solve my problem.

- I have a Mass Flow Rate of 0.5 [kg/s] in my input section.
- I wrote a junction box which stops the calculation when I reach a convergence criterion.

The problem is : I want to change the Mass Flow Rate to 0.3 [kg/s] when the convergence criterion is reached.

In the expression of the mass flow rate i wrote a USER CEL Function but in this function, I can't read the convergence criterion of my junction box. I have an error of type : Error detected by routine PSHDIR.

ghorrocks April 21, 2015 07:48

So why not do a simulation at 0.5 kg/s and let it reach the convergence criteria. Then a second simulation uses the first as an initial condition but with 0.3 kg/s mass flow rate.

This can be automated with a shell/batch file or in workbench. No fortran or user CEL is required.

And why do you need to use a junction box routine to find convergence? Are the built in convergence tests inadequate? Can't you just set the maximum number of iterations in the CFX-Pre GUI?

boubou April 21, 2015 09:34

Thanks for your reply. No because the goal of my work is to have in the same graph the different steps. I use this convergence criteria :

CONV=(MAXU-MINU)*2.0/(MAXU+MINU)*100.0

Where MAXU et MINU are the max and the min of my user point on the previous 40 iterations.

Opaque April 21, 2015 09:49

Not sure why you would like to measure convergence in such manner.

Regardless of whatever formula you want to use, you must be very careful the standard convergence criteria are fairly satisfied.

A global quantity, or local such a monitor point may falsely converge (region of small changes during convergence), and you will obtain the wrong overall results.

boubou April 21, 2015 10:17

Ok I can change the criteria but it doesn't solve my problem...
Maybe I can write the criteria with CEL expressions but is it possible to access to the value of U of the previous time step ?

Opaque April 21, 2015 11:38

Accessing the previous timestep value is not trivial. Such topic has been discussed in the past, and you can search through the forum for the latest description.

As an advice, you should not compare values between iterations to determine convergence regardless of the metric used. How do you remove the influence of under-relaxation out of the behavior between two consecutive iterations ? That is, if you set a criteria and a threshold to be satisfied, I could under-relax the solution to 0.1 (for example), and the solution may stop earlier than expected. Similarly, someone could inadvertently reduce the physical timescale and the software stop earlier than it should.

Your new convergence criteria must be independent of chosen under-relaxation factor, physical timescale, or timestep so you can be sure the solution is unique given the threshold chosen.

If you need the solutions for different mass flows on the same plot, I would follow Glenn's suggestions of running separate runs, export the plots and stitch them in Excel or the spreadsheet of your choice.

boubou April 22, 2015 06:33

Thanks Opale for your reply, I will work on that.

I have just another question : is it possible in a User CEL Function to retain a variable ?

Ex : - iteration N, X = expression
- iteration N+1, Y = X² with X the value at the iteration N

Thanks


All times are GMT -4. The time now is 21:38.