TAGGED: multi-phase-flow, multi-species, udf, vof
-
-
January 14, 2025 at 4:19 pm
sjohn
SubscriberI am working with a two-phase case, wherein each phase has only one species. Using DEFINE_SOURCE, I can remove mass from one phase. How do I add mass to the other phase?ÂÂHere is a simplified UDF to remove mass from one phase:Â[COLOR="DarkRed"]#include "udf.h"#include "math.h"Â/* Define the source term function */DEFINE_SOURCE(species_add_lit3, c, t, dS, eqn){Â Â real source;Â Â ÂÂ Â source = 1;Â Â dS[eqn] = 0;ÂÂ Â return source;}[/COLOR]ÂIn my actual UDF, the source is not constant but a function. -
January 14, 2025 at 5:19 pm
-
January 14, 2025 at 5:27 pm
sjohn
SubscriberThat's how I have been doing but get large difference in mass flowrate. For example, inlet is 1 g/s but outlet is 0.6 g/s. The mass flowrates were calculated using the built-in Flux Report Definition at inlet and outlet boundaries.Â
Here is UDFs for subtraction. The subtraction UDF is hooked to the liquid phase in Cell Zone Conditions. For addition, I just use negative sign in the UDF and hook it to the gas phase.#include "udf.h"#include "math.h"Â/* Define the source term function */DEFINE_SOURCE(species_sub_lit, c, t, dS, eqn){Â Â real source;Â Â real massfrac;Â Â real temperature;Â Â real k;Â Â real A = 10;Â ÂÂ Â real Ea = 50;Â ÂÂ Â real R = 8.314;Â ÂÂÂ Â massfrac = C_YI(c, t, 0);Â Â temperature = C_T(c, t);Â Â k = A * exp(-Ea / (R * temperature));Â Â source = -k * massfrac;Â Â dS[eqn] = -k;ÂÂ Â return source;}Â
-
January 14, 2025 at 5:38 pm
Rob
Forum ModeratorAre you recalculating the value, or using the value with a negative sign?Â
-
January 14, 2025 at 5:40 pm
sjohn
SubscriberAdditionally, I calculated outlet mass flowrate for each phase using my custom defintion.
liquid phase = MassFlowAve(VelocityMagnitude,['outlet'])*Area(['outlet'])*MassFlowAve(Density(phase='phase-liq'),['outlet']) = 22.6 g/s
gas phase = MassFlowAve(VelocityMagnitude,['outlet'])*Area(['outlet'])*MassFlowAve(Density(phase='phase-gas'),['outlet']) = 0.3 g/s
mixture = MassFlowAve(VelocityMagnitude,['outlet'])*Area(['outlet'])*MassFlowAve(Density(phase='mixture'),['outlet'])= 4.3 g/s
inlet = MassFlowAve(VelocityMagnitude,['inlet'])*Area(['inlet'])*MassFlowAve(Density(phase='mixture'),['inlet']) = 1.2 g/s
The inlet flowrate obtained using above formula matches with the inlet flowrate obtained using Flux Report Definition. The outlet flowrate obtained using the above formula (for mixture) does not match the outlet flowrate obtained using Flux Report Defintion. -
January 14, 2025 at 5:41 pm
Rob
Forum ModeratorUse the Flux Report for each phase.Â
-
January 14, 2025 at 5:43 pm
sjohn
SubscriberI am recalculating the values in the addition UDF (used to add mass to gas phase)
Should I be using the source or k value from subtraction UDF directly in the addition UDF? I don't know how to do that. Currently, they are two separate .c files. -
January 14, 2025 at 5:49 pm
sjohn
SubscriberUsing Flux Report Defintion,
Liq phase:
inlet flowrate = 1.23 g/soutlet flowrate = 0.64 g/s
user mass source = 2.841e-20 g/s
Â
Gas phase:
inlet flowrate = 0 g/soutlet flowrate = 1.56e-3 g/s
user mass source = 2.841e-20 g/s
-
January 14, 2025 at 9:22 pm
sjohn
SubscriberSo the addition and subtration of masses between the two phases match. So what could be the reason for the outlet flowrate to be so different than the inlet flowrate.
-
January 15, 2025 at 9:39 am
Rob
Forum ModeratorIs it a transient run? Just wondering if you're accumulating liquid as gas forms and flows out of the domain.Â
-
January 15, 2025 at 1:01 pm
sjohn
SubscriberSteady state
-
January 15, 2025 at 1:03 pm
Rob
Forum ModeratorHow does the domain mass monitor look? Ie is it flat or changing?Â
-
January 15, 2025 at 2:51 pm
sjohn
SubscriberIs this some sort of plot to determine mass conservation? How can I plot this?
-
January 15, 2025 at 3:30 pm
Rob
Forum ModeratorThere's a mass imbalance value in Residuals but that's on a per cell basis and is usually only useful to find regions where the solver is struggling.Â
If you plot volume integral of phase mass with iteration that's usually a good indicator of what's going on. You can also combine that with mass in & mass out and some maths (change in volume mass / time step) to see how the system is behaving.Â
-
- You must be logged in to reply to this topic.
-
2918
-
970
-
852
-
599
-
591
© 2025 Copyright ANSYS, Inc. All rights reserved.