|
[Sponsors] |
December 25, 2011, 17:21 |
pls help. UDF in DEFINE_SR_RATE
|
#1 |
New Member
golshadi
Join Date: Sep 2011
Posts: 14
Rep Power: 15 |
I have a rate of surface reaction:
-rM=(ks*KM^2*(CM^2-CW*CD/K)/(1+2*(KM*CM)^0.5+(KW*CW))) and have written this UDF for it: #include "udf.h" #define KEQ 7 #define KS 11.7 #define KM 884.6 #define KW 418.4 #define CH3OCH3 0 #define H2O 1 #define CH3OH 2 real reaction_rate(cell_t c, Thread *cthread,real mw[],real yi[]) { real concenCH3OCH3 = C_R(c,cthread) * yi[CH3OCH3] / mw[CH3OCH3]; real concenH2O = C_R(c,cthread) * yi[H2O] / mw[H2O]; real concenCH3OH = C_R(c,cthread) * yi[CH3OH] / mw[CH3OH]; real kcm= KM * concenCH3OH; real den=1+(2 * sqrt(kcm))+(KW * concenH2O); return -1*(KS *1000* pow(KM,2)) * (pow(concenCH3OH,2)-(concenH2O * concenCH3OCH3/KEQ))/(pow(den,4)); } DEFINE_SR_RATE(rate1,f,fthread,r,mw,yi,rr) { *rr = reaction_rate(F_C0(f,fthread),THREAD_T0(fthread),m w,yi); } I Compile and load and Hook it in (Define/User Defined/Function Hook/surface reaction rate). But in the menu of reaction I dont look it. and after iterating , 'FlUENT' writes this : Deleted old libudfrate\ntx86\2ddp\libudf.dll 1 file(s) copied. (system "copy c:\fluent6.3\fluent\fluent6.3.26\src\makefile_nt.u df libudfrate\ntx86\2ddp\makefile") 1 file(s) copied. (chdir "libudfrate")() (chdir "ntx86\2ddp")() my_rate1.c c:\fluent6.3\fluent\fluent6.3.26\src\machine.h(114 ) : warning C4005: 'stdout' : macro redefinition D:\C++\VC\INCLUDE\stdio.h(161) : see previous definition of 'stdout' c:\fluent6.3\fluent\fluent6.3.26\src\machine.h(115 ) : warning C4005: 'stderr' : macro redefinition D:\C++\VC\INCLUDE\stdio.h(162) : see previous definition of 'stderr' c:\fluent6.3\fluent\fluent6.3.26\src\machine.h(116 ) : warning C4005: 'stdin' : macro redefinition D:\C++\VC\INCLUDE\stdio.h(160) : see previous definition of 'stdin' # Generating udf_names.c because of makefile my_rate1.obj udf_names.c c:\fluent6.3\fluent\fluent6.3.26\src\machine.h(114 ) : warning C4005: 'stdout' : macro redefinition D:\C++\VC\INCLUDE\stdio.h(161) : see previous definition of 'stdout' c:\fluent6.3\fluent\fluent6.3.26\src\machine.h(115 ) : warning C4005: 'stderr' : macro redefinition D:\C++\VC\INCLUDE\stdio.h(162) : see previous definition of 'stderr' c:\fluent6.3\fluent\fluent6.3.26\src\machine.h(116 ) : warning C4005: 'stdin' : macro redefinition D:\C++\VC\INCLUDE\stdio.h(160) : see previous definition of 'stdin' # Linking libudf.dll because of makefile user_nt.udf udf_names.obj my_rate1.obj Microsoft (R) Incremental Linker Version 9.00.30729.01 Copyright (C) Microsoft Corporation. All rights reserved. Creating library libudf.lib and object libudf.exp Done. "D:/guess" Opening library "libudfrate"... Library "libudfrate\ntx86\2ddp\libudf.dll" opened rate1 Done. iter continuity x-velocity y-velocity energy ch3och3 h2o time/iter reversed flow in 40 faces on outflow 5. Error: FLUENT received fatal signal (ACCESS_VIOLATION) 1. Note exact events leading to error. 2. Save case/data under new name. 3. Exit program and restart to continue. 4. Report error to your distributor. Error Object: () pls Help me to solve this problem. |
|
December 25, 2011, 17:48 |
|
#2 |
Member
Join Date: Nov 2011
Location: Czech Republic
Posts: 97
Rep Power: 15 |
It looks like array indexing is messed up. You should try to place several Message methods into your code to see, where it is exactly failing.
|
|
December 26, 2011, 03:41 |
|
#3 | |
New Member
golshadi
Join Date: Sep 2011
Posts: 14
Rep Power: 15 |
Quote:
I'm amateur in C coding. pls explain more. FLUENT is giving below error: Error: FLUENT received fatal signal (ACCESS_VIOLATION) 1. Note exact events leading to error. 2. Save case/data under new name. 3. Exit program and restart to continue. 4. Report error to your distributor. Error Object: () I added a message above the *rr=... line, and it is shown in console fluent but after that the error is appeared. thanks |
||
December 26, 2011, 18:48 |
|
#4 |
Member
Join Date: Nov 2011
Location: Czech Republic
Posts: 97
Rep Power: 15 |
ACCESS_VIOLATION can be caused by two things:
1) A pointer is pointing to a memory, which doesn't belong to running process and it is dereferenced. 2) An array index is out of bounds. I have modified your code to help you see what is going on PHP Code:
|
|
December 27, 2011, 15:45 |
|
#5 |
New Member
golshadi
Join Date: Sep 2011
Posts: 14
Rep Power: 15 |
thanks a lot my friend , Sixkillers .
I discover my problem. because my c source file is written to access face type thread but I use it in a porous media, and the media is a volume cell, so : "t0 is NULL" is shown by it. so I used this source in a wall boundary of another case, and Fluent didn't show any error(for time-saving in c source I transformed Message lines to comment lines). in this try the mass fractions of species didn't change and it looks the reaction does not exist. so my problem is in two category: 1- why don't mass fractions of species change after correctly compiling & Hooking my UDF in second case? 2- for applying the UDF in porous media what changes should I do? I hope to help me. Last edited by golshadi; December 27, 2011 at 15:52. Reason: I made a mistake |
|
December 28, 2011, 18:09 |
|
#6 |
Member
Join Date: Nov 2011
Location: Czech Republic
Posts: 97
Rep Power: 15 |
1) I have no idea why it doesn't work, but you might want to try write several values from your method to a file (example how to do it: http://www.cfd-online.com/Forums/flu...avitation.html).
2) I am afraid that you will really have to use macro DEFINE_VR for porous media. In addition be sure that your rate law is in units [kmol/(m^3 * s)]. |
|
December 30, 2011, 15:08 |
|
#7 |
New Member
golshadi
Join Date: Sep 2011
Posts: 14
Rep Power: 15 |
By your suggestions my problems , in this stage of my work, almost are solved.
1- I checked carefully any part of my UDF in the way you said. I found that the fluent did not pass any mass fraction to my UDF so I correct it. 2- I used DEFINE_VR, but I don't know the result of my simulation will be correct. I want to say "YOU ARE KING OF UDF WRITTING" and thanks a lot. I'm sincerely grateful for your help. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
pls Help!...can't interpret UDF | X3mZ | Fluent UDF and Scheme Programming | 1 | December 12, 2010 13:05 |
udf problem.... pls help | anant | FLUENT | 2 | January 11, 2007 07:01 |
Error pls HELP on UDF .... | CFD USER | FLUENT | 1 | October 26, 2006 15:49 |
pls help with udf file | Arif | FLUENT | 1 | February 7, 2006 12:10 |
pls help : udf & cell temp. | A. H. Jaberi | FLUENT | 0 | December 16, 2004 06:33 |