udfGetEDEMData()

Return the data for a variable.

Syntax

data = udfGetEDEMData( udfHd, dataName ) ;

Type

AcuSolve-EDEM coupling user-defined drag, lift and torque models.

Parameters

udfHd
The opaque handle (pointer) which was passed to the user function.
dataName (integer)
Symbolic name of the requested data.
UDF_EDEM_FLOW_DENSITY
Flow density.
UDF_EDEM_FLOW_VISCOSITY
Flow viscosity.
UDF_EDEM_FLOW_POROSITY
Flow porosity.
UDF_EDEM_FLOW_VELOCITY
Flow velocity.
UDF_EDEM_FLOW_VELOCITY_CURL
Flow velocity curl.
UDF_EDEM_PARTICLE_VOLUME
Particle volume.
UDF_EDEM_PARTICLE_ANGLE
Particle angle.
UDF_EDEM_PARTICLE_POSITION
Particle position.
UDF_EDEM_PARTICLE_VELOCITY
Particle velocity.
UDF_EDEM_PARTICLE_VELOCITY_CURL
Particle velocity curl.
UDF_EDEM_DRAG_COEF
Drag coefficient.
UDF_EDEM_PAXIS_VELOCITY
pAxis * slipVel * slipVel.
UDF_EDEM_DRAG
Drag.
UDF_EDEM_LIFT
Lift.
UDF_EDEM_PARTICLE_QUATERNION
Particle quaternion.

Return Value

data (Real*)
Pointer to one, two, or three dimensional real array of the requested data. The dimensions of the array depend on dataName as follows. If the third (slowest) dimension of the array is equal to one, then the array may be treated as two dimensional. If the second dimension is likewise one, then the array is one dimensional.
Table 1.
dataName First Dimension Second Dimension
UDF_EDEM_FLOW_DENSITY nItems 1
UDF_EDEM_FLOW_VISCOSITY nItems 1
UDF_EDEM_FLOW_POROSITY nItems 1
UDF_EDEM_FLOW_VELOCITY nItems 3
UDF_EDEM_FLOW_VELOCITY_CURL nItems 3
UDF_EDEM_PARTICLE_VOLUME nItems 1
UDF_EDEM_PARTICLE_ANGLE nItems 1
UDF_EDEM_PARTICLE_POSITION nItems 3
UDF_EDEM_PARTICLE_VELOCITY nItems 3
UDF_EDEM_PARTICLE_VELOCITY_CURL nItems 3
UDF_EDEM_DRAG_COEF nItems 1
UDF_EDEM_PAXIS_VELOCITY nItems 3
UDF_EDEM_DRAG nItems 3
UDF_EDEM_LIFT nItems 3
UDF_EDEM_PARTICLE_QUATERNION nItems 4

Description

This routine returns the requested solution data. For example,
#include "acusim.h"
#include "udf.h"

/*===========================================================================
 *
 * Prototype the function
 *
 *===========================================================================
 */

UDF_PROTOTYPE( usrEDEMDrag ) ;

/*===========================================================================
 *
 * "usrEDEMDrag":  calculate EDEM particle drags
 *
 *  Arguments:
 *    udfHd     - opaque handle for accessing information
 *    outVec    - output vector
 *    nItems    - number of items in outVec (=1 in this case)
 *    vecDim    - vector dimension of outVec (=1 in this case)
 *
 *  Input file parameters:
 *    user_values = { ErgunA, ErgunB } 
 *    user_strings = { "" }
 *
 *===========================================================================
 */

Void usrEDEMDrag(           UdfHd		udfHd,
                            Real*		outVec,
                            Integer	        nItems,
                            Integer	        vecDim )
{

    Real	beta ;
    Real	betaArea ;
    Real	dens ;
    Real	visc ;
    Real	vol ;
    Real	diam ;
    Real*	scalar ;
    Real*	flowVel ;
    Real*	particleVel ;
    Real	slipVelMag ;
    Real	slipVel[3] ;
    Real	poros ;
    Real	CD ;
    Real	Re ;
    Real	ErgunA ;
    Real	ErgunB ;
    Real*       usrVals ;
    String*     usrStrs ;
    Real	carrierDens ;

/*---------------------------------------------------------------------------
 * Get the user data
 *---------------------------------------------------------------------------
 */
    udfCheckNumUsrVals(			udfHd,		2		) ;
    udfCheckNumUsrStrs(			udfHd,		1		) ;

    usrVals = udfGetUsrVals(        udfHd                           ) ;
    usrStrs = udfGetUsrStrs(        udfHd                           ) ;
    ErgunA = usrVals[0] ;
    ErgunB = usrVals[1] ;

/*---------------------------------------------------------------------------
 * Get particle and flow data at current particle location
 *---------------------------------------------------------------------------
 */
    scalar = udfGetEDEMData(	udfHd, UDF_EDEM_FLOW_DENSITY	) ;
    dens = scalar[0] ;

    scalar = udfGetEDEMData(	udfHd,	UDF_EDEM_PARTICLE_VOLUME) ;
    vol = scalar[0] ;

    scalar = udfGetEDEMData(	udfHd,	UDF_EDEM_FLOW_VISCOSITY	) ;
    visc = scalar[0] ;

    scalar = udfGetEDEMData(	udfHd,	UDF_EDEM_FLOW_POROSITY	) ;
    poros = scalar[0] ;

    flowVel = udfGetEDEMData(	udfHd,	UDF_EDEM_FLOW_VELOCITY	) ;

    particleVel = udfGetEDEMData(	udfHd,	UDF_EDEM_PARTICLE_VELOCITY) ;

    diam = pow( 1.909859317102744 * vol, 0.3333333333333333 	) ;
    if ( vol <= 0 ) {
	udfSetError( udfHd, "Error from \"%s\" UDF, EDEM particle volume"
			" should bigger than zero", usrStrs[0] ) ;
    }
/*---------------------------------------------------------------------------
 * Calculate drag with Gidaspow model
 *---------------------------------------------------------------------------
 */
    slipVel[0] = flowVel[0] - particleVel[0] ;
    slipVel[1] = flowVel[1] - particleVel[1] ;
    slipVel[2] = flowVel[2] - particleVel[2] ;

    slipVelMag = pow( slipVel[0], 2 )
		+ pow( slipVel[1], 2 )
		+ pow( slipVel[2], 2 ) ;
    slipVelMag = pow( slipVelMag, 0.5 ) ; 

    Re = poros * dens * slipVelMag * diam / visc ;

    if ( poros >= 0.8 ) {

       /* Wen-Yu */
	CD = 24. / Re * ( 1.0 + 0.15 * pow( Re, 0.687 ) ) ;
	if ( Re == 0 ) {
	    CD = 0.0 ;
	}
	if ( Re > 1000. ) {
	    CD = 0.44 ;
	}
	beta = 0.75 * CD * pow( poros,-1.65) * dens * slipVelMag ;

    } else {
	/* Ergun */
	beta = ErgunA * ( 1.0 - poros ) * visc / ( poros * diam )
		    + ErgunB * dens * slipVelMag ;
    }

    betaArea = beta * vol / diam ;

/*---------------------------------------------------------------------------
 * Push the drag force to AcuSolve 
 *---------------------------------------------------------------------------
 */
    outVec[0] = betaArea * slipVel[0] ;
    outVec[1] = betaArea * slipVel[1] ;
    outVec[2] = betaArea * slipVel[2] ;

} /* end of usrEDEMDrag() */

/*===========================================================================
 *
 * Prototype the function
 *
 *===========================================================================
 */

UDF_PROTOTYPE( usrEDEMLift ) ;


/*===========================================================================
 *
 * "usrEDEMLift":  calculate EDEM particle lift
 *
 *  Arguments:
 *    udfHd     - opaque handle for accessing information
 *    outVec    - output vector
 *    nItems    - number of items in outVec (=1 in this case)
 *    vecDim    - vector dimension of outVec (=1 in this case)
 *
 *  Input file parameters:
 *    user_values = { ErgunA, ErgunB } 
 *    user_strings = { "" }
 *
 *===========================================================================
 */

Void usrEDEMLift(       UdfHd		udfHd,
                        Real*		outVec,
                        Integer	        nItems,
                        Integer	        vecDim )
{

    Real	beta ;
    Real	betaArea ;
    Real	dens ;
    Real	visc ;
    Real	vol ;
    Real	diam ;
    Real*	scalar ;
    Real*	flowVel ;
    Real*	particleVel ;
    Real*	particleVelCurl ;
    Real*	flowVelCurl ;
    Real	slipVelMag ;
    Real	slipVel[3] ;
    Real	slipCurl[3] ;
    Real	slipVelXflowVelCurl[3] ;
    Real	slipCurlXslipVel[3] ;
    Real	poros ;
    Real	CD ;
    Real	Re ;
    Real	flowVelCurlMag ;
    Real	slipCurlMag ;
    Real	SaffmanCoef ;
    Real	MagnusCoef ;
    Real	CLS ;
    Real	betaLS ;
    Real	CLM ;
    Real	betaLM ;
    Real	gamma ;
    Real*       usrVals ;
    String*     usrStrs ;
    Real	carrierDens ;

/*---------------------------------------------------------------------------
 * Get the user data
 *---------------------------------------------------------------------------
 */
    udfCheckNumUsrVals(			udfHd,		2		) ;
    udfCheckNumUsrStrs(			udfHd,		1		) ;

    usrVals = udfGetUsrVals(        udfHd                           ) ;
    usrStrs = udfGetUsrStrs(        udfHd                           ) ;
    SaffmanCoef = usrVals[0] ;
    MagnusCoef = usrVals[1] ;

/*---------------------------------------------------------------------------
 * Get particle and flow data at current particle location
 *---------------------------------------------------------------------------
 */
    scalar = udfGetEDEMData(	udfHd, UDF_EDEM_FLOW_DENSITY	) ;
    dens = scalar[0] ;

    scalar = udfGetEDEMData(	udfHd,	UDF_EDEM_PARTICLE_VOLUME) ;
    vol = scalar[0] ;

    scalar = udfGetEDEMData(	udfHd,	UDF_EDEM_FLOW_VISCOSITY	) ;
    visc = scalar[0] ;

    scalar = udfGetEDEMData(	udfHd,	UDF_EDEM_FLOW_POROSITY	) ;
    poros = scalar[0] ;

    flowVel = udfGetEDEMData(	udfHd,	UDF_EDEM_FLOW_VELOCITY	) ;
    flowVelCurl = udfGetEDEMData(	udfHd,	UDF_EDEM_FLOW_VELOCITY_CURL) ;

    particleVel = udfGetEDEMData(	udfHd,	UDF_EDEM_PARTICLE_VELOCITY) ;

    particleVelCurl = udfGetEDEMData(	udfHd,	UDF_EDEM_PARTICLE_VELOCITY_CURL	) ;

    diam = pow( 1.909859317102744 * vol, 0.3333333333333333 	) ;

    if ( vol <= 0 ) {
	udfSetError( udfHd, "Error from \"%s\" UDF, EDEM particle volume"
			" should bigger than zero", usrStrs[0] ) ;
    }
/*---------------------------------------------------------------------------
 * Calculate lift with Saffman Magnus
 *---------------------------------------------------------------------------
 */
    slipVel[0] = flowVel[0] - particleVel[0] ;
    slipVel[1] = flowVel[1] - particleVel[1] ;
    slipVel[2] = flowVel[2] - particleVel[2] ;

    slipVelMag = pow( slipVel[0], 2 )
		+ pow( slipVel[1], 2 )
		+ pow( slipVel[2], 2 ) ;
    slipVelMag = pow( slipVelMag, 0.5 ) ; 

    flowVelCurlMag = pow( flowVelCurl[0], 2 )
			+ pow( flowVelCurl[1], 2 )
			+ pow( flowVelCurl[2], 2 ) ;
    flowVelCurlMag = pow( flowVelCurlMag, 0.5 ) ; 

    slipVelXflowVelCurl[0] = slipVel[1] * flowVelCurl[2] - slipVel[2] * flowVelCurl[1]  ; 
    slipVelXflowVelCurl[1] = slipVel[2] * flowVelCurl[0] - slipVel[0] * flowVelCurl[2]  ; 
    slipVelXflowVelCurl[2] = slipVel[0] * flowVelCurl[1] - slipVel[1] * flowVelCurl[0]  ; 

    slipCurl[0] = 0.5 * flowVelCurl[0] - particleVelCurl[0] ;
    slipCurl[1] = 0.5 * flowVelCurl[1] - particleVelCurl[1] ;
    slipCurl[2] = 0.5 * flowVelCurl[2] - particleVelCurl[2] ;

    slipCurlMag = pow( slipCurl[0], 2 )
		+ pow( slipCurl[1], 2 )
		+ pow( slipCurl[2], 2 ) ;
    slipCurlMag = pow( slipCurlMag, 0.5 ) ; 


    slipCurlXslipVel[0] = slipVel[2] * slipCurl[1] - slipVel[1] * slipCurl[2]  ;
    slipCurlXslipVel[1] = slipVel[0] * slipCurl[2] - slipVel[2] * slipCurl[0]  ; 
    slipCurlXslipVel[2] = slipVel[1] * slipCurl[0] - slipVel[0] * slipCurl[1]  ;


    Re = poros * dens * slipVelMag * diam / visc ;
    CLS = 0.0 ;
    betaLS = 0.0 ;
    if ( flowVelCurlMag > 0. && slipVelMag > 0. ) {
	gamma = flowVelCurlMag * diam / (2*slipVelMag) ;
	if ( Re <= 40. ) {
	    CLS = ( 1. - 0.3314 * pow(gamma,0.5) ) * exp(-0.1*Re)
		+ 0.3314 * pow(gamma,0.5) ;
	} else {
	    CLS = 0.0524 * pow(gamma*Re,0.5) ;
	}
        betaLS = SaffmanCoef * CLS * pow(diam,2) * pow(visc*dens,0.5)
                         / pow(flowVelCurlMag,0.5) ;
    }
   
    CLM = 0.0 ;
    betaLM = 0.0 ;
    if ( slipVelMag > 0. && slipCurlMag > 0. ) {
	if ( Re <= 1. ) {
        CLM = diam * slipCurlMag / slipVelMag ;
	} else if ( Re > 1. ) {
	    CLM = diam * slipCurlMag / slipVelMag
		* ( 0.178 + 0.822 * pow(Re,-0.522) ) ;
	}
        betaLM = MagnusCoef * CLM * pow(slipVelMag,2) * 3.141592653589793
		* pow(diam,2) * dens / ( slipCurlMag*slipVelMag ) ;
    }

/*---------------------------------------------------------------------------
 * Push the lift force to AcuSolve 
 *---------------------------------------------------------------------------
 */
    outVec[0] = betaLS * slipVelXflowVelCurl[0] + betaLM * slipCurlXslipVel[0] ;
    outVec[1] = betaLS * slipVelXflowVelCurl[1] + betaLM * slipCurlXslipVel[1] ;
    outVec[2] = betaLS * slipVelXflowVelCurl[2] + betaLM * slipCurlXslipVel[2] ;

} /* end of usrEDEMLift() */

Errors

  • This routine expects a valid udfHd.
  • This routine may only be called within an AcuSolve-EDEM coupling drag, lift and torque model user functions.
  • dataName must be one of the values given above.
  • The problem must contain the equation associated with the requested data.