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

udf of MHD body force

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 24, 2022, 18:24
Default udf of MHD body force
  #1
Member
 
sofia
Join Date: Apr 2010
Location: world
Posts: 31
Rep Power: 16
sofie1 is on a distinguished road
Hi ,
I am trying to simulate mhd flow in horizontal pipe with udf to calculate mhd body force , bf=(sigma/rho)*B*u

B is the magnetic induction,u is the velocity
so i write an udf but there is an error.
Does some body know this error


thanck you very much
Attached Files
File Type: txt body force.txt (518 Bytes, 50 views)
sofie1 is offline   Reply With Quote

Old   December 24, 2022, 18:27
Default MHD body force
  #2
Member
 
sofia
Join Date: Apr 2010
Location: world
Posts: 31
Rep Power: 16
sofie1 is on a distinguished road
Quote:
Originally Posted by sofie1 View Post
Hi ,
I am trying to simulate mhd flow in horizontal pipe with udf to calculate mhd body force , bf=(sigma/rho)*B*u

B is the magnetic induction,u is the velocity
so i write an udf but there is an error.
Does some body know this error


thanck you very much
************************************************** *******************


Magnetic Bodyforce calculation
************************************************** ********************/
#include "udf.h"


#define B_0 10. /* y component of magnetic field */
#define SIG 5.5E-6 /*electrical conductivity*/
#define rho 1239.1244

DEFINE_MAGNETIC-BODYFORCE(Cell_bforce, cell,thread)
{
real bforce,rho,veloc u;

veloc u=C-U(cell,thread);

bforce = -(SIG/rho)*B-0*B-0*veloc u;

return bforce;
}
sofie1 is offline   Reply With Quote

Old   December 26, 2022, 05:01
Default
  #3
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
fluent is using build in macros to execute with user's code
for your case you probably wanna go with DEFINE_SOURCE macro

Code:
#include "udf.h"

real B_0=10.0; /* y component of magnetic field*/
real SIG=5.5E-6; /*electrical conductivity*/
real rho=1239.1244;

DEFINE_SOURCE(Cell_bforce, cell, thread, dS, eqn)
{
	real source;
	real rho;
	real veloc_u;
	veloc_u = C_U(cell,thread);
	source = -(SIG/rho)*B_0*B_0*veloc_u;
	dS[eqn] = -(SIG/rho)*B_0*B_0;

	return source;
}
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   December 28, 2022, 17:30
Default
  #4
Member
 
sofia
Join Date: Apr 2010
Location: world
Posts: 31
Rep Power: 16
sofie1 is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
fluent is using build in macros to execute with user's code
for your case you probably wanna go with DEFINE_SOURCE macro

Code:
#include "udf.h"

real B_0=10.0; /* y component of magnetic field*/
real SIG=5.5E-6; /*electrical conductivity*/
real rho=1239.1244;

DEFINE_SOURCE(Cell_bforce, cell, thread, dS, eqn)
{
	real source;
	real rho;
	real veloc_u;
	veloc_u = C_U(cell,thread);
	source = -(SIG/rho)*B_0*B_0*veloc_u;
	dS[eqn] = -(SIG/rho)*B_0*B_0;

	return source;
}
Thank you very much AlexanderZ

The udf works well, but inserting it in another udf it doesn't work, please i need help;
/************************************************** *******************

Calculation of the properties of Fe3O4 nanoparticles
************************************************** ********************/
#include "udf.h"


#define FI 0.05
#define RHO_np 1398.194
#define SI_1 0.9830
#define SI_2 12.959
#define KTC_np 7
#define TI 5.E4
#define BETA_1 8.4407
#define BETA_2 -1.07304
#define CP_w 4181.8
#define KA 1.383E-23
#define SIi_1 2.8217E-2
#define SIi_2 3.917E-3
#define SIi_3 -3.0669E-2
#define SIi_4 -3.91123E-3
#define T_0 298.15
#define D_np 59.E-9
#define CP_np 640.0
#define B_0 10.0; /* y component of magnetic field */
#define SIG 5.5E-6; /*electrical conductivity*/
DEFINE_PROPERTY(cell_conductivity,cell,thread)
{
real ktc,ktc_w,temp,f,beta,rho_w;
temp = C_T(cell,thread);
f = ((SIi_1*FI+SIi_2*temp)/T_0)+(SIi_3*FI+SIi_4);
beta = BETA_1*(pow(100*FI,BETA_2));
rho_w = (-3.570*(pow(10,-3))*(pow(temp,2))+(1.88*temp+753.2));
ktc_w = (-8.354*0.000001*(pow(temp,2)))+((6.53*0.001*temp)-0.5981);
ktc = ((KTC_np+(2*ktc_w)-2*(ktc_w-KTC_np)*FI)/(KTC_np+(2*ktc_w)+(ktc_w-KTC_np)*FI))+(TI*beta*FI*rho_w*CP_w*(pow(((KA*temp )/(RHO_np*D_np)),0.5))*f);
return ktc;
}

DEFINE_PROPERTY(cell_density,cell,thread)
{
real temp,rho_w,rho;
temp = C_T(cell,thread);
rho_w = (-3.570*(pow(10,-3))*(pow(temp,2))+(1.88*temp+753.2));
rho = (FI*RHO_np)+((1-FI)*rho_w);
return rho;
}

DEFINE_PROPERTY(cell_viscosity,cell,thread)
{
real mu,mu_w,temp;
temp = C_T(cell,thread);
mu_w = (2.591*(pow(10,-5))*(pow(10,(238.3/(temp-143.2)))));
mu = (SI_1*exp(SI_2*FI)*mu_w);
return mu;
}

DEFINE_SOURCE(Cell_bforce, cell, thread, dS, eqn)
{
real source,rho_w,temp,veloc_u;


temp = C_T(cell,thread);
rho_w = (-3.570*(pow(10,-3))*(pow(temp,2))+(1.88*temp+753.2));

veloc_u = C_U(cell,thread);
source = -(SIG/rho_w)*B_0*B_0*veloc_u;
dS[eqn] = -(SIG/rho_w)*B_0*B_0;

return source;
}
sofie1 is offline   Reply With Quote

Old   December 28, 2022, 19:03
Default
  #5
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
was
Code:
#define B_0 10.0; /* y component of magnetic field */
#define SIG 5.5E-6; /*electrical conductivity*/
to be
Code:
#define B_0 10.0
#define SIG 5.5E-6
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   December 29, 2022, 17:54
Default udf of MHD body force
  #6
Member
 
sofia
Join Date: Apr 2010
Location: world
Posts: 31
Rep Power: 16
sofie1 is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
was
Code:
#define B_0 10.0; /* y component of magnetic field */
#define SIG 5.5E-6; /*electrical conductivity*/
to be
Code:
#define B_0 10.0
#define SIG 5.5E-6
Thank you very much but the error persists
sofie1 is offline   Reply With Quote

Old   December 29, 2022, 18:03
Thumbs up udf of MHD body force
  #7
Member
 
sofia
Join Date: Apr 2010
Location: world
Posts: 31
Rep Power: 16
sofie1 is on a distinguished road
Attachment 92827Attachment 92827
Quote:
Originally Posted by AlexanderZ View Post
was
Code:
#define B_0 10.0; /* y component of magnetic field */
#define SIG 5.5E-6; /*electrical conductivity*/
to be
Code:
#define B_0 10.0
#define SIG 5.5E-6
Thanck you very much it run finally
sofie1 is offline   Reply With Quote

Reply


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Drag Force Ratio for Flat Plate Rob Wilk Main CFD Forum 40 May 10, 2020 05:47
Finding Drag Force from Skin Friction Rob Wilk Main CFD Forum 0 May 8, 2020 07:04
Force on moving body joechorn Fluent UDF and Scheme Programming 5 April 2, 2015 12:25
UDF for body force for rotating cavity with natural convection s.jaiswal FLUENT 0 February 18, 2014 03:01
Help: UDF of "particle body force" !!! zhaoh FLUENT 3 January 16, 2007 21:17


All times are GMT -4. The time now is 14:51.