CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT

How to stop transient simulation which has been run from scheme script?

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By ZAB

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 22, 2017, 04:18
Default 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
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
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 22:15. Reason: 1
AlexanderZ is offline   Reply With Quote

Old   August 23, 2017, 02:04
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
If anyone has the idea, how to solve this problem, please share.

I appreciate any help. Thanks in advance!
AlexanderZ is offline   Reply With Quote

Old   August 27, 2017, 22:16
Default
  #3
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
If anyone has the idea, how to solve this problem, please share.

I appreciate any help. Thanks in advance!
AlexanderZ is offline   Reply With Quote

Old   August 28, 2017, 01:35
Default
  #4
Senior Member
 
KaLium's Avatar
 
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9
KaLium is on a distinguished road
does ctrl + C work?
KaLium is offline   Reply With Quote

Old   August 28, 2017, 03:10
Default
  #5
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Quote:
Originally Posted by KaLium View Post
does ctrl + C work?
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
AlexanderZ is offline   Reply With Quote

Old   August 30, 2017, 20:38
Default
  #6
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
If anyone has the idea, how to solve this problem, please share.

I appreciate any help. Thanks in advance!
AlexanderZ is offline   Reply With Quote

Old   August 30, 2017, 22:53
Default
  #7
ZAB
New Member
 
Zaka Muhammad
Join Date: Jan 2012
Posts: 6
Rep Power: 14
ZAB is on a distinguished road
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))
all you have to do is delete that file, the above command will return false when it can't find or can't open the file, this way you can stop by deleting the file in folder.

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))
    )
   )
AlexanderZ likes this.

Last edited by ZAB; August 30, 2017 at 23:23. Reason: elaborating the answer
ZAB is offline   Reply With Quote

Old   August 31, 2017, 01:05
Default
  #8
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
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
AlexanderZ is offline   Reply With Quote

Old   August 31, 2017, 04:25
Default
  #9
ZAB
New Member
 
Zaka Muhammad
Join Date: Jan 2012
Posts: 6
Rep Power: 14
ZAB is on a distinguished road
Quote:
I wonder, do you know the way, how to stop scheme if it is already started?
No, In my Understanding, Fluent Engine is running the scheme in Background. so probably only way to stop it properly would be by code itself.
ZAB is offline   Reply With Quote

Reply

Tags
scheme, udf and programming


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
Resume Transient simulation HMR CFX 1 June 28, 2011 21:13
execute udf in ss & transient simulation hosseinhgf FLUENT 0 December 1, 2010 08:41
Synthetic (pulsatile) jet transient simulation aero CFX 0 November 6, 2009 01:10
What's the best order to run this simulation in? siw CFX 1 November 4, 2009 19:42
transient simulation: natural convection problem? Basics CFX 3 September 25, 2002 09:42


All times are GMT -4. The time now is 01:26.