Version 1.3
3/23/2007
© 2007 ANSYS, Inc. All rights reserved.
CFX 11.0
ANSYS, Inc. Proprietary
Inventory #002445
6-1
CFX 表达式语言
(CEL)
CFX 表达式语言
(CEL)
讲座 6讲座 6
Version 1.3
3/23/2007
© 2007 ANSYS, Inc. All rights reserved.
Inventory #002445
6-2
CFX 11.0
ANSYS, Inc. Proprietary
• CEL - CFX Expression Language
– 允许用户创建方程 (可以定制求解的方程或是系统变量) 用于
CFX前处理和CFX后处理
• 例:
CFX 表达式语言CFX 表达式语言
Version 1.3
3/23/2007
© 2007 ANSYS, Inc. All rights reserved.
Inventory #002445
6-3
CFX 11.0
ANSYS, Inc. Proprietary
• 语法规则与常规的代数语法规则相同
• 算子:
+ (加) - (减) * (乘)
/ (除) ^ (乘方)
• 变量和表达式对大小写敏感 (例: 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]
CEL 规则CEL 规则
Version 1.3
3/23/2007
© 2007 ANSYS, Inc. All rights reserved.
Inventory #002445
6-4
CFX 11.0
ANSYS, Inc. Proprietary
Built In FunctionsBuilt In Functions
• 一些数学函数和算子也可以在CEL中使用
– 用户定制的函数可以通过使用Fortran语言创建
Function Operand’s Dimensions [x] Operand’s Values Result’s 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 < x Dimensionless
abs(x) Any Any [x]
sqrt(x) Any 0 ≤ x [x]^0.5
min(x,y) *** Any Any [x]
max(x,y) *** Any Any [x]
step(x) * Dimensionless Any Dimensionless
*step(x) is 0 for negative x, 1 for positive x and 0.5 for x=0.
** note that tan(x) is undefined for npi/2 where n=1, 3, 5 .. .
*** both x and y must have the same dimensions.
Version 1.3
3/23/2007
© 2007 ANSYS, Inc. All rights reserved.
Inventory #002445
6-5
CFX 11.0
ANSYS, Inc. Proprietary
x Direction 1 in Reference Coordinate Frame
y Direction 2 in Reference Coordinate Frame
z Direction 3 in Reference Coordinate Frame
r Radial spatial location, r = (x^2+y^2)^0.5
theta Angle, arctan(y/x)
t Time
u Velocity in the x coordinate direction
v Velocity in the y coordinate direction
w Velocity in the z coordinate direction
p (absolute) Pressure
ke Turbulent kinetic energy
ed Turbulent eddy dissipation
T Temperature
sstrnr Shear strain rate
density Density
rNoDim Non-dimensional radius (rotating frame only)
viscosity Dynamic Viscosity
Cp Specific Heat Capacity at Constant Pressure
cond Thermal Conductivity
AV name Additional Variable name
mf Mass Fraction
系统变量系统变量
• 许多系统变量是可以在CEL中进行使用的
• 单位已经被包含
• 下面是可以被使用的系统变量列表:
只用被应用时只用被应用时只用被应用时只用被应用时,,,,系统系统系统系统
参数才可以被选择参数才可以被选择参数才可以被选择参数才可以被选择
Version 1.3
3/23/2007
© 2007 ANSYS, Inc. All rights reserved.
Inventory #002445
6-6
CFX 11.0
ANSYS, Inc. Proprietary
如何创建CEL如何创建CEL
Version 1.3
3/23/2007
© 2007 ANSYS, Inc. All rights reserved.
Inventory #002445
6-7
CFX 11.0
ANSYS, Inc. Proprietary
如何创建CEL如何创建CEL
加入更多的表达式
(和在 CFX后处理
中采用相同的方法)
Version 1.3
3/23/2007
© 2007 ANSYS, Inc. All rights reserved.
Inventory #002445
6-8
CFX 11.0
ANSYS, Inc. Proprietary
这里 γ代表剪切应力率
CEL 在CFX前处理中
实例 1
CEL 在CFX前处理中
实例 1
• 创建一个粘性变量创建一个粘性变量创建一个粘性变量创建一个粘性变量
– 粘性剪切流体的粘度:
1−
=
nKγµ
单击鼠标右键选择系统变单击鼠标右键选择系统变单击鼠标右键选择系统变单击鼠标右键选择系统变
量量量量
Version 1.3
3/23/2007
© 2007 ANSYS, Inc. All rights reserved.
Inventory #002445
6-9
CFX 11.0
ANSYS, Inc. Proprietary
CEL 在CFX前处理中
实例 1
CEL 在CFX前处理中
实例 1
• 一个表达式可以直接输入一个表达式可以直接输入一个表达式可以直接输入一个表达式可以直接输入
Version 1.3
3/23/2007
© 2007 ANSYS, Inc. All rights reserved.
Inventory #002445
6-10
CFX 11.0
ANSYS, Inc. Proprietary
• 使用分步函数使用分步函数使用分步函数使用分步函数
– 在最初的19个迭代步中,设置入口温度为300 K 然后再
第20个迭代步以后上升为350 K
CEL 在CFX前处理中
实例 2
CEL 在CFX前处理中
实例 2
单击鼠标右键选择系统变量单击鼠标右键选择系统变量单击鼠标右键选择系统变量单击鼠标右键选择系统变量
Version 1.3
3/23/2007
© 2007 ANSYS, Inc. All rights reserved.
Inventory #002445
6-11
CFX 11.0
ANSYS, Inc. Proprietary
用户自定义函数用户自定义函数
• 可以定义自己的1-D 线形, 或是or 3-D云图函数
导入数据导入数据导入数据导入数据
或手动添或手动添或手动添或手动添
加加加加
Version 1.3
3/23/2007
© 2007 ANSYS, Inc. All rights reserved.
Inventory #002445
6-12
CFX 11.0
ANSYS, Inc. Proprietary
用户自定义函数
实例
用户自定义函数
实例
• 时间步随着迭代步的改变时间步随着迭代步的改变时间步随着迭代步的改变时间步随着迭代步的改变
迭代步数无量纲迭代步数无量纲迭代步数无量纲迭代步数无量纲
时间步为秒时间步为秒时间步为秒时间步为秒
Version 1.3
3/23/2007
© 2007 ANSYS, Inc. All rights reserved.
Inventory #002445
6-13
CFX 11.0
ANSYS, Inc. Proprietary
用户自定义函数
实例
用户自定义函数
实例
• 时间步随着迭代步的改变时间步随着迭代步的改变时间步随着迭代步的改变时间步随着迭代步的改变
Version 1.3
3/23/2007
© 2007 ANSYS, Inc. All rights reserved.
Inventory #002445
6-14
CFX 11.0
ANSYS, Inc. Proprietary
• 在指定位置允许对非逻辑合成函数进行计算.
• 例子:
– 计算在等值面上Cp的面积平均:
areaAve(Cp)@iso1
– 经过某一个位置的某种流体的流量:
oil.massFlow()@slice1
• 注意:
– “@
” -必须作用于某一个几何位置.
– 流体中的某相或某个组分可以通过下面方式选取
[.][.]
对于高级用户来说,在求解器中对积分函数进行操作也是可能
的。这些函数可以被输入到表达式中,也可以在Solver
Manager中被观测(详见文献中关于Output Control的描述)
在CFX后处理中的积分函数在CFX后处理中的积分函数
Version 1.3
3/23/2007
© 2007 ANSYS, Inc. All rights reserved.
Inventory #002445
6-15
CFX 11.0
ANSYS, Inc. Proprietary
• 系统中有一些已经定义好了的合成函数
• 0 或 1 取决于具体的函数---参看帮助文档
• 如果1 :
– 可以是Post当中的一个表达式; 在求解器当中只允许以变量形式
存在
– 返回值得单位取决于宗数的单位
合成变量合成变量
Version 1.3
3/23/2007
© 2007 ANSYS, Inc. All rights reserved.
Inventory #002445
6-16
CFX 11.0
ANSYS, Inc. Proprietary
监视器
监视表达式
监视器
监视表达式
• 下面列出了一些函数,他们是可以在监视表达式中获得的
并且可以在后处理中获得 (连续几页)
Function Name and Syntax
[]
area( )@
Area of a boundary or
interface.
Any 2D region (e.g., boundary
or interface)
area_x( )@
area_y( )@
area_z( )@
Area-weighted average of
on a boundary.
Any 2D region (e.g., a
boundary or interface)
areaAve()@
Area-weighted average of
on a boundary.
Any 2D region (e.g., a
boundary or interface)
areaInt()@
Area-weighted integral of
on a boundary.
Any 2D region (e.g., a
boundary or interface)
ave()@
Arithmetic average of
within a domain or subdomain.
Any 3D region (e.g., domain or
subdomain)
[.]force( )@
The magnitude of the force
vector on a boundary. Any 2D region (e.g., a wall)
Operation Valid
Version 1.3
3/23/2007
© 2007 ANSYS, Inc. All rights reserved.
Inventory #002445
6-17
CFX 11.0
ANSYS, Inc. Proprietary
监视器
监视表达式
监视器
监视表达式
Function Name and Syntax
[]
[.]force_x( )@
[.]force_y( )@
[.]force_z( )@
The (signed) component of the
force vector in the local x, y
or z direction. Any 2D region (e.g., a wall)
inside()@
Similar to the subdomain
variable, but allows a specific
2D or 3D location to be given.
Any 2D or 3D named sub-
region of the physical location
on which the expression is
evaluated.
mass()@
The total mass within a domain
or subdomain. This is fluid
dependent.
Any 3D region (e.g., domain or
subdomain)
massAve()@
Mass-weighted average of
on a domain or
subdomain.
Any 3D region (e.g., domain or
subdomain)
massInt()@
The mass-weighted integration
of within a domain or
subdomain
Any 3D region (e.g., domain or
subdomain)
[.]massFlow()@ Mass flow through a boundary.
Any fluid surfaces (e.g., Inlets,
Outlets, Openings and fluid-
fluid interfaces)
[.]massFlowAve()
@
Mass flow weighted average of
on a boundary.
Any fluid surfaces (e.g., Inlets,
Outlets, Openings and fluid-
fluid interfaces)
Operation Valid
Version 1.3
3/23/2007
© 2007 ANSYS, Inc. All rights reserved.
Inventory #002445
6-18
CFX 11.0
ANSYS, Inc. Proprietary
监视器
监视表达式
监视器
监视表达式
Function Name and Syntax
[]
[.]massFlowAveAbs()
@
Absolute mass flow weighted
average of on a
boundary.
Any fluid surfaces (e.g., Inlets,
Outlets, Openings and fluid-
fluid interfaces)
[.]massFlowInt()
@
Mass flow weighted integration
of on a boundary.
Any fluid surfaces (e.g., Inlets,
Outlets, Openings and fluid-
fluid interfaces)
maxVal()@
Maximum Value of
within a domain or subdomain.
Any 3D region (e.g., domain or
subdomain)
minVal()@
Minimum Value of within
a domain or subdomain.
Any 3D region (e.g., domain or
subdomain)
probe()@
Returns the value of the
specified variable on the
specified Point locator.
Any point object (e.g., a
Source Point or Cartesian
Monitor Point)
rmsAve()@
RMS average of within a
domain.
Any 3D region (e.g., domain or
subdomain)
sum()@
Sum of over all domain
or subdomain vertices.
Any 3D region (e.g., domain or
subdomain)
Operation Valid
Version 1.3
3/23/2007
© 2007 ANSYS, Inc. All rights reserved.
Inventory #002445
6-19
CFX 11.0
ANSYS, Inc. Proprietary
• CEL 允许用户在CFX前处理,CFX求解
器和CFX后处理中创建自己的表达式
关键点关键点