|
[Sponsors] |
How to stop transient simulation which has been run from scheme script? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
August 22, 2017, 05:18 |
How to stop transient simulation which has been run from scheme script?
|
#1 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
Please, help me, if you can.
Problem description: For User_Defined model in Fluent the GUI was developed using scheme language. One of the feature of model is it's capability to stop simulation when the stop_criteria is met. To make this, one approach was applied: Start loop -> Make only one timestep iteration, than check stop_criteria in UDF. If stop_criteria is False, than repeat timestep iteration. If stop_criteria is True -> exit loop/stop simulation. This approach works well, however, there is a great disadvantage. Once the number of maximum repeats in loop is set and simulation starts, it is impossible to stop simulation at any moment. Instead, we have to wait until stop_criteria is True or max repeat number. GUI is not active when scheme script is working. It is a big problem, if the wrong result is observed from the very beginning. For example: we want to simulate process 100 sec long, put 100 repeat numbers in loop of 1 sec time step -> total 100*1sec = 100 sec. We may observe wrong result from 5sec, but can't stop simulation. Question: 1. How can I modefy code to make it possible to stop solution any moment? 2. Are there other approaches to stop simulation when to stop_criteria is been met Code example: Code:
(define (my-iter max-iter) (do ((i 1 (+ i 1)) ) ((or (> i max-iter)(%rpgetvar 'stop_criteria?))) ; Get stop_criteria value from UDF part (rpsetvar 'physical-time-step (%rpgetvar 'model_time_step_size)) ; Set timestep size for new time iteration (ti-menu-load-string (format #f "solve d-t-i 1 ~a" (%rpgetvar 'model_iteration_count))) ; Set number of internal iteratons for new time iteration (newline) ) ) Last edited by AlexanderZ; August 27, 2017 at 23:15. Reason: 1 |
|
August 23, 2017, 03:04 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
If anyone has the idea, how to solve this problem, please share.
I appreciate any help. Thanks in advance! |
|
August 27, 2017, 23:16 |
|
#3 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
If anyone has the idea, how to solve this problem, please share.
I appreciate any help. Thanks in advance! |
|
August 28, 2017, 02:35 |
|
#4 |
Senior Member
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9 |
does ctrl + C work?
|
|
August 28, 2017, 04:10 |
|
#5 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
Thank you for response! I really appreciate! However:
ctrl+C or ctrl+c double times is not the solution. As i tried to describe, it is not ONLY ONE transient simulation, but it is a LOOP of transient simulations. Even if ctrl+C will stop one of them, the next one will start. My scripts works this way -> example: If I want to simulate 10 sec, I run a loop of 10 transient simulations 1 sec long 10times * 1sec = 10sec simulation. The other problem, once script is running -> Fluent GUI becomes inactive |
|
August 30, 2017, 21:38 |
|
#6 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
If anyone has the idea, how to solve this problem, please share.
I appreciate any help. Thanks in advance! |
|
August 30, 2017, 23:53 |
|
#7 |
New Member
Zaka Muhammad
Join Date: Jan 2012
Posts: 6
Rep Power: 14 |
A simple solution is to check for a specific file in your directory. if you can't find that file, set the 'stop_critera to true and jump out of loop
Code:
(if (file-exists? "someFile.txt") (display 'continue) (rpsetvar 'stop_criteria? #t)) you can put it here Code:
(define (my-iter max-iter) (do ((i 1 (+ i 1)) ) ((or (> i max-iter)(%rpgetvar 'stop_criteria?))) ; Get stop_criteria value from UDF part (rpsetvar 'physical-time-step (%rpgetvar 'model_time_step_size)) ; Set timestep size for new time iteration (ti-menu-load-string (format #f "solve d-t-i 1 ~a" (%rpgetvar 'model_iteration_count))) ; Set number of internal iteratons for new time iteration (newline) (if (file-exists? "someFile.txt") (display 'continue) (rpsetvar 'stop_criteria? #t)) ) ) Last edited by ZAB; August 31, 2017 at 00:23. Reason: elaborating the answer |
|
August 31, 2017, 02:05 |
|
#8 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
To ZAB
Thank you for sharing! You approach should work for my case. This is effective solution, however, a tricky one. I wonder, do you know the way, how to stop scheme if it is already started? For example, we can stop fluent using Ctrl+C, but for scheme it doesn't work. Best regards, Zorin Alexander |
|
August 31, 2017, 05:25 |
|
#9 | |
New Member
Zaka Muhammad
Join Date: Jan 2012
Posts: 6
Rep Power: 14 |
Quote:
|
||
Tags |
scheme, udf and programming |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Resume Transient simulation | HMR | CFX | 1 | June 28, 2011 22:13 |
execute udf in ss & transient simulation | hosseinhgf | FLUENT | 0 | December 1, 2010 09:41 |
Synthetic (pulsatile) jet transient simulation | aero | CFX | 0 | November 6, 2009 02:10 |
What's the best order to run this simulation in? | siw | CFX | 1 | November 4, 2009 20:42 |
transient simulation: natural convection problem? | Basics | CFX | 3 | September 25, 2002 10:42 |