CFX之CEL语言介绍
- 格式:doc
- 大小:474.00 KB
- 文档页数:24
ANSYS CFX-Pre User Guide1、CFX-Pre Basics:1、Starting CFX-Pre:File >> New Case;General:通用CFX-Pre界面,用于所有类型CFD模拟;Turbomachinery:涡轮机械CFD模拟;Quick Setup:CFX-Pre简化,仅用于单计算域(single-domain)、单相(single-phase)问题模拟;不支持:多相(multiphase)、燃烧(combustion)、辐射(radiation)、高等湍流模型(advanced turbulence models)CFD模拟。
Library Template:模板库提供特定物理模拟模板;2、CFX-Pre W orkspace:Outline 结构:(1)Mesh:网格操作如:导入(import)、变换(transformation)、渲染(render)、可视化(show、hide)(2)Simulation:AnalysisAnalysis Type:稳态(steady)、瞬态(transient)分析,Domain:流体(fluid)、多孔介质(porous)、固体(solid)计算域,区域、类型、属性设置;Domain Interfaces:计算域、网格连接界面;Global Initialization:全局计算域初始化,单一计算域初始化于Domain中设置;Solver:求解单位(Solution Units)、求解控制(Solver Control)、输出控制(Output Control);Coordinate Frame:默认笛卡尔坐标系,可创建新坐标系统;Materials、Reactions:材料、化学反应;Expressions、Functions、V ariables:表达式、自定义函数、变量、及子程序;(3)Simulation Control:分析求解控制、及求解结构序列(Configuration)设置;(4)Case Options:显示、标示设置;3、CFS-Pre 文件类型:(1)Case File(.cfx):CFX-Pre数据文件,包括模拟物理学定义、计算区域设置、网格信息;(2)Mesh File:网格文件;(3)CFX-Solver Input Files(.def,.mdef):CFX-Solver输入文件,单一结构输入文件(.def);多结构输入文件(.mdef),需补充构造序列(Configuration Definition)定义文件(.cfg);(4)CFS-Solver Results File(.res,.mres,.trn,.bak):结果文件(.res单一结构,.mres多结构),多结构模拟.mres文件,同时可生成单一.res结果文件;中间结果文件(.trn瞬态结果文件,.bak备份文件),Output Control >> Trn Results、Backup设置;(5)CFX-Solver Error Results File(.err):CFX-Solver求解失败错误信息文件;(6)Session File(.pre):CFX-Pre录制CCL操作命令;(7)CCL File(CFX Command Language,.ccl):CFX-Pre保存CCL 命令状态文件,较Session File,仅对当前CCL命令操作状态保存。
第十四章 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>,若只是两个无量纲的变量进行相加用户不需要考虑量纲的问题;但是这两个变量具有量纲则需要考虑量纲的问题了。
ansysCFX中CEL使用讲解Version 1.3CFX 表达式语言 (CEL)讲座 63/23/2007 ? 2007 ANSYS, Inc. All rights reserved.CFX 11.0 ANSYS, Inc. ProprietaryInventory #002445 6-1Version 1.3CFX 表达式语言 ? CEL - CFX Expression Language–允许用户创建方程(可以定制求解的方程或是系统变量) 用于CFX前处理和CFX后处理 ? 例:3/23/2007 ? 2007 ANSYS, Inc. All rights reserved.CFX 11.0 ANSYS, Inc. ProprietaryInventory #002445 6-2Version 1.3CEL 规则语法规则与常规的代数语法规则相同 ? 算子: + (加) - (减) * (乘) / (除) ^ (乘方) ? 变量和表达式对大小写敏感 (例: t 和 T) ? 对于加和减运算表达式必须在尺度上一致 (例: 1.0 [mm] + 0.45 [yds]) ? 分数和小数是可以使用的 (例: a^(1/2) + 1.0^0.5) ? 表达式的单位无需说明–他们是表达式计算的结果 (例: a [kg m^-3] * b [m s^-1] 计算的结果是[kg m^-2 s^-1] ? 一些常量在表达式中也是可以使用的: – e Constant: 2.7182818 – g Acceleration due to gravity: 9.806 [m s^-2] – pi Constant: 3.1415927 – R Universal Gas Constant: 8314.5 [m^2 s^-2 K^-1]3/23/2007 ? 2007 ANSYS, Inc. All rights reserved. CFX 11.0 ANSYS, Inc. ProprietaryInventory #002445 6-3Version 1.3Built In Functions一些数学函数和算子也可以在CEL中使用–用户定制的函数可以通过使用Fortran语言创建Function sin(x) cos(x) tan(x) ** asin(x) acos(x) atan(x) exp(x) loge(x) log10(x) abs(x) sqrt(x) min(x,y) *** max(x,y) *** step(x) * Operand’s Dimensions [x] Angle Angle Angle Dimensionless Dimensionless Dimensionless Dimensionless Dimensionless Dimensionless Any Any Any Any Dimensionless Operand’s Values Any Any Any -1 ≤ x ≤ 1 -1 ≤ x ≤ 1 Any Any 0*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π/2 where n=1, 3, 5 .. . *** both x and y must have the same dimensions.3/23/2007 ? 2007 ANSYS, Inc. All rights reserved. CFX 11.0 ANSYS, Inc. ProprietaryInventory #002445 6-4Version 1.3系统变量许多系统变量是可以在CEL中进行使用的 ? 单位已经被包含 ? 下面是可以被使用的系统变量列表:x y z r theta t u v w p ke ed T sstrnr density rNoDim viscosity Cp cond AV name mf3/23/2007 ? 2007 ANSYS, Inc. All rights reserved.Direction 1 in Reference Coordinate Frame Direction 2 in Reference Coordinate Frame Direction 3 in Reference Coordinate Frame Radial spatial location, r = (x^2+y^2)^0.5 Angle,arctan(y/x) Time Velocity in the x coordinate direction Velocity in the y coordinate direction Velocity in the z coordinate direction (absolute) Pressure Turbulent kinetic energy Turbulent eddy dissipation Temperature Shear strain rate Density Non-dimensional radius (rotating frame only) Dynamic Viscosity Specific Heat Capacity at Constant Pressure Thermal Conductivity Additional Variable name Mass FractionCFX 11.0 ANSYS, Inc. Proprietary只用被应用时,只用被应用时,系统参数才可以被选择Inventory #002445 6-5Version 1.3如何创建CEL3/23/2007 ? 2007 ANSYS, Inc. All rights reserved.CFX 11.0 ANSYS, Inc. ProprietaryInventory #002445 6-6Version 1.3如何创建CEL加入更多的表达式 (和在 CFX后处理中采用相同的方法)3/23/2007 ? 2007 ANSYS, Inc. All rights reserved.CFX 11.0 ANSYS, Inc. ProprietaryInventory #002445 6-7Version 1.3CEL 在CFX前处理中实例 1 ? 创建一个粘性变量–粘性剪切流体的粘度:μ = Kγ n ?1这里γ 代表剪切应力率单击鼠标右键选择系统变量3/23/2007 ? 2007 ANSYS, Inc. All rights reserved. CFX 11.0ANSYS, Inc. ProprietaryInventory #002445 6-8Version 1.3CEL 在CFX前处理中实例 1 ? 一个表达式可以直接输入3/23/2007 ? 2007 ANSYS, Inc. All rights reserved.CFX 11.0 ANSYS, Inc. ProprietaryInventory #002445 6-9Version 1.3CEL 在CFX前处理中实例 2 ? 使用分步函数–在最初的19个迭代步中,设置入口温度为300 K 然后再第20个迭代步以后上升为350 K单击鼠标右键选择系统变量3/23/2007 ? 2007 ANSYS, Inc. All rights reserved.CFX 11.0 ANSYS, Inc. ProprietaryInventory #002445 6-10Version 1.3用户自定义函数可以定义自己的1-D 线形, 或是or 3-D云图函数导入数据或手动添加3/23/2007 ? 2007 ANSYS, Inc. All rights reserved.CFX 11.0 ANSYS, Inc. ProprietaryInventory #002445 6-11Version 1.3用户自定义函数实例 ? 时间步随着迭代步的改变迭代步数无量纲时间步为秒3/23/2007 ? 2007 ANSYS, Inc. All rights reserved.CFX 11.0 ANSYS, Inc. ProprietaryInventory #002445 6-12Version 1.3用户自定义函数实例 ? 时间步随着迭代步的改变3/23/2007 ? 2007 ANSYS, Inc. All rights reserved.CFX 11.0 ANSYS, Inc. ProprietaryInventory #002445 6-13Version 1.3在CFX后处理中的积分函数对于高级用户来说,在求解器中对积分函数进行操作也是可能的。
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将永远和我们的用户伙伴一起,用最先进的技术手段,不断揭开我们身边真实物理世界的神秘面纱。
一.CFX产品特点简介CFX是全球第一个在复杂几何、网格、求解这三个CFD传统瓶径问题上均获得重大突破的商业CFD软件。
借助于其独一无二的,有别于其它CFD软件的技术特点,CFX领导着新一代高性能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>,若只是两个无量纲的变量进行相加用户不需要考虑量纲的问题;但是这两个变量具有量纲则需要考虑量纲的问题了。
表达式可以由之前已定义的表达式进行定义,例如:<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]。