CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Including source term into energy equation - Eulerian Multiphase (https://www.cfd-online.com/Forums/fluent-udf/136322-including-source-term-into-energy-equation-eulerian-multiphase.html)

DudaAPD May 26, 2014 16:22

Including source term into energy equation - Eulerian Multiphase
 
Hi all,

I am trying to include the term V.Grad[P] --> (u.dp/dx + y.dp/dy) as a source into the energy equation when solving with Eulerian Multiphase model. I am a newbie to UDFs, hence any help is well apreciated :D

So far I came up with the following (considering that once I have something working I will still need to implement it in parallel):

Code:

#include "udf.h"
#include "mem.h"
#include "sg_mphase.h"

DEFINE_SOURCE (VGradP, c, t, dS, eqn)
{
  Thread *thread_gas, *thread_liq, *superthread;
  Thread *mix_thread=THREAD_SUPER_THREAD(superthread);
  real source, x_liq_vel, x_gas_vel, y_liq_vel, y_gas_vel;
  real p_op;

  thread_liq = THREAD_SUB_THREAD(mix_thread,0);
  thread_gas = THREAD_SUB_THREAD(mix_thread,1);

  x_liq_vel = C_U(c,thread_liq);
  y_liq_vel = C_V(c,thread_liq);
  x_gas_vel = C_U(c,thread_gas);
  y_gas_vel = C_V(c,thread_gas);
  dS[eqn] = 0;

  if (NNULLP (THREAD_STORAGE(t,SV_P_G)))
 
  source = x_liq_vel*C_P_G(c,thread_liq)[0] + y_liq_vel*C_P_G(c,thread_liq)[1];
  return source;
}

The case is 2D, axi-symetric, pipe for Liquid with constant density or compressible liquid (primary phase) and compressible gas (ideal gas or another real gas model) as secondary phase.

Since I have a compressible gas, Fluent tells me to use the operating density with value = 0, so that it calculates the densities with the real Absolute Pressure, i.e. it won't subtract the column pressure g*Rho_0*h. Therefore, I need somehow to guarantee that my UDF is actually using the right pressure for the calculations.

I am not sure if I will have to work with "Data Access Macros", such as area, face, centroids, etc.

Hopefully, the code above (I know it is wrong), gives an idea of what I have in mind for the UDF.

Thank you in advance for your time,

DudaAPD May 28, 2014 08:34

Please, any help is well apreciated.
:)

SJSW October 7, 2015 22:00

Is it OK to compile the UDF file?

I don't know what 0 and 1 mean in
"
thread_liq = THREAD_SUB_THREAD(mix_thread,0);
thread_gas = THREAD_SUB_THREAD(mix_thread,1);
"

It seems 0 and 1 are zone ID and they are not defined?
I mean that one can type any number, but the UDF doesn't know what it is.


All times are GMT -4. The time now is 15:03.