|
[Sponsors] |
August 25, 2010, 06:10 |
ACCESS_VIOLATION error
|
#1 |
New Member
Emily
Join Date: Aug 2010
Posts: 5
Rep Power: 16 |
Hello, I am trying to model the heat transfer within a hydrogen fuel cell and I keep getting the message ACCESS_VIOLATION when I try applying my UDF.
#include "udf.h" DEFINE_INIT(init_func,d) { Domain *d; Thread *t; real sum_diss=0.; cell_t c; d = Get_Domain(1); } DEFINE_SOURCE(sink_mass, c, t, dS, eqn) { real sink_mass; sink_mass=-C_UDMI(c,t,0)*rau0*0.0166*(1-poros); return sink_mass; } DEFINE_SOURCE(energy_source, c, t, dS, eqn) { real energy_source; energy_source=-C_UDMI(c,t,0)*rau0*0.0166*(1-poros)*deltah/mh2; return energy_source; } DEFINE_EXECUTE_AT_END(execute_at_end) { real step =RP_Get_Real("physical-time-step"); Domain *domain = Get_Domain(1); int ID=2; Thread *t =Lookup_Thread(domain, ID); cell_t c; begin_c_loop(c,t) { double temper,P,hsmp,lnpeq,Peq, dxdt; temper=C_T(c,t); P=(C_R(c,t)*rgp*C_T(c,t)/mh2)*0.00001; hsmp= C_UDMI(c,t, 1 )*(HsMmaxprim-hsurm)+hsurm; lnpeq=A-B/temper+C*hsmp+D*pow(tan(pi*hsmp/2.0/HsMmaxprim),n)+E*pow(tan(pi*hsmp/2.0/HsMmaxprim),(-m)); Peq=exp(lnpeq); C_UDMI(c,t,0)=mh2*Ca*exp(Ea/(rgp*temper))*log(P/Peq)/0.0166; C_UDMI(c,t,1 )=C_UDMI(c,t,1 )+C_UDMI(c,t,0)*step; } end_c_loop(c,t) } I have defined things but didnt think that was important. Can anyone please tell me what is wrong with this code!! It is fairly urgent! Thank you for any help |
|
August 25, 2010, 07:04 |
|
#2 |
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20 |
You have to check if the pointers are valid and if you have enough user defined memory allocated:
Code:
... if (N_UDM > 0) sink_mass=-C_UDMI(c,t,0)*rau0*0.0166*(1-poros); else Error("Not enough UDM's defined!\n"); return sink_mass; } ... if (N_UDM > 0) energy_source=-C_UDMI(c,t,0)*rau0*0.0166*(1-poros)/mh2; else Error("Not enough UDM's defined!\n") return energy_source; ... int ID=2; Thread *t =Lookup_Thread(domain, ID); cell_t c; if(NULL == t) Error("No such thread!\n"); ... if (N_UDM < 2) Error("Not enough UDM's defined!\n") C_UDMI(c,t,0)=mh2*Ca*exp(Ea/(rgp*temper))*log(P/Peq)/0.0166; C_UDMI(c,t,1 )=C_UDMI(c,t,1 )+C_UDMI(c,t,0)*step; ... |
|
August 25, 2010, 07:24 |
|
#3 |
New Member
Emily
Join Date: Aug 2010
Posts: 5
Rep Power: 16 |
Thanks for your help. I seem to have fixed the code but when I try and hook the function into the model, the sources do not appear in the hooking function box. Any ideas?
Thanks again! |
|
August 27, 2010, 03:01 |
|
#4 | |
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20 |
Quote:
I suspect you're looking in the wrong place. Check section 6.2.19 in the User Defined Function Manual to see how sources are hooked in fluent. |
||
August 27, 2010, 04:16 |
|
#5 |
New Member
Emily
Join Date: Aug 2010
Posts: 5
Rep Power: 16 |
I have been following the instructions, but when going into the assigning hooks where you assign inital_func etc not all of my functions are there. The heat source appears but the energy source does not.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] GroovyBC the dynamic cousin of funkySetFields that lives on the suburb of the mesh | gschaider | OpenFOAM Community Contributions | 300 | October 29, 2014 19:00 |
Errors running allwmake in OpenFOAM141dev with WM_COMPILE_OPTION%3ddebug | unoder | OpenFOAM Installation | 11 | January 30, 2008 21:30 |
[Netgen] Compiling Netgen on Fedora Core is driving me crazy | jango | OpenFOAM Meshing & Mesh Conversion | 3 | November 9, 2007 14:29 |
DecomposePar links against liblamso0 with OpenMPI | jens_klostermann | OpenFOAM Bugs | 11 | June 28, 2007 18:51 |
user defined function | cfduser | CFX | 0 | April 29, 2006 11:58 |