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

2 separated 3D models : 2 way coupling at a boundary?

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree2Likes
  • 1 Post By diamondx
  • 1 Post By diamondx

Reply
 
LinkBack Thread Tools Display Modes
Old   May 11, 2013, 11:52
Default 2 separated 3D models : 2 way coupling at a boundary?
  #1
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Laval University, Canada
Posts: 366
Rep Power: 9
macfly is on a distinguished road
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
Attached Images
File Type: jpg two-way-coupling.jpg (15.4 KB, 29 views)

Last edited by macfly; May 11, 2013 at 12:11.
macfly is offline   Reply With Quote

Old   May 11, 2013, 17:44
Default
  #2
Super Moderator
 
diamondx's Avatar
 
Ghazlani M. Ali
Join Date: May 2011
Location: Canada
Posts: 1,291
Blog Entries: 23
Rep Power: 20
diamondx will become famous soon enough
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
Far likes this.
__________________
Regards,
New to ICEM CFD, try this document --> http://goo.gl/G2gkE
Ali
diamondx is offline   Reply With Quote

Old   May 12, 2013, 12:42
Default
  #3
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Laval University, Canada
Posts: 366
Rep Power: 9
macfly is on a distinguished road
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?
macfly is offline   Reply With Quote

Old   May 13, 2013, 06:36
Default
  #4
New Member
 
rayolau
Join Date: Aug 2012
Posts: 23
Rep Power: 5
rayolau is on a distinguished road
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!
rayolau is offline   Reply With Quote

Old   May 13, 2013, 08:15
Default
  #5
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Laval University, Canada
Posts: 366
Rep Power: 9
macfly is on a distinguished road
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
macfly is offline   Reply With Quote

Old   May 13, 2013, 10:23
Default
  #6
Super Moderator
 
diamondx's Avatar
 
Ghazlani M. Ali
Join Date: May 2011
Location: Canada
Posts: 1,291
Blog Entries: 23
Rep Power: 20
diamondx will become famous soon enough
@macfly... what conference you attending ? the combustion institute ?
__________________
Regards,
New to ICEM CFD, try this document --> http://goo.gl/G2gkE
Ali
diamondx is offline   Reply With Quote

Old   May 13, 2013, 10:33
Default
  #7
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Laval University, Canada
Posts: 366
Rep Power: 9
macfly is on a distinguished road
right on Ali
macfly is offline   Reply With Quote

Old   May 13, 2013, 10:40
Default
  #8
Super Moderator
 
diamondx's Avatar
 
Ghazlani M. Ali
Join Date: May 2011
Location: Canada
Posts: 1,291
Blog Entries: 23
Rep Power: 20
diamondx will become famous soon enough
I'm in the process of making a badge for you... haha
Far likes this.
__________________
Regards,
New to ICEM CFD, try this document --> http://goo.gl/G2gkE
Ali
diamondx is offline   Reply With Quote

Old   May 13, 2013, 20:05
Default
  #9
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Laval University, Canada
Posts: 366
Rep Power: 9
macfly is on a distinguished road
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 09:28.
macfly is offline   Reply With Quote

Old   May 14, 2013, 08:33
Default
  #10
New Member
 
rayolau
Join Date: Aug 2012
Posts: 23
Rep Power: 5
rayolau is on a distinguished road
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))
Thanks!!
rayolau is offline   Reply With Quote

Old   May 14, 2013, 08:43
Default
  #11
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Laval University, Canada
Posts: 366
Rep Power: 9
macfly is on a distinguished road
Quote:
Originally Posted by rayolau View Post
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:

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 09:29.
macfly is offline   Reply With Quote

Old   May 20, 2013, 08:02
Default
  #12
New Member
 
rayolau
Join Date: Aug 2012
Posts: 23
Rep Power: 5
rayolau is on a distinguished road
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 ()")
Model2
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 ()")
For folders, q and T are initial profiles, so they can be eliminated.

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.
rayolau is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
An error has occurred in cfx5solve: volo87 CFX 5 June 14, 2013 17:44
Error finding variable "THERMX" sunilpatil CFX 8 April 26, 2013 07:00
CFX13 Post Periodic interface EtaEta CFX 7 December 8, 2011 18:15
Solver error message!!! IoSa CFX 1 September 14, 2006 04:48
Trimmed cell and embedded refinement mesh conversion issues michele OpenFOAM Other Meshers: ICEM, Star, Ansys, Pointwise, GridPro, Ansa, ... 2 July 15, 2005 04:15


All times are GMT -4. The time now is 00:52.