|
[Sponsors] |
how to define fluctuating volume fraction at inlet |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 11, 2015, 05:15 |
how to define fluctuating volume fraction at inlet
|
#1 |
New Member
ZHAO Yuqaio
Join Date: Apr 2011
Posts: 8
Rep Power: 15 |
Guys, thank you for spending time on this post!
I really need some help from you guys! I'm currently trying to simulate a 2-phase pipe flow. I'm trying to set the 2-phase inlet with fluctuating air volume fraction, something like: from 0 to 1 sec ------> air volume fraction = 0.2 + 0.2*t from 1 to 2 sec ------> air volume fraction = 0.4 - 0.2*t Could I know how to write a udf to control that? I've tried the following code similar to what I did for fluctuating velocity: #include "udf.h" DEFINE_PROFILE(volume_fraction, thread, position) { real t, v_f; face_t f; begin_f_loop(f,thread) { t = RP_Get_Real("flow-time"); { if(t>0 && t<=1) { v_f = 0.2 + 0.2*t; } else if(t>1 &&t<=2) { v_f = 0.4 - 0.2*t; } } F_PROFILE(f,thread,position) = v_f; } end_f_loop(f,thread) } However, I'm getting error message as follows: error C2223: left of '-> nelements' must point to struct/union error C2223: left of '-> storage' must point to struct/union Can anyone please help me on this? Thank you so much! I'm a newbee in udf. Have a nice day guys! |
|
March 11, 2015, 05:53 |
|
#2 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
Did the fluctuating velocity DEFINE_PROFILE UDF work, and can you provide the code?
Also, try to stay consistent with naming variables such as DEFINE_PROFILE(volume_fraction, t, i). You may trip the compiler and/or solver up, if for example thread or position were special variables or functions used by Fluent. |
|
March 12, 2015, 02:19 |
|
#3 |
New Member
ZHAO Yuqaio
Join Date: Apr 2011
Posts: 8
Rep Power: 15 |
Thanks for the reply!
It works for fluctuating velocity. The code is as follows: #include "udf.h" DEFINE_PROFILE(inlet_velocity, thread, position) { real t, v; face_t f; begin_f_loop(f,thread) { t = RP_Get_Real("flow-time"); { if(t>0 && t<=1) { v = 1.5 + 1.5*t; } else if(t>1 &&t<=2) { v_f = 3 - 1.5*t; } } F_PROFILE(f,thread,position) = v; } end_f_loop(f,thread) } It works pretty well. Let me try with renaming the variables. Thanks a lot! |
|
March 12, 2015, 04:07 |
|
#4 | |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Quote:
|
||
March 12, 2015, 22:20 |
|
#5 |
New Member
ZHAO Yuqaio
Join Date: Apr 2011
Posts: 8
Rep Power: 15 |
||
March 12, 2015, 22:35 |
|
#6 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
The UDF doesn't appear to have any obvious errors, which leaves the implementation. Are you sure you're compiling and hooking the UDF correctly (same way as the velocity b.c.)?
|
|
March 12, 2015, 22:49 |
|
#7 | |
New Member
ZHAO Yuqaio
Join Date: Apr 2011
Posts: 8
Rep Power: 15 |
Quote:
I was unable to compile the udf. It kept showing me the error message: error C2223: left of '-> nelements' must point to struct/union error C2223: left of '-> storage' must point to struct/union and "...The UDF library you are trying to load (libudf) is not compiled for 2d on the curent platform (win64)..." I couldn't hook the udf to fluent. |
||
March 12, 2015, 23:08 |
|
#8 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
I'm wondering if it's something to do with the variable names. Try renaming the DEFINE_PROFILE variables as I suggested earlier and rename 't' to 'myTime' or something to make absolutely sure that Fluent isn't trying to use these variables for another purpose.
If that fails, then I suppose try stripping back the code to the very basics (no time dependency, constant value etc) to see which line is causing you grief because the error is not providing a line number to work from. |
|
March 13, 2015, 05:29 |
|
#9 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
And please be sure that you copied the right code here. (The code that gives the errors.)
The code that worked that you put here had a typo. How can that happen, when you copy-paste? I am not trying to annoy you, but please make sure the code we are looking at is the correct code, and has no typos. |
|
March 16, 2015, 00:53 |
|
#10 | |
New Member
ZHAO Yuqaio
Join Date: Apr 2011
Posts: 8
Rep Power: 15 |
Quote:
I managed to use "profile file" instead of using udf. I found profile is slightly simpler to use, just a bit tedious. Need to manually type all the time instance. |
||
March 16, 2015, 01:03 |
|
#11 | |
New Member
ZHAO Yuqaio
Join Date: Apr 2011
Posts: 8
Rep Power: 15 |
Quote:
|
||
April 7, 2017, 11:04 |
|
#12 |
New Member
Bahador
Join Date: Jun 2016
Posts: 3
Rep Power: 10 |
Sorry, I thought i knew the problem.
|
|
Tags |
fluctuating flow, udf |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Other] mesh airfoil NACA0012 | anand_30 | OpenFOAM Meshing & Mesh Conversion | 13 | March 7, 2022 18:22 |
volume fraction = nan | Virtual-iCFD | OpenFOAM Running, Solving & CFD | 8 | June 12, 2015 19:15 |
How to define the phase volume fraction in CEL expression | huangxianbei | CFX | 1 | November 1, 2013 05:24 |
mpirun interFoam very stable --> then blows up | ghadab | OpenFOAM Running, Solving & CFD | 3 | October 27, 2013 11:34 |
Estimation of "inlet solid volume fraction"...? | Genanry | FLUENT | 1 | February 15, 2007 11:29 |