 ## Fluids

• tejasvikrishna45
Subscriber

I am trying to model a second grade fluid for which I wrote an UDF. The problem is the momentum source has a term that goes like d3u/d2ydt.

Can any one tell me if a time derivative can be included in the source term? Once I take that time derivative related term, the rest of the source term works and converges pretty easily.

Thanks,

TJ

• Konstantine Kourbatski
Ansys Employee

please refer to Sec. 3.2.3.8. Previous Time Step Macros in Fluent Customization Manual. Knowing current value and the value at the previous time step, you can construct a 1st order time derivative. For 2nd order, macros are also available at the t - 2* dt. If this is not enough, you can save required data from previous steps in a user-defined memory, and then use it to reconstruct time derivatives.

• tejasvikrishna45
Subscriber

Thanks for the reply kkourbat. I have tried all the things that you have talked about. My problem is that the solution diverges with those time derivatives.

Thanks a lot.

• DrAmine
Ansys Employee

For which equations are you writing source terms? Have you linearized the source terms?

• tejasvikrishna45
Subscriber

The source term I wrote was for divergence of additional stress.

I am trying to solve this model in channel flow with time varying pressure boundary conditions.

additional stress tensor phi is defined such that phi_11 = -a*(u')^2 , phi_12 = a*d(u')/dt, phi_21 = a*d(u')/dt,, phi_22 = a*(u')^2.

where a is a constant and u' = du/dy

I took divergence of the above defined stress tensor.

I am not sure how to linearize this divergence of the above stress tensor

Thanks,

TJ

• DrAmine
Ansys Employee

If the linearization is not possible based on the dependent variable of the underlying equation you need to make that as a sort of false time stepping (like density divided by fluxes through the cells..).

Without linearization you need then to use smaller time scales and perhaps under-relax the solution process.

But the most important question: why do you need that?

• tejasvikrishna45
Subscriber

Thanks for the prompt reply. We are trying to model a class of fluids called 2nd grade/order fluids, equations of which  are shown in the attachment below.

Since what I have is the time derivative of velocity gradient(with divergence it technically becomes time derivative of second velocity gradient) I really cant think of any clever way to linearize like the density example. I will try further reducing my time scales and under-relaxation factors to see if that helps.

Thanks,

TJ

• DrAmine
Ansys Employee

Hm a sort of viscoelastic fluid. You can additionally check POLYFLOW which is superior when it comes to specific rehelogy (including POLYMAT). A solution in Fluent is possible but would require some babysitting

• tejasvikrishna45
Subscriber

I do have access to polyflow here at Texas A&M University. However I really want to see if this code I wrote can be made to work.

I know for a fact that all my other terms are consistent and working, it is only the term that contains the time derivative that causes issues.

I think it will be really helpful to talk to some technical expert like you. Can you tell me the procedure to be able to do that?

• DrAmine
Ansys Employee

Polyflow is the right tool for that with its capability to model differential viscosity models.

Good luck.

• Konstantine Kourbatski
Ansys Employee

Hello,

This is always a significant challenge to deal with strong explicit nonlinear sources added through a UDF. As abenhadj pointed out, linearization of this complex source implementation is not possible in the framework of the Fluent's UDFs.

My suggestions are as following:

1) save source components into user defined memories in DEFINE_ADJUST by looping over all the cells in the fluid thread. This will make the source components available for post-processing. Don't apply sources to the equations yet

2) use if(first_iteration) in DEFINE_ADJUST to retain information only at the 1st iteration of the subiterative loop

3) post-process the source UDMs to confirm they are what you are expecting. Using a simple canonical problem where sources can be analytically calculated would help with comparison

4) apply sources, but with a small value multiplier to artificially reduce their magnitude. This will help you establish stability limits on the source magnitude

5) apply source relaxations, i. e.

source = alpha * source_current_iteration + (1 - alpha) * source_prev_iteration

where 0 <= alpha < = 1

Slow ramp up of source magnitude (4) and applying source relaxation (5) can potentially help to stabilize the solution.

6) apply this together with under-relaxing equations to which the sources are applied to.

Other than that, there is little else I can think of, other than some implicit source implementation, which unfortunately cannot be done in the framework provided by Fluent. 