CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Udf mass transfer multiphase access violation

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By pakk
  • 1 Post By pakk

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 25, 2014, 06:55
Default Udf mass transfer multiphase access violation
  #1
Member
 
majid kamyab
Join Date: Jul 2014
Posts: 32
Rep Power: 12
majid_kamyab is on a distinguished road
the case is a 2 phase vapor-liquid modeled by Eulerian framework and k-e
and there are only 2 species. there is a mass transfer between the phases
I have written a UDF for mass transfer but an error occurs when I try to run calculation in parallel mode and when I run in series access violation error occurs
The code is written below


#include "udf.h"
DEFINE_MASS_TRANSFER(liq_gas_source,c,t,from_index ,from_species_index, to_index, to_species_index)
{
real m_lg,c_meth_l,c_meth_v,k_l,dal,usg,kappa,m,c_sat;
dal=1.46*0.000000001;
usg=0.294188;
kappa=0.000484011/748;
m=1.204;
k_l=2*sqrt((dal/3.1415)*sqrt(usg*9.8/kappa));
m_lg = k_l*(C_YI(c,from_index,from_species_index)-m*C_YI(c,to_index,to_species_index));
return (m_lg);
}


the code can be interpreted but during the first calculation the following error occurs:




Updating solution at time level N... done.
iter continuity u-mixture-li u-mixture-ga v-mixture-li v-mixture-ga w-mixture-li w-mixture-ga k-mixture-li eps-mixture- ch3oh<l>-mix n-propanol-g vf-mixture-g time/iter
!417331 solution is converged
417331 7.7100e-04 2.3939e-04 6.4021e-05 5.8865e-04 1.0116e-04 2.8676e-04 8.3530e-05 1.4561e-04 2.6601e-04 0.0000e+00 0.0000e+00 2.7556e-05 0:01:40 100

999999 (..\src\mpsystem.c@1173): mpt_read: failed: errno = 10054

999999: mpt_read: error: read failed trying to read 4 bytes: Invalid argument
MPI Application rank 0 exited before MPI_Finalize() with status -1073741819
The Parallel FLUENT process could not be started.
majid_kamyab is offline   Reply With Quote

Old   September 25, 2014, 07:18
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
When using parallel, compiling is usually much safer than interpreting. Try that.
pakk is offline   Reply With Quote

Old   September 25, 2014, 09:26
Default
  #3
Member
 
majid kamyab
Join Date: Jul 2014
Posts: 32
Rep Power: 12
majid_kamyab is on a distinguished road
Quote:
Originally Posted by pakk View Post
When using parallel, compiling is usually much safer than interpreting. Try that.
so there is no problem with the code?
majid_kamyab is offline   Reply With Quote

Old   September 25, 2014, 10:21
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Quote:
Originally Posted by majid_kamyab View Post
so there is no problem with the code?
I don't know. Your primary problem is that you try interpret for parallel calculations, where compile is more appropriate.

I could spend the next hour figuring out if your code would give errors if you would compile it, but I am not going to do that, because it is much faster for you if you just compile it and see what the result is.
pakk is offline   Reply With Quote

Old   September 25, 2014, 10:24
Default
  #5
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 27
ghost82 will become famous soon enough
Did you read this?
http://www.cfd-online.com/Forums/ans...g-mpi-why.html

It seems your problem is not related to the code.
ghost82 is offline   Reply With Quote

Old   September 25, 2014, 10:31
Default
  #6
Member
 
le hoang anh
Join Date: Oct 2012
Posts: 96
Rep Power: 14
lehoanganh07 is on a distinguished road
Your code have problem both series and parallel simulation?
I think the problem is C_YI(cell,thread,i) but your code C_YI(cell, index,i)
So I think it may cause error
lehoanganh07 is offline   Reply With Quote

Old   September 25, 2014, 12:23
Default
  #7
Member
 
majid kamyab
Join Date: Jul 2014
Posts: 32
Rep Power: 12
majid_kamyab is on a distinguished road
Yes I have already read that
my RAM is 8 Gb and my mesh is about 200,000 Cells
so I dont think the problem is with the RAM
majid_kamyab is offline   Reply With Quote

Old   September 26, 2014, 04:29
Default
  #8
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Is there a reason why you don't take 2 minutes to compile it and tell us if that solves the problem?
pakk is offline   Reply With Quote

Old   September 26, 2014, 05:52
Default
  #9
Member
 
majid kamyab
Join Date: Jul 2014
Posts: 32
Rep Power: 12
majid_kamyab is on a distinguished road
Quote:
Originally Posted by pakk View Post
Is there a reason why you don't take 2 minutes to compile it and tell us if that solves the problem?
Dear pakk the following error occurs when I try to load the library

the UDF library you are trying to load (libudf) is not compiled for parallel use in current platform (win64)

as I mentioned earlier I couldnt interpret it even in serial mode
I am a new user and I was trying to learn how to compile
and thats why I didnt answer quickly
thanks in advance
majid_kamyab is offline   Reply With Quote

Old   September 26, 2014, 05:54
Default
  #10
Member
 
majid kamyab
Join Date: Jul 2014
Posts: 32
Rep Power: 12
majid_kamyab is on a distinguished road
Quote:
Originally Posted by lehoanganh07 View Post
Your code have problem both series and parallel simulation?
I think the problem is C_YI(cell,thread,i) but your code C_YI(cell, index,i)
So I think it may cause error
I think that the problem is with the C_YI too.
I have tried
Thread *gas=THREAD_SUB_THREAD(t,to_index);
Thread *gas=THREAD_SUB_THREAD(t,to_index);
but there are another parse errors in these lines
thanks in advance
majid_kamyab is offline   Reply With Quote

Old   September 26, 2014, 06:08
Default
  #11
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Quote:
Originally Posted by majid_kamyab View Post
Dear pakk the following error occurs when I try to load the library

the UDF library you are trying to load (libudf) is not compiled for parallel use in current platform (win64)

as I mentioned earlier I couldnt interpret it even in serial mode
I am a new user and I was trying to learn how to compile
and thats why I didnt answer quickly
thanks in advance
Ok.
But my question was not what happens if you try to load the library, but what happens if you try to compile your file. Apparantly, that gave an error. Look at that error to see what is wrong with your code.
pakk is offline   Reply With Quote

Old   September 26, 2014, 06:22
Default
  #12
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Example of how I would debug this:

I tried to compile your code, and saw the following error:
Quote:
..\..\src\test.c(10) : error C2223: left of '->storage' must point to struct/union
..\..\src\test.c(10) : error C2223: left of '->storage' must point to struct/union
This means that something is wrong in (or before) line 10.
Line 10 is:
Code:
m_lg = k_l*(C_YI(c,from_index,from_species_index)-m*C_YI(c,to_index,to_species_index));
So I look at the definition of C_YI (Fluent UDF manual 3.2.3.6.):
Quote:
C_YI(c,t,i)

cell_t c, Thread *t, int i
Translated to your code, c should be a cell_t, from_index should be a Thread*, and from_species_index should be an int.
But, from the definition of DEFINE_MASS_TRANSFER (2.4.6):
C is indeed cell_t, from_index is an int, and from_species_index is also an int.

So, what is wrong? The second input variable of C_YI.

Looking at variable types alone, the following looks more reasonable:
Code:
m_lg = k_l*(C_YI(c,t,from_species_index)-m*C_YI(c,t,to_species_index));
pakk is offline   Reply With Quote

Old   September 26, 2014, 07:01
Default
  #13
Member
 
majid kamyab
Join Date: Jul 2014
Posts: 32
Rep Power: 12
majid_kamyab is on a distinguished road
Quote:
Originally Posted by pakk View Post
Example of how I would debug this:

I tried to compile your code, and saw the following error:


This means that something is wrong in (or before) line 10.
Line 10 is:
Code:
m_lg = k_l*(C_YI(c,from_index,from_species_index)-m*C_YI(c,to_index,to_species_index));
So I look at the definition of C_YI (Fluent UDF manual 3.2.3.6.):


Translated to your code, c should be a cell_t, from_index should be a Thread*, and from_species_index should be an int.
But, from the definition of DEFINE_MASS_TRANSFER (2.4.6):
C is indeed cell_t, from_index is an int, and from_species_index is also an int.

So, what is wrong? The second input variable of C_YI.

Looking at variable types alone, the following looks more reasonable:
Code:
m_lg = k_l*(C_YI(c,t,from_species_index)-m*C_YI(c,t,to_species_index));



In this code the mass fraction of the gas phase and the liquid phase must be used but in the
C_YI(c,t,from_species_index)
the mass fraction of the cell is used isnt that right?
I have used THREAD_SUB_THREAD for identification of the gas phase and also the liquid phase is it correct?(I have mentioned in the last reply
majid_kamyab is offline   Reply With Quote

Old   September 26, 2014, 07:29
Default
  #14
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
The correct syntax depends on what you want your code to do.
Your equation is:
Code:
m_lg = k_l*(A-m*B);
Here, A and B are mass fractions. Which mass fractions do you want them to be?

In "C_YI(c,t,i)", c and t indicate which cell you want to look at, and i indicates which mass fraction you want to use. I am fairly sure about the c and the t, but to know which i you should use (from_index,from_species_index, to_index or to_species_index), you should look at the problem you want to solve. All four are acceptable from a programming point of view, they just give solutions to different physical problems.
majid_kamyab likes this.
pakk is offline   Reply With Quote

Old   September 26, 2014, 08:26
Default
  #15
Member
 
majid kamyab
Join Date: Jul 2014
Posts: 32
Rep Power: 12
majid_kamyab is on a distinguished road
Quote:
Originally Posted by pakk View Post
The correct syntax depends on what you want your code to do.
Your equation is:
Code:
m_lg = k_l*(A-m*B);
Here, A and B are mass fractions. Which mass fractions do you want them to be?

In "C_YI(c,t,i)", c and t indicate which cell you want to look at, and i indicates which mass fraction you want to use. I am fairly sure about the c and the t, but to know which i you should use (from_index,from_species_index, to_index or to_species_index), you should look at the problem you want to solve. All four are acceptable from a programming point of view, they just give solutions to different physical problems.
let me be more specific
there are two species ( methanol and propanol) and I want to calculate mass fraction of methanol IN THE LIQUID PHASE and the mass fraction of methanol IN THE VAPOR PHASE
so I dont want the mass fraction of the liquid phase or methanol in the cell.
as I think t is a mixture thread (super thread) and I think I am making mistake using THREAD_SUB_THREAD
majid_kamyab is offline   Reply With Quote

Old   September 26, 2014, 08:43
Default
  #16
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
I am not experienced enough in species' udfs to tell you what to use. I can only tell you that from a programming point of view, you select the species phase with the third input, and that should be an int.
majid_kamyab likes this.
pakk is offline   Reply With Quote

Old   September 26, 2014, 09:22
Default
  #17
Member
 
majid kamyab
Join Date: Jul 2014
Posts: 32
Rep Power: 12
majid_kamyab is on a distinguished road
Ive got my answer
The macro C_YI(cell, thread, I) should be used in the form of following.

thread_loop_c(thread, domain) { if( THREAD_ID(t) == 8 ) { begin_c_loop(cell, thread) {

C_YI(cell, thread, I) ; } } }

The value "8" specified above is the "thread id" that will be got in Define-Boundary Conditions . And , "I" of C_YI(cell, thread, I) shows species which you want to get the mass fraction.
majid_kamyab is offline   Reply With Quote

Old   September 26, 2014, 09:24
Default
  #18
Member
 
majid kamyab
Join Date: Jul 2014
Posts: 32
Rep Power: 12
majid_kamyab is on a distinguished road
Quote:
Originally Posted by pakk View Post
I am not experienced enough in species' udfs to tell you what to use. I can only tell you that from a programming point of view, you select the species phase with the third input, and that should be an int.
thanks a lot for the time you have spent on this Thread
Ive got my answer from another Thread
I posted it here too if you are interested
majid_kamyab is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to access only one phase in multiphase model by UDF wersoe Fluent UDF and Scheme Programming 1 January 4, 2017 08:11
mass transfer coefficient for boundary condition niek Main CFD Forum 0 March 29, 2011 06:33
Hooking a DPM Particle Heat and Mass Transfer UDF to FLUENT subhankar_bhandari FLUENT 0 August 19, 2010 04:01
Hooking a DPM Particle Heat and Mass Transfer UDF to FLUENT subhankar_bhandari Main CFD Forum 0 August 19, 2010 04:01
Multiphase flow with mass transfer? A. Ataki FLUENT 1 November 10, 2003 05:46


All times are GMT -4. The time now is 16:01.