|
[Sponsors] |
Issues with mass source macros in a multiphase system |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 8, 2015, 16:43 |
Issues with mass source macros in a multiphase system
|
#1 |
New Member
Christina P.
Join Date: Oct 2012
Posts: 22
Rep Power: 13 |
Hi everyone,
I'm trying to write a UDF that describes phase change (just working on getting evaporation right now). I've been trying out my UDF on a "1D" Stefan problem (see attached PDF). My biggest problem right now is with an if statement in the mass source macro (DEFINE_SOURCE) that is hooked to my primary phase, the vapor. Here's the macro in question: Code:
DEFINE_SOURCE(gas, cell, thread, dS, eqn) { real source = 0.0; /* Initialize the variable "source"*/ real a_c = 0.04; real a_c_coeff=(2.0*a_c)/(2.0-a_c); real M = 0.018015; /* molar mass [kg/mol] */ real R = 8.314; /* universal gas constant [J/molK] */ real Tsat = 373.1; /* saturation temperature [K] */ real Psat = 101325.0; /* saturation pressure [Pa] */ real DeltaH = 2256560.0; /*vaporization enthalpy [J/kg] */ real rho_L = 958.4; /* liquid density [kg/m3] */ real rho_V = 0.597; /* vapor density [kg/m3] */ /* Initialize and define thread pointer/pointer array */ Thread *tm = THREAD_SUPER_THREAD(thread); /* *tm is a pointer to the mixture-level thread */ Thread **pt = THREAD_SUB_THREADS(tm); /* **pt is a pointer ARRAY, whose elements contain pointers to the phase-level threads */ /* If the temperature of the cell (located in a primary phase cell thread) is greater than Tsat */ /* AND the volume fraction of the primary phase is less than one (i.e. there is some liquid in the cell), then... */ if (C_T(cell, thread) > 373.1 && C_VOF(cell,thread) < 1.0) { source = C_UDMI(cell,tm,0)*a_c_coeff*sqrt(M/(2.0*M_PI*R))*((C_P(cell,thread)/sqrt(C_T(cell,thread)))-(Pvaporavg/sqrt(Tvaporavg))); } else { source = 0.0; } /* Set the user-defined memory location, labeled 1, as the mass source term for the vapor phase*/ C_UDMI(cell, tm, 1) = source; /* Set the user-defined memory location, labeled 2, as the energy source term, which is just the mass source term multiplied */ /* by the latent heat of vaporization. */ C_UDMI(cell, tm, 2) = -1.*source*DeltaH; dS[eqn] = 0; return source; } My specific issue is that the solver doesn't always enter into the if statement when it should. When the interface temperature gets above 373.1K, I would expect a mass source to appear along the entire length interface. However, I don't see that at all. Instead, it's just one localized circular region where a mass source appears. Does anyone have any experience with if statements inside DEFINE_SOURCE macros for a mass source in a multiphase simulation? Have I formatted it correctly? I've been trying to figure out if it's something to do with the data structures in multiphase situations, i.e. phase-level threads versus mixture-level threads, or a data type problem, or a problem with the if statement syntax. I haven't been able to find anything helpful in the UDF manual or elsewhere online. I've submitted my question to ANSYS but am waiting to hear back. Thank you!! |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
wmake compiling new solver | mksca | OpenFOAM Programming & Development | 14 | June 22, 2018 06:29 |
SparceImage v1.7.x Issue on MAC OS X | rcarmi | OpenFOAM Installation | 4 | August 14, 2014 06:42 |
Trouble compiling utilities using source-built OpenFOAM | Artur | OpenFOAM Programming & Development | 14 | October 29, 2013 10:59 |
Version 15 on Mac OS X | gschaider | OpenFOAM Installation | 113 | December 2, 2009 10:23 |
DecomposePar links against liblamso0 with OpenMPI | jens_klostermann | OpenFOAM Bugs | 11 | June 28, 2007 17:51 |