
[Sponsors] 
October 31, 2015, 03:48 
Source terms for Lorentz force

#1 
New Member
Ganesh K C
Join Date: Oct 2014
Location: Tiruchirappalli, India
Posts: 29
Rep Power: 4 
How to include the Lorentz force equation in Fluent during Melting and solidification.
the equations for x,y and z coordinates are as follows, Fx = ((mu * I^2) / (4*3.14^2 * reff^2 * r)) * (exp (r^2 / (2*reff^2))) * (1(exp (r^2 / (2*reff^2)))) * (1(z/t)^2) * (x/r) Fy = ((mu * I^2) / (4*3.14^2 * reff^2 * r)) * (exp (r^2 / (2*reff^2))) * (1(exp (r^2 / (2*reff^2)))) * (1(z/t)^2) * (y/r) Fz = ((mu*I^2)/(4*3.14*3.14*r^2*c)) * ((1(exp (r^2 / (2*reff^2))))^2) * (1(z/t)) where, mu, I, c are constants. Kindly help to add this equations in Fluent without MHD module. 

November 2, 2015, 16:31 

#2 
Senior Member
Join Date: Mar 2015
Posts: 800
Rep Power: 11 
Have you tried adding these forces as source terms using the DEFINE_SOURCE macro?


November 3, 2015, 00:52 

#3 
New Member
Ganesh K C
Join Date: Oct 2014
Location: Tiruchirappalli, India
Posts: 29
Rep Power: 4 
dear e,
i have trouble with prepare the UDF using this equation. can you show some udf using this equation ? 

November 3, 2015, 04:03 

#4 
Senior Member
Join Date: Mar 2015
Posts: 800
Rep Power: 11 
There are detailed examples in the UDF manual, which part are you stuck on? The constants can be retrieved with macros, for example C_MU_L(c,t) returns the laminar viscosity of the local cell.


November 3, 2015, 04:14 

#5 
New Member
Ganesh K C
Join Date: Oct 2014
Location: Tiruchirappalli, India
Posts: 29
Rep Power: 4 
the thing is i need to include the electromagnetic force in the model without MHD module. so from the reference the lorentz force equations are obtained. now i need to give this equations as momentum source. so is it possible to enter these equations directly using DEFINE_SOURCE or is there any other procedure i should follow ? the final out put will be the electromagnetic force into the model.


November 3, 2015, 04:43 

#6 
Senior Member
Join Date: Mar 2015
Posts: 800
Rep Power: 11 
Have a read of the "Momentum Conservation Equations" section in the theory guide, you'll find that the last term on the right hand side is the modeldependent source term. Use the DEFINE_SOURCE macro for setting this source term in the relevant equations.


November 3, 2015, 05:01 

#7 
New Member
Ganesh K C
Join Date: Oct 2014
Location: Tiruchirappalli, India
Posts: 29
Rep Power: 4 
whether the following UDF is the correct way of representation?
#include "udf.h" #define mu 1.26*(10e6) #define I 160 #define reff 0.008 #define r 0.005 /* Momentum source term in x */ DEFINE_SOURCE(xmom_source,c,t,dS,eqn) { float x[ND_ND], source; face_t f; F_CENTROID (x,f,t); source =((mu*I*I)/(4*3.14*3.14*reff*reff*r)) * (exp (r*r / (2*reff*reff))) * (1(exp (r*r / (2*reff*reff)))) * pow((1(x[1]/t),2) * (x[0]/r); dS[eqn] = 0; return source; } /* Momentum source term in y */ DEFINE_SOURCE(ymom_source,c,t,dS,eqn) { float x[ND_ND], source; face_t f; F_CENTROID (x,f,t); source = ((mu*I*I)/(4*3.14*3.14*reff*reff*r)) * (exp (r*r / (2*reff*reff))) * (1(exp (r*r / (2*reff*reff)))) * pow((1(x[1]/t),2) * (x[1]/r); dS[eqn] = 0; return source; }
__________________
 K.C.Ganesh Research Scholar NIT Trichy India 

November 3, 2015, 15:20 

#8 
Senior Member
Join Date: Mar 2015
Posts: 800
Rep Power: 11 
Yes, that's the general approach. Are you getting similar results to the MHD module? Try a simple case to start with to validate your code.
Is your viscosity 12.6e6 or 1.26e6? It'd be clearer to have the single value instead of multiplying by 10e6. 

November 12, 2015, 03:18 

#9 
New Member
Ganesh K C
Join Date: Oct 2014
Location: Tiruchirappalli, India
Posts: 29
Rep Power: 4 
i have prepared the UDF of Lorentz for as source term for 3D. while compiling in fluent uing define / userdefine function / interpreted, option, am getting the following error: line 14: invalid type for binary expression: float / pointer to structure.
what does this error mean and how to overcome this ? the UDF is given as follows, #include "udf.h" #define mu 0.00000126 #define I 160 #define reff 0.008 #define r 0.005 /* Momentum source term in x */ DEFINE_SOURCE(xmom_source,c,t,dS,eqn) { float x[ND_ND], source; face_t f; F_CENTROID (x,f,t); source =((mu*I*I)/(4*3.14*3.14*reff*reff*r)) * (exp (r*r / (2*reff*reff))) * (1(exp (r*r / (2*reff*reff)))) * pow((1(x[1]/t),2) * (x[0]/r); dS[eqn] = 0; return source; } /* Momentum source term in y */ DEFINE_SOURCE(ymom_source,c,t,dS,eqn) { float x[ND_ND], source; face_t f; F_CENTROID (x,f,t); source =((mu*I*I)/(4*3.14*3.14*reff*reff*r)) * (exp (r*r / (2*reff*reff))) * (1(exp (r*r / (2*reff*reff)))) * pow((1(x[1]/t),2) * (x[1]/r); dS[eqn] = 0; return source; } /* Momentum source term in z */ DEFINE_SOURCE(zmom_source,c,t,dS,eqn) { float x[ND_ND], source; face_t f; F_CENTROID (x,f,t); source = ((mu*I*I)/(4*3.14*3.14*r*r)) * pow((1(exp (r*r / (2*reff*reff)))),2) * (1(x[2]/t)); dS[eqn] = 0; return source; }
__________________
 K.C.Ganesh Research Scholar NIT Trichy India 

November 12, 2015, 04:57 

#10 
Senior Member
Join Date: Mar 2015
Posts: 800
Rep Power: 11 
Line 14 corresponds to "F_CENTROID (x,f,t);". It's possible this face centroid data is only available for UDFs that are compiled. It's probably good practice to compile all UDFs because some macros require compilation. The UDF manual also notes that this macro is only available for the pressurebased solver.


November 13, 2015, 02:11 

#11 
New Member
Ganesh K C
Join Date: Oct 2014
Location: Tiruchirappalli, India
Posts: 29
Rep Power: 4 
dear sir,
i am using pressure based solver solver for the 'melting and solidification' model. should it be compiled using external ccompiler? but i could successfully use 'DEFINE_PROFILE' macro in UDF that consists of F_CENTROID. fluent could interpret that UDF. the following UDF is working without Lorentz force equations, #include "udf.h" DEFINE_PROFILE(Gauss,t,i) { real x[ND_ND], c[ND_ND]; face_t f; real r; r = 0.005; begin_f_loop(f, t) { F_CENTROID (x,f,t); F_PROFILE (f,t,i) = (3*(100*10*0.7/0.001) / (3.14*pow(r,2))) * exp (3*(x[0]*x[0])/ pow(r,2)); } end_f_loop(f,t) } how can i include the lorentz force equations in the UDF now?
__________________
 K.C.Ganesh Research Scholar NIT Trichy India 

November 19, 2015, 01:06 

#12 
New Member
Ganesh K C
Join Date: Oct 2014
Location: Tiruchirappalli, India
Posts: 29
Rep Power: 4 
i still have same problem. can any one help me out in this ?
__________________
 K.C.Ganesh Research Scholar NIT Trichy India 

January 20, 2016, 10:26 

#13 
New Member
Ganesh K C
Join Date: Oct 2014
Location: Tiruchirappalli, India
Posts: 29
Rep Power: 4 
how to compile a UDF and bring into fluent ? i need to bring the previously mentioned equations to the model
__________________
 K.C.Ganesh Research Scholar NIT Trichy India 

January 20, 2016, 17:00 

#14 
Senior Member
Join Date: Mar 2015
Posts: 800
Rep Power: 11 
You'll need a compiler to compile the UDFs for Fluent. In Windows you could use Microsoft Visual Studio Express for Desktop (ensure the compiler is compatible with the Fluent version). There are a few comments in the FAQ on this website to get you started.


Tags 
fluent  udf, lorentz force, welding 
Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
groovyBC in openFOAM2.0 for parabolic velocity bc  ofslcm  OpenFOAM PreProcessing  25  March 6, 2017 11:03 
Patches to compile OpenFOAM 2.2 on Mac OS X  gschaider  OpenFOAM Installation on Windows, Mac and other Unsupported Platforms  134  December 5, 2015 04:30 
swak4foam building problem  GGerber  OpenFOAM Installation  54  April 24, 2015 16:02 
Compressor Simulation using rhoPimpleDyMFoam  Jetfire  OpenFOAM Running, Solving & CFD  107  December 9, 2014 14:38 
pisoFoam compiling error with OF 1.7.1 on MAC OSX  Greg Givogue  OpenFOAM Programming & Development  3  March 4, 2011 18:18 