CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   CFX (http://www.cfd-online.com/Forums/cfx/)
-   -   how to use UDF& USER_GETVAR // what is the problem in my code (http://www.cfd-online.com/Forums/cfx/115799-how-use-udf-user_getvar-what-problem-my-code.html)

D.ko April 7, 2013 08:06

how to use UDF& USER_GETVAR // what is the problem in my code
 
I coded like below

i don't know why it does not work

help me



#include "cfx5ext.h"
dllexport(nucl)
SUBROUTINE NUCL (NLOC, NRET, NARG, RET, ARGS, CRESLT,
& CZ,DZ,IZ,LZ,RZ)
c
implicit none
C
C User CEL routine to calculate velocity boundary
C Creates a parabolic inlet profile as function of the y coordinate
C
#include "MMS.h"
#include "cfd_constants.h"
#include "stack_point.h"
C ================================================== ====================
C Arguments
C ================================================== ====================
C
C Result flag
CHARACTER CRESLT*(*)
C Number of locations in space over which calculations will be performed
INTEGER NLOC
C Number of CEL arguments
INTEGER NARG
C Number of return variables
INTEGER NRET
C
C Argument array
REAL ARGS(NLOC,NARG)
C Return variable array
REAL RET(NLOC,NRET)
C
C Stacks
INTEGER IZ(*)
CHARACTER CZ(*)*(1)
DOUBLE PRECISION DZ(*)
LOGICAL LZ(*)
REAL RZ(*)
C ================================================== ====================
C Local parameters
C ================================================== ====================
C
REAL pi, sigma, R, qc, M, k
PARAMETER (pi = 3.14, sigma = 1, R = 1, qc=1, M=1, k=1)
C
C ================================================== ====================
C Local variables
C ================================================== ====================
C
INTEGER ILOC
REAL dden, cden, rcri, Tc, Pc, PSAT, mcri, fraction, nucl, n,
& Sheat, Lheat , a, b
CHARACTER*(MXDNAM) ACTION,CGROUP,CEQN,CTERM,CPVAR,
& CLVAR,CPATCH,CRESLOC,CPHASE
CHARACTER*120 h2ol, h2og
C------------------------------
C Stack pointers
C ------------------------------
__stack_point__ Tc
__stack_point__ Pc
__stack_point__ PSAT
__stack_point__ dden
__stack_point__ cden
__stack_point__ Lheat
__stack_point__ a
__stack_point__ b
C
C ================================================== ====================
C Executable statements
C ================================================== ====================
C Initialise success flag.
CRESLT = 'GOOD'
C Initialise RET to zero.
CALL SET_A_0 ( RET, NLOC*NRET )
C
C---- Determine userís phase name for use in USER_GETVAR
C
C Use USER_ASSEMBLE_INFO to determine solver equation and principal
C variable names CEQN, CPVAR.
ACTION = 'GET'
CALL USER_ASSEMBLE_INFO (ACTION,CGROUP,CEQN,CTERM,CPVAR,
& CLVAR,CPATCH,CRESLOC,
& CZ,DZ,IZ,LZ,RZ)
IF (CRESLOC.NE.'GOOD' .AND. CRESLOC.NE.'SOME') THEN
CRESLT = 'FAIL'
GO TO 999
ENDIF
C
C
C
C
C
C
C
C
C
DO ILOC = 1,NLOC
fraction = ARGS(ILOC,1)
c   
C Extract phase name from principal variable
CALL GET_PHASE_FROM_VAR (CPVAR, CPHASE)
C Convert solver phase name to user phase name.
CALL CONVERT_NAME_S2U('Phase',CPHASE,' ',h2og,
& CRESLT, CZ,DZ,IZ,LZ,RZ)
IF (CRESLT .NE. 'GOOD') GO TO 999
c
call USER_GETVAR ('h2og.Saturation Pressure', CRESLT,
& PSAT, CZ, DZ, IZ, LZ, RZ)
IF (CRESLT .NE. 'GOOD') GO TO 999
c
call USER_GETVAR ('h2og.Pressure', CRESLT,
& Pc, CZ, DZ, IZ, LZ, RZ)
IF (CRESLT .NE. 'GOOD') GO TO 999
c
call USER_GETVAR ('h2og.Temperature', CRESLT,
& Tc, CZ, DZ, IZ, LZ, RZ)
IF (CRESLT .NE. 'GOOD') GO TO 999
c
call USER_GETVAR ('h2og.Density', CRESLT,
& cden, CZ, DZ, IZ, LZ, RZ)
IF (CRESLT .NE. 'GOOD') GO TO 999
c
c
c
CALL CONVERT_NAME_S2U('Phase',CPHASE,' ',h2ol,
& CRESLT, CZ,DZ,IZ,LZ,RZ)
IF (CRESLT .NE. 'GOOD') GO TO 999
c
call USER_GETVAR ('h2ol.Density', CRESLT,
& dden, CZ, DZ, IZ, LZ, RZ)
IF (CRESLT .NE. 'GOOD') GO TO 999
c
c
call USER_GETVAR ('h2ol.Latent Heat', CRESLT,
& Lheat, CZ, DZ, IZ, LZ, RZ)
IF (CRESLT .NE. 'GOOD') GO TO 999
c
call USER_GETVAR ('h2ol.Specific Heat Capacity at Constant
& Volume', CRESLT, a, CZ, DZ, IZ, LZ, RZ)
IF (CRESLT .NE. 'GOOD') GO TO 999
c
call USER_GETVAR ('h2ol.Specific Heat Capacity at Constant
& Pressure', CRESLT, b, CZ, DZ, IZ, LZ, RZ)
IF (CRESLT .NE. 'GOOD') GO TO 999
c
Sheat=a/b
C
C
c
c
c
c
c
rcri = (2*sigma)/(R*Tc*dden*CLOG(Pc/PSAT))
mcri=(4/3)*pi*dden*(rcri**3)
n=((sheat-1)/(sheat+1))*(Lheat/(R*Tc))*((Lheat/(R*Tc))-(1/2))
c
nucl= (qc/(1+n))*SQRT((2*sigma)/(pi*M))*
& ((cden**2)/dden)*EXP((-4*pi*sigma*(rcri**2))/(3*k*Tc))
RET(ILOC,1) = mcri*fraction*nucl
END DO
C
C Set success flag.
CRESLT = 'GOOD'
C
999 CONTINUE
END

ghorrocks April 7, 2013 18:00

Nobody on this forum has time to debug your code from scratch.

Post the error message you are getting, or something to suggest why it is not working. "i don't know why it does not work" is not a very useful description of the failure.

D.ko April 8, 2013 00:16

sorry
 
i don' know how to use this page.
i will change question


All times are GMT -4. The time now is 13:35.