|
[Sponsors] |
2 separated 3D models : 2 way coupling at a boundary? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 11, 2013, 12:52 |
2 separated 3D models : 2 way coupling at a boundary?
|
#1 |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
Hi,
Is there a way to couple two separated 3D models (opened in 2 Fluent instances) at a boundary? And run an interaction sequence back and forth between both models (see picture): 1. Solve model 1 2. Write heat flux profile of the coupled boundary 3. Read profile from model 1 in model 2 at the coupled boundary 4. Solve model 2 5. Write temperature profile of the coupled boundary 6. Read profile from model 2 in model 1 at the coupled boundary 7. Return to step 1 and so on. A scheme commands journal file? A complex journal file? Fluent TUI commands from an external program? Impossible in Workbench: the "model coupling" apparatus doesn't accept 2 Fluent models. The 2-way coupling that I want to perform is pretty simple, I don't know why it's not implemented in Workbench yet, in a general way, in order to couple 2 separated models. I'm a bit confused as to where to start! Frank Last edited by macfly; May 11, 2013 at 13:11. |
|
May 11, 2013, 18:44 |
|
#2 |
Super Moderator
Ghazlani M. Ali
Join Date: May 2011
Location: Tokyo, Japan
Posts: 1,385
Blog Entries: 23
Rep Power: 29 |
i will go for the complex journal file... doable but complicated. you mentioned "return to step 1 and so on"... it sounds like a loop. that is not doable with a journal file.
otherwise it should be something like: /read model 1 /solve 1000 /export-profile temperature (not the actual command, it is just an exemple) /read model 2 /read-profile temperature and so on... good luck finding those command tough |
|
May 12, 2013, 13:42 |
|
#3 |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
Hi diamondx,
Thanks for your suggestion, it would be pretty easy to implement, but here's the flaw: a whole lot of time wasted loading the models at each coupling. Suppose there is thousands of time steps and the model takes a 10-15 seconds to be read, a lot of wasted CPU time there. I need to have 2 Fluent windows opened, each one having their respective model loaded, ready to read a profile from the other model and iterate. But I don't know how I can tell, say model 2, to wait for the profile from model 1 and then iterate, and vice versa. Any skilled programmers around? |
|
May 13, 2013, 07:36 |
|
#4 |
New Member
rayolau
Join Date: Aug 2012
Posts: 23
Rep Power: 14 |
Hi macfly, I'm working in the same idea like you. I think we need udf for write profiles and then TUI commands for stop and continue the calculate for wait the profiles of the other model.
I'm looking for this commands, but I don't find nothing interesting. You have any idea about this? Thanks and good luck! |
|
May 13, 2013, 09:15 |
|
#5 |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
Hi rayolau,
I'm working on a scheme code and it looks good, I think I'm getting there. Scheme language is vast, It's just a matter of finding the right commands. I'll post my code later, I'm in a conference rush this week... later |
|
May 13, 2013, 11:33 |
|
#7 |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
right on Ali
|
|
May 13, 2013, 21:05 |
|
#9 |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
Here's a working algorithm with scheme files.
In this example: - Model 1 and 2 are two separate solids with energy equation ON. - Both models are transient. - The two-way coupled boundary is named 'wall_coupling' in both models. - Coupling is as in the picture of post #1. - Model 1 is in folder D:\Model1 - Model 2 is in folder D:\Model2 - Every second, each model looks in the folder of the other model to see if the new profile is available. - I'm running Fluent under Windows, the system command 'del' is 'rm' under Linux I think. - It's not a super optimized elegant and perfect code, but it works! Open Model 1 and read following scheme file. After each time step, Fluent waits for a new 'T.prof' from Model 2 in order to continue: Code:
(define nit 1) (let loop () ; 1st time step (if (= nit 1) (ti-menu-load-string "define/user-defined/interpreted-functions model1.c ""cpp"" 10000 no")) ; read some udf (if (= nit 1) (ti-menu-load-string "solve/initialize/hyb-initialization")) ; initialize (if (= nit 1) (ti-menu-load-string "solve/dual-time-iterate 1 10000")) ; iterate (if (= nit 1) (ti-menu-load-string "file/write-profile q.prof wall_coupling () heat-flux ()")) ; write q" profile (if (= nit 1) (set! nit (+ nit 1))) ; counter ; ; else time steps, conditional to existence of T profile from Model 2 (if (file-exists? "D:\Model2\T.prof") (ti-menu-load-string "define/boundary-conditions/wall/...ugly line answering many questions...")) ; define profile boundary condition (if (file-exists? "D:\Model2\T.prof") (ti-menu-load-string "file/read-profile D:\Model2\T.prof")) ; read T profile (if (file-exists? "D:\Model2\T.prof") (ti-menu-load-string "solve/dual-time-iterate 1 10000")) ; iterate (if (file-exists? "D:\Model2\T.prof") (ti-menu-load-string "file/write-profile q.prof wall_coupling () heat-flux ()")) ; write q" profile (if (file-exists? "D:\Model2\T.prof") (set! nit (+ nit 1))) ; counter (if (file-exists? "D:\Model2\T.prof") (system "del D:\Model2\T.prof")) ; delete T profile (if (= nit 5) (cx-interrupt)) ; interrupt Fluent after max number of iteration ;(if (= nit 5) (cx-exit)) ; exit Fluent after max number of iteration ; ; pause in order to control the search interval (cx-pause 1) (loop)) Open Model 2 in another Fluent instance and read the following scheme file. After each time step, Fluent waits for a new 'q.prof' from Model 1 in order to continue: Code:
(define nit 1) (let loop () ; 1st time step (if (= nit 1) (ti-menu-load-string "define/user-defined/interpreted-functions model2.c ""cpp"" 10000 no")) ; read some udf (if (= nit 1) (ti-menu-load-string "solve/initialize/hyb-initialization")) ; initialize (if (= nit 1) (ti-menu-load-string "solve/dual-time-iterate 1 10000")) ; iterate (if (= nit 1) (ti-menu-load-string "file/write-profile T.prof wall_coupling () temperature ()")) ; write T profile (if (= nit 1) (set! nit (+ nit 1))) ; counter ; ; else time steps, conditional to existence of q" profile from Model 1 (if (file-exists? "D:\Model1\q.prof") (ti-menu-load-string "define/boundary-conditions/wall/...ugly line answering many questions...")) ; define profile boundary condition (if (file-exists? "D:\Model1\q.prof") (ti-menu-load-string "file/read-profile D:\Model1\q.prof")) ; read q" profile (if (file-exists? "D:\Model1\q.prof") (ti-menu-load-string "solve/dual-time-iterate 1 10000")) ; iterate (if (file-exists? "D:\Model1\q.prof") (ti-menu-load-string "file/write-profile T.prof wall_coupling () temperature ()")) ; write T profile (if (file-exists? "D:\Model1\q.prof") (set! nit (+ nit 1))) ; counter (if (file-exists? "D:\Model1\q.prof") (system "del D:\Model1\q.prof")) ; delete q" profile (if (= nit 5) (cx-interrupt)) ; interrupt Fluent after max number of iteration ;(if (= nit 5) (cx-exit)) ; exit Fluent after max number of iteration ; ; pause in order to control the search interval (cx-pause 1) (loop)) Last edited by macfly; May 14, 2013 at 10:28. |
|
May 14, 2013, 09:33 |
|
#10 |
New Member
rayolau
Join Date: Aug 2012
Posts: 23
Rep Power: 14 |
Hi macfly!
The algorithm I has been very helpful. But I have a question, in case you want to exchange more than one profile, ie, that model 1 store q (heat-flux) and k (speed, for example) and the "else time step" expect the existence profiles of T (temperature) and P (pressure) of model 2, How do you write the two conditions? Does using &? something like this: Code:
(define nit 1) (let loop () ; 1st time step (if (= nit 1) (ti-menu-load-string "define/user-defined/interpreted-functions model1.c ""cpp"" 10000 no")) ; read some udf (if (= nit 1) (ti-menu-load-string "solve/initialize/hyb-initialization")) ; initialize (if (= nit 1) (ti-menu-load-string "solve/dual-time-iterate 1 10000")) ; iterate (if (= nit 1) (ti-menu-load-string "file/write-profile q.prof wall_coupling () heat-flux ()")) ; write q" profile (if (= nit 1) (ti-menu-load-string "file/write-profile k.prof wall_coupling () velocity magnitude ()")) ; write k" profile (if (= nit 1) (set! nit (+ nit 1))) ; counter ; ; else time steps, conditional to existence of T profile from Model 2 (if (file-exists? "D:\Model2\T.prof") (ti-menu-load-string "file/read-profile D:\Model2\T.prof")) ; read T profile (if (file-exists? "D:\Model2\P.prof") (ti-menu-load-string "file/read-profile D:\Model2\P.prof")) ; read P profile (if (file-exists? "D:\Model2\T.prof"&"D:\Model2\P.prof") (ti-menu-load-string "solve/dual-time-iterate 1 10000")) ; iterate ... (loop)) |
|
May 14, 2013, 09:43 |
|
#11 | |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
Quote:
I don't see any problem doing that, but it's not a 'AND', you just read both profiles before iterating. In the 'if (file-exists? ...)' commands, you can add a 3rd parenthese that does something if the file does not exist. I've never used boolean operators in Scheme and I'm not sure they exist. Last edited by macfly; May 14, 2013 at 10:29. |
||
May 20, 2013, 09:02 |
|
#12 |
New Member
rayolau
Join Date: Aug 2012
Posts: 23
Rep Power: 14 |
Hi macfly, thanks sharing your scheme file.
I have written my scheme file, based on its structure, with some changes in the order of execution, because I want that the interchange of profiles is occurring in each iteration, and for this, I suppress the loop, and put the file.scm into the Calculation activities --> Executed commands --> (ti-read-scheme) file.scm My scheme file for the model1 is the next: (I changed the name of the profiles and the path, for continue your coupling attachment as in the picture of post #1.) Model1 Code:
;First, delete the profile q.prof (if (file-exists? "D:\Model1\q.prof") (system "del D:\Model1\q.prof")) ; delete q.prof ;Second, read T profile (if (file-exists? "D:\Model2\T.prof") (ti-menu-load-string "file read-profile D:\Model2\T.prof")) ;Third, define boundary condition (if (file-exists? "D:\Model2\T.prof") (ti-menu-load-string "define/boundary-conditions/..."")) ;Fourth, save q.prof (ti-menu-load-string "file/write-profile q.prof wall_coupling () heat-flux ()") Code:
;First, delete the profile T.prof (if (file-exists? "D:\Model2\T.prof") (system "del D:\Model2\T.prof")) ; delete q.prof ;Second, read q profile (if (file-exists? "D:\Model1\q.prof") (ti-menu-load-string "file read-profile D:\Model2\q.prof")) ;Third, define boundary condition (if (file-exists? "D:\Model1\q.prof") (ti-menu-load-string "define/boundary-conditions/..."")) ;Fourth, save T.prof (ti-menu-load-string "file/write-profile q.prof wall_coupling () temperature ()") The problem is that in the second step (read q and T prof, in both schemes), is not suficient to waiting for the necessary profile, to continue calculating. For exemple, in model 1, if the T. prof profile does not exist, is not expected to be created, continues the scheme and give error. I think that I need write some sentence for the second and third step, that if not exists the necessary profile, wait to be created. I want write sentence if...else with a loop only for second and third steps, but I'm begginer in programming and I don't know how to do well. Any ideas? Thanks in advance, Laura. I attached a scheme of I would to this two steps. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
An error has occurred in cfx5solve: | volo87 | CFX | 5 | June 14, 2013 18:44 |
Error finding variable "THERMX" | sunilpatil | CFX | 8 | April 26, 2013 08:00 |
CFX13 Post Periodic interface | EtaEta | CFX | 7 | December 8, 2011 18:15 |
Solver error message!!! | IoSa | CFX | 1 | September 14, 2006 05:48 |
[Commercial meshers] Trimmed cell and embedded refinement mesh conversion issues | michele | OpenFOAM Meshing & Mesh Conversion | 2 | July 15, 2005 05:15 |