CFX之CEL语言介绍要点
- 格式:doc
- 大小:464.50 KB
- 文档页数:24
ANSYS CFX——流体动力学分析技术的开拓者产品关键字精确的数值方法快速稳健的求解技术丰富的物理模型旋转机械流动分析的专有特征先进的网格剖分技术发展历史CFX 是全球第一个通过ISO9001 质量认证的大型商业CFD 软件,是英国AEATechnology 公司为解决其在科技咨询服务中遇到的工业实际问题而开发,诞生在工业应用背景中的CFX 一直将精确的计算结果、丰富的物理模型、强大的用户扩展性作为其发展的基本要求,并以其在这些方面的卓越成就,引领着CFD 技术的不断发展。
目前,CFX 已经遍及航空航天、旋转机械、能源、石油化工、机械制造、汽车、生物技术、水处理、火灾安全、冶金、环保等领域,为其在全球6000 多个用户解决了大量的实际问题。
回顾CFX 发展的重要里程,总是伴随着她对革命性的CFD 新技术的研发和应用。
1995年,CFX收购了旋转机械领域著名的加拿大ASC公司,推出了专业的旋转机械设计与分析模块-CFX-Tascflow ,CFX-Tascflow 一直占据着90% 以上的旋转机械CFD 市场份额。
同年,CFX 成功突破了 CFD 领域的在算法上的又一大技术障碍,推出了全隐式多网格耦合算法,该算法以其稳健的收敛性能和优异的运算速度,成为CFD 技术发展的重要里程碑。
CFX一直和许多工业和大型研究项目保持着广泛的合作,这种合作确保了CFX 能够紧密结合工业应用的需要,同时也使得CFX 可以及时加入最先进的物理模型和数值算法。
作为CFX 的前处理器,ICEM CFD 优质的网格技术进一步确保 CFX 的模拟结果精确而可靠。
2003年,CFX 加入了全球最大的 CAE 仿真软件ANSYS 的大家庭中。
我们的用户将会 得到包括从固体力学、流体力学、传热学、电学、磁学等在内的多物理场及多场耦合整体解 决方案。
CFX 将永远和我们的用户伙伴一起,用最先进的技术手段,不断揭开我们身边真 实物理世界的神秘面纱。
CFX软件介绍ANSYS CFX——流体动⼒学分析技术的开拓者产品关键字精确的数值⽅法快速稳健的求解技术丰富的物理模型旋转机械流动分析的专有特征先进的⽹格剖分技术发展历史CFX 是全球第⼀个通过ISO9001 质量认证的⼤型商业CFD 软件,是英国AEATechnology 公司为解决其在科技咨询服务中遇到的⼯业实际问题⽽开发,诞⽣在⼯业应⽤背景中的CFX ⼀直将精确的计算结果、丰富的物理模型、强⼤的⽤户扩展性作为其发展的基本要求,并以其在这些⽅⾯的卓越成就,引领着CFD 技术的不断发展。
⽬前,CFX 已经遍及航空航天、旋转机械、能源、⽯油化⼯、机械制造、汽车、⽣物技术、⽔处理、⽕灾安全、冶⾦、环保等领域,为其在全球6000 多个⽤户解决了⼤量的实际问题。
回顾CFX 发展的重要⾥程,总是伴随着她对⾰命性的CFD 新技术的研发和应⽤。
1995年,CFX收购了旋转机械领域著名的加拿⼤ASC公司,推出了专业的旋转机械设计与分析模块-CFX-Tascflow ,CFX-Tascflow ⼀直占据着90% 以上的旋转机械CFD 市场份额。
同年,CFX 成功突破了 CFD 领域的在算法上的⼜⼀⼤技术障碍,推出了全隐式多⽹格耦合算法,该算法以其稳健的收敛性能和优异的运算速度,成为CFD 技术发展的重要⾥程碑。
CFX⼀直和许多⼯业和⼤型研究项⽬保持着⼴泛的合作,这种合作确保了CFX 能够紧密结合⼯业应⽤的需要,同时也使得CFX 可以及时加⼊最先进的物理模型和数值算法。
作为CFX 的前处理器,ICEM CFD 优质的⽹格技术进⼀步确保 CFX 的模拟结果精确⽽可靠。
2003年,CFX 加⼊了全球最⼤的 CAE 仿真软件ANSYS 的⼤家庭中。
我们的⽤户将会得到包括从固体⼒学、流体⼒学、传热学、电学、磁学等在内的多物理场及多场耦合整体解决⽅案。
CFX 将永远和我们的⽤户伙伴⼀起,⽤最先进的技术⼿段,不断揭开我们⾝边真实物理世界的神秘⾯纱。
Version 1.33/23/2007©2007 ANSYS, Inc. All rights reserved.CFX 11.0ANSYS, Inc. ProprietaryInventory #002445TOC-1CFX前处理计算域讲座3Version 1.32007 ANSYS, Inc. All rights reserved.Inventory #002445TOC-2ANSYS, Inc. Proprietary计算域只包含有此次计算中使用的的网格流体计算域固体计算域旋转计算域静态计算域Version 1.3 Inventory #002445TOC-3Version 1.3Version 1.3•在ANSYS CFX 中, 用户在开始一个模拟前,必须为这个模拟指定一个参考压力. 它代表绝对压力数据,所有的相关压力都是基于此而衡量的•参考压力是用于避免四舍五入时产生的错误,也就是说当在一个流体区域内动压的差异与绝对压力的水平可以比较的时候. (实例见下页)relativereference absolute P P P +=在定义计算域时指定在定义边界条件时指定参考压力:边界条件•在结果文件中的压力值不包含静水压的贡献, 所以静水压的数值要在结果加上参考压力的值才是实际压力的值•如果流动是考虑浮力的并且参考压力设置为0Pa,静水压的贡献就会被考虑到结构之中•对于不考虑浮力的流体来说,静水压就不存在•当边界条件和初始条件被指定时,他们的值是相对于参考压力的值,除了当系统变量P 按照绝对压力的形势在CFX表达式中被使用(CEL)多孔区域•利用这个模型可以模拟这样的流动现象,即由于几何形状过于复杂,而无法进行网格划分的情况Images Courtesy of Babcock and Wilcox, USA多孔区域•各向同性损失模型–各向同性动量损失可以用线性或是二次阻力系数来指定,或是通过使用渗透性和损失系数来指定. 这个模型适用于各向同性多孔区域。
第十四章 14: CFX 表达式语言(CEL)CFX Expression Language (CEL) is an interpreted, declarative language that has been developed to enable CFX users to enhance their simulations without recourse to writing and linking separate external Fortran routines.You can use CEL expressions anywhere a value is required for input in ANSYS CFX.CEL can be used to:∙Define material properties that depend on other variables.∙Specify complex boundary conditions.∙Add terms to the solved equations.You can also monitor the value of an expression during the solution using monitor points. Important: There is some CEL that works elsewhere in ANSYS CFX, but not in CFD-Post. Any expression created in CFX-Pre and used as a Design Exploration output parameter could potentially cause fatal errors during the Design Exploration run, so you should create all expressions for Design Exploration output parameters in CFD-Post.14.1.1. Values and ExpressionsCEL can be used to generate both values and expressions. Values are dimensional (that is, with units) or dimensionless constants. The simplest type of definition is the dimensionless value, for example:b = 3.743You can also specify a value with units, for example:g = 9.81 [m s^-2]The dimensions of the quantities of interest for CFD calculations can be written in terms of mass, length, time, temperature and angle. The concept of units is fundamental to the behavior of values and expressions.Values can be used directly, or they can be used as part of an expression. For example, you can use an expression to add two values together:<Expr_1> = <Value_1> + <Value_2>In this example, you may want to predefine <Value_1> and <Value_2>, but this is not required. However, in order to add two quantities together, they must have the same dimension; that is, it is meaningful to add a quantity in inches to one expressed in meters, but it is not meaningful to add one expressed in kilograms to one in square feet.Expressions can also be functions of other (predefined) expressions:<Expr_2> = <Expr_1> + <Value_3>Units follow the conventions in the rest of CFX, in that a calculation has a set of solution units (by default, SI units), and that any quantity can be defined either in terms of the solution units, or any other set of units with the correct form.An expression does not have its own units string, but if it references quantities that have dimensions, these will determine the resulting units for the expression. For example, if an expression depends inversely on the square of the x coordinate, then it has implied dimensions of length to the power -2.14.1.1.1. Using Locators in ExpressionsA CFX simulation has physics areas and mesh areas; physics areas are boundaries while mesh areas are regions. These two types of area can occupy completely different spaces in a simulation; however, there is no requirement that area names be unique between physics and mesh. This can lead to ambiguities when you use these names in expressions.To avoid these ambiguities, ANSYS CFX first checks to see if "@<locator>" is a physics name; if this is not found, the name is checked in the list of mesh names. Thus if "in1" is both the name of a physics area and the name of a mesh area, "@<locator>" is taken to indicate the physics area.ANSYS CFX also has @REGION CEL syntax so that you can identify a named area as being a mesh area. Thus to identify the mesh area in1, you would use the syntax:@REGION:in1Note that if <locator> does not appear as a physics name or a mesh name, the expression fails.14.1.2. CFX Expression Language StatementsThe CFX Expression Language is declarative. You declare the name and definition of the expression using expression language statements. The statements must conform to a predefined syntax that is similar to Fortran mathematical statements and to C statements for logical expressions.The statement must consist of the following:∙ a number, optionally with associated units. This defines a constant. Constants without units are termed dimensionless.∙for mathematical expressions, one or more references to mathematical constants, system variables, or existing user variables, separatedby +(addition), - (subtraction), * (multiplication), / (division)and ^(exponentiation), with optional grouping of these by parentheses. Thesyntax rules for these expressions are the same as those for conventionalarithmetic.∙for logical expressions involving relational operators, one or more references to mathematical constants or results from mathematical expressions, separatedby <= (is less than or equal to), < (is less than), == (is equal to),!= (is not equalto), > (is greater than) and >= (is greater than or equal to) with optional groupingof these by parentheses.∙for logical expressions involving logical operators, one or more references to logical constants or results from relational operations separatedby !(negation), && (logical AND) and || (logical OR), with optional grouping byparentheses.14.1.2.1. Use of ConstantsConstants do not need to be defined prior to being used in an expression. For example, you could choose to evaluate the expression x + 5 [m]. Or, you could define a constant, b = 5 [m] and then create an expression x + b.The logical constants are false and true. Results of logical expressions are either false or true, which are evaluated as 0 and 1 (corresponding to false and true, respectively) when a numerical representation is required.The use of constants may be of benefit in generating complicated expressions or if you have several expressions that use the same constants.14.1.2.2. Expression SyntaxAll numbers are treated as real numbers.The precedence of mathematical operators is as follows (from highest to lowest):∙The power operator ^ as in x^y.∙The unary minus or negation operator - as in -x.∙Multiplication and division as in x*y/z.∙Addition and subtraction as in x+y-z.The precedence of logical and relational operators is as follows (from highest to lowest):∙The negation operator ! as in !x.∙The relational operators involving less than or greater than (<=, <, > and >=) as in x >= y.∙The relational operator is equal to and is not equal to (== and !=) as in x != y.∙The logical AND operator (&&) as in x && y.∙The logical OR operator (||) as in x || y.14.1.2.3. Multiple-Line ExpressionsIt is often useful, particularly with complex expressions, to use more than one line when creating your expression. CFX allows you to use multiple lines to generate an expression, provided each line is separated by an appropriate operator.For example, you may have an equation, A + B/C, that consists of three complex terms, A, B, and C. In this case, you could use three lines to simplify creating the expression:A +B/ CNote that the operator may be used at the end of a line (A +) or at the beginning of a line (/ C). You do not need to enter the operator twice.Once the expression has been created, it will appear in the Existing Definitions list box as if it were generated on a single line (A + B/C).14.2.1. CEL OperatorsCFX provides a range of mathematical, logical and operational operators as built-in functions to help you create complex expressions using the Expression details view.Table 14.1: CEL Operators14.2.2. Conditional if StatementCEL supports the conditional if statement using the following syntax:if( cond_expr, true_expr, false_expr )where:cond_expr: is the logical expression used as the conditional test∙true_expr: is the mathematical expression used to determine the result if the conditional test is true.∙false_expr : is the mathematical expression used to determine the result if the conditional test is false.Note: The expressions true_expr and false_expr are always evaluated independent of whether the evaluation of cond_expr is true or false. As a consequence, a conditional statement cannot be used to avoid division by zero as in if( x>0, 1/x, 1.0). In this case, when x=0.0, a division by zero will still occur because the expression 1/x is evaluated independent of whether x>0 is satisfied or not.14.2.3. CEL ConstantsRight-click in the Expression details view to access the following useful constants when developing expressions:Table 14.2: CEL Constants14.2.4. Using ExpressionsThe interaction with CEL consists of two phases:∙ a definition phase, and,∙ a use phase.The definition phase consists of creating a set of values and expressions of valid syntax. The purpose of the Expression details view is to help you to do this.14.2.4.1. Use of Offset TemperatureWhen using temperature values in expressions, it is generally safer to use units of [K] only. When units are used that posses an offset (for example, [C]), they are converted internally to [K]. For terms that have temperature to the power of unity, any unit conversion will include the offset between temperature scales. However, in all other cases the offset is ignored because this is usually the most appropriate behavior. You should therefore take care when specifying an expression involving non-unit powers of temperature. For example, each of the expressions below is equivalent:Temperature = 30 [C]Temperature = 303.15 [K]Temperature = 0 [C] + 30 [K]Temperature = 273.15 [K] + 30 [K]These are only equivalent because all units are to the power of unity and units other than [K] appear no more than once in each expression. The following expression will not produce the expected result:Temperature = 0 [C] + 30 [C]This is equivalent to 576.30 [K] because each value is converted to [K] and then summed. The two expression below are equivalent (as expected) because the offset in scales is ignored for non-unit powers of temperature:Specific Heat = 4200 [J kg^-1 C^-1]Specific Heat = 4200 [J kg^-1 K^-1]15.5. Quantitative Function ListThe available quantitative functions are outlined in the sections that follow.In the table that follows, <Expression> applies to CFD-Post only. CFX-Pre andCFX-Solver can only accept variables as arguments to quantitative functions. Note that for CFX-Pre and CFX-Solver, an Additional Variable can be used to pass an expression indirectly into a quantitative function.The behavior of the functions in the table below depends on the type of <Location>. Typically:∙On domains and subdomains, the functions use vertex (node) values for the operand.∙On a boundary, the functions use conservative values for the operand unless this is overridden by the Boundcon variable operator in CFX-Pre.∙On user locations in CFD-Post, the functions use values interpolated from nodal values.Table 15.4: CEL Functions in CFX-Pre/CFX-Solver and in CFD-Post15.5.1. areaThe area function is used to calculate the area of a 2D locator.area[_<Axis>[_<Coord Frame>] ]()@<Location>where:∙<Axis> is x, y, or z∙<Coord Frame> is the coordinate frame∙<Location> is any 2D region (such as a boundary or interface).An error is raised if the location specified is not a 2D object. If an axis is not specified, the total area of the location is calculated.area()@Isosurface1 calculates the total area of the location,and Isosurface1.area_y()@Isosurface1 calculates the projected areaof Isosurface1 onto a plane normal to the Y-axis.15.5.1.1. Tools > Command Editor Example>calculate area, <Location>, [<Axis>]The specification of an axis is optional. If an axis is not specified, the value held in the object will be used. To calculate the total area of the location, the axis specification should be left blank (that is, type a comma after the location specification).>calculate area, myplane calculates the area of the locator myplane projected onto a plane normal to the axis specification in the CALCULATOR object.。
ANSYS CFX——流体动力学分析技术的开拓者产品关键字精确的数值方法快速稳健的求解技术丰富的物理模型旋转机械流动分析的专有特征先进的网格剖分技术发展历史CFX是全球第一个通过ISO9001质量认证的大型商业CFD软件,是英国AEA Technology 公司为解决其在科技咨询服务中遇到的工业实际问题而开发,诞生在工业应用背景中的CFX 一直将精确的计算结果、丰富的物理模型、强大的用户扩展性作为其发展的基本要求,并以其在这些方面的卓越成就,引领着CFD技术的不断发展。
目前,CFX已经遍及航空航天、旋转机械、能源、石油化工、机械制造、汽车、生物技术、水处理、火灾安全、冶金、环保等领域,为其在全球6000多个用户解决了大量的实际问题。
回顾CFX发展的重要里程,总是伴随着她对革命性的CFD新技术的研发和应用。
1995年,CFX收购了旋转机械领域著名的加拿大ASC公司,推出了专业的旋转机械设计与分析模块-CFX-Tascflow,CFX-Tascflow一直占据着90%以上的旋转机械CFD市场份额。
同年,CFX 成功突破了CFD领域的在算法上的又一大技术障碍,推出了全隐式多网格耦合算法,该算法以其稳健的收敛性能和优异的运算速度,成为CFD技术发展的重要里程碑。
CFX一直和许多工业和大型研究项目保持着广泛的合作,这种合作确保了CFX能够紧密结合工业应用的需要,同时也使得CFX可以及时加入最先进的物理模型和数值算法。
作为CFX的前处理器,ICEM CFD优质的网格技术进一步确保CFX的模拟结果精确而可靠。
2003年,CFX加入了全球最大的CAE仿真软件ANSYS的大家庭中。
我们的用户将会得到包括从固体力学、流体力学、传热学、电学、磁学等在内的多物理场及多场耦合整体解决方案。
CFX将永远和我们的用户伙伴一起,用最先进的技术手段,不断揭开我们身边真实物理世界的神秘面纱。
产品特色CFX是全球第一个在复杂几何、网格、求解这三个CFD传统瓶径问题上均获得重大突破的商业CFD软件。
在CFX中,CFX表达式语言(CFX Expression Language :CEL)作为一种解释性和说明性的语言嵌入到CFX中。
利用CEL,用户可以提高分析模拟的功能,而不需要使用外部分离的Fortran子程序。
在ANSYS的CFX程序中,只要是可以输入值的地方就可以使用CEL表达式进行输入。
CEL的适用范围:通过变量定义材料属性;设定复杂的边界条件;对于求解方程增加求解项。
用户也可以使用监测点功能,在求解过程中对于某个CEL表达式进行监测。
注意:有些CEL表达式只能在ANSYS的CFX中使用,而不能使用在CFD的后处理中。
任何在CFX前处理器中创建的CEL表达式并作为设计浏览器(Design Exploration)中的输出参数,在设计浏览器运行的过程中可能导致致命的错误;所以,若用户需要进行设计浏览,则需要在CFD-Post(后处理)中创建所需所有的设计变量。
本读本包含如下内容:1、CEL基础。
2、CEL操作符,常量和表达式。
3、CEL的例子。
4、CEL技术细节。
1、CEL基础值和表达式利用CEL可以创建值变量和表达式。
值变量可以是带量纲的,也可以是不带量纲的。
例如下面这个最简单的不带量纲的变量:b = 3.743用户也可以创建具有量纲的变量,如下:g = 9.81 [m s^-2]在CFD计算过程中,变量的量纲是具有意义的,它们表征了质量,长度,时间,温度或者角度的信息。
量纲也是理解值和表达式的基础概念之一。
在CEL中,值可以直接指定,也可以作为表达式的一部分。
例如,用户可以使用两个值变量求和形成一个表达式:<Expr_1> = <Value_1> + <Value_2>在本例中,用户可能希望将<Value_1>和<Value_2>相加并赋值给<Expr_1>,若只是两个无量纲的变量进行相加用户不需要考虑量纲的问题;但是这两个变量具有量纲则需要考虑量纲的问题了。
Additional VariablesIntroductionThe topic(s) in this section include:∙User Interface∙Creating an Additional VariableAdditional variables are non-reacting scalar components that may be transported through the flow.This chapter describes the procedure for creating an additional variable, and the user interfaces used to define and apply additional variables.Modeling information for additional variables is available.∙Additional Variables∙Additional Variables in Multiphase Flow Implementation information for Additional Variables in Multiphase Flow is available.∙Additional Variables∙Additional Variables in Multiphase FlowUser InterfaceThe following topic(s) will be discussed:∙Insert Additional Variable Dialog Box∙Basic Settings Tab for Additional Variable Objects∙Fluid Models and Fluid Details Tabs for Domain Objects∙Boundary Details and Fluid Values Tabs for Boundary Condition ObjectsInsert Additional Variable Dialog BoxThe Insert Additional Variable dialog box is used to initiate the creation of a new additional variable. It is accessible by clickingAdditional Variable, or by selecting Insert > Expressions,Functions and Variables > Additional Variable.Basic Settings Tab for Additional Variable ObjectsThe Basic Settings tab is used to define the fundamental properties of an additional variable. It is accessible by creating a new additional variable or by editing an additional variable listed in the tree view.Variable Type∙SpecificThe additional variable is solved on a per-unit-mass basis. Fordetails, see Volumetric and Specific Additional Variable.∙VolumetricThe additional variable is solved on a per-unit-volume basis. For details, see Volumetric and Specific Additional Variable.∙UnspecifiedThe additional variable is defined in terms of an algebraicexpression using CEL. For details, see Unspecified AdditionalVariables.UnitsSpecify the units that describe the additional variable. For details, see Additional Variables.Tensor TypeThe Tensor Type can be set to Scalar or Vector. If an additional variable is defined as type Vector, the components of a vector algebraic equation can be defined at the domain level.Vector additional variables cannot be directly referenced in CEL expressions. The syntax for referencing a component of a vector additional variable is as follows:<Component Name>.<Additional Variable Name>_x。
在CFX中,CFX表达式语言(CFX Expression Language :CEL)作为一种解释性和说明性的语言嵌入到CFX中。
利用CEL,用户可以提高分析模拟的功能,而不需要使用外部分离的Fortran子程序。
在ANSYS的CFX程序中,只要是可以输入值的地方就可以使用CEL表达式进行输入。
CEL的适用范围:通过变量定义材料属性;设定复杂的边界条件;对于求解方程增加求解项。
用户也可以使用监测点功能,在求解过程中对于某个CEL表达式进行监测。
注意:有些CEL表达式只能在ANSYS的CFX中使用,而不能使用在CFD的后处理中。
任何在CFX前处理器中创建的CEL表达式并作为设计浏览器(Design Exploration)中的输出参数,在设计浏览器运行的过程中可能导致致命的错误;所以,若用户需要进行设计浏览,则需要在CFD-Post(后处理)中创建所需所有的设计变量。
本读本包含如下内容:1、CEL基础。
2、CEL操作符,常量和表达式。
3、CEL的例子。
4、CEL技术细节。
1、CEL基础值和表达式利用CEL可以创建值变量和表达式。
值变量可以是带量纲的,也可以是不带量纲的。
例如下面这个最简单的不带量纲的变量:b = 3.743用户也可以创建具有量纲的变量,如下:g = 9.81 [m s^-2]在CFD计算过程中,变量的量纲是具有意义的,它们表征了质量,长度,时间,温度或者角度的信息。
量纲也是理解值和表达式的基础概念之一。
在CEL中,值可以直接指定,也可以作为表达式的一部分。
例如,用户可以使用两个值变量求和形成一个表达式:<Expr_1> = <Value_1> + <Value_2>在本例中,用户可能希望将<Value_1>和<Value_2>相加并赋值给<Expr_1>,若只是两个无量纲的变量进行相加用户不需要考虑量纲的问题;但是这两个变量具有量纲则需要考虑量纲的问题了。
表达式可以由之前已定义的表达式进行定义,例如:<Expr_2> = <Expr_1> + <Value_3>在CFX中进行表达式求值往往需要进行单位装换,在缺省状态下使用公制单位制(SI单位制),这样用户就可以使用任何自己的单位制了。
若某个表达式未设定自己的单位字符串,但是引用的变量中有的是具有单位的,则结果表达式的单位由引用的变量或表达式计算后的量纲所决定。
例如:某个表达式引用了x坐标平方的倒数,则隐式的使用了长度的-2次方单位。
在表达式中使用定位符在CFX模拟过程中,具有物理面和网格面的概念:物理面:在CFX中表征物理边界条件的面称之为物理面;网格面:在CFX中在几何拓扑结构中划分网格的面称之为网格面。
在模拟过程中,这两种类型的面可能占据完全不同的几何区域;然而,并不需要将物理面和网格面的名称完全区分开,这样只会在表达式使用过程中造成混淆。
为了避免混淆,在CFX使用“@<locator>”进行物理面和网格面的区分。
若在面名称中找到了“@<locator>”定位符则表示是一个物理面;若未找到则在网格面的列表中进行查找。
例如:“in1”既是一个物理面的名称,可能也是一个网格面的名称,则“@<locator>”表示使用的是一个物理面。
在CFX中,用户可以使用@REGION参数表示某个命名的面是网格面。
例如,为了表示网格面in1,可以使用如下表达式:@REGION:in1注意:若定位符不是作为物理面或者网格面的表达式而出现,则该表达式无效。
CEL语句CEL语言是一种说明性的语言。
用户使用表达式语句进行表达式的申明和定义,并和Fortran以及C语言进行表达式定义的相一致:语句中必须包含如下内容:The statement must consist of the following:•一个数,量纲可选,用于定义一个常量。
•对于数学表达式,可能需要引用一个或者多个数学常量,变量,系统变量或者用户自定义的变量,并由+,-,*,/和^运算符进行连接,并用()定义运算的优先级,这些规则和传统的数学运算规则一致。
•对于关系表达式则包含关系运算符,一个或者多个数学常量或者从数学表示计算的结果,并由<=,<,==,!=,>.>=连接而成,并可以由可选的()设定运算优先级。
•对于逻辑表达式包含逻辑操作符,一个或者多个逻辑常量或者关系运算的结果,并通过!,&&,||连接而成,并可以由可选的()设定运算优先级。
使用常量在表达式中使用常量并不需要预先定义,例如:可以使用x + 5 [m]进行表达式计算;或者用户也可以先定义一个常量b=5[m],再创建一个表达式x+b。
逻辑常量值为false和true。
逻辑表达式的计算结果为0或者1,分别对应false 和TRUE。
推荐用户使用常量进行表达式的定义,因为可能有多个表达式同时引用一个常量的情况,这样只需要修改常量表达式即可。
表达式参数在CEL语言中,所有的数值均作为实数进行处理;并遵循如下从高到低的计算优先级顺序。
•指数运算:x^y。
•单操作数的取负运算:-x。
•乘除运算具有相同的优先级:x*y/z。
•加减运算:x+y-z。
逻辑运算和关系运算遵循如下从高到低的计算优先级顺序:•非运算:!x。
•关系运算(<=, <, > and >=):x >= y。
•关系运算(== and !=):x != y。
•逻辑与运算:x && y。
•逻辑或运算:x || y。
多行表达式多行表达式有时是十分有用的,尤其是对于复杂的表达式,可以使用多行创建用户需要的表达式。
在CFX中可以创建多行表达式,每行需要用合适的分隔符进行分隔。
例如:用户需要表达式A + B/C,其中A,B和C都是复杂的表达式。
在这种情况下,可以使用三行进行表达式的书写:A +B/ C注意:第一行表达式A书写完成后用+结束,表达式B写在单独的一行上,而表达式C用/开头。
一旦表达式书写完成,他将出现在表达式定义的列表中CEL中的操作符,常量和表达式操作符在CFX中提供了一定范围的数学,逻辑以及操作性的操作符,并以内建函数的形式帮助用户创建复杂的表达式。
下表中列出了CEL表达式中所使用的操作符的详细信息。
if条件语句CEL supports the conditional if statement using the following syntax:在12版的CFX中提供了if条件语句,而在以往的CFX中是使用step函数实现的条件判断功能。
if语句的使用格式如下:if( cond_expr, true_expr, false_expr )其中:•cond_expr: 用于进行测试的逻辑表达式。
•true_expr: 当逻辑表达式为真时所执行的数学运算表达式。
•false_expr : 当逻辑表达式为假时所执行的数学运算表达式。
注意:true_exp以及false_expr表达式无论逻辑表达式是真还是假时均单独运算。
其结果是条件表达式在这样的表达式if( x>0, 1/x, 1.0)中不能避免除零错误,当x=0时,而无论x>0的条件是否满足表达式1/x也会执行。
CEL常量在表达式列表的详细视图中右击鼠标可以访问CEL常量,列表如下:表达式的使用CEL表达式的使用分为两个阶段:•定义CEL表达式•引用CEL表达式CEL表达式的定义阶段是指使用值集以及合法的参数创建表达式的过程,利用表达式详细视图可以帮助用户创建表达式。
使用温度的偏移量在表达式中使用温度值的时候,一般较安全的方式均采用[K]作为温度单位。
设想一下若需要将[K]的温度单位进行偏移并转变成[C]单位,这样的装换是在内部进行的,例如:下面的四个语句等价:Temperature = 30 [C]Temperature = 303.15 [K]Temperature = 0 [C] + 30 [K]Temperature = 273.15 [K] + 30 [K]因为在CFX程序内部[C]单位和[K]是兼容的并在内部做了单位转化,但是下面的语句和上面的效果不同:Temperature = 0 [C] + 30 [C]上面的语句等价于将Temperature设定为576.3[K],这是因为在CFX内部首先将0[C]和30[C]分别转化为273.15[K]和303.15[K],之后再进行相加操作;所以和用户设想的结果产生了偏差。
但是下面的两个语句等价:Specific Heat = 4200 [J kg^-1 C^-1]Specific Heat = 4200 [J kg^-1 K^-1]例子1:基于粘度的雷诺数在本例中,我们假定某种流体的动力学粘度未知,但是雷诺数和入口速度以及长度比已知,流体为可压缩流即密度可变。
根据上述信息,可以通过下面的公式计算流体粘度:其中:Re:雷诺数ρ:流体密度U:入口速度L:长度比μ:流体粘度与上述公式等价的CCL语言如下:LIBRARY :CEL :EXPRESSIONS :Re = 4.29E6 [ ]Vel = 60 [m s^-1]L=1.044[m]Visc=areaAve(density)@in*Vel*L/ReENDENDMATERIAL : Air Ideal GasOption = Pure SubstancePROPERTIES :Option = Ideal GasMolar Mass = 2.896E1 [kg kmol^-1]Dynamic Viscosity = ViscSpecific Heat Capacity = 1.E3 [J kg^-1 K^-1]Thermal Conductivity = 2.52E-2 [W m^-1 K^-1]ENDENDEND这里共创建了4个CEL表达式,前3个表达式分别用于创建Re,Vel以及L,并在第四个表达式引用前3个表达式用于创建表达式Visc,其中areaAve(density)@in用于计算入口in的平均密度。
完成Visc的表达式定义之后,就可以在MATERIAL > PROPERTIES用于定义材料的粘度特性了。
例子2:入口温度的反馈控制在本例中通过改变入口的温度从而改变出口的温度,示意图如下:流体分别从主入口和侧边第一个入口流入,温度分别为275[K]和375[K]。
侧边第二个入口的流体温度和出口温度相关,当出口温度大于325[K],则该入口流体温度设定为275[K];当出口温度小于325[K],则该入口流体温度设定为375[K]。