# Conditional Expression in CFX Pre

 Register Blogs Members List Search Today's Posts Mark Forums Read

 April 23, 2012, 19:57 Conditional Expression in CFX Pre #1 Senior Member   Ashkan Javadzadegan Join Date: Sep 2010 Posts: 234 Rep Power: 7 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

 April 24, 2012, 01:42 #2 Super Moderator   Glenn Horrocks Join Date: Mar 2009 Location: Sydney, Australia Posts: 10,929 Rep Power: 85 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.

 May 6, 2012, 18:04 hi ghorrocks #3 Senior Member   Danial Join Date: Nov 2011 Posts: 179 Rep Power: 5 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])

 May 6, 2012, 20:19 #4 Super Moderator   Glenn Horrocks Join Date: Mar 2009 Location: Sydney, Australia Posts: 10,929 Rep Power: 85 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].

 May 6, 2012, 20:24 HI #5 Senior Member   Danial Join Date: Nov 2011 Posts: 179 Rep Power: 5 Thanks ghorrocks but i tried it it does not even read the expression with rhos =8450 and shows syntax errors. it represents "unexpected character"

 May 6, 2012, 20:39 #6 Super Moderator   Glenn Horrocks Join Date: Mar 2009 Location: Sydney, Australia Posts: 10,929 Rep Power: 85 Attach the CCL and output file.

May 6, 2012, 20:53
HI
#7
Senior Member

Danial
Join Date: Nov 2011
Posts: 179
Rep Power: 5
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
Attached Files
 Cp.txt (229 Bytes, 201 views)

 May 6, 2012, 21:04 #8 Super Moderator   Glenn Horrocks Join Date: Mar 2009 Location: Sydney, Australia Posts: 10,929 Rep Power: 85 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.

 May 6, 2012, 21:16 Hi #9 Senior Member   Danial Join Date: Nov 2011 Posts: 179 Rep Power: 5 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. 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.

 May 6, 2012, 21:21 #10 Super Moderator   Glenn Horrocks Join Date: Mar 2009 Location: Sydney, Australia Posts: 10,929 Rep Power: 85 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?

 May 6, 2012, 23:05 HI #11 Senior Member   Danial Join Date: Nov 2011 Posts: 179 Rep Power: 5 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

 May 7, 2012, 07:01 #12 Super Moderator   Glenn Horrocks Join Date: Mar 2009 Location: Sydney, Australia Posts: 10,929 Rep Power: 85 Can you describe what you are modelling and why the three phases are important?

 May 7, 2012, 17:21 Hi #13 Senior Member   Danial Join Date: Nov 2011 Posts: 179 Rep Power: 5 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

 May 7, 2012, 17:28 #14 Super Moderator   Glenn Horrocks Join Date: Mar 2009 Location: Sydney, Australia Posts: 10,929 Rep Power: 85 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?

May 7, 2012, 19:21
Hi
#15
Senior Member

Danial
Join Date: Nov 2011
Posts: 179
Rep Power: 5
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.
Attached Files
 output.docx (54.9 KB, 58 views)

 May 7, 2012, 19:33 HI #16 Senior Member   Danial Join Date: Nov 2011 Posts: 179 Rep Power: 5 I am only modeling a single drolet spreading on metal surface. eulerian phase models are used.

 May 7, 2012, 19:35 #17 Super Moderator   Glenn Horrocks Join Date: Mar 2009 Location: Sydney, Australia Posts: 10,929 Rep Power: 85 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?

 May 7, 2012, 20:37 Hi #18 Senior Member   Danial Join Date: Nov 2011 Posts: 179 Rep Power: 5 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. so what do you think ,that if statement trick could work for phase change ?

 May 8, 2012, 07:13 #19 Super Moderator   Glenn Horrocks Join Date: Mar 2009 Location: Sydney, Australia Posts: 10,929 Rep Power: 85 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

 May 8, 2012, 19:50 Hi Glenn #20 Senior Member   Danial Join Date: Nov 2011 Posts: 179 Rep Power: 5 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 ".

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post mihirbhagat CFX 0 July 5, 2011 05:22 ashtonJ CFX 1 June 13, 2011 02:34 mactech001 CFX 9 April 11, 2010 21:08 peterputer1 CFX 2 September 23, 2009 08:08 Vivek Vasudevan CFX 2 March 20, 2007 07:31

All times are GMT -4. The time now is 06:17.