CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   CFX (https://www.cfd-online.com/Forums/cfx/)
-   -   Conditional Expression in CFX Pre (https://www.cfd-online.com/Forums/cfx/100310-conditional-expression-cfx-pre.html)

ashtonJ April 23, 2012 19:57

Conditional Expression in CFX Pre
 
Dear All,

Please let me know how I can write the following conditional expression in CFX-Pre.

If x>0.2 then x1=x+0.2
If x<0.2 then x1=x-0.2
if x=0.2 then x1=x

Thanks
Regards,
AshtonJ

ghorrocks April 24, 2012 01:42

You can write it two ways:
1) Using a CEL step function - this is a bit weird but works fine once you understand the concept.
2) Using a CEL if function - this was introduced for CFX V14 and simplifies this sort of thing.

Look in the tutorials and documentation for details of how to implement it.

Danial Q May 6, 2012 18:04

hi ghorrocks
 
I have tried cfx v14 "if conditional statement" feature but mine resulted in dimensionless quantity while it was not supposed to be that way.:( its weired.This if statement given below was mine;

if(T == 1726[K], rhos == 8450[kg m^-3], rhol == 7780[kg m^-3])

ghorrocks May 6, 2012 20:19

Two problems with this statement, both of them are fatal errors:
1) If true then rhos is defined and rhol is undefined. If false then rhos is undefined and rhol is defined. Your function should make all variables defined for all conditions.
2) rhos == 8450 and rhol == 7780 is wrong. The "==" operator is a boolean operator which returns true if both arguements are equal. You want the "=" operator which assigns the value to the variable. So it should be rhos = 8450 [kg m^-3].

Danial Q May 6, 2012 20:24

HI
 
Thanks ghorrocks but i tried it it does not even read the expression with rhos =8450 and shows syntax errors. it represents "unexpected character"

ghorrocks May 6, 2012 20:39

Attach the CCL and output file.

Danial Q May 6, 2012 20:53

HI
 
1 Attachment(s)
I have attache ccl file for Cp, the syntax i followed is given in Ch 13 of reference guide, which states that
" CEL supports the conditional if statement usin following syntax:
if ( cond_expr, true-expr, false_ expr)
where
cond expres is logical expression
true expres is mathematical expres
false expres is mathematical expres

ghorrocks May 6, 2012 21:04

This expression has all the errors I previously noted, and added a few more:
3) the units for the variables change (cps is defined as J kg^-1 then again as J kg^-1 K^-1)
4) This appears to assume CEL is a sequential language, ie it executes from the top down. It does not.

This is not getting anywhere. Can you describe in English what you want to do, and I will give you some tips from there.

Danial Q May 6, 2012 21:16

Hi
 
Sorry for units mistake, but apart from units because i corrected them later (i sent u older file i guess where i had wrong units), this if statement should work for my case where i wanted to define cp at two temperatures.
i mean if temp reaches say 1700C, cp should be say 550 units ,if temperature is not equal to 1700, then cp should be 620, while initial temp of this material is say 2400C. so i was trying to define property (cp) some value untill it reaches 1700C (frm 2400C) so i tried to impliment this if statement to define a range of temp where cp changes and hence supports phase change in result.:D
it was supposed to help me in phase chnage problem.
while these cp's at different temperarures were defined as cp's of liquid and solid state of material.

ghorrocks May 6, 2012 21:21

This will not work. The temperature will never be exactly 1700C, so it will never trigger. And if you make it happen over a range of temperatures the energy gone as "phase change" will vary depending on how long the stuff stays in the defined range. If phase change was that simple it would already be in the software like that.

Can you describe what you are trying to do? What are you trying to get out of the analysis?

Danial Q May 6, 2012 23:05

HI
 
infact i was trying to make it work for phase chnage problem..it was just an idea to define phase chnage on the basis of varying properties9as function of temp) during phase chnage. I could have used the phase chnage equilibrium model ,already provided in ansys cfx but in my case total three phases were involved (air, liquid and solid) and phase chnage equilibrium model works only for two phases(as i am told by ansys support) involved so they suggested me to define some properties in some range as function of temperature. that is why i employed this idea.
that was my last hope to do it:( otherwise i tried polynomial function approach too but i dnt hv enough data to make polynomials for all of the properties and its neither available for higher temps in my case.
if you could help me that would be great. Thanks

ghorrocks May 7, 2012 07:01

Can you describe what you are modelling and why the three phases are important?

Danial Q May 7, 2012 17:21

Hi
 
I am modeling solidification of liquid metal droplet on another metal piece(substrate). so ofcourse there will be three phase as air will be one while othe rtwo phases will belong to liquid droplet(metal) which will solidify and become solid droplet(metal). so homogeneous multiphase and free surface model ,i ma going to apply along with phase change. conduction is only source considered for heat transfer between solidifying droplet and substrate. To make phase change work, i need something workable, for that reason i was trying to apply "if statement" to define range between initial liquid droplet temp and its solidus temp.( 2400-1700C). In this range, i am trying to define its properties like (cp, mu, rho) to help it for phase change. I hope u got my point. if you have any idea how can i make it work, it would be great.Thanks

ghorrocks May 7, 2012 17:28

Are you directly modelling each metal droplet as a free surface model, or as an aggregate (eg particle tracking or eularian model)?

What is the size ofthe metal droplets, and what is the size of the domain you are modelling?

Danial Q May 7, 2012 19:21

Hi
 
1 Attachment(s)
the dia of droplet is few microns like 10 microns and substrate is of few cms, volume of fraction method will be used to track teh shape and dia of droplet.. i have generated an output file, though could not chnage the phase but got those if statements right(with no errors). Please have a look at them and may be it would make it more understandable.

Danial Q May 7, 2012 19:33

HI
 
I am only modeling a single drolet spreading on metal surface. eulerian phase models are used.

ghorrocks May 7, 2012 19:35

If you are trying to resolve the shape of the droplets and they are about 10um you are going need a mesh of 1um or finer. If the substrate is a few cm you are going to need a supercomputer to handle the mesh size you will generate.

You have lots of expert parameters. Most of them are probably doing more harm than good. Are you sure you need them all? Why are the defaults wrong?

You have major problems with convergence due to clipping. Also, why restrain the max iterations to 4?

There is a lot of complex physics in this model. Have you checked that all the models are working on a simple validation case before combining them all together?

Danial Q May 7, 2012 20:37

Hi
 
Due to that very reason of droplet size, at the moment i have generated automatic mesh with coarse feature, because i want to make model work first.Then i will go for finer meshing.
Nopes not all of them , may be i should check them again and reduce them for running the model at first.
I din't get that clipping thing in my output file. what doest that mean? I set 4 iterations to see if solver is working and what kinda output ,it is going to generate for my present set up, nothing serious purpose, just to get early output file for wild guess.
i did not check all of them separately:o.
so what do you think ,that if statement trick could work for phase change ?

ghorrocks May 8, 2012 07:13

I would not limit the coeff loops to 4, even when you are just debugging. Then the time steps cannot converge and the solution quickly becomes rubbish. For debugging either use a coarse mesh or only a few time steps.

Even better, I would do models which build up the physics of this model one bit at a time - first get free surface flow working (with no pahse change or CHT), then add the CHT solid, then do a simulation with just the phase change - then combine it all together when you know how it all works.

Glenn

Danial Q May 8, 2012 19:50

Hi Glenn
 
Thanks for your suggestions. My main concern at the moment is how to make phase change work in my case because in ANSYS documents ,i did not find anything relevant to this scenario though there is much about two fluids only. Would you like to share any ideas??
another thing, i increased the iterations to 100 from 4 but still it shows the error about " clipping ".


All times are GMT -4. The time now is 04:07.