|
[Sponsors] |
September 22, 2007, 19:14 |
ACCESS VIOLATION
|
#1 |
Guest
Posts: n/a
|
Greetings all,
I am trying to apply an external magnetic field into my system by using the concept of magnetic nozzle. I solved the magnetic field equation for a single helholtz coil and simply used superposition principle to add up the magnetic field contribution from all helmholtz coil. Now I was able to interpret the code into FLUENT, but when I try to hook the code through EXECUTE_ON_DEMAND, FLUENT returns an error message saying, "ACCESS VIOLATION' Would anyone know how to overcome this problem? I also get the same error message when I try to solve the magnetic induction equation... but here's the code only for the generation of external magnetic field. #include "udf.h" #include "sg.h" #include "mem.h" #define EX 0 /*Strenght of imposed Electric field in X direction*/ #define EY 0 /*Strenght of imposed Electric field in Y direction*/ #define EZ 0 /*Strenght of imposed Electric field in Z direction*/ #define sigma_e 800 /*conductivity of midium in mho/m*/ #define Ckn 0.5 /*Closure coefficient in Interaction term for k equation*/ #define Cen 1.0 /*Closure coefficient in Interaction term for epsilon equation*/ #define Lmag 0.005 /*Length Scale for Magnetic term in turbulent dissipation*/ #define permeability 1.2566371*pow(10,-6) /*Permeability of vacuum or air in N/A^2*/ #define I 1000.0/*Current around the helmholtz coil at throat in Amp*/ #define rt 0.25/*Radius of Throat of magnetic nozzle in meters*/ #define ri 0.5/*Radius of magnetic nozzle inlet in meters*/ #define ro 0.5/*Radius of magnetic nozzle outlet in meters*/ #define lsys 5/*Total length of the system i.e. length from inlet to outlet in meters*/ #define nc 50/*Number of coils that will be used to simulate the magnetic nozzle */ #define cp -1/*Nozzle convergence point in meters note: it will simply be used to form the nozzle mathematically */ #define dp +1/*Nozzle divergence point in meters note: it will simply be used to form the nozzle matehmatically */ #define czp 0/*Zero point of the converging in meters note: again, for mathematical modeling purpose*/ #define dzp 0/*Zero point of the divergering in meters note: again for mathematical modeling purpose*/ #define tzp 0.5/*Zero point of the thorat in meters note: again for mathematical modeling purpose*/ #define nix -2.5 /*inlet location from center of axis in meters */ #define ntx 0 /*throat location from center of axis in meters */ #define nox 2.5 /*outlet location from center of axis in meters */ DEFINE_ON_DEMAND(Define_B_Field) { int i, r[nc], x[nc]; /*r[nc]=Radius of helmholtz coil at x distance away from axis, x[nc]= x distance of center of each coil from the axis */ real dx, magconstr, magconstt, theta, phi; real ci, ct, co; Domain *d; Thread *t; cell_t c; d= Get_Domain(1); ci = ri*ri/fabs(nix); /*Constant to generate the equation of line for parabola of converging section */ co = ro*ro/fabs(nox); /*Constant to generate the equation of line for parabola of diverging section */ ct = (pow(ci*nix,0.5)-rt)/(nix*nix); /*constant to generate the equation of line for upwar parabola of thorat section */ magconstr = permeability*I/2; /*Constants known for the calculation of magfield for radial component*/ magconstt = permeability*I/4; /*constants known for the calculation of magfield for longitudinal component*/ dx=lsys/nc; /*increment between rings in meters */ for ( i = 1 ; i <= nc; i++ ) { x[i]= -lsys/2 + (i-1)*dx; if (x[i] < cp) /*if x position is before the converging point*/ { r[i] = pow(ci*fabs(x[i]),0.5); } else if (x[i] > cp & x[i] < dp) /*if x position is past converging point but behind diverging point */ { r[i]=ct*x[i]*x[i]+tzp; } else if (x[i] > dp) /* if x position is past diverging point */ { r[i] = pow(co*fabs(x[i]),0.5); } } /*Now calculating magnetic field @ each cell centroid*/ thread_loop_c(t,d) /*Loop overall cell threads in the domain*/ { begin_c_loop(c,t) /*Begin looping over all cells in the thread of domain. yeyah it's 9/21/07 2:20 AM I'm wired*/ { real px, p; C_CENTROID(x,c,t); px=x[0]-x[i]; /*x-coordinate of the cell centroid with respect to the current ring center*/ p=pow(px*px + x[1]*x[1] + x[2]*x[2],0.5); /*Position vector magnitude of cell center from center of Helmholz coil*/ theta=atan2((pow(px*px+x[1]*x[1],0.5)),x[2]);/*Longitudinal angle from z-axis*/ phi = atan2(x[1],x[2]); /*Azimuthal angle in the xy-plane with respect to z-axis*/ C_UDMI(c,t,0)=0.0; /*x-component of applied magnetic field*/ C_UDMI(c,t,1)=0.0; /*y-component of applied magnetic field*/ C_UDMI(c,t,2)=0.0; /*z-component of applied magnetic field*/ for (i;i<=nc;i++) { C_UDMI(c,t,0) +=magconstr*r[i]*r[i]*cos(theta)*sin(theta)*cos(phi)* (1+(15*r[i]*r[i]*p*p*r[i]*r[i]*sin(theta)*sin(theta))/ (4*pow(r[i]*r[i]+p*p,2)))/((pow(r[i]*r[i]+p*p,3/2))) -magconstt*sin(theta)*cos(theta)*cos(phi)* (2*r[i]*r[i] - p*p +(15*r[i]*r[i]*p*p*sin(theta)*sin(theta)* (4*r[i]*r[i] - 3*p*p)/(8*pow(r[i]*r[i] + p*p,2))))/ (pow(r[i]*r[i] + p*p,5/2)); /*x-component of magnetic field for each helmholtz coil*/ C_UDMI(c,t,1) +=magconstr*r[i]*r[i]*cos(theta)*sin(theta)*sin(phi)* (1+(15*r[i]*r[i]*p*p*r[i]*r[i]*sin(theta)*sin(theta))/ (4*pow(r[i]*r[i]+p*p,2)))/((pow(r[i]*r[i]+p*p,3/2))) -magconstt*sin(theta)*cos(theta)*sin(phi)* (2*r[i]*r[i] - p*p +(15*r[i]*r[i]*p*p*sin(theta)*sin(theta)* (4*r[i]*r[i] - 3*p*p)/(8*pow(r[i]*r[i] + p*p,2))))/ (pow(r[i]*r[i] + p*p,5/2)); /*y-component of magnetic field for each helmholtz coil*/ C_UDMI(c,t,2) +=magconstr*r[i]*r[i]*cos(theta)*cos(theta)* (1+(15*r[i]*r[i]*p*p*r[i]*r[i]*sin(theta)*sin(theta))/ (4*pow(r[i]*r[i]+p*p,2)))/((pow(r[i]*r[i]+p*p,3/2))) +magconstt*sin(theta)*sin(theta)* (2*r[i]*r[i] - p*p +(15*r[i]*r[i]*p*p*sin(theta)*sin(theta)* (4*r[i]*r[i] - 3*p*p)/(8*pow(r[i]*r[i] + p*p,2))))/ (pow(r[i]*r[i] + p*p,5/2)); /*z-component of magnetic field for each helmholtz coil*/ } } end_c_loop(c,t) } } It's a bit messy, but thank you for whomever that read through my code and spent their time figuring out the possible problem. I'm thinking that if I know what the problem is in this, I could figure out how to fix my induction code as well. -Will |
|
September 23, 2007, 02:51 |
Re: ACCESS VIOLATION
|
#2 |
Guest
Posts: n/a
|
Dear all,
I've figured my problem. I didn't define the number of user memory before I hooked it. Thank you if you were taking a look at my code anyways Will |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
specified shear at wall - temperature gradient - UDF - access violation error | senD | Fluent UDF and Scheme Programming | 9 | September 18, 2014 07:29 |
UDF Access violation | therandomestname | FLUENT | 0 | April 15, 2011 17:31 |
Access violation - Help please | AlwaysLearning | FLUENT | 3 | August 22, 2006 12:21 |
ACCESS VIOLATION error opening a .dat file | DavidSF | FLUENT | 12 | April 8, 2005 15:37 |
Interface Access Violation | Newbie Fluent User | FLUENT | 1 | July 25, 2003 13:45 |