Question about the calculation of available amount of reactant based on cell content

 Register Blogs Members List Search Today's Posts Mark Forums Read

 April 26, 2021, 00:10 Question about the calculation of available amount of reactant based on cell content #1 Member   xingangzheng Join Date: Jul 2009 Posts: 34 Rep Power: 14 Hi at all! I am trying to find a way to calculate the available amount of reactant based on cell content in one calculation step. The purpose is used it to evaluate whether the available reactants are greater than the source terms in each cell. The following code was found. But the calculation process is a little bit confused. 1) Here, the flux from C0 to the face is regarded as positive value, and the flux from C1 is just the opposite ; So the thread of C0 is used in the first 'if' stament, and C1 is used to the negative flux. Is this right ? ( Or this is a kind of upwind format of flux) 2) the transient behavior is reflected by ' f_h2o * CURRENT_TIMESTEP '. Is this reasonable? m_h2o = C_VOLUME(c,t) * C_R(c,t) * C_YI(c,t,i); c_face_loop(c,t,n) { f = C_FACE(c,t,n); tf = C_FACE_THREAD(c,t,n); /* At faces with out flow */ if(F_FLUX(f,tf) > 0.0) { f_h2o += F_FLUX(f,tf) * C_YI(c,t,i); } else { /* At faces with in flow */ t1 = F_C1_THREAD(f,tf); c1 = F_C1(f,tf); f_h2o += - F_FLUX(f,tf) * C_YI(c1,t1,i); } } /* Available amount of h2o based on cell content in one calculation step */ dm_h2o = m_h2o + f_h2o * CURRENT_TIMESTEP; 3) If the above two is correct. Is the following modification appropriate /* At faces with out flow */ if(F_FLUX(f,tf) > 0.0) { f_h2o += -F_FLUX(f,tf) * C_YI(c,t,i); /****here a minus sign is added to indicates outflow *****/ } else { /* At faces with in flow */ t1 = F_C1_THREAD(f,tf); c1 = F_C1(f,tf); f_h2o += - F_FLUX(f,tf) * C_YI(c1,t1,i); } } dm_h2o = m_h2o + f_h2o * CURRENT_TIMESTEP; Thank you very much in advance.

 April 26, 2021, 01:05 #2 Senior Member   Join Date: Nov 2013 Posts: 1,969 Rep Power: 24 I don't understand your goal... Why is Code: `m_h2o = C_VOLUME(c,t) * C_R(c,t) * C_YI(c,t,i);` not sufficient? Why do you calculate the flux into the cell, ate you trying to predict the next time step? The description does not mention that, or I fail to understand something. __________________ "The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".

April 26, 2021, 01:25
#3
Member

xingangzheng
Join Date: Jul 2009
Posts: 34
Rep Power: 14
Thank you sir.

The background is as follows.
There are source terms caused by reaction or condensation. If the available amount of reactant in one cell is fewer than the mass sources calculated by formulas, then the available amount is used to replace the original calculated value.
If not, there will be an imbalance. The calculated mass sources are going to be added all the time, when Qavailable<Qsource.

There is another situation，when Qavailable=0, but the calculated Qsource may be added to another phases.

Quote:
 Originally Posted by pakk I don't understand your goal... Why is Code: `m_h2o = C_VOLUME(c,t) * C_R(c,t) * C_YI(c,t,i);` not sufficient? Why do you calculate the flux into the cell, ate you trying to predict the next time step? The description does not mention that, or I fail to understand something.

April 26, 2021, 01:36
#4
Member

xingangzheng
Join Date: Jul 2009
Posts: 34
Rep Power: 14
m_h2o = C_VOLUME(c,t) * C_R(c,t) * C_YI(c,t,i) is a static quantity.

For the transient behavior, the mass variation in a control volume may need to consider the flux. Because in one step time, the flux_in can increase the available quantity in a cell, and the flux_out can decrease the available quantity in a cell.

I don't know this description is right or wrong.

Quote:
 Originally Posted by pakk I don't understand your goal... Why is Code: `m_h2o = C_VOLUME(c,t) * C_R(c,t) * C_YI(c,t,i);` not sufficient? Why do you calculate the flux into the cell, ate you trying to predict the next time step? The description does not mention that, or I fail to understand something.

April 26, 2021, 02:57
#5
Senior Member

Join Date: Nov 2013
Posts: 1,969
Rep Power: 24
Quote:
 Originally Posted by ustbdynamic m_h2o = C_VOLUME(c,t) * C_R(c,t) * C_YI(c,t,i) is a static quantity. For the transient behavior, the mass variation in a control volume may need to consider the flux. Because in one step time, the flux_in can increase the available quantity in a cell, and the flux_out can decrease the available quantity in a cell. I don't know this description is right or wrong.
Hard to follow... Why is this a static quantity? density and mass fraction are not static.

Adding the flux gives you a reasonable prediction of the quantity at the next time step, which might be useful in some cases, but not in your case, as far as I can see.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".

April 26, 2021, 03:42
#6
Member

xingangzheng
Join Date: Jul 2009
Posts: 34
Rep Power: 14
For example, using m_h2o = C_VOLUME(c,t) * C_R(c,t) * C_YI(c,t,i), you may obtain the available reactant is 5 kg. Within the calculation time step, the net flux into the cell may be 10 kg.
So the total available reactant is 15 kg.

The corresponding physical phenomenon can be the condensation process of water vapor. If the power of cold source is high, in one step time, it will condense the original vapor (5 kg)，and then cause the vapor flux (10 kg) into the cell.

This is the original intention of it.

Now the first question seems to be whether it is necessary to consider the increment caused by flux in one step.

Quote:
 Originally Posted by pakk Hard to follow... Why is this a static quantity? density and mass fraction are not static. Adding the flux gives you a reasonable prediction of the quantity at the next time step, which might be useful in some cases, but not in your case, as far as I can see.

April 26, 2021, 08:29
#7
Senior Member

Join Date: Nov 2013
Posts: 1,969
Rep Power: 24
Quote:
 Originally Posted by ustbdynamic For example, using m_h2o = C_VOLUME(c,t) * C_R(c,t) * C_YI(c,t,i), you may obtain the available reactant is 5 kg. Within the calculation time step, the net flux into the cell may be 10 kg. So the total available reactant is 15 kg.
No, the total available reactant at the time step is 5 kg.
15 kg is the prediction for the total available reactant at the next time step. But the extra 10 kg is not yet in your cell.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".

April 26, 2021, 23:25
#8
Member

xingangzheng
Join Date: Jul 2009
Posts: 34
Rep Power: 14
Quote:
 Originally Posted by pakk No, the total available reactant at the time step is 5 kg. 15 kg is the prediction for the total available reactant at the next time step. But the extra 10 kg is not yet in your cell.
Thank you again.
There still seems to be some doubt.

Take the previous for example.
Assuming a single component gas, C_YI(c,t,i)=1. m_h2o = C_VOLUME(c,t) * C_R(c,t) * 1, which will be approximately a constant for the pressure changed not very much. (nearly kept 5 kg in the cell).

If there is zero flux in and out of the cell，the maximum condensation indeed equal to 5 kg. But if there is 10 kg flux each time, the maximum condensation can be greater than 5 kg at each time.

As is the case for condenser with only entrances. It may condense much more mass than its holding in a time step. Of course, condensation mass also has a certain relationship with the time step size.

Therefor, I think the mass flux influences the available reactant mass for both current time step and the next time step.

I don't know if I've made it clear.

 April 27, 2021, 02:01 #9 Senior Member   Join Date: Nov 2013 Posts: 1,969 Rep Power: 24 If you have 10000 money in your bank account, and every month you earn 2000 money, how much can you spend now? My answer is 10000 money. But I see your point. If I increase the time step to ten years, I have 10000 money, and earn 240000 money. How much can I spend in the ten years? You can argue 250000 is a better answer. Sure, but then your problem is different: your time step is too large! Make the time step small enough, so that the change is small. If you don't, you will get convergence problems anyway. And then, you can simply ignore the flux. __________________ "The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".

April 27, 2021, 02:58
#10
Member

xingangzheng
Join Date: Jul 2009
Posts: 34
Rep Power: 14
Quote:
 Originally Posted by pakk If you have 10000 money in your bank account, and every month you earn 2000 money, how much can you spend now? My answer is 10000 money. But I see your point. If I increase the time step to ten years, I have 10000 money, and earn 240000 money. How much can I spend in the ten years? You can argue 250000 is a better answer. Sure, but then your problem is different: your time step is too large! Make the time step small enough, so that the change is small. If you don't, you will get convergence problems anyway. And then, you can simply ignore the flux.
Dear pakk, thank you very much. I will rethink this process.

April 27, 2021, 03:52
#11
Senior Member

Join Date: Nov 2013
Posts: 1,969
Rep Power: 24
Quote:
 Originally Posted by ustbdynamic Dear pakk, thank you very much. I will rethink this process.
You're welcome. Your question is very important for a good understanding, great that you asked!
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".

April 27, 2021, 04:56
#12
Member

xingangzheng
Join Date: Jul 2009
Posts: 34
Rep Power: 14
Quote:
 Originally Posted by pakk You're welcome. Your question is very important for a good understanding, great that you asked!

Dear pakk, I'm sorry again to trouble you.

If without considering the convergence problems or other questions, Can the following code realize the functions described above. In particular, the use of C (C0), C1 to match the flux direction (flow into or out of the cell).

Thank you very much.

m_h2o = C_VOLUME(c,t) * C_R(c,t) * C_YI(c,t,i);
c_face_loop(c,t,n)
{
f = C_FACE(c,t,n);
/* At faces with out flow */
if(F_FLUX(f,tf) > 0.0)
{
f_h2o += F_FLUX(f,tf) * C_YI(c,t,i);
}
else
{
/* At faces with in flow */
c1 = F_C1(f,tf);
f_h2o += - F_FLUX(f,tf) * C_YI(c1,t1,i);
}
}
/* Available amount of h2o based on cell content in one calculation step */
dm_h2o = m_h2o + f_h2o * CURRENT_TIMESTEP;