CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   STAR-CCM+ (http://www.cfd-online.com/Forums/star-ccm/)
-   -   Fieldfunction Velocity (i) Direction (http://www.cfd-online.com/Forums/star-ccm/92583-fieldfunction-velocity-i-direction.html)

eRzBeNgEl September 19, 2011 07:25

Fieldfunction Velocity (i) Direction
 
Hi guys.

I want to setup a field function for calculation of beta1 and beta2 (angles of fluid before blade and after). my idea is to calcluate this in the following way:

1. Radial Angle = atan2(x.abs(y))
2. Relative Radial Velocity = sin($Radial Angle)*$$Velocity[1] - cos($Radial Angle)*$$Velocity[2]
3. Beta = atan2($$Relative Radial Velocity/$$Velocity[3])

It the syntax and also the calculation itself right`?

Thanks a lot

abdul099 September 19, 2011 19:06

No, at least the syntax is not right. And this is no statement about the calculation itself, I haven't checked it (too late now, I have to go to bed).

In 1, it should be atan2(x,abs(y)) with a comma instead of a dot
In 3, you are referencing a vector field function ($$Relative Radial Velocity), but you didn't specify whether you want to use the magnitude (mag($$Relative Radial Velocity) or any of it's components ($$Relative Radial Velocity[x]). Further there are spaces in the name, so you can't reference it without brakets. It has to be $${Relative Radial Velocity}[0]. Be aware, there are wavy brakets needed! By the way, this also affects point 1 and 2 ($Radial Angle instead of ${Radial Angle}).

Generally spoken, I recommend to use field function names without spaces or minus (-). A minus is a common error source, as nearly everybody forgets one day to put the field function name with the minus in wavy brakets and wonders, why the field function does not compile. That's hard to find, when you notice the compile error two hours after programming the field function when starting the simulation and an error message pops up. That's the point when you start to get crazy because you will double check all, the syntax, all other field functions, you will copy and paste the name and all looks fine - but the field function keeps on not to compile. I speak from experience ;)
A space in the name is the same. It's not matter IF you will forget to put the brakets, it's just a matter WHEN you will forget it. But you WILL forget it one day. And when another guy has to look at the simulation, maybe a colleague, this two errors will knock him out unless he isn't a really smart guy. When he is a smart guy, he will find it in two minutes. When he isn't, he will kill you...


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