|
[Sponsors] |
Accessing phase volm fraction in UDF for a source term in mixture model |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 19, 2013, 08:54 |
Accessing phase volm fraction in UDF for a source term in mixture model
|
#1 |
New Member
Aditya Pandare
Join Date: Aug 2012
Location: Pune, India
Posts: 20
Rep Power: 14 |
Hello
I am trying to simulate cavitation using a UDF for the source term of vapor phase in the mixture model. I am having trouble accessing the volume fraction of the secondary phase. this is the UDF I wrote. I am new to UDFs, so please help me. #include "udf.h" DEFINE_SOURCE(re,c,t,dS,eqn) { real source, prsr, alpha, pv, zoneid; zoneid = 11; Thread *mixture_thread = Lookup_Thread(domain,zid); Thread **pt; pt = THREAD_SUB_THREADS(mixture_thread); prsr = C_P(c,t); alpha = C_VOF(c,pt[3]); pv = -97000; source = 0.02 * (sqrt((2/3)*(pv - prsr)/998.2)) * (1-alpha) * 998.2 * 0.5542 / 0.0717; dS[eqn] = - 0.02 * (sqrt((2/3)*(pv - prsr)/998.2)) * 998.2 * 0.5542 / 0.0717; return source; } It gives a parse error for the 2 lines beginning with "Thread" Any help in understanding the working of the THREAD syntaxes! |
|
March 19, 2013, 09:53 |
|
#2 | |
Member
Li Huang
Join Date: Jan 2011
Posts: 30
Rep Power: 15 |
What are the error messages exactly?
I had a quick look at your code. It seems to me that you have "domain" undefined, which normally is 1. What operating system are you using? To my experience, if you are under windows, most likely you have to declare all you local variables at top, for example, before the line "zoneid = 11;" in your code. If you are under Linux, this does not matter. Good luck Quote:
|
||
March 19, 2013, 10:16 |
|
#3 |
Senior Member
Paritosh Vasava
Join Date: Oct 2012
Location: Lappeenranta, Finland
Posts: 732
Rep Power: 23 |
Shouldn't you use 'zoneid' instead of 'zid' in the line 'Thread *mixture_thread = Lookup_Thread(domain,zid);' ??
|
|
March 19, 2013, 10:27 |
|
#4 |
New Member
Aditya Pandare
Join Date: Aug 2012
Location: Pune, India
Posts: 20
Rep Power: 14 |
@lihuang: The messages are: "error: line no.: parse error."
I am using 32bit windows 7. But I have declared those in the "real......" line, right? Actually since I am new to UDFs, I do not know how to define the domain. Could you help me do that? How is the domain defined? what is the syntax? @vasava: yes I should. I have made that change. Thank you both for your quick replies! |
|
March 19, 2013, 14:36 |
|
#5 | |
Member
Li Huang
Join Date: Jan 2011
Posts: 30
Rep Power: 15 |
Quote:
While using Lookup_Thread, you need to know what kind of "domain" you are looking at. There are three kinds: Mixture domain, sub-domain (phase domains), and interaction domain. For mixture domain, domainID=1; for phase domains, domainID can be found in the Phase Panel in Fluent. Good luck |
||
March 20, 2013, 00:10 |
|
#6 |
New Member
Aditya Pandare
Join Date: Aug 2012
Location: Pune, India
Posts: 20
Rep Power: 14 |
Thank you for your help! But i am still facing problems in that UDF.
I moved the two lines up before the "zoneid=11" line; but it still gives me a "parse error" in the "Thread *mixture_thread;" line. Also, If i move the "Thread *mixture_thread = Lookup_Thread(domain,zoneid);" line before the "zoneid = 11;" line, how will it know the zoneid to use in the Lookup thread command? Another question: i am "interpreting" this udf file; does that make any difference? yes I have looked up the zone-ID in the phases dialog box. but here; the "lookup_thread"is used to define the mixture thread; so I am using the zone-ID from the BC dialog box. Is this correct? I am using this mixture-thread to define the "pt" with the "thread_sub_threads". This is how I used the UDF with the corrections you told me: #include "udf.h" DEFINE_SOURCE(re,c,t,dS,eqn) { real source, prsr, alpha, pv, zoneid; Thread *mixture_thread; Thread **pt; zoneid = 11; Thread *mixture_thread = Lookup_Thread(domain,zoneid); pt = THREAD_SUB_THREADS(mixture_thread); prsr = C_P(c,t); alpha = C_VOF(c,pt[3]); pv = -97000; source = 0.02 * (sqrt((2/3)*(pv - prsr)/998.2)) * (1-alpha) * 998.2 * 0.5542 / 0.0717; dS[eqn] = - 0.02 * (sqrt((2/3)*(pv - prsr)/998.2)) * 998.2 * 0.5542 / 0.0717; return source; } Please help! |
|
March 20, 2013, 00:29 |
|
#7 | |
Member
Li Huang
Join Date: Jan 2011
Posts: 30
Rep Power: 15 |
Quote:
#include "udf.h" DEFINE_SOURCE(re,c,t,dS,eqn) { real source, prsr, alpha, pv; Thread *mixture_thread; Thread **pt; Domain *domain; /* domain is declared as a variable */ int zoneid = 11; domain = Get_Domain(1); /* returns fluid domain pointer */ mixture_thread = Lookup_Thread(domain,zoneid); pt = THREAD_SUB_THREADS(mixture_thread); prsr = C_P(c,t); alpha = C_VOF(c,pt[3]); pv = -97000; source = 0.02 * (sqrt((2/3)*(pv - prsr)/998.2)) * (1-alpha) * 998.2 * 0.5542 / 0.0717; dS[eqn] = - 0.02 * (sqrt((2/3)*(pv - prsr)/998.2)) * 998.2 * 0.5542 / 0.0717; return source; } Try this. It compiles fine under windows 7. I don't think the interpreting approach plays a role here. It should be the same. Good luck! |
||
March 20, 2013, 00:47 |
|
#8 |
New Member
Aditya Pandare
Join Date: Aug 2012
Location: Pune, India
Posts: 20
Rep Power: 14 |
Although the UDF interpretation showed no errors (like "parse error in lines" which were showing in my UDF!); Fluent shows "FATAL_ERROR: access violation" when i run the case after loading the UDF.
Im probably stating this again; but for the sake of clarity: 1. 11 is the ID of the internal fluid in the BC dialog box (used as zone-id in Lookup_thread) 2. 3 is the ID of the secondary phase in the phase dialog box (used in C_VOF) (my case has 2 phases, primary and secondary) is this correct? I also call your attention to the "alpha = C_VOF(c,pt[3]);" line. is this correct? Thank you! |
|
March 20, 2013, 09:56 |
|
#9 | |
Member
Li Huang
Join Date: Jan 2011
Posts: 30
Rep Power: 15 |
Quote:
I think you are doing right on No. 1. But for No. 2, primary phase thread index=0, first secondary phase thread index=1, second secondary phase thread index=2, and so on. So in your case, you should try "alpha = C_VOF(c,pt[1]);". Let me know how it goes. If it does not solve your problem, you probably need to explain more about what you want to do with your case and the UDF. |
||
March 21, 2013, 00:38 |
|
#10 |
New Member
Aditya Pandare
Join Date: Aug 2012
Location: Pune, India
Posts: 20
Rep Power: 14 |
Yes, that is okay. Thats why I replied late as well.
I realised that since I was hooking my source term to the vapor equation, the thread "t" corresponded to the vapor phase itself. So I did not need to create a separate pointer for that. so C_VOF(c,t) worked okay. What I needed to do was create a pointer for the mixture phase; which I did following your instructions: Domain *domain; int zoneid = 11; domain = Get_Domain(1); mixture_thread = Lookup_Thread(domain,zoneid); prsr = C_P(c,mixture_thread); this worked well. Thank you very much for your help!! I am grateful. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Error message: Insufficient Catalogue Size | Paresh Jain | CFX | 33 | August 16, 2024 06:09 |
UDF source term | jerome_ | FLUENT | 2 | July 11, 2011 12:55 |
A question about UDF utility in mixture and multiphase model | aleisia | Fluent UDF and Scheme Programming | 0 | June 7, 2011 17:32 |
gradient source term UDF | ak6g08 | Fluent UDF and Scheme Programming | 0 | July 9, 2009 07:37 |
UDF Source Term Units? | Brian | FLUENT | 1 | October 24, 2005 10:15 |