For given temperature, pressure, and mixture composition, you can obtain thermodynamic properties of a mixture material in liquid, gas, and two-phase regimes using get_prop_NIST_msp. NIST implements the GERG model for thermodynamic properties of the mixtures. This model applies mixing rules to the Helmholtz energy for each mixture components. Mixture data for the binary pairs can be found in hmx.bnc provided with your ANSYS Fluent installation.
Void get_prop_NIST_msp(double t, double p, double z[], double prop[]);
|
Argument Type |
Description |
|---|---|
|
|
Temperature (K). |
|
|
Pressure (Pa). |
|
|
Real array, mass fractions of each component/species. The sum of the mass fractions for all the materials in a mixture must be 1. |
Function returns
double prop[]: Real array with thermodynamic properties as follows.
|
Thermodynamic Properties Output | |
|---|---|
|
Vapor quality | |
|
|
vapor/gas moles/mixture moles
0<
|
|
|
vapor/gas mass fraction |
|
|
vapor/gas volume fraction |
|
Density (Kg/m^3) | |
|
|
bulk/mixture density |
|
|
liquid phase density |
|
|
vapor/gas phase density |
|
Specific-heat, cp (J/Kg-K) | |
|
|
bulk/mixture specific heat |
|
|
liquid phase specific heat |
|
|
vapor/gas phase specific heat |
|
Thermal conductivity (W/m-K) | |
|
|
bulk/mixture thermal conductivity |
|
|
liquid phase thermal conductivity |
|
|
vapor/gas phase thermal conductivity |
|
Viscosity (Pa-s) | |
|
|
bulk/mixture viscosity |
|
|
liquid phase viscosity |
|
|
vapor/gas phase viscosity |
|
Enthalpy (J/Kg) | |
|
|
bulk/mixture enthalpy |
|
|
liquid phase enthalpy |
|
|
vapor/gas phase enthalpy |
|
Speed of sound (m/s) | |
|
|
bulk speed of sound (0 if two-phase regime) |
|
|
in liquid phase |
|
|
in vapor/gas phase |
|
Component mass fractions in liquid phase | |
|
|
component/species, i = [0] … [n-1] |
|
Component mass fractions in vapor phase | |
|
|
component/species, i = [0] … [n-1] |
Important: The ranges of temperatures and pressures must be carefully selected, so that the limits on the material property application are not breached.
NIST is currently unable to calculate two-phase or mixture regime properties since all properties are relative to a pure or single phase. ANSYS Fluent implements simple mixing rules based on volume fractions:
where is the bulk property,
refers to a liquid or vapor phase,
are the phase specific properties in vapor and liquid, and
is the volume fraction of the
th phase.
You can embed the get_prop_NIST_msp UDF access macro in a number of Fluent UDF functions, such as DEFINE_ON_DEMAND. For example, you can use get_prop_NIST_msp to build a property database with variables of temperature, pressure and composition.
To use the get_prop_NIST_msp access function, you must first enable the NIST real gas model for multi-species by entering the following text command in the Fluent console:
define/user-defined/real-gas-models/nist-multispecies-real-gas-model
use multispecies NIST real gas? [no]
yes
Once the model is enabled, the list of available pure-fluid materials that you can select will be displayed.
Then enter responses to the following prompts in the console:
Number of species [0]
Enter the number of species that form the mixture.
select real-gas data file 1 []
For each fluid material, enter the name enclosed in quotation marks. For example:
select real-gas data file 1 []
"methane.fld"
select real-gas data file 2 []
"ethane.fld"
Once the fluids are selected, Fluent prints a list of properties for each fluid material and its application ranges of temperature and pressure.
Create NIST LookUp Table for multi components?
[no]
Enter no at the prompt.
Follow the normal UDF practices.
If the input parameters for get_prop_NIST_msp are outside the limits specified in NIST, the first element of the prop[] array, prop[NIST_q_molar]=q, will return the value of -2999.0. This indicates that NIST calculations of thermodynamic properties are questionable or simply impossible for given temperature, pressure and/or combination of materials. Since the returned value is a real double number, you can capture this error by using an appropriate conditional statement, such as
if (q > -2999.1 && q < -2998.9)
The following UDF, named getprop_msp, is called from a DEFINE_ON_DEMAND UDF Macro (
DEFINE_ON_DEMAND
). The function obtains thermodynamic properties of a mixture consisting of seven species. The species names and mass fractions are specified in the arrays spe_names[] and spe_mfractions[], respectively. (Note that the spe_mfractions[] array could also be variable.) The values of these thermodynamic properties are generated by the NIST Real Gas Model (current Version 9.1) in ANSYS Fluent. A series of temperature and pressure conditions are specified in the arrays temp[] and press[], respectively.
The obtained properties values are printed in the console and stored in the NIST_output.txt file. Any errors messages are recorded in the NIST_errors.txt file.
The UDF can be executed as an interpreted or compiled UDF in ANSYS Fluent.
#include "udf.h"
#include <string.h>
#define NUM_MAX 150
#define SPE_MAX 20
#define N_SPE 7
#define N_DATA 6
DEFINE_ON_DEMAND(getprop_msp)
{
double t,p,q,sum;
double z[SPE_MAX]={0.};
FILE *fp1,*fp2;
int i,j,k,n,ncomps;
double prop[NUM_MAX]={0.};
double temp[N_DATA]={185,200,215,200,200,200};
double press[N_DATA]={5.e6,5.e6,5.e6,4.5e6,5.5e6,6.e6};
char *spe_names[N_SPE]={"methane","nitrogen","carbon-dioxide","ethane","propane","isobutane","butane"};
double spe_mfractions[N_SPE]={0.70061,0.20227,0.023246,0.053209,0.014306,0.0031167,0.0032414};
fp1 = fopen("NIST_output.txt","w");
fp2 = fopen("NIST_errors.txt","w");
/* testing nist property access function */
ncomps = N_SPE; /* number of species. to be matched by setting in fluent */
/* composition in mass fraction */
sum = 0.;
for (i=0; i<N_SPE; i++)
{
z[i] = spe_mfractions[i];
sum += z[i];
}
for (i=0; i<N_SPE; i++)
z[i] /= sum;
Message0("\nComposition (Mass Fractions): %d species\n",ncomps);
for (i=0; i<ncomps; i++)
Message0(" %s : %f ",spe_names[i],z[i]);
fprintf(fp1, "quality_molar, quality_mass, quality_vol, density, den_liq, den_vap, h, h_liq, h_vap,
cp, cp_liq, cp_vap, ktc, ktc_liq, ktc_vap, mu, mu_liq, mu_vap, ");
for (i=0; i<ncomps; i++)
fprintf(fp1, " %s_liq, ",spe_names[i]);
for (i=0; i<ncomps; i++)
fprintf(fp1, " %s_vap, ",spe_names[i]);
fprintf(fp1, " speed-of-sound");
fprintf(fp2, "NIST calculations questionable or not possible for the following given inputs\n");
fprintf(fp2, "\nPlease make sure the inputs are within permitted limits set by NIST!");
fprintf(fp2, "\nTemperature Pressure Composition: (Mass Fractions) ");
fprintf(fp2, "\n(K) (Pa) ");
for (i=0; i<ncomps; i++)
fprintf(fp2, " %s ",spe_names[i]);
for (k=0; k<N_DATA; k++)
{
t = temp[k];
p = press[k];
get_prop_NIST_msp(t,p,z,prop); /* call NIST property calculations */
q = prop[NIST_q_molar]; /* error handling */
if (q > -2999.1 && q < -2998.9)
{
fprintf(fp2, "\n%5.4e %5.4e ",t,p);
for (i=0; i<ncomps; i++)
fprintf(fp2, " %5.4e ",z[i]);
continue;
}
Message0("\n\ngetprop_msp: T=%f (K), P=%e (Bar) ",t,p/1.e5);
Message0("\n\nquality (mol/mol)=%f quality (kg/kg)=%f quality (vol/vol)=%f\n", prop[NIST_q_molar],
prop[NIST_q_mass],prop[NIST_q_vol]);
Message0("\n Bulk Liquid-Phase Vapor-Phase\n");
Message0("\ndensity (kg/m^3): %f %f %f\n",prop[NIST_den_m],
prop[NIST_den_l],prop[NIST_den_v]);
Message0("\nspecific-heat (kj/kg-k): %f %f %f\n",prop[NIST_cp_m]/1.e3,
prop[NIST_cp_l]/1.e3,prop[NIST_cp_v]/1.e3);
Message0("\nthermal-ktc (mk/m-k): %f %f %f\n",prop[NIST_ktc_m]*1.e3,
prop[NIST_ktc_l]*1.e3,prop[NIST_ktc_v]*1.e3);
Message0("\nviscosity (uPa-s): %f %f %f\n",prop[NIST_mu_m]*1.e6,
prop[NIST_mu_l]*1.e6,prop[NIST_mu_v]*1.e6);
Message0("\nenthalpy (kj/kg): %f %f %f\n",prop[NIST_h_m]/1.e3,
prop[NIST_h_l]/1.e3,prop[NIST_h_v]/1.e3);
Message0("\nspeed of sound (m/s): %f %f %f\n",prop[NIST_a_m],
prop[NIST_a_l],prop[NIST_a_v]);
Message0("\nMass fractions in liquid phase: ");
for (i=0; i<ncomps; i++)
Message0("%s : %f ",spe_names[i],prop[NIST_massfrac0_l+i]);
Message0("\nMass fractions in vapor phase: ");
for (i=0; i<ncomps; i++)
Message0("%s : %f ",spe_names[i],prop[NIST_massfrac0_v+i]);
/* quality */
fprintf(fp1, "\n%5.4f %5.4f %5.4f ", prop[NIST_q_molar],prop[NIST_q_mass],prop[NIST_q_vol]);
/* density (kg/m^3) */
fprintf(fp1, "%5.4f %5.4f %5.4f ",prop[NIST_den_m],prop[NIST_den_l],prop[NIST_den_v]);
/* enthalpy (KJ/Kg) */
fprintf(fp1, "%5.4f %5.4f %5.4f ",prop[NIST_h_m]/1.e3,prop[NIST_h_l]/1.e3,prop[NIST_h_v]/1.e3);
/* specific-heat cp (Kj/Kg-k) */
fprintf(fp1, "%5.4f %5.4f %5.4f ",prop[NIST_cp_m]/1.e3,prop[NIST_cp_l]/1.e3,prop[NIST_cp_v]/1.e3);
/* thermal conductivity (mw/m-k) */
fprintf(fp1, "%5.4f %5.4f %5.4f ",prop[NIST_ktc_m]*1.e3,prop[NIST_ktc_l]*1.e3,prop[NIST_ktc_v]*1.e3);
/* viscosity (uPa-s) */
fprintf(fp1, "%5.4f %5.4f %5.4f ",prop[NIST_mu_m]*1.e6,prop[NIST_mu_l]*1.e6,prop[NIST_mu_v]*1.e6);
/* Mass fractions in liquid phase */
for (i=0; i<ncomps; i++)
fprintf(fp1, "%5.4f ",prop[NIST_massfrac0_l+i]);
/* Mass fractions in vapor phase */
for (i=0; i<ncomps; i++)
fprintf(fp1, "%5.4f ",prop[NIST_massfrac0_v+i]);
/* speed of sound (m/s) */
fprintf(fp1, "%5.4f %5.4f %5.4f ",prop[NIST_a_m],prop[NIST_a_l],prop[NIST_a_v]);
}
fclose(fp1);
fclose(fp2);
}