CFX11 Customizing CH2 CCL and CEL
February 4, 2017 | Author: Vignesh Waran | Category: N/A
Short Description
Download CFX11 Customizing CH2 CCL and CEL...
Description
2008 International ANSYS Conference Training Manual
Customizing CFX CFX Command Language (CCL) and CFX Expression Language (CEL)
ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
2-1
August 26, 2008 Inventory #002568
CCL and CEL
Methods of customization
Training Manual
• CFX can be customized using: – CFX Command Language (CCL) • Including CFX Expression Language (CEL) • Additional variables • User sources
– Embedded Perl in CCL – User Fortran – Customised executables produced by ANSYS (modified source code)
ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-2
August 26, 2008 Inventory #002568
CCL and CEL
CFX Command Language (CCL)
Training Manual
• CCL is the language used to specify the solver physics, including: – – – – –
Material properties Physical models Boundary conditions Initialisation Solver control
• A knowledge of CCL is helpful for User Fortran • Many users do not need to use CCL as it is automatically generated by CFX-Pre • Advanced users will find CCL a time-saving and powerful feature • CCL is also used by CFX-Pre and CFX-Post ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-3
August 26, 2008 Inventory #002568
CCL and CEL
Why edit CCL?
Training Manual
• CCL is normally generated automatically by CFX-Pre, but may also be edited manually • Useful for trivial changes without starting CFX-Pre • Some advanced solver functionality can only be set up this way for example: – Some advanced CCL parameters – Certain expert parameters e.g. EXPERT PARAMETERS: solve meshdisp = f END
• Advanced users often use CCL to make more complex changes ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-4
August 26, 2008 Inventory #002568
CCL and CEL
Editing CCL
Training Manual
• CCL is contained within the definition file Command File (CCL)
• The definition file is a binary file and cannot be edited directly
Mesh (def and res file) Definition or Results file
• The CCL editor may be used to make simple changes
Solution Data (res file or def file after solution interpolation)
• More complex changes require the CCL to be manually edited
ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-5
August 26, 2008 Inventory #002568
CCL and CEL
Editing CCL using cfx5cmds
Training Manual
The cfx5cmds utility is used from the command line as follows: •
Read CCL from the definition file: cfx5cmds -def file1.def -text file1.ccl -read
• The CCL may then be edited using a text editor: • Finally, write the modified CCL to the definition file: cfx5cmds -def file1.def -text file1.ccl -write file1.def (original)
cfx5cmds -read
file1.def (original)
Editor
file1.ccl (original)
cfx5cmds -write file1.ccl (modified) file1.def (modified)
ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-6
August 26, 2008 Inventory #002568
CCL and CEL
CCL structure and syntax
Training Manual
• Comments start with # (inline comments permitted) • \ (backslash) is the continuation character • Organised as a hierarchical structure of CCL objects, which may contain other objects and parameters LIBRARY: MATERIAL: Water at RTP Option = Pure Substance PROPERTIES: Option = General Fluid Density = 9.98E2 [kg m^-3] Dynamic Viscosity = 1.E-3 [kg m^-1 s^-1] Specific Heat Capacity = 4.19E3 [J kg^-1 K^-1] Thermal Conductivity = 5.91E-1 [W m^-1 K^-1] Thermal Expansivity = 2.1E-4 [K^-1] END END END
• RULES file contains allowed objects and parameters (located in the etc subdirectory in a CFX installation) ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-7
August 26, 2008 Inventory #002568
CCL and CEL
The -ccl option
Training Manual
• This allows CCL to be specified directly to the solver without modifying the definition file • Example of usage: cfx5solve -def test.def –ccl file1.ccl • Important notes: – The CCL in the definition file is not changed – The CCL specified with the –ccl option does not replace the CCL in the definition file – The specified CCL is merged with the CCL already in the definition file – Can be used to add or modify but not remove CCL
• The resulting CCL used by the solver is given at the top of the solver output file ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-8
August 26, 2008 Inventory #002568
CCL and CEL
CFX Expression Language (CEL)
Training Manual
• CFX Expression Language (CEL) is a subset of CCL • It is important to be comfortable with the syntax and application of CEL in order to use CFX user CEL functions (user Fortran) effectively
ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-9
August 26, 2008 Inventory #002568
CCL and CEL
CFX Expression Language (CEL)
Training Manual
• CEL is an interpreted, declarative language which enables users to enhance simulations without recourse to external fortran routines • Many functions which could only be performed in user Fortran in CFX-4 and CFX-TASCflow can be performed using CEL • CEL uses mathematical expressions for physical quantities as opposed to using fixed values • Access is available to many CFX internal variables (including solution variables) ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-10
August 26, 2008 Inventory #002568
CCL and CEL
CFX Expression Language (CEL)
Training Manual
• CEL includes built-in mathematical functions • In CFX-Pre, CEL can be used on any form which has an Expression Editor button (click in the value field to see this button) • Since CEL is a subset of CCL, it may also be edited as part of a CCL file • Examples where CEL may be used: – – – –
Variable Material Properties Complex boundary conditions Variable initial conditions User Sources
• In CFX-Post (e.g to define user defined variables)
ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-11
August 26, 2008 Inventory #002568
CCL and CEL
Creating Expressions - constants
Training Manual
• Constant value expressions are specified with units. For example: x1 = 4.8 [m] inletspeed = 840.25 [m/s] Tsource = 353.15 [K] inletmf = 0.9
• If no units are specified, the value is interpreted as dimensionless ( [ ] is also dimensionless)
ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-12
August 26, 2008 Inventory #002568
CCL and CEL
Creating Expressions - continued
Training Manual
• Expressions are mathematical combinations of predefined values, system variables, numerical constants, and other predefined expressions: area = 0.25*pi*d^2 xc = R*cos(theta) vel12scaled = scale*sqrt(u^2+v^2)
• Expressions may include in-line units: xoffset = x + 4 [m] vdot = mdot / 133 [kg m^-3]
• The result units of expressions are not declared. They are the result of units in the expression. The following expression has units of [kg m^-2 s^-1] 8.0[kg m^-3] * 3.3[m s^-1])
ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-13
August 26, 2008 Inventory #002568
CCL and CEL
Rules for Expressions
Training Manual
• Variables and expressions are case sensitive • Brackets can be used to specify the order of operations • For multiple line expressions, operators may be used to separate each line e.g., A+ B/C could be written as: A+ B /C
• Expressions must be dimensionally consistent e.g: 1.0[mm] + 0.45[yds] 2.5[s m^-1] - (3.0[m s^-1])^-1 1.0[mm] + 0.3[kg]
ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
(valid) (valid) (invalid)
1-14
August 26, 2008 Inventory #002568
CCL and CEL
System Variables
Training Manual
• Only a very small selection is shown, there are many others • Use the right-click menu in the Expression Editor for a complete list of available variables Variable
Units
Description
x,y,z
m
Direction 1, 2 and 3 in Local Coordinate Frame
u
m s-1
Velocity in the x coordinate direction
p
kg m-1 s-2
Pressure
ptot
kg m-1 s-2
Total Pressure
mf
dimensionless
Mass Fraction
density
kg m-3
Density
T
K
Temperature
viscosity
kg m-1 s-1
Dynamic Viscosity
Cp
m2 s-2 K-1
Specific Heat Capacity at Constant Pressure
cond
kg m s-3 K-1
Thermal Conductivity
ctstep
dimensionless
Current time step
atstep
dimensionless
Accumulated time step
citern
dimensionless
Current iteration number
aitern
dimensionless
Accumulated iteration number
ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-15
August 26, 2008 Inventory #002568
CCL and CEL
System Variable Prefixes
Training Manual
• In order to distinguish system variables of different components and fluids, prefixes are used. This is relevant in multi-phase or multi-component simulations. For example: Variable
Meaning
pressure
Pressure (no prefix required).
Air.density
Density of ‘Air’.
Air.viscosity
Viscosity of ‘Air’.
Air.carbondioxide.mf
Mass fraction of carbon dioxide in air (in a multi-component mixture).
• For single-phase, single component simulations, the prefix can usually be omitted
ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-16
August 26, 2008 Inventory #002568
CCL and CEL
Vector & Tensor Components
Training Manual
• CEL is a scalar language. To specify the components of velocity or stress variable use u,v,w postfixes. Velocity itself is a special case and the short forms u, v, w are valid for the x, y, z components of the velocity. All other vectors and tensors use post fixes X,Y,Z. Variable
Components
Velocity
Velocity u, Velocity v, Velocity w or u,v,w
Reynolds stress
Reynolds Stress uu, Reynolds Stress uv, ..
Normal Vector
Normal Vector X, Normal Vector Y, Normal Vector Z
• Note that short name forms use lower case X,Y,Z post fixes. E.g. Magnetic Induction X or bmag x are identical. ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-17
August 26, 2008 Inventory #002568
CCL and CEL
Variables : Normal Vectors
Training Manual
• Normal unit and area vectors can be used in CEL expressions on 2D regions – A = Normal X * …… – B = Normal Area X * ….
• Only supported on 2D region element faces, or integrations points • Can only be used in expressions on boundaries (e.g: boundary conditions or boundary sources) or domain interfaces
ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-18
August 26, 2008 Inventory #002568
CCL and CEL
Variables : Coordinate Frames
Training Manual
• Local coordinate frame transformations currently only apply to position variables on RHS of expressions: – x, y, z, r, theta, aaxis, taxis, raxis
• If desired, in 11.0 local transformations are applied to vector and tensor variables (eg: velocity) by setting the expert parameter – cel global to local = t
• Default value is set to false for backwards compatibility issues
ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-19
August 26, 2008 Inventory #002568
CCL and CEL
Variable Operators
Training Manual
• Variable operators can be used in CEL expressions • Curl, Gradient, Trnmin, Trnmax, Trnrms, Trnsdv, Trnavg: A = Pressure.Trnrms * ….. B = Temperature.Trnavg C = Temperature.Gradient X Gradients on vertices only available for solved for (principal) variables plus Temperature, Density and Algebraic AV’s – Gradients on vertices require parallel communication – – – –
• Variable operators cannot be used as arguments to integrated CEL functions, nor can be monitored/probed at a point – Workaround: create an algebraic AV, and use it instead – Workaround also works to get at gradients of non-principal variables ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-20
August 26, 2008 Inventory #002568
CCL and CEL
CEL Built-in constants
Training Manual
Constant
Value
Units
Description
e
2.7182818
dimensionless
Usual meaning
g
9.806
m/s2
Acceleration due to gravity
pi
3.1415927
dimensionless
Usual meaning
R
8314.5
m2/(s2 K)
Universal gas constant
stefan
5.670400E-08
W m-2 K-4
Stefan-Boltzmann constant
boltzmann
1.3806503E-23
J K-1
Boltzmann’s constant
planck
6.62606876E-34
Js
Planck Constant
clight
2.99792458E+08
m/s
Speed of light
avogadro
6.02214199E+23
mol-1
Avogadro constant
ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-21
August 26, 2008 Inventory #002568
CCL and CEL
CEL operators
Training Manual
Operator
Description
1st operand dimensions
2nd operand dimensions
Operand values
Result dimensions
-x
Negation (unary)
any
-
any
[x]
x+y
Addition
any
[x]
any
[x]
x-y
Subtraction
any
[x]
any
[x]
x∗y
Product
any
any
any
[x]*[y]
x/y
Quotient
any
any
y≠0
[x]/[y]
X^y
Power
any
[]
Any
[x] [y]
(if y0
[x] [y]
[]
[]
Y>0
[]
(where y is a simple constant expression)
x^y
Power (where y is not simple and constant)
ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-22
August 26, 2008 Inventory #002568
CCL and CEL
CEL Built-in functions
Training Manual
Function
Description
Argument units
Result units
sin(x)
sine
angle
dimensionless
cos(x)
cosine
angle
dimensionless
tan(x)
tangent
angle
dimensionless
asin(x)
sin-1
dimensionless
angle
acos(x)
cos-1
dimensionless
angle
atan(x)
tan-1
dimensionless
angle
atan2(x,y)
tan-1
dimensionless
angle
sinh(x)
hyperbolic sine
angle
dimensionless
cosh(x)
hyperbolic cosine
angle
dimensionless
tanh(x)
hyperbolic tangent
angle
dimensionless
exp(x)
ex
dimensionless
dimensionless
ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-23
August 26, 2008 Inventory #002568
CCL and CEL
CEL Built-in functions
Training Manual
Function
Description
Argument units Result units
loge(x)
natural log
dimensionless
dimensionless
ln(x)
(alias for loge function)
log10(x)
log base 10
dimensionless
dimensionless
log(x)
(alias for log10 function)
abs(x)
|x|
any
units of x
sqrt(x)
square root
any
units of x½
step(x)
step function
dimensionless
dimensionless
min(x,y)
minimum
any ([x] = [y])
units of x
max(x,y)
maximum
any ([x] = [y])
units of x
int(x)
integer part of x
any
units of x
nint(x)
nearest integer
any
units of x
besselJ(n,x)
bessel function (1st kind)
dimensionless
dimensionless
besselY(n,x)
bessel function (2nd kind)
dimensionless
dimensionless
ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-24
August 26, 2008 Inventory #002568
CCL and CEL
Expression Editor
Training Manual
• Available from many forms and from the toolbar:
• Interactive tool for developing and managing expressions within CFXPre • Define, delete, edit and copy values and expressions • Plot and evaluate expressions
ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-25
August 26, 2008 Inventory #002568
CCL and CEL
CEL Example (boundary condition)
Training Manual
• Setting a parabolic velocity profile for an inlet boundary:
Right click will bring a lot of functionalities
ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-26
August 26, 2008 Inventory #002568
CCL and CEL
Integrated quantity CEL functions
Training Manual
• These allow integrated quantities to be used in CEL expressions • Integrated quantity functions operate on a ‘locator’: – min, max, average values of variables over points, areas, volumes – area, volume, force on a boundary – volume and area integrals of variables
• These may be calculated over a domain, subdomain or boundary patch, see following table for valid locations for each quantity. Defined mesh regions may also be used. • In the Solver, the integrated quantities are evaluated at the start of each time-step • In a parallel run, data is automatically collated over all partitions and the required global value returned ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-27
August 26, 2008 Inventory #002568
CCL and CEL
List of integrated quantity CEL functions Function
Return units
Valid regions D
S
Training Manual
Description
B
area()
area
Y
Total surface area of all faces of specified boundary
area_x(), area_y(), area_z()
area
Y
Total surface area of all faces of specified boundary projected in the x, y or z direction
massFlowAve(φ φ)
units of φ
Y
Mass flow weighted average of φ on a 2D locator (non-boundary regions use approximate mass flows)
massFlowAveAbs(φ φ)
units of φ
Y
Absolute Mass flow weighted average of φ on a 2D locator (non-boundary regions use approximate mass flows)
massFlow()
mass flow
Y
Mass flow through faces of specified 2D locator (non-boundary regions use approximate mass flows)
massFlowInt(φ φ)
units of φ . area
Y
Mass flow weighted integration of φ on specified 2D locator (non-boundary regions use approximate mass flows)
massAve(φ φ)
units of φ
areaAve(φ φ)
units of φ
rmsAve(φ φ)
units of φ
Y
volumeAve(φ φ)
units of φ
Y
areaInt(φ φ)
units of φ . area
ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
Y
Mass weighted average of φ
Y Y
Area weighted average of φ on a boundary
Y
RMS average of φ on a boundary or domain Volume weighted average of φ on a domain
Y
1-28
Surface area integration of φ on a boundary
August 26, 2008 Inventory #002568
CCL and CEL
List of integrated quantity CEL functions
Function
Return units
Valid regions D
S
B
Training Manual
Description
ave(φ φ)
units of φ
Y
Y
Y
Arithmetic average of φ
sum (φ φ)
units of φ
Y
Y
Y
Sum of φ over all domain vertices or boundary faces
minVal (φ φ)
units of φ
Y
Y
Y
Minimum value of φ When φ is a vector or tensor the minimum magnitude is returned
maxVal (φ φ)
units of φ
Y
Y
Y
Maximum value of φ When φ is a vector or tensor the maximum magnitude is returned
probe (φ φ)
units of φ
force()
force
Y
Magnitude of the total force on a 2D locator (non-boundary regions use approximate forces)
force_x()
force
Y
Total force in the x-direction on boundary faces (non-boundary regions use approximate forces)
force_y()
force
Y
Total force in the y-direction on a 2D locator (non-boundary regions use approximate forces)
force_z()
force
Y
Total force in the z-direction on a 2D locator (non-boundary regions use approximate forces)
ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
Cartesian coordinate
Value of φ at specified point locator
1-29
August 26, 2008 Inventory #002568
CCL and CEL
List of integrated quantity CEL functions
Function
Return units
Valid regions D
S
Training Manual
Description
B
torque()
torque
Y
Magnitude of the total torque on a 2D locator (non-boundary regions use approximate torques)
torque_x()
torque
Y
Total torque in the x-direction on a 2D locator (non-boundary regions use approximate torques)
torque_y()
torque
Y
Total torque in the y-direction on a 2D locator (non-boundary regions use approximate torques)
torque_z()
torque
Y
Total torque in the z-direction on a 2D locator (non-boundary regions use approximate torques)
volume()
volume
Y
Y
Total volume of a domain or subdomain
mass()
mass
Y
Y
Total mass within a domain or subdomain
volumeInt (φ φ)
units of φ . vol
Y
Y
Volume weighted integration of φ
massInt (φ φ)
units of φ . mass
Y
Y
Mass weighted integration of φ
inside()
dimensionless
Y
Y
ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
Y
1-30
Returns 1 if in specified region 0 if not.
August 26, 2008 Inventory #002568
CCL and CEL
Regions for integrated quantities
Training Manual
• Non-physics regions are available as locators for integrated quantities – Non-physics = not used for a BC, subdomain, domain – General syntax: Function()@ – can be a general 2D or 3D region defined during mesh generation or in CFX Pre
• Non-unique named locators can be differentiated using the REGION: syntax – User defined region or mesh region • massFlow()@REGION: Inlet
– Physics boundary • massFlow()@Inlet – “REGION” syntax does not yet work in CFX Post, which has its own approach for addressing non-unique names ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-31
August 26, 2008 Inventory #002568
CCL and CEL
Integrated functions + Local Coordinates
Training Manual
• Return value of integrated CEL vector functions such as force(), torque() and area() respect local coordinate frame definitions • The syntax [_CoordFrame] for those vector based CEL functions is supported, for example: – torque_x_Coord 1()@REGION: inlet – force_y_My Local CoordFrame()@Wall – area_z_Coord 2()@Inlet
ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-32
August 26, 2008 Inventory #002568
CCL and CEL
Examples of using integrated quantity functions
Training Manual
• Expression to return the nodal average value of the density of the fluid called ‘FuelGas’ in the domain called ‘Tank’ rhoMean = ave(FuelGas.density)@Tank
• Expression to return the area of the boundary called ‘inlet1’ area1 = area()@inlet1
• Expression to return the mass flow of the fluid called ‘FuelGas’ through the boundary called ‘inlet1’ mdotGasIn = FuelGas.massFlow()@inlet1
• Expression to return the area of the mesh region called ‘in1’ area2 = area()@REGION:in1
ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-33
August 26, 2008 Inventory #002568
CCL and CEL
Example: Applying a parabolic inlet profile with CEL
Training Manual
• Step with parabolic inlet velocity profile • This is achieved by setting the inlet velocity as a function of one of the coordinate values: e.g. umax(1-(y/ymax)2) • A very simple example implemented in CEL
ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-34
August 26, 2008 Inventory #002568
CCL and CEL
Example: Applying a parabolic inlet profile with CEL
• May easily be set up from CFX-Pre or by editing the command language from an existing definition file • A number of CEL values and expressions are defined • The inlet velocity is specified using a CEL expression • In a later practical exercise, this example will be implemented in user Fortran ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
Training Manual
LIBRARY: .. .. CEL: EXPRESSIONS: velmax = 1.0E-03 [m/s] ymax = 0.05 [m] ynorm = y/ymax END END END BOUNDARY: inlet Boundary Type = INLET Coord Frame = Coord 0 Location = inlet BOUNDARY CONDITIONS: FLOW REGIME: Option = Subsonic END MASS AND MOMENTUM: Normal Speed = velmax * (1.0 - ynorm^2) Option = Normal Speed END END END 1-35
August 26, 2008 Inventory #002568
CCL and CEL
User specified sources
Training Manual
• User Sources may be specified for any equation • In CFX, sources are in residual mode. This is different from the level mode implementation in some codes. The implications of this are: – The source (Sφ φ) is set to the actual source value. • Either a source per unit area/volume – “Source” option • Or the total source over the entire location – “Total Source” option
– An optional source coefficient may be specified e.g. ∂Sφ/ φ/∂ φ/∂φ or an approximation to this – The source coefficient has no effect on the converged solution, but will affect convergence – A positive source coefficient is likely to cause divergence
ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-36
August 26, 2008 Inventory #002568
CCL and CEL
User specified sources
Training Manual
• Sources may be specified on subdomains or at a point location in a domain • Sources may be defined using an expression, which may include a user CEL function (Fortran) • There are special considerations for sources in a multiphase simulation: – Fluid specific sources are added to the phase equations without volume fraction weighting. If required, this must be included explicitly – Bulk sources are multiplied by the volume fraction
• For mass sources: – Values may be specified for incoming variables – If values are not specified, then the solution values are used ANSYS, Inc. Proprietary © 2008 ANSYS, Inc. All rights reserved.
1-37
August 26, 2008 Inventory #002568
View more...
Comments