## Fluids

#### UDF for contact angle

• ursen
Subscriber

Hi!

I would like to write UDF code for a drop on a surface for which I want to change contact angle every few seconds.

In my first try I write this UDF - but the contact angle begins changing even before the first second runs out. Where did I go wrong?

To summon up - I want the inicial contact angle 90°, then I would like it to change (for example to 110° and stay that way for a second and then change to for example 130°.

```DEFINE_PROFILE(take_sest,t,i)
{

face_t f;
real current_time;
current_time = CURRENT_TIME;

begin_f_loop(f,t)
{

if(CURRENT_TIME <= 1.0)
F_PROFILE(f,t,i) = 90.0;
else if(CURRENT_TIME >1.0 && CURRENT_TIME <= 2.0)
F_PROFILE(f,t,i) = 110.0;
else if (CURRENT_TIME > 3.0)
F_PROFILE(f,t,i) = 130.0;

}
end_f_loop(f,t);
}```
• ursen
Subscriber
I still haven't figure it out. Please some help.nI've also tried this code:nDEFINE_PROFILE(take_sedem,t,i)n{nntface_t f;ntreal current_time;ntcurrent_time = CURRENT_TIME;nntbegin_f_loop(f,t)nt{nntif(CURRENT_TIME <= 0.2)ntF_PROFILE(f,t,i) = 90;ntelse if(CURRENT_TIME > 0.2 && CURRENT_TIME <= 0.4)ntF_PROFILE(f,t,i) = 110;ntelsentF_PROFILE(f,t,i) = 130;nnt}nend_f_loop(f,t);n}nnWith this code and the one from upper post, drop at some point completely spreads - it doesn't stays at 90? angle at the begining, for some reason stays at 110?, but than just completely spreads. It even begins to climb up on the edges of domena. nI've also tried this:nDEFINE_PROFILE(take_devet, t, i)n{ntreal con;ntreal the_current_time;ntface_t f;nntthe_current_time = CURRENT_TIME;nnif ((the_current_time >= 0) && (the_current_time < 0.2))n{ncon = 90;n}nelse if ((the_current_time >= 0.2) && (the_current_time < 0.4))n{ncon = 100;n}nelse if ((the_current_time >= 0.4) && (the_current_time < 0.6))n{ncon = 110;n}nelsen{ncon = 120;n}begin_f_loop(f,t)n{nF_PROFILE(f,t,i) = con;n}nend_f_loop(f,t)n} nnBut in this case the drop begins to move - (as always in the begining it doesn't stay at 90?), when reaches 110? it begins to move right to the edge of domena, and eventually hits the edge.As far as I'm concerned all the above codes are OK from the C language point. I don't know what am I doing wrong so that the calculation fails. nI have a time step 1e-5, which sould be small enough.Thanks for your helpn
• DrAmine
Ansys Employee
Are you using a recent Fluent release? If yes please use Fluent Expression for this simple task.n
• DrAmine
Ansys Employee
The return value should be in Radians.n