CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   what's -1.#IND? (http://www.cfd-online.com/Forums/fluent-udf/112851-whats-1-ind.html)

Raymond.Leoi February 6, 2013 10:45

what's -1.#IND?
 
when I ran the following udf for the source of energy, s_p that I defined appears as a weired number, -1.#IND. Then
Error: Divergence detected in AMG solver: temperature
Error Object: #f

Any idea for this problem?

DEFINE_SOURCE(energy_source, cell, thread, dS, eqn)
{
real source;
real s_j, s_p;

s_j = -C_UDSI_DIFF(cell,thread,0)*NV_MAG2(C_UDSI_G(cell,t hread,0));

s_p = - C_UDSI_G(cell,thread,2)[0]*C_UDSI_G(cell,thread,0)[0] /
- C_UDSI_G(cell,thread,2)[1]*C_UDSI_G(cell,thread,0)[1] /
- C_UDSI_G(cell,thread,2)[2]*C_UDSI_G(cell,thread,0)[2];

s_p = -s_p*C_T(cell,thread)*C_UDSI_DIFF(cell,thread,0);

/* s_p = 0.; */
printf("s_j: %g\n", s_j);
printf("s_p: %g\n", s_p);

source = s_j + s_p;
dS[eqn] = 0.0;

return source;
}

Raymond.Leoi February 6, 2013 11:24

It seems IND indicates indefinite. However, I already initialize all those gradient in DEFINE_INIT. -1.#IND still comes up. How can I fix it?

syavash February 10, 2013 19:08

Quote:

Originally Posted by Raymond.Leoi (Post 406370)
It seems IND indicates indefinite. However, I already initialize all those gradient in DEFINE_INIT. -1.#IND still comes up. How can I fix it?

Hi,

It seems that you have a divide by zero problem, check your UDS value to make sure everything's right.

Goodluck

akm February 12, 2013 08:11

Quote:

Originally Posted by Raymond.Leoi (Post 406370)
It seems IND indicates indefinite. However, I already initialize all those gradient in DEFINE_INIT. -1.#IND still comes up. How can I fix it?

What do you mean you have initialized the gradients?? C_UDSI_G is calculated by the solver itself, and cannot be initialized by the user.
Your problem might be because the gradients have not been assigned at the beginning of the iterations. You can use an 'if' condition to ensure that the gradients are available, otherwise return a zero source.

Code:

if (NULL != THREAD_STORAGE(thread,SV_UDS_I(0)) && NULL != T_STORAGE_R_NV(thread,SV_UDSI_G(0)))
{
  s_j = ...
  s_p = ...
  source = s_j+s_p;
  dS[eqn]= ...
  return source;
}
else
{
  dS[eqn]=0;
  return 0;
}

Also, i see that you have assigned dS[eqn] = 0. dS[] is the differential of the source term wrt the variable for which the source is given. dS is provided for better convergence.
in your case it should be:
Code:

s_p = -s_p*C_T(cell,thread)*C_UDSI_DIFF(cell,thread,0);
source = s_j + s_p;
dS[eqn] = s_p/C_T(cell,thread);
return source;


Raymond.Leoi February 19, 2013 07:42

Thanks for your suggestion, Akm. DS=0. means that the source term is fedback explicitly.

Quote:

Originally Posted by akm (Post 407402)
What do you mean you have initialized the gradients?? C_UDSI_G is calculated by the solver itself, and cannot be initialized by the user.
Your problem might be because the gradients have not been assigned at the beginning of the iterations. You can use an 'if' condition to ensure that the gradients are available, otherwise return a zero source.

Code:

if (NULL != THREAD_STORAGE(thread,SV_UDS_I(0)) && NULL != T_STORAGE_R_NV(thread,SV_UDSI_G(0)))
{
  s_j = ...
  s_p = ...
  source = s_j+s_p;
  dS[eqn]= ...
  return source;
}
else
{
  dS[eqn]=0;
  return 0;
}

Also, i see that you have assigned dS[eqn] = 0. dS[] is the differential of the source term wrt the variable for which the source is given. dS is provided for better convergence.
in your case it should be:
Code:

s_p = -s_p*C_T(cell,thread)*C_UDSI_DIFF(cell,thread,0);
source = s_j + s_p;
dS[eqn] = s_p/C_T(cell,thread);
return source;



Raghuvir February 20, 2013 13:11

Hi,I have a similar problem. I am working on adding a body force to navier stokes equation, which is a function of voltage and charge density.
I added Voltage and charge density as two UDS,0 and 1 respectively. For UDS'0' (volt), I use poissons potential equation i.e., del^2(V) = -rho_q/enod. So,diffusivity is -1 and source term is charge_density/e_nod. For UDS'1', I use charge conservation equation. i.e., grad(charge_density*mu_constant*E) = 0 where E = -grad(V). So, I use flux equation, calculate gradv term at face by taking average of two neighbour cells or zero if its boundary.

UDS-0 :-
source = -( C_UDSI(c,t,1) ) / (8.8514e-12) ;
dS[eqn] = 0 ;
return source ;

UDS-1:-


NV_VS_VS(fluxvec, =, C_UDSI_G(c0,t0,0), * , 0.5, + , C_UDSI_G (c1,t1,0) , * , 0.5 ) ;
flux = -NV_DOT(fluxvec, A)*2e-4; /* Average flux through face */
return flux;


Model :-

two electrodes surrounded by air. one electrode with 27k volt and charge density as 0.016. another electrode with 0 volt and o charge density.

PROBLEM :-


I get Nan values for UDS-1 (charge density) when I initialise it with anything except zero. If I initialise UDS-1 with 0 then the residual monitors of UDS-1 instantly go to e-43 values. But I see changes in UDS scalars only near electrodes and near domain boundaries, rest of the domain has constant UDS values.

I Tried
initialising without udf and then adding them after some iterations....but no luck.

I am guessing its sth to do with flux equation in that UDS-1 equation. Could anyone please help me with finding the error.


All times are GMT -4. The time now is 00:02.