|
[Sponsors] |
![]() |
![]() |
#1 |
Member
Steven Taggart
Join Date: Jan 2014
Location: Hull, UK
Posts: 51
Rep Power: 9 ![]() |
Hello,
I am trying to construct a mass transfer UDF for use in Fluent and I am having mixed results. I have a function at the start to calculate the saturation pressure, the value of this should then be used in the mass transfer calculation, however I am uncertain how to call the saturation pressure into the mass transfer function. Could anyone give any pointers on the best way to do this? I have included the code below, highlighted is my (poor!) attempt at calling the value of the saturation pressure into the mass transfer calculation. Thanks! #include "udf.h" DEFINE_PROPERTY(psat,c,t) { real a[3] = {6.81228, 1301.679, -3.494}; real b[3] = {7.5322, 835.06, 268.223}; real Psat; real T = C_T(c,t); if (T <= 200) Psat = pow(10, a[0]-(a[1]/(T + a[2]))); else Psat = pow(10, b[0]-(b[1]/(T + b[2]))); return Psat; } DEFINE_MASS_TRANSFER(liq_gas_source, cell, thread, from_index,from_species_index, to_index, to_species_index) { real m_lg; real Tc = C_T(cell, thread); real Pc = C_P(cell, thread); real Tsat = 195; real Psat = psat; Thread *liq = THREAD_SUB_THREAD(thread, from_index); Thread *gas = THREAD_SUB_THREAD(thread, to_index); Tc = MAX(Tc, 273.15); m_lg = 0.; if (Pc <= Psat) { m_lg = 0.1*C_VOF(cell,liq)*C_R(cell,liq)*fabs(Tc-Tsat)/Tsat; } if ((m_lg == 0. ) && (Pc > Psat)) { m_lg = -0.1*C_VOF(cell,gas)*C_R(cell,gas)*fabs(Tsat-Tc)/Tsat; } return (m_lg); } |
|
![]() |
![]() |
![]() |
![]() |
#2 |
Member
Join Date: Sep 2016
Posts: 35
Rep Power: 6 ![]() |
you can define the psat before the define property function...just write real Psat after the #include "udf.h" line. You don't need to redefine it in the define property function...just assign the value to it
|
|
![]() |
![]() |
![]() |
![]() |
#3 |
Member
Steven Taggart
Join Date: Jan 2014
Location: Hull, UK
Posts: 51
Rep Power: 9 ![]() |
Hi Boh,
I am not sure I follow, I am using the define property function to calculate the Psat, how do I access this calculated Psat value in the define_mass_transfer function? Thanks for your time. Steven. |
|
![]() |
![]() |
![]() |
![]() |
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,676
Rep Power: 22 ![]() |
I think the following should work (perhaps after fixing some typos that I made, I did not test the code):
Code:
real my_psat(cell_t c,Thread *t) { real a[3] = {6.81228, 1301.679, -3.494}; real b[3] = {7.5322, 835.06, 268.223}; real Psat; real T = C_T(c,t); if (T <= 200) Psat = pow(10, a[0]-(a[1]/(T + a[2]))); else Psat = pow(10, b[0]-(b[1]/(T + b[2]))); return Psat; } DEFINE_PROPERTY(psat,c,t) { return(my_psat(c,t)); } DEFINE_MASS_TRANSFER(liq_gas_source, cell, thread, from_index,from_species_index, to_index, to_species_index) { real m_lg; real Tc = C_T(cell, thread); real Pc = C_P(cell, thread); real Tsat = 195; real Psat = my_psat(cell,thread); Thread *liq = THREAD_SUB_THREAD(thread, from_index); Thread *gas = THREAD_SUB_THREAD(thread, to_index); Tc = MAX(Tc, 273.15); m_lg = 0.; if (Pc <= Psat) { m_lg = 0.1*C_VOF(cell,liq)*C_R(cell,liq)*fabs(Tc-Tsat)/Tsat; } if ((m_lg == 0. ) && (Pc > Psat)) { m_lg = -0.1*C_VOF(cell,gas)*C_R(cell,gas)*fabs(Tsat-Tc)/Tsat; } return (m_lg); } |
|
![]() |
![]() |
![]() |
![]() |
#5 |
Member
Steven Taggart
Join Date: Jan 2014
Location: Hull, UK
Posts: 51
Rep Power: 9 ![]() |
Hi Pakk,
Thanks for your help, I will try that out. Steven |
|
![]() |
![]() |
![]() |
![]() |
#6 |
Member
Steven Taggart
Join Date: Jan 2014
Location: Hull, UK
Posts: 51
Rep Power: 9 ![]() |
Hello,
I used the code included below and it compiles fine but I have been getting errors when I initialise the simulation. I have included the error message below. From having a look online it seems to be a variable trying to access some information that is not available but I cant seem to work it out. #include "udf.h" real my_psat(cell_t c, Thread *t) { real a[3] = {6.81228, 1301.679, -3.494}; real b[3] = {7.5322, 835.06, 268.223}; real Psat; real T = C_T(c,t); if (T <= 200) Psat = pow(10, a[0]-(a[1]/(T + a[2]))); else Psat = pow(10, b[0]-(b[1]/(T + b[2]))); return Psat; } DEFINE_PROPERTY(Psat,c,t) { return (my_psat(c,t)); } DEFINE_MASS_TRANSFER(liq_gas_source, cell, thread, from_index,from_species_index, to_index, to_species_index) { real m_lg; real Tc = C_T(cell, thread); real Pc = C_P(cell, thread); real Psat = my_psat(cell, thread); real Tsat = 195; Thread *liq = THREAD_SUB_THREAD(thread, from_index); Thread *gas = THREAD_SUB_THREAD(thread, to_index); m_lg = 0.; if (Pc <= Psat) { m_lg = 0.1*C_VOF(cell,liq)*C_R(cell,liq)*fabs(Tc-Tsat)/Tsat; } if ((m_lg == 0. ) && (Pc > Psat)) { m_lg = -0.1*C_VOF(cell,gas)*C_R(cell,gas)*fabs(Tsat-Tc)/Tsat; } return (m_lg); } ================================================== ============================ Node 0: Process 564: Received signal SIGSEGV. ================================================== ============================ ================================================== ============================ Node 1: Process 4352: Received signal SIGSEGV. ================================================== ============================ ================================================== ============================ Node 2: Process 6456: Received signal SIGSEGV. ================================================== ============================ ================================================== ============================ Node 3: Process 8004: Received signal SIGSEGV. ================================================== ============================ MPI Application rank 0 exited before MPI_Finalize() with status 2 The fl process could not be started. |
|
![]() |
![]() |
![]() |
![]() |
#7 |
Senior Member
Join Date: Nov 2013
Posts: 1,676
Rep Power: 22 ![]() |
Try to initialize without the UDF.
|
|
![]() |
![]() |
![]() |
![]() |
#8 |
Member
Steven Taggart
Join Date: Jan 2014
Location: Hull, UK
Posts: 51
Rep Power: 9 ![]() |
Hi Pakk,
I tried initializing without the UDF and it works fine but as soon as I turn on the UDF (either at the start or after some iterations) I get the same error. Steven |
|
![]() |
![]() |
![]() |
![]() |
#9 |
Member
Steven Taggart
Join Date: Jan 2014
Location: Hull, UK
Posts: 51
Rep Power: 9 ![]() |
Hi Pakk,
Its the temperature macro in the first routine that seems to be causing the problem. If I assign a value to the temperature everything is fine but if I try and access the cell temperature through C_T(c,t) I run in to problems. Am I accessing the cell temperature in the correct way? |
|
![]() |
![]() |
![]() |
![]() |
#10 |
Member
Join Date: Sep 2016
Posts: 35
Rep Power: 6 ![]() |
Sorry I misunderstood your question....anyway I found this 2 UDF that I think will help you:
http://users.ugent.be/~mvbelleg/case...sflux_source.c http://users.ugent.be/~mvbelleg/case...D/Parameters.c I think you're trying to do something similar (same approach suggested by Pakk) |
|
![]() |
![]() |
![]() |
![]() |
#11 |
Senior Member
Join Date: Nov 2013
Posts: 1,676
Rep Power: 22 ![]() |
At the location where you are asking Fluent to calculate psat, is the temperature defined there? (Are you solving the energy equation?)
|
|
![]() |
![]() |
![]() |
![]() |
#12 |
Member
Steven Taggart
Join Date: Jan 2014
Location: Hull, UK
Posts: 51
Rep Power: 9 ![]() |
Thanks for them Boh, I will have a look through them tonight.
Pak, yes I have the energy equation on, I moved the psat routine to inside the mass flow rate routine and it seems to access the temperature fine. This may be a solution but I would like to work out why I cant do it as originally intended as I would like to keep both calculations separate. Steven |
|
![]() |
![]() |
![]() |
![]() |
#13 |
Senior Member
Join Date: Nov 2013
Posts: 1,676
Rep Power: 22 ![]() |
Oh, then I think it is very possible that I made a mistake with pointer grammar.
Maybe the proper grammar is: Code:
real my_psat(cell_t c, Thread *t) { ... real T = C_T(c,*t); I make more mistakes with this than I like to admit... |
|
![]() |
![]() |
![]() |
Tags |
mass transfer, saturation |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
using define mass transfer udf for cavitation | Komon | Fluent UDF and Scheme Programming | 14 | June 21, 2016 03:50 |
udf source code for modelling mass transfer during film boiling | vinita123 | Fluent UDF and Scheme Programming | 0 | December 22, 2015 09:43 |
transient mass transfer in multiphase flow | Tensian | Fluent UDF and Scheme Programming | 0 | November 16, 2015 11:39 |
Question about heat transfer coefficient setting for CFX | Anna Tian | CFX | 1 | June 16, 2013 07:28 |
I need UDF help. | S.Whitney | FLUENT | 0 | October 15, 2007 12:29 |