TAGGED: adsorption, udf
-
-
September 3, 2023 at 6:59 pm
James
SubscriberHello!
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#includeDEFINE_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 0C_UDMI(c, t, 0) = 0.0; // q_i at the ith time stepC_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 phaseC_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 am
Atharva Nagarkar
SubscriberHello!
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 am
James
SubscriberI will take care next time, and thank you!
-
-
- You must be logged in to reply to this topic.

Boost Ansys Fluent Simulations with AWS
Computational Fluid Dynamics (CFD) helps engineers design products in which the flow of fluid components is a significant challenge. These different use cases often require large complex models to solve on a traditional workstation. Click here to join this event to learn how to leverage Ansys Fluids on the cloud, thanks to Ansys Gateway powered by AWS.

Earth Rescue – An Ansys Online Series
The climate crisis is here. But so is the human ingenuity to fight it. Earth Rescue reveals what visionary companies are doing today to engineer radical new ideas in the fight against climate change. Click here to watch the first episode.

Ansys Blog
Subscribe to the Ansys Blog to get great new content about the power of simulation delivered right to your email on a weekly basis. With content from Ansys experts, partners and customers you will learn about product development advances, thought leadership and trends and tips to better use Ansys tools. Sign up here.
- Floating point exception in Fluent
- What are the differences between CFX and Fluent?
- Heat transfer coefficient
- Difference between K-epsilon and K-omega Turbulence Model
- Getting graph and tabular data from result in workbench mechanical
- The solver failed with a non-zero exit code of : 2
- Suppress Fluent to open with GUI while performing in journal file
- Mesh Interfaces in ANSYS FLUENT
- Time Step Size and Courant Number
- error: Received signal SIGSEGV
-
7626
-
4456
-
2955
-
1427
-
1322
© 2023 Copyright ANSYS, Inc. All rights reserved.