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

Source terms for Lorentz force

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   October 31, 2015, 03:48
Exclamation Source terms for Lorentz force
  #1
New Member
 
Ganesh K C
Join Date: Oct 2014
Location: Tiruchirappalli, India
Posts: 24
Rep Power: 3
kcgmech is on a distinguished road
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.
kcgmech is offline   Reply With Quote

Old   November 2, 2015, 16:31
Default
  #2
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 560
Rep Power: 6
`e` is on a distinguished road
Have you tried adding these forces as source terms using the DEFINE_SOURCE macro?
`e` is offline   Reply With Quote

Old   November 3, 2015, 00:52
Default
  #3
New Member
 
Ganesh K C
Join Date: Oct 2014
Location: Tiruchirappalli, India
Posts: 24
Rep Power: 3
kcgmech is on a distinguished road
dear e,
i have trouble with prepare the UDF using this equation. can you show some udf using this equation ?
kcgmech is offline   Reply With Quote

Old   November 3, 2015, 04:03
Default
  #4
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 560
Rep Power: 6
`e` is on a distinguished road
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.
`e` is offline   Reply With Quote

Old   November 3, 2015, 04:14
Default
  #5
New Member
 
Ganesh K C
Join Date: Oct 2014
Location: Tiruchirappalli, India
Posts: 24
Rep Power: 3
kcgmech is on a distinguished road
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.
kcgmech is offline   Reply With Quote

Old   November 3, 2015, 04:43
Default
  #6
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 560
Rep Power: 6
`e` is on a distinguished road
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 model-dependent source term. Use the DEFINE_SOURCE macro for setting this source term in the relevant equations.
`e` is offline   Reply With Quote

Old   November 3, 2015, 05:01
Default
  #7
New Member
 
Ganesh K C
Join Date: Oct 2014
Location: Tiruchirappalli, India
Posts: 24
Rep Power: 3
kcgmech is on a distinguished road
whether the following UDF is the correct way of representation?

#include "udf.h"
#define mu 1.26*(10e-6)
#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
kcgmech is offline   Reply With Quote

Old   November 3, 2015, 15:20
Default
  #8
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 560
Rep Power: 6
`e` is on a distinguished road
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.6e-6 or 1.26e-6? It'd be clearer to have the single value instead of multiplying by 10e-6.
`e` is offline   Reply With Quote

Old   November 12, 2015, 03:18
Default
  #9
New Member
 
Ganesh K C
Join Date: Oct 2014
Location: Tiruchirappalli, India
Posts: 24
Rep Power: 3
kcgmech is on a distinguished road
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
kcgmech is offline   Reply With Quote

Old   November 12, 2015, 04:57
Default
  #10
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 560
Rep Power: 6
`e` is on a distinguished road
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 pressure-based solver.
`e` is offline   Reply With Quote

Old   November 13, 2015, 02:11
Default
  #11
New Member
 
Ganesh K C
Join Date: Oct 2014
Location: Tiruchirappalli, India
Posts: 24
Rep Power: 3
kcgmech is on a distinguished road
dear sir,
i am using pressure based solver solver for the 'melting and solidification' model. should it be compiled using external c-compiler? 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
kcgmech is offline   Reply With Quote

Old   November 19, 2015, 01:06
Default
  #12
New Member
 
Ganesh K C
Join Date: Oct 2014
Location: Tiruchirappalli, India
Posts: 24
Rep Power: 3
kcgmech is on a distinguished road
i still have same problem. can any one help me out in this ?
__________________
--
K.C.Ganesh
Research Scholar
NIT Trichy
India
kcgmech is offline   Reply With Quote

Old   January 20, 2016, 10:26
Default
  #13
New Member
 
Ganesh K C
Join Date: Oct 2014
Location: Tiruchirappalli, India
Posts: 24
Rep Power: 3
kcgmech is on a distinguished road
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
kcgmech is offline   Reply With Quote

Old   January 20, 2016, 17:00
Default
  #14
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 560
Rep Power: 6
`e` is on a distinguished road
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.
`e` is offline   Reply With Quote

Reply

Tags
fluent - udf, lorentz force, welding

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
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
groovyBC in openFOAM-2.0 for parabolic velocity bc ofslcm OpenFOAM Pre-Processing 24 August 23, 2015 22:41
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


All times are GMT -4. The time now is 00:33.