CFX培训教材09CEL语言

ANSYS CFX培训教材ANSYS CFX

第九节:CEL语言

安世亚太科技(北京)有限公司

CEL

CEL -CFX Expression Language

允许使用者在CFX Pre和CFD Post中创建方程(可以是求解变量/系统变量

–CFX-Pre CFD-Post

的函数)

例如:

CEL 规则

语法规则与通常的算术相同:

+(加) -(减去)*(乘) /(除)^(求幂)

变量和表达式区分大小写(如: t 和T)

对于加和减运算,表达式必须在量纲上致(例如: 1.0 [mm] + 0.45 [yds] O K)对于加和减运算表达式必须在量纲上一致:10[mm]+045[yds]

–不能出现量纲不一致的情况

:a^(1/2)+10^05

可以采用分数和十进制数的求幂(例如: 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 重力加速度: 9.806 [m s^-2]

–pi Constant: 3.1415927

–R 通用气体常数: 8314.5 [m^2 s^-2 K^-1]

内部函数

一些数学函数和算子也可以在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

≤ x ≤ 1Angle

asin(x) Dimensionless -1

≤ x ≤ 1 Angle

acos(x) Dimensionless -1

atan(x) Dimensionless Any Angle

()y g

exp(x) Dimensionless Any Dimensionless

x Dimensionless

<

loge(x) Dimensionless 0

<

x Dimensionless

log10(x) Dimensionless 0

abs(x) Any Any [x]

sqrt(x) Any 0 ≤ x [x]0.5

sqrt(x)Any0x[x]^05

if(test, res1, res2)*Any Any Any (res1 and res2 must have the same dimensions) min(x,y) **** Any Any [x]

max(x,y) **** Any Any [x]

step(x) * Dimensionless Any Dimensionless

*if函数包含一个test, 和两个输出结果。当test为true是时,返回第一个输出结果res1. 如果test为false, 返回res2. 如(x>1[m], 1, 0), 当x大于1 [m]的时候,设置体分数为1,如果x小于1[m],设置体分数为0,如果x=1,结果为(res1+res2)/2

**当x为负数时,step(x)=0;x为正时,step(x)= 1;x=0时,step(x)= 0.5

*** note that tan(x) is undefined for nπ/2 where n=1, 3, 5 .. .

(),,

**** both x and y must have the same dimensions.

求解变量

表达式中可以包含求解器变量x Direction 1 in Reference Coordinate Frame Direction 2in 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.5theta Angle, arctan(y/x)t Time

Velocity in the x coordinate direction 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), 有些情

况下变量不可用–例如.需要利用T 求解热传递

(g y)viscosity Dynamic Viscosity

Cp Specific Heat Capacity at Constant Pressure cond Thermal Conductivity AV name Additional Variable name Mass Fraction mf

Mass Fraction

添加更多的表达式(在CFD-Post中有

类似的方法)

在定义窗口点击右键

,可以添加变量,常

数,函数,位置和创建好的表达式

创建一个可变粘度

粘性剪切流体的粘度

这里–粘性剪切流体的粘度:1

?=n K γ

μ这里,

γ代表剪切应力率单击鼠标右键选择系统变量/表达式

表达式还可以直接输入

使用“if”功能

在–头19个迭代步设置入口温度为300K ,在20个迭代步以后入口温度升为320K

求通过鼠标右键选择解器变量

Note: 在21st 迭代进口温度

320K

为320 K

用户函数

可以自定义1-D 的线插值函数或3-D 的空间插值函数

导入数据

点或手动

添加数据

例如: 设置时间步(timestep)随着

迭代次数的变化而变化,如

迭代数无量纲

Timestep量纲为妙

“s”

继续...

例如: 设置时间步(timestep)随着迭代次数的变化而变化,如

在表达式中可以通过积分评估某处的变量

–例如:

–在某等值面上计算面积平均的定压比热容: areaAve(Cp)@iso1

–某种流体通过某位置的质量流: oil.massFlow()@slice1

CFX P CFD P t中都可用

CFX-Pre 和CFD-Post中,都可用

–CFX-Pre中使用更为严格

?例如. 函数的参数必须是变量,而不能是表达式

函数的参数必须是变量而不能是表达式

“@”必须提供一个指定的几何位置

–某边界条件名字, 某domain名字, 某监测点名字等.

对通常的网格区域“@REGION:

相/组分可通过下面方式选取:

[][]@ [.][.]@– E.g. Air.Nitrogen.massFlow()@outlet

有些功能允许x, y 或z 算符:

–area_x()@boundary 在x方向上的面积投影

area x()@boundary

–force_z()@wall 在wall上的作用力的z方向分量

–详见帮助文档

这些功能也可在不同的坐标系下实现:

–force_z_MyCoord()@wall 在坐标系“MyCoord” 下,在wall上作用力的z方向分量 每个函数需要或者0个或者1个自变量

–areaAve需要1个自变量: areaAve(Temperature)@Wall

–massFlow不需要自变量: massFlow()@Inlet

返回值的单位取决于自变量的单位

值单度单–areaAve(Temperature)@Wall 返回值的单位为温度的单位

下列为部分函数列表

–完整列表见帮助

完列表见帮助

–创建表达式时,点击右键会显示大多数函数

F ti N d S t

Function Name and Syntax

[]

area( )@Area of a boundary or

interface.

Any 2D region (e.g., boundary

or interface)

Th(i d)t f th

Operation Valid

area_x( )@ area_y( )@ area_z( )@The (signed) component of the

normal area vector in the local

x, y or z direction.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)

The magnitude of the force

[.]force( )@

g

vector on a boundary.Any 2D region (e.g., a wall)

Function Name and Syntax [][]f ()@The (signed)component of the Operation

Valid

[.]force_x( )@[.]force_y( )@[.]force_z( )@

The (signed) component of the force v ector in the local x, y or z direction.Any 2D region (e.g., a wall)

Similar to the subdomain

Any 2D or 3D named sub-region of the physical location inside()@

Similar to the subdomain v ariable, but allows a specific 2D or 3D location to be giv en.region of the physical location on which the expression is ev aluated.The total mass within a domain or subdomain. This is fluid Any 3D region (e.g., domain or mass()@

dependent.

y g (g

subdomain)massAv e()@

Mass-weighted av erage 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)

Any fluid surfaces (e.g., Inlets, Outlets Openings and fluid [.]massFlow()@Mass flow through a boundary.Outlets, Openings and fluid-fluid interfaces)

[.]massFlowAv e() Mass flow weighted av erage of ar>on a boundary Any fluid surfaces (e.g., Inlets,

Outlets, Openings and fluid-fluid interfaces)@

on a boundary.fluid interfaces)

Function Name and Syntax []Absolute mass flow weighted Any fluid surfaces (e.g.,Inlets,Operation

Valid

[.]massFlowAv eAbs() @

Absolute mass flow weighted av erage of on a boundary.

Any fluid surfaces (e.g., Inlets, Outlets, Openings and fluid-fluid interfaces)

[.]massFlowInt() Mass flow weighted integration

Any fluid surfaces (e.g., Inlets, Outlets, Openings and fluid-[]()@

g g of on a boundary.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)

Returns the v alue of the

specified v ariable on the Any point object (e.g., a Source Point or Cartesian probe()@specified v ariable on the specified Point locator.Source Point or Cartesian Monitor Point)

rmsAv e()@RMS av erage of within a domain.Any 3D region (e.g., domain or subdomain)Sum of ov er all domain Any 3D region (e g domain or sum()@

Sum of ov er all domain or subdomain v ertices.Any 3D region (e.g., domain or subdomain)

一些有用的函数

inside()函数,当在指定位置之内时返回值为1,当位于指定位置之外时,返回值为0

之外时回值为

–用于限定函数的范围,如subdomain或边界(boundary)

step() 函数,当变量为正时返回值为1,变量值为负时返回值是0–开关函数

–if()函数也能作为开关函数

areaAve() 和massFlowAve() 用于评估某一位置的平均量

()是加权平均用于非流动量的边界,例如出处压力–areaAve() 是一加权平均. 用于“非流动量”的wall, .出口处压力,wall上的温度

–massFlowAve()是对局部质量流的加权平均. 通常用于评估流动量,

通常用于评估“流动量”

例如出口处的温度.

谢谢https://www.360docs.net/doc/ca3334888.html,

相关主题
相关文档
最新文档