Another application of the user state point function could be
to calculate the isentropic expansion efficiency of a device. The
following example code shows the usage of the USER_STATEPT
function to accomplish this task. Input arguments for this routine
are the mass flow averaged values of total enthalpy () and entropy () at a reference plane
1 as well as the mass flow averaged values of total enthalpy () and total pressure
() at a second reference plane, such as an outlet.
The isentropic expansion efficiency is defined as:
(19–6) |
With the isentropic enthalpy, , being the enthalpy .
To calculate the isentropic efficiency, the following input
data is provided to USER_STATEPT
:
Number of independent input properties:
2
Input property names:
Static Entropy
,Pressure
Input property values:
S1
,P2
Output property name:
Air Ideal Gas.Static Enthalpy
Note: Even though P2
holds the value of
total pressure, the input property name must be called Pressure
.
The CCL that is required to plot the efficiency in the CFX-Solver Manager is as follows:
LIBRARY: USER ROUTINE DEFINITIONS: USER ROUTINE: User Routine 1 Calling Name = my_eff Library Name = efficiency Library Path = .. Option = User CEL Function END END CEL: FUNCTION: Function 1 Argument Units = [J/kg],[J/kg],[J/kg/K],[Pa] Option = User Function Result Units = [] User Routine Name = User Routine 1 END EXPRESSIONS: H1 = massFlowAve(Total Enthalpy in Stn Frame)@Inflow H2 = massFlowAve(Total Enthalpy in Stn Frame)@Outflow S1 = massFlowAve(Static Entropy)@Inflow P2 = massFlowAve(Total Pressure in Stn Frame)@Outflow # Eff = Function 1(H1,H2,S1,P2) END END END FLOW: Flow Analysis 1 OUTPUT CONTROL: MONITOR OBJECTS: MONITOR BALANCES: Option = Full END MONITOR FORCES: Option = Full END MONITOR PARTICLES: Option = Full END MONITOR RESIDUALS: Option = Full END MONITOR TOTALS: Option = Full END MONITOR POINT: Eff1 Option = Expression Expression Value = Eff END END RESULTS: File Compression Level = Default Option = Standard END END END
The Fortran source code for the expansion efficiency calculation is given below:
#include "cfx5ext.h" dllexport(my_eff) SUBROUTINE MY_EFF ( & NLOC,NRET,NARG,RET,ARGS,CRESLT, CZ,DZ,IZ,LZ,RZ) CC CD User routine: Compute isentropic efficiency CC CC -------------------- CC Input CC -------------------- CC CC NLOC - size of current locale CC NRET - number of components in result CC NARG - number of arguments in call CC ARGS() - (NLOC,NARG) argument values CC CC -------------------- CC Modified CC -------------------- CC CC Stacks possibly. CC CC -------------------- CC Output CC -------------------- CC CC RET() - (NLOC,NRET) return values CC CRESLT - 'GOOD' for success CC CC -------------------- CC Details CC -------------------- CC CC Template routine for user state point code CC CC====================================================================== C C ------------------------------ C Argument list C ------------------------------ C INTEGER NLOC,NARG,NRET CHARACTER CRESLT*(*) REAL ARGS(NLOC,NARG), RET(NLOC,NRET) C INTEGER IZ(*) CHARACTER CZ(*)*(1) DOUBLE PRECISION DZ(*) LOGICAL LZ(*) REAL RZ(*) C C ------------------------------ C External routines C ------------------------------ C C ------------------------------ C Local Parameters C ------------------------------ C C ------------------------------ C Local Variables C ------------------------------ C INTEGER NPROPIND CHARACTER*(80) CPROPCALC, CPROPIND(2) C REAL RPROPIND(2), H1, H2, HIS, S1, SN, P2, DHIS, DHLOC, & ETA_E C C ------------------------------ C Stack pointers C ------------------------------ C C======================================================================= C C --------------------------- C Executable Statements C --------------------------- C C---- Initialize RET(1:NLOC*NRET) to zero. C CALL SET_A_0(RET,NLOC*NRET) C C----------------------------------------------------------------------- C Averaged values of inlet total enthalpy, inlet entropy, outlet C total enthalpy and outlet total pressure are passed into his C routine. C Mass flow averaging is used. C----------------------------------------------------------------------- C H1 = ARGS(NLOC,1) H2 = ARGS(NLOC,2) S1 = ARGS(NLOC,3) P2 = ARGS(NLOC,4) C C----------------------------------------------------------------------- C Compute isentropic efficiency C----------------------------------------------------------------------- C C---- Number of input properties C NPROPIND = 2 C C---- Input properties are entropy and pressure C CPROPIND(1) = 'Static Entropy' CPROPIND(2) = 'Pressure' C C---- Input values are s1 and p2 C RPROPIND(1) = S1 RPROPIND(2) = P2 C C---- Compute isentropic enthalpy, h = h(s1,p2) C CPROPCALC = 'Air Ideal Gas.Static Enthalpy' CALL USER_STATEPT(HIS,CPROPCALC,CPROPIND,RPROPIND, & NPROPIND,'SKIP',CRESLT, CZ,DZ,IZ,LZ,RZ) C C---- Expansion efficiency C DHIS = HIS - H1 DHLOC = H2 - H1 C IF (DHIS.LT.0.0 .AND.DHLOC.LT.0.0 .AND.DHIS.LT.DHLOC) THEN ETA_E = (H2 - H1)/(HIS - H1 + SN) ELSE ETA_E = 1.0 ENDIF C C----------------------------------------------------------------------- C C---- Copy output property value to RET(1:NLOC,1). C --> NLOC = 1 C RET(1,1) = ETA_E C C---- Set success flag. C CRESLT = 'GOOD' C C----------------------------------------------------------------------- END