Calculating a variable based on the data from two different cell zones
Hi, everyone!
I woulk like to kindly ask for some help with a UDF that I am trying to write. I am modelling the membrane permeation. I want to calculate the flux near the solid-liquid interface based on the pressure difference. However, can the pressure difference be gotten by direct subtraction, and how to guarantee the one-to-one correspondence of two subtracted cell value? |
Code:
begin_f_loop(f1,ft1) So I suggest you to use UDMs to store pressure Code:
DEFINE_ADJUST(adjust_flux,domain) |
@AlexanderZ,thank you! Your help is very helpful to me, and I will try it.
|
1 Attachment(s)
Quote:
Code:
DEFINE_INIT(UDM,domain) As shown in the attached FIG, a) the pressures on the left side of membrane are stored into 4th layer cells of C_UDMI(c,t,0), and the ones on the right side are stored into 7th layer of C_UDMI(c,t,1)? b) the formula C_UDMI(c,t,2)=C_UDMI(c,t,0)-C_UDMI(c,t,1) can achieve the subtraction of 4th layer and 7th layer cells? c) if not, how to achieve this aim? Maybe my understanding is wrong, so hope your suggestions. Thanks for any help! |
my bad, you are right, you can't compare udm_0 with udm_1 because they have data in different cells
may be you can make your own arrays and compare them directly: Code:
#include "udf.h" |
Quote:
Code:
face_t f1, f2; |
variable should be defined in the top of function, before other instructions
try this Code:
#include "udf.h" |
Quote:
I am solving the same problem. I tried this approach and was able to store saturation pressure (function of temperature) in my arrays. However, the sequence of storing values in each array is different from each other. Thus a direct comparison is not helpful. my code: thread_loop_c(t,d) { begin_c_loop(c,t) { C_CENTROID(x,c,t); if (x[1] < 0.001001 && x[1] > 0.001){ psc[i] = exp(25.317-5144/C_T(c,t)); i++; }} end_c_loop(c,t) i=0; begin_c_loop(c,t) { C_CENTROID(x,c,t); if (x[1] > 0.00123 && x[1] < 0.00124){ psh[i] = exp(25.317-5144/C_T(c,t)); C_UDMI(c,t,1) = psh[i]; i++; }} end_c_loop(c,t) I printed the values of the x-coordinate(x[0]) for both c-loops to see the sequence of storing values. A sample (initial 5 values) for both loops are : i = 0,1,2,3,4,...... loop 1: 22.783333, 22.816667, 15.05, 22.85, 15.083333,........ loop 2: 84.916667, 84.883333, 26.516667, 84.85, 118.25,.... In my understanding, these two loops should return the same values to get the correct pressure difference at each cell. Thank you |
check this thread, the way to get link between cells is described there:
https://www.cfd-online.com/Forums/fl...-transfer.html |
Dear Alexander
Thank you so much. Your suggestion worked. Can you suggest any reference for CX_Find_Cell_With_Point() function for more clarity? It is not available in the ANSYS UDF manual. |
All times are GMT -4. The time now is 22:37. |