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 ".

ghorrocks May 8, 2012 21:21

The 4 iterations was not necessarily the cause of the clipping error. It was just a bad idea which CAN cause lots of problems so is best removed.

Soldification models in CFX are not supported as a release option to my knowledge. I know people have done it and there might be beta options to help but I am not sure. You will need to talk to CFX support for details on this.

Danial Q May 9, 2012 00:44

Hi
 
glenn, i did send a mail to LEAP AUTRALIA and they replied ;

" You treat the material as a single fluid but have Cp(T), rho(T), mu(T) which allows you to have different properties either side of the phase change boundary. To make it work you don't change phase at a single temperature but across a small temperature range, just as would happen if you have a mushy zone. "

here comes the problem that how should i define these properties as a function of temperature. for that reason i tried "if statement" or the second option was to do in fortran and add it in my external library. But the version available here does not have "cfx5ext.h" in ansys files.
What is your opinion about preparing a fortran file, would that be workable idea?
Thanks

ghorrocks May 9, 2012 07:26

No, apply these functions as 1D interpolation functions. No need for fortran.

Danial Q May 9, 2012 17:42

HI
 
I dont think so that linear function can be made for phase change, for specific heat its ok as pure metals have almost constant cp.But for density and viscosity, linear functions cant work(bcoz of enthalpy chnage).m i right?

ghorrocks May 9, 2012 18:42

The whole idea of using just the material properties to model phase change is an approximation. Things like latent heats, superheat/subcool, spinondal temperature/attainable limit of superheat etc cannot be accounted for with this approach. If parameters like this are important for your model then you will probably find this approach is not going to work.

But if they are not important it might work - it is up to you to determine the error involved in this simplification.

Danial Q May 9, 2012 19:09

HI
 
1 Attachment(s)
Yes, as i already told you that my problem involves phase change so that's why i am reluctant to use this approach.
Hey glenn, i have generated another output file this time i guess there are no significant errors apart from phase chnage(as it dint work yet).Could you please have a look at it.Thanks

Danial Q May 10, 2012 00:50

Hi
 
2 Attachment(s)
I have few questions like;
> There are some tutorials such as (spray dryer, steam jet) where (air + steam/water) is present and phase change is also occuring EVEN WITH MULTICOMPONENTS INVOLVED. Can I use the same approach for my problem?
> I have defined an opening boundary where opening temp is set 2427C which is actually the temperature of that sprayed molten metal droplet. I was curious that why cant i set the temperature of air (25 C) as opening temp. And in solver during monitor point graph (variable value and accumulated time step),
if opening T = 2427C, there is no chnage in scale along variable axis
if opening T = 25 C , it varies.
I have attached both graphs, strange thing is liquid droplet temp, which is 2427C while graph shows its 2700C :eek:. Could you please have a look at it.
Thanks

ghorrocks May 10, 2012 06:42

Your question has now become "how do I do advance phase change modelling in CFX". I think this is too difficult a topic to discuss on the forum.

Danial Q May 10, 2012 18:21

Hi Glenn
 
My problem is same as I stated earlier, the point to mention spray dryer and steam jet is, if I can use the same approah for my problem? I just wanted your opinion to make sure that I was thinking in a right direction.Thanks
cheers

ghorrocks May 10, 2012 23:49

Sorry, I do not understand the question. Can you phrase it more clearly?

Danial Q May 11, 2012 00:54

Hi Glenn
 
I mean to say that is it posiible that i could use the same approach for phase chnage ,as used in steam jet or spray dryer cases. Though in those case, its evaporation phenomena but as far as phase change is concerned it might work for me as solidifcation. Because in cases (steam jet and spray dryer) total three phases are involved (air + H2Ovap + H2Oliq). While in my case, (air + liq metal + solidmetal). do you think this evapration cases can be used as anology for phase chnage application????

ghorrocks May 11, 2012 07:11

While the spray dryer tutorial is a 3 phase model, it is three very different phases to yours. Details make all the difference in multiphase models. In the spray dryer you have solids (modelled as lagrangian particles), liquid water (modelled as a variable on the particles) and gas (air and water vapour). You are trying to model 3 phases with a eularian model. Totally different. And the phase change model used in the spray dryer has almost nothing in common with what you need for solidification.

And the steam jet is only a 2 phase model (liquid and gas), but the gas is a multicomponent gas (air and water). Again, very little in common with your application.

You need to find an example which models solidification in a eularian/free surface model. It will be complex in CFX as there is no built in model for it.

I was playing with Fluent today and noticed its solidifcation model. I have no idea if it is appropriate for you, but I suspect you will have more luck with that compared to CFX where no solidification model exists.

Danial Q May 12, 2012 02:49

Hi Glenn
 
Thanks, it is clear now. well so i am in hell of a situation here.while my mentor believes that this model is possible in ansys cfx. anyhow, another suggestion i got from some one is about defining (air+ liquid metal) as a mixture (binary; which i totally disagree) even though a mixture seems useless option to me whether its variable, fixed or ideal. Am I right?

Yea, I started to learn Fluid too for the purpose, but again problem is getting properties data for Ni at those high temps to define its properties as function of temp.Again, density in fluent is also defined by "Peng Robinson eq." ,even other choices (presented models) need some critical propeties and i found Fluent more tricky than CFX. so din't spent that much time on that.good luck to me, its my first year project in phd and year is almost over:rolleyes:.

Thanks.

ghorrocks May 13, 2012 07:07

Quote:

my mentor believes that this model is possible in ansys cfx
Possible - yes, it is. Others have modelled it. Is it easy - no. There is no built in model for it, so you are going to have to develop the model yourself.

Can I recommend you do some study and familiarise yourself with exactly what multiphase and multicomponent means. It is best if you understand what these models actually imply then you can answer your question in red by yourself.

Don't have material properties? Then you need JMatPro (http://www.sentesoftware.co.uk/home.aspx). It has all the material properties you need for just about any alloy you can about. But it is expensive unfortunately - but do you want comprehensive material properties or not?

Danial Q May 13, 2012 18:32

HI Glenn
 
Thanks. Developing model by myself...? Do you mean selecting right options while setting physics or writing some program files... ?

As far as ,multiphase and multicomponent is concerned, in my opinion, multiphase flow involves different phases of fluids on macroscopic scale only (single fluid with two phases or two/more fluids with different phases), and muticomponent implies the fluid containing different types of components on molecular scale( e.g air contains multicomponent, or smoke contains multicomponent normally etc.) correct me please, if i am wrong.
And in my case, i am pretty sure that it is homogeneous multiphase flow, involving two pure fluids (air & Ni). so, ideal mixture assumption for air and nickle ,in my opinion is out of question. Correct me if i am mistaken.

ghorrocks May 13, 2012 18:37

Develop the model by yourself means applying through the use of source and sink terms to create and destroy stuff, and do all the coupling to the energy equation yourself. How much of this is relevant depends on the physics of your model, and it is up to you to determine that.

You understand the difference between multiphase and multicomponent. And your comment about the ideal mixture assumption is correct.

Danial Q May 13, 2012 20:15

HI
 
It seems like some diplomatic statement :D.well, and to do all this what could be helpful literature should i study or work on.

Thanks Glenn, you have been really helpful.

Danial Q May 16, 2012 20:47

Hi Glenn
 
Could you please give me some advice that how to define temperature range. I mean should I generate expressions or I have to do some CCL editing stuff. any document or references??
I tried "if statement" with (T >= 1500) e.g and it worked up to some extent, i got considerable results. But for sake of accuracy , it would be good if i could do that by defining range.

Thanks

ghorrocks May 16, 2012 20:56

Sorry, I do not understand your question. What do you mean by "if statement" worked to some extent? What do you mean by defining a range?

Danial Q May 16, 2012 22:35

Hi
 
1 Attachment(s)
I used this "if statement" to define temperature and regarding values of properties. And i want to define a range for these values like from 1000 to 2000 K. i have attached graphs to show that this statement worked as properties changed as my expectations. here is the statement;

if( T >= 1727 [K],7780[kg m^-3], 8115[ kg m^-3]).
here i want to define range for T (1000-2000).
Thanks


All times are GMT -4. The time now is 15:01.