CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > CFX

Conditional Expression in CFX Pre

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 23, 2012, 19:57
Question Conditional Expression in CFX Pre
  #1
Senior Member
 
Ashkan Javadzadegan
Join Date: Sep 2010
Posts: 255
Rep Power: 16
ashtonJ is on a distinguished road
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
ashtonJ is offline   Reply With Quote

Old   April 24, 2012, 01:42
Default
  #2
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,703
Rep Power: 143
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
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.
ghorrocks is offline   Reply With Quote

Old   May 6, 2012, 18:04
Default hi ghorrocks
  #3
Senior Member
 
Danial
Join Date: Nov 2011
Posts: 179
Rep Power: 14
Danial Q is on a distinguished road
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])
Danial Q is offline   Reply With Quote

Old   May 6, 2012, 20:19
Default
  #4
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,703
Rep Power: 143
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
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].
ghorrocks is offline   Reply With Quote

Old   May 6, 2012, 20:24
Default HI
  #5
Senior Member
 
Danial
Join Date: Nov 2011
Posts: 179
Rep Power: 14
Danial Q is on a distinguished road
Thanks ghorrocks but i tried it it does not even read the expression with rhos =8450 and shows syntax errors. it represents "unexpected character"
Danial Q is offline   Reply With Quote

Old   May 6, 2012, 20:39
Default
  #6
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,703
Rep Power: 143
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
Attach the CCL and output file.
ghorrocks is offline   Reply With Quote

Old   May 6, 2012, 20:53
Default HI
  #7
Senior Member
 
Danial
Join Date: Nov 2011
Posts: 179
Rep Power: 14
Danial Q is on a distinguished road
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
File Type: txt Cp.txt (229 Bytes, 449 views)
Danial Q is offline   Reply With Quote

Old   May 6, 2012, 21:04
Default
  #8
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,703
Rep Power: 143
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
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.
ghorrocks is offline   Reply With Quote

Old   May 6, 2012, 21:16
Talking Hi
  #9
Senior Member
 
Danial
Join Date: Nov 2011
Posts: 179
Rep Power: 14
Danial Q is on a distinguished road
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.
Danial Q is offline   Reply With Quote

Old   May 6, 2012, 21:21
Default
  #10
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,703
Rep Power: 143
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
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?
ghorrocks is offline   Reply With Quote

Old   May 6, 2012, 23:05
Default HI
  #11
Senior Member
 
Danial
Join Date: Nov 2011
Posts: 179
Rep Power: 14
Danial Q is on a distinguished road
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
Danial Q is offline   Reply With Quote

Old   May 7, 2012, 07:01
Default
  #12
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,703
Rep Power: 143
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
Can you describe what you are modelling and why the three phases are important?
ghorrocks is offline   Reply With Quote

Old   May 7, 2012, 17:21
Default Hi
  #13
Senior Member
 
Danial
Join Date: Nov 2011
Posts: 179
Rep Power: 14
Danial Q is on a distinguished road
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
Danial Q is offline   Reply With Quote

Old   May 7, 2012, 17:28
Default
  #14
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,703
Rep Power: 143
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
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?
ghorrocks is offline   Reply With Quote

Old   May 7, 2012, 19:21
Default Hi
  #15
Senior Member
 
Danial
Join Date: Nov 2011
Posts: 179
Rep Power: 14
Danial Q is on a distinguished road
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
File Type: docx output.docx (54.9 KB, 135 views)
Danial Q is offline   Reply With Quote

Old   May 7, 2012, 19:33
Default HI
  #16
Senior Member
 
Danial
Join Date: Nov 2011
Posts: 179
Rep Power: 14
Danial Q is on a distinguished road
I am only modeling a single drolet spreading on metal surface. eulerian phase models are used.
Danial Q is offline   Reply With Quote

Old   May 7, 2012, 19:35
Default
  #17
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,703
Rep Power: 143
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
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?
ghorrocks is offline   Reply With Quote

Old   May 7, 2012, 20:37
Default Hi
  #18
Senior Member
 
Danial
Join Date: Nov 2011
Posts: 179
Rep Power: 14
Danial Q is on a distinguished road
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 ?
Danial Q is offline   Reply With Quote

Old   May 8, 2012, 07:13
Default
  #19
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,703
Rep Power: 143
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
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
ghorrocks is offline   Reply With Quote

Old   May 8, 2012, 19:50
Default Hi Glenn
  #20
Senior Member
 
Danial
Join Date: Nov 2011
Posts: 179
Rep Power: 14
Danial Q is on a distinguished road
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 ".
Danial Q is offline   Reply With Quote

Reply


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 Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
only 1 of many named selections not showing up in cfx pre mihirbhagat CFX 2 April 26, 2019 04:56
Defining a domain in CFX Pre ashtonJ CFX 1 June 13, 2011 02:34
different CFX Pre and Post mesh region mactech001 CFX 9 April 11, 2010 21:08
Problems with adding two meshes together in CFX Pre peterputer1 CFX 2 September 23, 2009 08:08
CFX Pre - TGrid Vivek Vasudevan CFX 2 March 20, 2007 06:31


All times are GMT -4. The time now is 20:25.