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

UDF for capillary driven flow in porous media

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By sshivam8172
  • 1 Post By vinerm

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 4, 2020, 14:38
Exclamation UDF for capillary driven flow in porous media
  #1
New Member
 
Shivam Salokhe
Join Date: Jun 2020
Posts: 10
Rep Power: 6
sshivam8172 is on a distinguished road
Hello Everyone,

I am trying to simulate the capillary driven flow in porous media using VOF model. I have considered an upward wicking case where the capillary force acts in the opposite direction to the gravitational force. This capillary force is the only force that pulls liquid up. The inlet and outlet boundary conditions are atmospheric pressure conditions. I have developed the following code to add capillary force to the secondary phase-only but I not getting satisfactory results. any suggestions will be very helpful.
The code interprets with no errors. I don't see any changes in liquid volume fractions



#include "udf.h"

#define AIR_PHASE_ID 2 /*primary phase*/
#define LIQUID_PHASE_ID 3 /*secondary phase*/

#define POROUS_CELL_ZONE_ID 2 /*cell zone ID*/

#define C_CAPILLARY_MOM_SOURCE_X(C,T) C_UDMI(C,T,0)
#define C_CAPILLARY_MOM_SOURCE_Y(C,T) C_UDMI(C,T,1)
#define C_CAPILLARY_MOM_SOURCE_Z(C,T) C_UDMI(C,T,2)
#define CAPILLARY_PRESSURE 12.35 /* 2.gamma.cos(theta)/R */

real area_factor(real volume, real vof)
{
real factor;

factor = pow(volume, 2.0 / 3.0);
factor *= 1.0 - 4.0*(vof - 0.5)*(vof - 0.5); /* = 1.0 at VOF=0.5, 0.0 at VOF = 0.0 or 1.0 */

return factor;
}

void set_capillary_pressure_sources(Thread *lct, real *direction)
{
cell_t c;
real vol;
real capillary_force;

begin_c_loop(c, lct)
{
vol = C_VOLUME(c, lct);

capillary_force = CAPILLARY_PRESSURE * area_factor(vol, C_VOF(c, lct)) / vol; /*source term with unit N/m3*/

ND_VS(C_CAPILLARY_MOM_SOURCE_X(c, lct), C_CAPILLARY_MOM_SOURCE_Y(c, lct), C_CAPILLARY_MOM_SOURCE_Z(c, lct), =, direction, *, capillary_force);
}
end_c_loop(c, lct)
}
DEFINE_ADJUST(capillary_sources, mixture_domain)
{
Domain *liquid_domain;
Domain *air_domain;
Thread *lct;
Thread *act;
real capillary_direction[ND_ND];

liquid_domain = Get_Domain(LIQUID_PHASE_ID);
air_domain = Get_Domain(AIR_PHASE_ID);


printf("Setting sources in the domain");

lct = Lookup_Thread(liquid_domain, POROUS_CELL_ZONE_ID);
act = Lookup_Thread(air_domain, POROUS_CELL_ZONE_ID);

NV_D(capillary_direction, =, 1.0, 1.0, 0.0);
set_capillary_pressure_sources(lct, capillary_direction);

printf("Done.\n");
}

DEFINE_SOURCE(caplillary_mom_x_source, c, ct, ds, eqn)
{
return C_CAPILLARY_MOM_SOURCE_X(c, ct);
}

DEFINE_SOURCE(caplillary_mom_y_source, c, ct, ds, eqn)
{
return C_CAPILLARY_MOM_SOURCE_Y(c, ct);
}

DEFINE_SOURCE(caplillary_mom_z_source, c, ct, ds, eqn)
{
return C_CAPILLARY_MOM_SOURCE_Z(c, ct);
}
Wyj likes this.
sshivam8172 is offline   Reply With Quote

Old   June 4, 2020, 17:06
Default Udm
  #2
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
You are defining sources using UDMs but what is contained in those memories? No where in the code are any values being assigned to UDMs. So, the sources are 0.
sshivam8172 likes this.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   June 5, 2020, 08:19
Default
  #3
New Member
 
Shivam Salokhe
Join Date: Jun 2020
Posts: 10
Rep Power: 6
sshivam8172 is on a distinguished road
Yes, I did not realize this before. Could you suggest some corrections in the code? I created this code by modifying the previous codes available.

Thanks
Shivam
sshivam8172 is offline   Reply With Quote

Old   June 5, 2020, 09:38
Default Code
  #4
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
To help you, I need to know what is it that you want to do, what is the objective of the code. As of now, there are redundancies in the code. UDMs may not even be required. Two functions have been written outside DEFINE_ macros, however, only called once. That makes it difficult instead of being easier to read.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   June 5, 2020, 10:09
Default
  #5
New Member
 
Shivam Salokhe
Join Date: Jun 2020
Posts: 10
Rep Power: 6
sshivam8172 is on a distinguished road
I am trying to simulate the upward wicking flow in porous media. To do so, I am using the VOF method. The inlet and outlet both have atmospheric pressure conditions. The action of gravity is in negative y-direction. So the main mechanism for flow is the capillary action. The main objective of this code is to add a positive momentum source to the secondary phase which is based on the capillary force.

Hope this helps
sshivam8172 is offline   Reply With Quote

Old   June 5, 2020, 10:19
Default UDMs
  #6
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
Replace all components of C_CAPILLARY_MOM_SOURCE_X(c, lct) in ND_VS function with three C_UDMIs.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   June 5, 2020, 10:29
Default
  #7
New Member
 
Shivam Salokhe
Join Date: Jun 2020
Posts: 10
Rep Power: 6
sshivam8172 is on a distinguished road
line 35 - ND_VS(C_UDMI(C,T,0), C_UDMI(C,T,1), C_UDMI(C,T,2), =, direction, *, capillary_force);

I replaced it but fluent shows following error,

line 35: T: undeclared variable.

So I changed, t with lct everywhere. The code does not show any errors related to syntax.
When I hook UDF as follows -
Define adjust- capillary_sources
user defined memory locations - 5
y momentum source in cell zone conditions - caplillary_mom_y_source.

I dont see any variation in liquid volume fraction.
sshivam8172 is offline   Reply With Quote

Old   June 5, 2020, 11:54
Default Source Terms
  #8
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
If you are hooking these as momentum sources, then there won't be any effect on the volume fraction. The sources will only affect the flow.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   June 5, 2020, 12:05
Default
  #9
New Member
 
Shivam Salokhe
Join Date: Jun 2020
Posts: 10
Rep Power: 6
sshivam8172 is on a distinguished road
Okay. Can you suggest any method so that I get it working?
sshivam8172 is offline   Reply With Quote

Old   June 5, 2020, 12:07
Default Flow and Volume Fraction
  #10
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
As per your objective, you need to add momentum so that the liquid moves. That part is being done by your code. However, the issue you are reporting is related to volume fraction. The UDF you have will not affect the volume fraction.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   June 5, 2020, 12:16
Default
  #11
New Member
 
Shivam Salokhe
Join Date: Jun 2020
Posts: 10
Rep Power: 6
sshivam8172 is on a distinguished road
Okay. Yeah, that right. Do you have any suggestions on which logic should I be using that causes the secondary liquid to pump up according to capillary pressure?

It will be helpful to have your comments on this?

Thanks
Shivam
sshivam8172 is offline   Reply With Quote

Old   June 5, 2020, 16:56
Default Capillary Force
  #12
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
The code that you have should work after the modifications suggested, provided you hook it at right place. All the source UDFs must be hooked in the Cell Zones to the corresponding fields, i.e., momentum fields. If the source values are non-zero, then you should see its effects. To check, you can plot UDMs and see if the values are non-zero. For z-momentum, the values would be 0.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   June 8, 2020, 11:12
Default
  #13
New Member
 
Shivam Salokhe
Join Date: Jun 2020
Posts: 10
Rep Power: 6
sshivam8172 is on a distinguished road
Ok thanks, I will try to run simulation to see why it is happening.
sshivam8172 is offline   Reply With Quote

Old   June 8, 2020, 14:06
Default
  #14
New Member
 
Shivam Salokhe
Join Date: Jun 2020
Posts: 10
Rep Power: 6
sshivam8172 is on a distinguished road
Hello, I did a simulation by specifying the smaller amount for the initial liquid volume fraction with the modified UDF. Now I can see the change in liquid volume fraction. Thanks for the suggestion that you provided.

I even tried simulating the case using original UDF that also worked fine but the variation in liquid volume fraction w.r.t time is very fast than modified UDF (modified UDF results are logically correct). I am curious about, how should I make sure that the momentum source is being attached to the secondary phase (liquid) only.? When I plot UDM in XY plot, I only see 0 value.

Thanks.
Shivam
sshivam8172 is offline   Reply With Quote

Old   June 15, 2020, 05:26
Default Momentum Source
  #15
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
Since you are using VOF, there is only one momentum equation; not two separate equations for two phases. To ensure that the momentum is added only within the liquid phase, just multiply the source with the volume fraction of liquid phase.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   June 16, 2020, 13:48
Default
  #16
New Member
 
Shivam Salokhe
Join Date: Jun 2020
Posts: 10
Rep Power: 6
sshivam8172 is on a distinguished road
Thanks for the reply. Yes, only a single set of momentum equations is solved for the VOF model. However, I did not get why I need to multiply source term with volume fraction. could explain it in few words??

Best,
Shivam
sshivam8172 is offline   Reply With Quote

Old   June 16, 2020, 14:07
Default
  #17
New Member
 
Join Date: Apr 2020
Posts: 3
Rep Power: 6
Zahra99 is on a distinguished road
Hi
This so good and perfect, I used it.
Thank you very much for your helps and guides.

chiropractic
Zahra99 is offline   Reply With Quote

Old   June 16, 2020, 14:51
Default
  #18
New Member
 
Shivam Salokhe
Join Date: Jun 2020
Posts: 10
Rep Power: 6
sshivam8172 is on a distinguished road
can you explain the problem that you are trying to simulate?
sshivam8172 is offline   Reply With Quote

Old   June 16, 2020, 15:32
Default Weightage
  #19
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
Volume fraction is being used as weight. Source will have a non-zero value only if volume fraction is greater than 0, otherwise, it will be 0.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   October 4, 2020, 04:27
Default
  #20
Wyj
New Member
 
李正
Join Date: Apr 2020
Posts: 7
Rep Power: 6
Wyj is on a distinguished road
I like this post very much, I hope the host can share more, thank you

Last edited by Wyj; October 5, 2020 at 22:57.
Wyj is offline   Reply With Quote

Reply

Tags
fluent - udf, multiphase flows, porous media model, udf capillary force


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
A solver for two-phase flow with a porous media enoch OpenFOAM Programming & Development 6 October 10, 2022 10:11
Capillary driven flow through porous media alexlpn Fluent Multiphase 1 October 8, 2019 08:18
Flow through two combined porous media with diffrent permeability Sandee Main CFD Forum 0 March 28, 2015 11:35
Flow through porous media near well-borne I_Fedorov FLUENT 0 October 29, 2014 16:05
How to model granular flow through porous media Axius FLUENT 2 August 7, 2014 11:34


All times are GMT -4. The time now is 17:55.