|
[Sponsors] |
Question about the calculation of available amount of reactant based on cell content |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 25, 2021, 23:10 |
Question about the calculation of available amount of reactant based on cell content
|
#1 |
Member
xingangzheng
Join Date: Jul 2009
Posts: 37
Rep Power: 16 |
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, 00:05 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26 |
I don't understand your goal... Why is
Code:
m_h2o = C_VOLUME(c,t) * C_R(c,t) * C_YI(c,t,i);
__________________
"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, 00:25 |
|
#3 | |
Member
xingangzheng
Join Date: Jul 2009
Posts: 37
Rep Power: 16 |
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:
|
||
April 26, 2021, 00:36 |
|
#4 | |
Member
xingangzheng
Join Date: Jul 2009
Posts: 37
Rep Power: 16 |
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:
|
||
April 26, 2021, 01:57 |
|
#5 | |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26 |
Quote:
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, 02:42 |
|
#6 |
Member
xingangzheng
Join Date: Jul 2009
Posts: 37
Rep Power: 16 |
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. |
|
April 26, 2021, 07:29 |
|
#7 | |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26 |
Quote:
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, 22:25 |
|
#8 | |
Member
xingangzheng
Join Date: Jul 2009
Posts: 37
Rep Power: 16 |
Quote:
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, 01:01 |
|
#9 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26 |
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, 01:58 |
|
#10 | |
Member
xingangzheng
Join Date: Jul 2009
Posts: 37
Rep Power: 16 |
Quote:
|
||
April 27, 2021, 02:52 |
|
#11 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26 |
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, 03:56 |
|
#12 | |
Member
xingangzheng
Join Date: Jul 2009
Posts: 37
Rep Power: 16 |
Quote:
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); 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; |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Moisture evaporation - CELL based approach | Kummi | OpenFOAM | 0 | October 14, 2019 07:33 |
Neighboring cells in tetrahedral mesh | vishwesh | OpenFOAM Programming & Development | 9 | November 10, 2017 07:06 |
How to use "translation" in solidBodyMotionFunction in OpenFOAM | rupesh_w | OpenFOAM Running, Solving & CFD | 5 | August 16, 2016 04:27 |
[General] Wrong Calculation of Cell Volume | olli191 | ParaView | 1 | August 3, 2016 04:09 |
How to include cell volumes in calculation of volScalarField? | zordiack | OpenFOAM Programming & Development | 4 | April 11, 2014 05:57 |