CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Divergence in AMG solver after adding in mass source (https://www.cfd-online.com/Forums/fluent-udf/194854-divergence-amg-solver-after-adding-mass-source.html)

say2017 October 25, 2017 13:55

Divergence in AMG solver after adding in mass source
 
Hello,

I am trying to simulate a heat pipe and have managed to compile the code with no errors. However, as soon I load in one of the source terms, I get an error that says "Divergence detected in AMG solver: x-momentum". I have tried changing the URFs and reducing the time step but I still get this error. I have included the code for the mass source, which is the only source term I am currently loading, below. Any help will be appreciated! Thank you.

DEFINE_SOURCE(mass_source,c,t,dS,i)
{
face_t f;
Thread *tf;
int n;
int nn;
real S = 0;

/* loop over all faces of cell */
c_face_loop(c,t,n){
/* find face and thread */
f = C_FACE(c,t,n);
tf = C_FACE_THREAD(c,t,n);

for(nn=0;nn<N_WICK_VAPOR_INTERFACE; ++nn){
if ((THREAD_ID(tf)==t_wall_wick_id[nn])||(THREAD_ID(tf)==t_wall_vapor_id[nn])){
if (THREAD_ID(tf)==t_wall_wick_id[nn]){
S += F_UDMI(f,tf,MVAR)/C_VOLUME(c,t);
}
else{
S -= F_UDMI(f,tf,MVAR)/C_VOLUME(c,t);
}
}
}
}
return S;
}

ahmed425 October 28, 2017 22:26

I'm not expert in UDFs but I always see that the arguments of any source function ends with a variable called eqn and at the end before the return statements there is a command like: dS[eqn]=0;

this might be one reason

the other thing that I can think of is you can initialize your model and solve for a number of iterations without the source then you can add the source and see what happens.

good luck

Micael October 29, 2017 06:36

For verification, return zero value and put "S" in a UDM instead so you can visualise it and assess it is right.

Otherwise, ahmed425's idea to do few iterations before including the UDF is worth trying. Sometime source term at very first iteration can cause problem.

say2017 October 29, 2017 10:53

Thank you ahmed and micael. I have tried running it without the UDF at first and implementing it later but it still didn't work. However, I did finally manage to solve my problem. If anyone else has the same issue, try using the coupled solver especially if you have a transient simulation.


All times are GMT -4. The time now is 05:09.