TAGGED: adsorption, udf
-
-
September 3, 2023 at 6:59 pmJamesSubscriber
Hello!
I am trying to model fixed bed adsorption using Linear driving force model given by dq/dt = kf(q* - q) where kf is a constant q* = (KL*qm*C)/(1 + KL*C), where KL and qm are constants and C is the concentration. I defined C as a user defined scalar instead of using mass fraction for convenience with numbers (Does that make any difference?). The dq/dt equation is then applied in the source term as -(1-porosity)*rho*dq/dt.Â
I put messages in my UDF to show me the values of the UDS and other variables calculated and they are absolutely ridiculous. An example is:
The value of q_i is now -38065484171715682240850117399674880.000000
q_i is the value of q at the previous time step.
Anyway, can someone look at my code and see where I am going wrong, please?
#include#includeÂDEFINE_INIT(Initial,domain){  Thread *t;  cell_t c;  thread_loop_c(t, domain)  {    begin_c_loop(c, t)    {      // Initially the contaminant concentration in solid phase is 0      C_UDMI(c, t, 0) = 0.0; // q_i at the ith time step      C_UDMI(c, t, 1) = 0.0; // q_i+1 at the i+1th time step    }    end_c_loop(c, t)  }}DEFINE_ADJUST(define_q_ads, domain)  /*Adjust is the first step in the solution loop*/{  Thread *t;  cell_t c;  real dt;  real rp = 1.1/1000;  real De = 25;  real qm = 154;  real KL = 0.63;  real kf = 15*De/(rp*rp);  real qe; Â  thread_loop_c(t, domain)  {    begin_c_loop(c, t)    {      dt = RP_Get_Real("physical-time-step");      qe = (KL*qm*C_UDSI(c,t,0))/(1+KL*C_UDSI(c,t,0)); // C_UDSI contains the concentration in the liquid phase  Â      C_UDMI(c, t, 1) = C_UDMI(c, t, 0) + kf*dt*((qe - C_UDMI(c, t, 0)));      // q_i+1 = q_i + kf*dt*(qe - q_i)     Â    }    end_c_loop(c, t)  }}DEFINE_SOURCE(m_src, c, t, dS, eqn) /*Source term calculation happens after the adjust function*/ Â{  real source;  real eta = 0.77;  real rho = 743;  int ThreadID = THREAD_ID(t);  source = -(1-eta)*rho*C_UDMI(c,t,1);  Message("====================================================================\n");  Message("The value of source in the cell thread %i is %f\n", ThreadID, source);  Message("====================================================================\n");  dS[eqn] = 0.0;  return source;}DEFINE_EXECUTE_AT_END(execute_at_end)  /*Executes at the end of the iteration. Updates q_i for the next time step*/{  Domain* domain = Get_Domain(1);  Thread* t;  cell_t c;  thread_loop_c(t, domain)  {    begin_c_loop(c, t)    {       C_UDMI(c, t, 0)=C_UDMI(c, t, 1);       Message("The value of q_i is now %f\n",C_UDMI(c,t,0));    }    end_c_loop(c, t)  }}  -
September 6, 2023 at 10:55 amAtharva NagarkarAnsys Employee
Hello!
As part of the Ansys policy, employees cannot debug UDFs on the forum. However, I would suggest you to have a look at the following things.
For the macro C_UDSI, if you try to use the macro before you have specified the user-defined scalars in your Ansys Fluent model then an error will result.
3.2. Data Access Macros (ansys.com) -> Check section 3.2.11.3
Please also have a look at the definition of the macro C_UDMI and how the arguments are defined at the link below.
3.2. Data Access Macros (ansys.com) -> Check section 3.2.12.4
Additionally, this is the link from the Ansys manual for defining the source term. Make sure that you have correctly defined the dS[] array with respect to the dependent variable.
2.3. Model-Specific DEFINE Macros (ansys.com) -> Check section 2.3.43
Lastly, these are the time dependent macros which you can use to access variables for previous timesteps.
3.5. Time-Dependent Macros (ansys.com)
If you are not able to access the link, please refer to this forum discussion: Using Help with links (ansys.com)
Thanks!
-
September 7, 2023 at 11:09 amJamesSubscriber
I will take care next time, and thank you!
-
-
- The topic ‘Unnatural values calculated by UDF’ is closed to new replies.
- Non-Intersected faces found for matching interface periodic-walls
- Unburnt Hydrocarbons contour in ANSYS FORTE for sector mesh
- Help: About the expression of turbulent viscosity in Realizable k-e model
- Cyclone (Stairmand) simulation using RSM
- error udf
- Script error Code: 800a000d
- Fluent fails with Intel MPI protocol on 2 nodes
- Diesel with Ammonia/Hydrogen blend combustion
- Mass Conservation Issue in Methane Pyrolysis Shock Tube Simulation
- Encountering Error in Heterogeneous Surface Reaction
-
1191
-
513
-
488
-
225
-
209
© 2024 Copyright ANSYS, Inc. All rights reserved.