## Fluids

#### How to use arccos(teta) in UDF requiring input parameter c (=cos(teta))?

Tagged:

• Jayda
Subscriber

Dear Forum,

I created a user defined function for the scattering phase. The UDF requires the scattering phase to be defined via cos(theta) = c. Thus: DEFINE_SCAT_PHASE_FUNC(phi, c, fsf).

However, my phi (phase function) is defined in terms of teta (T) instead of phi:

phi =0.326*((1/(1+((T*180/pi)/11.5)^2))+(1*e^(-((T*180/pi)^2)/(2*2.5^2))+8))

T = theta = arccos(cos(T)) = arccos(c)

Thus:

phi =0.326*((1/(1+((arccos(c)*180/pi)/11.5)^2))+(1*e^(-((arccos(c)*180/pi)^2)/(2*2.5^2))+8))

Is this translation from theta to c correct and can I thus use the latter formula for the UDF?

• Does using arccos(c) give a problem, for example when teta = -pi, it will give an irrational number as output? Or is teta defined from 0 to +pi only?

Bests,

Jayda

• DrAmine
Ansys Employee
Not really related to Ansys Fluent. It is just C/C++ programming. Always take care to avoid Division by 0 or NAN.
• Karthik R