资源描述
,Text line 1-Arial 20 pt.,Second line indent, Arial 18 pt.,Third level Arial 16 pt.,Fourth level Arial 14 pt.,Fifth level Arial 12 pt.,CFX Expression Language,Click to edit Master title style,11-,19,ANSYS, Inc. Proprietary, 2010 ANSYS, Inc. All rights reserved.,Release 13.0,December 2010,Training Manual,Text line 1-Arial 20 pt.,Second line indent, Arial 18 pt.,Third level Arial 16 pt.,Fourth level Arial 14 pt.,Fifth level Arial 12 pt.,CFX 12.0 Introductory Training,Click to edit Master title style,TOC-,*,ANSYS, Inc. Proprietary, 2010 ANSYS, Inc. All rights reserved.,Release 13.0,December 2010,Training Manual,11-,1,ANSYS, Inc. Proprietary, 2010 ANSYS, Inc. All rights reserved.,Release 13.0,December 2010,Text line 1-Arial 20 pt.,Second line indent, Arial 18 pt.,Third level Arial 16 pt.,Fourth level Arial 14 pt.,Fifth level Arial 12 pt.,Click to edit Master title style,TOC-,*,ANSYS, Inc. Proprietary, 2010 ANSYS, Inc. All rights reserved.,Release 13.0,December 2010,Text line 1-Arial 20 pt.,Second line indent, Arial 18 pt.,Third level Arial 16 pt.,Fourth level Arial 14 pt.,Fifth level Arial 12 pt.,Click to edit Master title style,Chapter 11CFX Expression Language(CEL),CFX,编程输入设置,CEL -,C,FX,E,xpression,L,anguage,Allows the user to create equations (can be functions of solution/system variables) that can be used in CFX-Pre and CFD-Post,Example:,CEL,The syntax rules are the same as those for conventional arithmetic. Operators are written as:,+,(addition),-,(subtraction),*,(multiplication),/,(division),(exponentiation),Variables and expressions are case sensitive (example: t vs. T),Expressions must be dimensionally consistent for addition and subtraction operations (example:,1.0 mm + 0.45 yds,is OK),You cannot add values with inconsistent dimensions,Fractional and decimal powers are allowed,(example:,a(1/2) + 1.00.5,),Units of expressions are not declared they are the result of units in the expression (example:,a kg m-3 * b m s-1,has units of kg m-2 s-1,Some constants are also available in CEL for use in expressions:,e Constant: 2.7182818,g Acceleration due to gravity: 9.806 m s-2,pi Constant: 3.1415927,R Universal Gas Constant: 8314.5 m2 s-2 K-1,CEL Rules,Numerical functions and operators are also available in CEL,Right-click when creating expressions for a complete list,Custom functions with User Fortran can also be created,Function Operands Dimensions xOperands ValuesResults Dimensions,sin(x),Angle Any Dimensionless,cos(x),Angle Any Dimensionless,tan(x),*,Angle Any Dimensionless,asin(x),Dimensionless -1,x,1 Angle,acos(x),Dimensionless -1,x,1 Angle,atan(x),Dimensionless Any Angle,exp(x),Dimensionless Any Dimensionless,loge(x),Dimensionless 0 x Dimensionless,log10(x),Dimensionless 0 1m, 1, 0),In this case, if the result is precisely equal to 1m, the result is (res1+res2)/2,*step(x) is 0 for negative x, 1 for positive x and 0.5 for x=0.,* note that tan(x) is undefined for n,p,/2 where n=1, 3, 5 . .,* both x and y must have the same dimensions.,Built In Functions,xDirection 1 in Reference Coordinate Frame,yDirection 2 in Reference Coordinate Frame,zDirection 3 in Reference Coordinate Frame,rRadial spatial location, r = (x2+y2)0.5,thetaAngle, arctan(y/x),tTime,uVelocity in the x coordinate direction,vVelocity in the y coordinate direction,wVelocity in the z coordinate direction,p(absolute) Pressure,keTurbulent kinetic energy,edTurbulent eddy dissipation,TTemperature,sstrnrShear strain rate,densityDensity,rNoDimNon-dimensional radius (rotating frame only),viscosityDynamic Viscosity,CpSpecific Heat Capacity at Constant Pressure,condThermal Conductivity,AV nameAdditional Variable name,mfMass Fraction,Solver variables are available for use in any expression,Below is a partial list of the available system variables:,When creating expressions, right-click to access a full list,Depending on your physics, some variables will not be valid e.g. you need to solver heat transfer to use T,Solver Variables,How To Create Expressions,To add more expressions (similar method in CFD-Post),How To Create Expressions,Right-click in the Definition window to access Variables, Constants, Functions, Locators and existing Expressions,where, is the shear strain rate,Creating a variable viscosity,Viscosity of a shear thickening fluid:,Solver Variable and Expression Name are both accessed via the right mouse button,CEL in CFX-Pre: Example 1,Alternatively, an expression can be entered directly into a field,CEL in CFX-Pre: Example 1,Using an “if” Function,Set inlet temperature to 300 K for the first 19 iterations then raise it to 320 K after 20 iterations,Solver variable accessed with the right mouse button,Note: On the 21,st,iteration inlet temp = 310 K,CEL in CFX-Pre: Example 2,You can also define your own 1-D linear, or 3-D cloud of points interpolation functions,Import data points or add manually,User Functions,Example: Having the timestep change,with iteration number as shown here,Timestep size is in seconds,Continued on next slide.,User Functions: Example,Iteration Number is dimensionless,Example: Having the timestep change,with iteration number as shown here,User Functions: Example,Integrated quantities can be used in expressions to evaluate variables over some location,Examples:,Calculate the area average of,Cp,on an isosurface:,areaAve(Cp)iso1,Mass flow of particular fluid through a locator:,oil.massFlow()slice1,Available in CFX-Pre and CFD-Post,Usage is more strict in CFX-Pre,E.g. the argument supplied to the function must be a variable, not an expression,“,” syntax must always supply a named location used in the physics definition,A boundary condition name, a domain name, a monitor point name, etc.,To reference general mesh regions use the syntax,“REGION:”,Phases/components can be referenced using:.,E.g.,Air.Nitrogen.massFlow()outlet,Integrated Quantities,Integrated Quantities,Some functions allow an x, y or z operator:,area_x()boundary,gives the area projected in the x-direction,force_z()wall gives the z component of the force on the wall,See documentation for a full list,These functions also allow an optional coordinate frame:,force_z_MyCoord()wall gives the z component of the force on the wall using the coordinate frame “MyCoord”,Each function requires either 0 or 1 arguments,areaAve,requires 1 argument:,areaAve(,Temperature,)Wall,massFlow,requires 0 arguments:,massFlow()Inlet,Return value units depend on the argument units,areaAve(Temperature)Wall,will return a value with units of Temperature,Below is a partial list of functions,See documentation for a complete list,Right-clicking when creating an expression will show most functions,Integrated Quantities,Integrated Quantities,Integrated Quantities,Useful Functions,The,inside(),function returns 1 when inside the specified location and 0 when outside,Useful to limit the scope of a function to a subdomain or boundary,The,step(),function return 1 when the argument is positive and 0 when the argument is negative,Useful as an on-off switch,if(),function can also be used as a switch,areaAve(),and,massFlowAve(),are used to evaluate the average of a quantity on a location,areaAve(),is an area-weighted average. It is usually used on wall boundaries and when the quantity is not “carried with the flow”, e.g. Pressure at an outlet, Temperature on a wall,massFlowAve(),is an average weighted by the local mass flow. It is usually used to evaluate quantities that are “carried with the flow”, e.g. Temperature at an outlet,
展开阅读全文