|
[Sponsors] |
January 8, 2019, 14:26 |
Steady state timestep
|
#1 |
New Member
Join Date: May 2018
Posts: 29
Rep Power: 8 |
Hello,
I want to calculate a custom ODE for every cell, so I created a user defined memory (UDM) for its result value. Then I thought I could use the DEFINE_ADJUST macro to change the UDM's value respectively. For example following rate equation (just as an example): dx/dt = -k * c(species1) My approach was the following Code:
DEFINE_ADJUST(adjust_macro, d) { Thread *t; cell_t c; real dt = CURRENT_TIMESTEP; thread_loop_c(t, d) { begin_c_loop(c, t) // get concentration real conc = C_R(c, t) * C_YI(c, t, i_specie1) / mw_specie1; // HERE APPLY THE RATE CHANGE TO THE VALUE C_UDMI(c, t, MY_UDMI) += (-k * conc) * dt; end_c_loop(c, t) } } Any help is appreciated, thank you! |
|
January 9, 2019, 00:26 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
this code doesn't manipulate timestep, do you understand this?
timestep is involved in last equation and is equal to the value (timestep size), which you put in fluent GUI. And it is constant (else you are using adaptive timestep). It could be 1sec, 2, 111, any value you've put in GUI IF you want to change timestep using UDF you should use DEFINE_DELTAT macro best regards |
|
January 9, 2019, 04:36 |
|
#3 |
New Member
Join Date: May 2018
Posts: 29
Rep Power: 8 |
Thank you for your answer!
Well I don't want to change the time step actually. I want to calculate the result of a rate equation/ode according to the current timestep. Actually I want to synchroniously solve a rate equation/ode of a scalar (non specie concentration) to the chemical reaction. I have a volumetric reaction with a DEFINE_VR_RATE udf set up, thus I'm not using the stiff chemistry solver. But I want to have the same possibility of using the "dt" parameter of DEFINE_CHEM_STEP without changing said solver. |
|
January 9, 2019, 10:26 |
|
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
||
January 9, 2019, 12:44 |
|
#5 |
New Member
Join Date: May 2018
Posts: 29
Rep Power: 8 |
||
January 11, 2019, 09:43 |
|
#6 |
New Member
Join Date: May 2018
Posts: 29
Rep Power: 8 |
First off, sorry for the double post.
But I try to ask the question more general: Is there any possibility to add a custom differential equation to the Fluent solver. Or somehow couple a new differential equation with the equations being solved by Fluent anyways. I think this shouldn't be that much of a challenge for a software that's main task is basically solving differential equations. Hope anyone can help me, thanks. |
|
January 13, 2019, 22:10 |
|
#7 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
User-Defined Scalars may be the answer to your question
More information could be found in Ansys Fluent Customization manual best regards |
|
January 14, 2019, 10:48 |
|
#8 | |
New Member
Join Date: May 2018
Posts: 29
Rep Power: 8 |
Quote:
I want to add a additional ODE with respect to the scalar with units of a concentration (kmol/m^3): The resulting unit of this source term then is kmol/m^3 s. So I wrote a DEFINE_SOURCE looking like the following: Code:
DEFINE_SOURCE(source_phi, c, t, dS, eqn) { real rho = C_R(c, t); real c_1= rho * C_YI(c, t, I_1) / M_i[I_1]; real phi = C_UDSI(c, t, I_PHI); real source = 2 * k1 * c_1 - k2 * pow(phi, 2); dS[eqn] = -2 *k2 * phi; return source; } |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Effect of initial condition for steady state vs Transient | prasa | ANSYS | 0 | August 22, 2018 05:45 |
Domain Reference Pressure and mass flow inlet boundary | AdidaKK | CFX | 75 | August 20, 2018 06:37 |
Calculation of the Governing Equations | Mihail | CFX | 7 | September 7, 2014 07:27 |
Constant velocity of the material | Sas | CFX | 15 | July 13, 2010 09:56 |
About the difference between steady and unsteady problems | Lisa | Main CFD Forum | 11 | July 5, 2000 15:37 |