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/)
-   -   Problem with UDS and UDM. (https://www.cfd-online.com/Forums/fluent-udf/242304-problem-uds-udm.html)

KLD April 14, 2022 08:01

Problem with UDS and UDM.
 
Hi everybody,
I'm doing a simulation of an electrodepostion process and I need to code a UDS and UDM (below) to calculate the thickness of the zinc layer on my cathode (Domain ID=2). The problem is that I'm getting a zero FOR THE UDS and the UDM just like it doesn't work.
Any help well be appreciated.
Thanks.


# include "udf.h"
# define domain_ID 2
DEFINE_EXECUTE_AT_END(adjust_gradient)
{
Domain *domain;
Thread *t;
cell_t c;
face_t f;/*real F=0.0044910826582479*/
real J;
real *E;
real EMag;
real sigma= 20;
domain=Get_Domain(2);
/* Fill UDS with the variable. */
thread_loop_c (t,domain)
{
begin_c_loop (c,t)
{
E=C_PHI_1_G(c,t);/*call potential gradient vector from adjacent cell of the face*/
EMag=NV_MAG(E);/*magnitude of potential gradient vector*/
J=sigma*EMag;/*current density*/
C_UDSI(c,t,0)=C_UDSI_M1(c,t,0)+((0.1475*J)-0.0963)*J*0.0044910826582479;/*cathode thickness*/

}
end_c_loop (c,t)
}
thread_loop_f (t,domain)
{
if (THREAD_STORAGE(t,SV_UDS_I(0))!=NULL)
begin_f_loop (f,t)
{
E=C_PHI_1_G(F_C0(f,t),THREAD_T0(t));/*call potential gradient vector from adjacent cell of the face*/
EMag=NV_MAG(E);/*magnitude of potential gradient vector*/
J=sigma*EMag;
F_UDSI(f,t,0)=C_UDSI_M1(F_C0(f,t),THREAD_T0(t),0)+ ((0.1475*J)-0.0963)*J*0.0044910826582479;
}
end_f_loop (f,t)
}
}
DEFINE_EXECUTE_AT_END(store_gradient)
{
Domain *domain;
cell_t c;
Thread *t;
domain=Get_Domain(2);
/* Fill the UDM with magnitude of gradient. */
thread_loop_c (t,domain)
{
begin_c_loop (c,t)
{
C_UDMI(c,t,0) =C_UDSI_M1(c,t,0)+NV_MAG(C_UDSI_G(c,t,0));
}
end_c_loop (c,t)
}
}

AlexanderZ April 14, 2022 22:32

first, do you have multiphase flow?
as you are using "domain=Get_Domain(2);" for single phase domain is always 1.

As you are using value from previous timestep C_UDSI_M1(c,t,0) how did you organize it for the first time step? Previous timestep doesn't exist yet.

Probably, better to define *E as a vector explicitly:
Code:

real NV_VEC(E);


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