CEL教程.docx
- 文档编号:3613011
- 上传时间:2022-11-24
- 格式:DOCX
- 页数:12
- 大小:36.41KB
CEL教程.docx
《CEL教程.docx》由会员分享,可在线阅读,更多相关《CEL教程.docx(12页珍藏版)》请在冰豆网上搜索。
CEL教程
Chapter 13:
CFXExpressionLanguage(CEL)
CFXExpressionLanguage(CEL)isaninterpreted,declarativelanguagethathasbeendevelopedtoenableCFXuserstoenhancetheirsimulationswithoutrecoursetowritingandlinkingseparateexternalFortranroutines.
YoucanuseCELexpressionsanywhereavalueisrequiredforinputinANSYSCFX.
CELcanbeusedto:
∙Definematerialpropertiesthatdependonothervariables.
∙Specifycomplexboundaryconditions.
∙Addtermstothesolvedequations.
Youcanalsomonitorthevalueofanexpressionduringthesolutionusingmonitorpoints.
Important:
ThereissomeCELthatworkselsewhereinANSYSCFX,butnotinCFD-Post.AnyexpressioncreatedinCFX-PreandusedasaDesignExplorationoutputparametercouldpotentiallycausefatalerrorsduringtheDesignExplorationrun,soyoushouldcreateallexpressionsforDesignExplorationoutputparametersinCFD-Post.
Thischapterdescribes:
∙CELFundamentals
∙CELOperators,Constants,andExpressions
∙CELExamples
∙CELTechnicalDetails
Release13.0-©2010SASIP,Inc.Allrightsreserved.
13.1. CELFundamentals
Thefollowingtopicswillbediscussed:
∙ValuesandExpressions
∙CFXExpressionLanguageStatements
Release13.0-©2010SASIP,Inc.Allrightsreserved.
13.1.1. ValuesandExpressions
CELcanbeusedtogeneratebothvaluesandexpressions.Valuesaredimensional(thatis,withunits)ordimensionlessconstants.Thesimplesttypeofdefinitionisthedimensionlessvalue,forexample:
b=3.743
Youcanalsospecifyavaluewithunits,forexample:
g=9.81[ms^-2]
ThedimensionsofthequantitiesofinterestforCFDcalculationscanbewrittenintermsofmass,length,time,temperatureandangle.Theconceptofunitsisfundamentaltothebehaviorofvaluesandexpressions.
Valuescanbeuseddirectly,ortheycanbeusedaspartofanexpression.Forexample,youcanuseanexpressiontoaddtwovaluestogether:
Inthisexample,youmaywanttopredefine
Expressionscanalsobefunctionsofother(predefined)expressions:
UnitsfollowtheconventionsintherestofCFX,inthatacalculationhasasetofsolutionunits(bydefault,SIunits),andthatanyquantitycanbedefinedeitherintermsofthesolutionunits,oranyothersetofunitswiththecorrectform.
Anexpressiondoesnothaveitsownunitsstring,butifitreferencesquantitiesthathavedimensions,thesewilldeterminetheresultingunitsfortheexpression.Forexample,ifanexpressiondependsinverselyonthesquareofthex coordinate,thenithasimplieddimensionsoflengthtothepower-2.
13.1.1.1. UsingLocatorsinExpressions
ACFXsimulationhasphysicsareasandmeshareas;physicsareasareboundarieswhilemeshareasareregions.Thesetwotypesofareacanoccupycompletelydifferentspacesinasimulation;however,thereisnorequirementthatareanamesbeuniquebetweenphysicsandmesh.Thiscanleadtoambiguitieswhenyouusethesenamesinexpressions.
Toavoidtheseambiguities,ANSYSCFXfirstcheckstoseeif"@
ANSYSCFXalsohas@REGIONCELsyntaxsothatyoucanidentifyanamedareaasbeingamesharea.Thustoidentifythemeshareain1,youwouldusethesyntax:
@REGION:
in1
Notethatif
Release13.0-©2010SASIP,Inc.Allrightsreserved.
13.1.2. CFXExpressionLanguageStatements
TheCFXExpressionLanguageisdeclarative.Youdeclarethenameanddefinitionoftheexpressionusingexpressionlanguagestatements.ThestatementsmustconformtoapredefinedsyntaxthatissimilartoFortranmathematicalstatementsandtoCstatementsforlogicalexpressions.
Thestatementmustconsistofthefollowing:
∙anumber,optionallywithassociatedunits.Thisdefinesaconstant.Constantswithoutunitsaretermeddimensionless.
∙formathematicalexpressions,oneormorereferencestomathematicalconstants,systemvariables,orexistinguservariables,separatedby+(addition),-(subtraction),* (multiplication),/(division)and^(exponentiation),withoptionalgroupingofthesebyparentheses.Thesyntaxrulesfortheseexpressionsarethesameasthoseforconventionalarithmetic.
∙forlogicalexpressionsinvolvingrelationaloperators,oneormorereferencestomathematicalconstantsorresultsfrommathematicalexpressions,separatedby<=(islessthanorequalto),<(islessthan),==(isequalto),!
=(isnotequalto),>(isgreaterthan)and>=(isgreaterthanorequalto)withoptionalgroupingofthesebyparentheses.
∙forlogicalexpressionsinvolvinglogicaloperators,oneormorereferencestologicalconstantsorresultsfromrelationaloperationsseparatedby!
(negation),&&(logicalAND)and||(logicalOR),withoptionalgroupingbyparentheses.
13.1.2.1. UseofConstants
Constantsdonotneedtobedefinedpriortobeingusedinanexpression.Forexample,youcouldchoosetoevaluatetheexpressionx+5[m].Or,youcoulddefineaconstant,b=5[m]andthencreateanexpressionx+b.
Thelogicalconstantsarefalseandtrue.Resultsoflogicalexpressionsareexpressedas0and1(correspondingtofalseandtrue,respectively).
Theuseofconstantsmaybeofbenefitingeneratingcomplicatedexpressionsorifyouhaveseveralexpressionsthatusethesameconstants.
13.1.2.2. ExpressionSyntax
Allnumbersaretreatedasrealnumbers.
Theprecedenceofmathematicaloperatorsisasfollows(fromhighesttolowest):
∙Thepoweroperator^asinx^y.
∙Theunaryminusornegationoperator-asin-x.
∙Multiplicationanddivisionasinx*y/z.
∙Additionandsubtractionasinx+y-z.
Pleasenotethat,asofANSYSCFX10.0,theprecedenceofmathematicaloperatorshasbeenmadeconsistentwithstandardprogramminglanguagessuchasFortranandC.Therefore,thepoweroperator,whichpreviouslyhadlowerprecedencethanunaryminus,nowhasthehighestprecedence.
Theprecedenceoflogicalandrelationaloperatorsisasfollows(fromhighesttolowest):
∙Thenegationoperator!
asin!
x.
∙Therelationaloperatorsinvolvinglessthanorgreaterthan(<=,<,>and>=)asinx>=y.
∙Therelationaloperatorisequaltoandisnotequalto(==and!
=)asinx!
=y.
∙ThelogicalANDoperator(&&)asinx&&y.
∙ThelogicalORoperator(||)asinx||y.
13.1.2.3. Multiple-LineExpressions
Itisoftenuseful,particularlywithcomplexexpressions,tousemorethanonelinewhencreatingyourexpression.CFXallowsyoutousemultiplelinestogenerateanexpression,providedeachlineisseparatedbyanappropriateoperator.
Forexample,youmayhaveanequation,A+B/C,thatconsistsofthreecomplexterms,A,B,andC.Inthiscase,youcouldusethreelinestosimplifycreatingtheexpression:
A+
B
/C
Notethattheoperatormaybeusedattheendofaline(A+)oratthebeginningofaline(/C).Youdonotneedtoentertheoperatortwice.
Oncetheexpressionhasbeencreated,itwillappearintheExistingDefinitionslistboxasifitweregeneratedonasingleline(A+B/C).
Release13.0-©2010SASIP,Inc.Allrightsreserved.
13.2. CELOperators,Constants,andExpressions
Thefollowingtopicsarediscussed:
∙CELOperators
∙ConditionalifStatement
∙CELConstants
∙UsingExpressions
Release13.0-©2010SASIP,Inc.Allrightsreserved.
13.2.1. CELOperators
CFXprovidesarangeofmathematical,logicalandoperationaloperatorsasbuilt-infunctionstohelpyoucreatecomplexexpressionsusingtheExpressiondetailsview.
Table 13.1 CELOperators
Operator
FirstOperand’sDimensions[x]
SecondOperand’sDimensions[y]
Operands’Values(Approx)
Result’sDimensions
-x
Any
Any
[x]
x+y
Any
[x]
Any
[x]
x-y
Any
[x]
Any
[x]
x*y
Any
Any
Any
[x]*[y]
x/y
Any
Any
0
[x]/[y]
x^y(ifyisasimple,constant,integerexpression)
Any
Dimensionless
Any[a]
[x]^y
x^y(ifyisanysimple,constant,expression)
Any
Dimensionless
x>0
[x]^y
x^y(ifyisnotsimple&constant)
Dimensionless
Dimensionless
x>0
Dimensionless
!
x
Dimensionless
0or1
Dimensionless
x<=y
Any
[x]
0or1
Dimensionless
x Any [x] 0or1 Dimensionless x>y Any [x] 0or1 Dimensionless x>=y Any [x] 0or1 Dimensionless x==y Any [x] 0or1 Dimensionless x! =y Any [x] 0or1 Dimensionless x&&y Dimensionless Dimensionless 0or1 Dimensionless x||y Dimensionless Dimensionless 0or1 Dimensionless [a]Fory<0,xmustbenon-zero. Release13.0-©2010SASIP,Inc.Allrightsreserved. 13.2.2. ConditionalifStatement CELsupportstheconditionalifstatementusingthefollowingsyntax: if(cond_expr,true_expr,false_expr) where: ∙cond_expr: isthelogicalexpressionusedastheconditionaltest ∙true_expr: isthemathematicalexpressionusedtodeterminetheresultiftheconditionaltestistrue. ∙false_expr: isthemathematicalexpressionusedtodeterminetheresultiftheconditionaltestisfalse. Note: Theexpressionstrue_exprandfalse_exprarealwaysevaluatedindependentofwhethertheevaluationofcond_expristrueorfalse.Asaconsequence,aconditionalstate
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- CEL 教程
![提示](https://static.bdocx.com/images/bang_tan.gif)