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

Any help greatly appreciated - Erosion

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 7, 2016, 12:03
Default Any help greatly appreciated - Erosion
  #1
New Member
 
Taz Hussain
Join Date: Feb 2016
Posts: 8
Rep Power: 10
Taz-CFD is on a distinguished road
Hello fellow CFD compatriots. I am trying to model erosion within Fluent using the DNV erosion model. I am pretty new to UDF's but have managed to come up with the the following. Can someone please look at it and let me know if looks okay?

The equations I am basing it on are on page 11 on http://brage.bibsys.no/xmlui/bitstre...=1&isAllowed=y

Heres my code:

#include "udf.h"
#include "math.h"
const float PI =3.141593;
float A1 =9.37
float A2 =-42.295;
float A3 =110.864;
float A4 =-175.804;
float A5 =170.137;
float A6 =-98.398;
float A7 =31.211;
float A8 =-4.172;
float K= 2.0e-9; /* material constant /*
float pt=7800; /* density of steel/*
float at=0.0005; /* target area /*

DEFINE_DPM_EROSION(DNVV, p, t, f, normal, alpha, Vmag, mdot)
{
real erosion;
real a=alpha;
real v=Vmag;
real F_alpha;
real m=mdot;
real V;
real F;
V=pow(v,2.6);
F=A1*pow(((a*PI)/180),1)+A2*pow(((a*PI)/180),2)+A3*pow(((a*PI)/180),3)+A4*pow(((a*PI)/180),4)+ A5*pow(((a*PI)/180),5)+A6*pow(((a*PI)/180),6)+A7*pow(((a*PI)/180),7)+A8*pow(((a*PI)/180),8);
erosion=(m*K*V*F)/(pt*at)
F_STORAGE_R(f,t,SV_DPMS_EROSION)=erosion;
}

Looking forward to your replies! Here's my email if you'd prefer to email me on there: taz_78684@hotmail.co.uk

Kindest regards,
Taz
Taz-CFD is offline   Reply With Quote

Old   March 7, 2016, 12:33
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
An important test to see if you made mistakes is to just compile it. If you get errors, you did something wrong. (If you don't get errors, it does not mean you did not make mistakes!)
The code you showed above has some mistakes that the compiler would have seen immediately, so it looks like you did not even try your code!

I can see at least two things wrong in the code.

Your comments in the code are wrong:
Code:
float K= 2.0e-9; /* material constant /*
should be
Code:
float K= 2.0e-9; /* material constant */
Also you forgot a semicolon ( ; ) after the following:
Code:
erosion=(m*K*V*F)/(pt*at)
pakk is offline   Reply With Quote

Old   March 8, 2016, 06:42
Default
  #3
New Member
 
Taz Hussain
Join Date: Feb 2016
Posts: 8
Rep Power: 10
Taz-CFD is on a distinguished road
Quote:
Originally Posted by pakk View Post
An important test to see if you made mistakes is to just compile it. If you get errors, you did something wrong. (If you don't get errors, it does not mean you did not make mistakes!)
The code you showed above has some mistakes that the compiler would have seen immediately, so it looks like you did not even try your code!

I can see at least two things wrong in the code.

Your comments in the code are wrong:
Code:
float K= 2.0e-9; /* material constant /*
should be
Code:
float K= 2.0e-9; /* material constant */
Also you forgot a semicolon ( ; ) after the following:
Code:
erosion=(m*K*V*F)/(pt*at)
Hi there pakk, thank you for your reply! i have made the following changes:

#include "udf.h"
#include "math.h"
#define PI =3.141593
float A1 =9.37;
float A2 =-42.295;
float A3 =110.864;
float A4 =-175.804;
float A5 =170.137;
float A6 =-98.398;
float A7 =31.211;
float A8 =-4.172;
float K= 2.0e-9; /* material Constant */
float pt=7800; /* density of steel */


DEFINE_DPM_EROSION(DNVV, p, t, f, normal, alpha, Vmag, mdot)
{
real erosion;
real a=alpha;
real v=Vmag;
real F_alpha;
real m=mdot;
real V;
real at;
at=(PI*pow(0.026,2))/4.*sin(a); /* area exposed to erosion */
V=pow(v,2.6); /* impact velocity of particle raised to constant n */
F_alpha=A1*pow(((a*PI)/180),1)+A2*pow(((a*PI)/180),2)+A3*pow(((a*PI)/180),3)+A4*pow(((a*PI)/180),4)+ A5*pow(((a*PI)/180),5)+A6*pow(((a*PI)/180),6)+A7*pow(((a*PI)/180),7)+A8*pow(((a*PI)/180),8);
erosion=(m*K*V*F)/(pt*at);
F_STORAGE_R(f,t,SV_DPMS_EROSION)=erosion;
}

But now I get an error referring to this line - at=(PI*pow(0.026,2))/4.*sin(a); /* area exposed to erosion */

It says invalid type for pointer deference: double

Thank you once again for your help,
Regards

Taz
Taz-CFD is offline   Reply With Quote

Old   March 9, 2016, 07:49
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Two relevant lines:

Code:
#define PI =3.141593
...
at=(PI*pow(0.026,2))/4.*sin(a);
The define line means: everywhere where is written "PI", act as if it says "=3.141593".
Let's do that:

Code:
at=(=3.141593*pow(0.026,2))/4.*sin(a);
This does not make sense, and I can imagine that Fluent has some problems with this line. I don't know how this leads to the error message you saw, but I am no compiler...

One solution: remove the "=" from your definition:
Code:
#define PI 3.141593
A different solution, better in my view: don't define your own pi, but use M_PI that is already defined by Fluent:
Code:
at=(M_PI*pow(0.026,2))/4.*sin(a);
By the way: are you sure you don't miss any brackets in this expression? I don't want to dive into your model, but I am worried it should be this:

Code:
at=(M_PI*pow(0.026,2))/(4.*sin(a));
pakk is offline   Reply With Quote

Old   March 9, 2016, 07:59
Default
  #5
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
While I am at it: I would simplify your code...
Why do add a variable a that is the same as alpha? Why v the same as Vmag? Why m the same as mdot?

And you use "(a*PI)/180" a lot in your code. Make that a variable!
But I think it is even wrong to use this... Angle a is already in radians, but it looks like you think a is in degrees and you still have to do the conversion...

Thirdly: you use "F" in your erosion calculation, but that is never defined. And you define F_alpha, but you never use it. I guess they refer to the same thing...

Altogether:


Code:
DEFINE_DPM_EROSION(DNVV, p, t, f, normal, a, v, m) 
{
real V = pow(v,2.6); /* impact velocity of particle raised to constant n */;
real at = (PI*pow(0.026,2))/4.*sin(a) /* area exposed to erosion */
real F_alpha=A1*pow(a,1)+A2*pow(a,2)+A3*pow(a,3)+A4*pow(a,4)+ A5*pow(a,5)+A6*pow(a,6)+A7*pow(a,7)+A8*pow(a,8);

F_STORAGE_R(f,t,SV_DPMS_EROSION)=(m*K*V*F_alpha)/(pt*at);;
}
pakk is offline   Reply With Quote

Old   March 9, 2016, 18:51
Default
  #6
New Member
 
Taz Hussain
Join Date: Feb 2016
Posts: 8
Rep Power: 10
Taz-CFD is on a distinguished road
Quote:
Originally Posted by pakk View Post
While I am at it: I would simplify your code...
Why do add a variable a that is the same as alpha? Why v the same as Vmag? Why m the same as mdot?

And you use "(a*PI)/180" a lot in your code. Make that a variable!
But I think it is even wrong to use this... Angle a is already in radians, but it looks like you think a is in degrees and you still have to do the conversion...

Thirdly: you use "F" in your erosion calculation, but that is never defined. And you define F_alpha, but you never use it. I guess they refer to the same thing...

Altogether:


Code:
DEFINE_DPM_EROSION(DNVV, p, t, f, normal, a, v, m) 
{
real V = pow(v,2.6); /* impact velocity of particle raised to constant n */;
real at = (PI*pow(0.026,2))/4.*sin(a) /* area exposed to erosion */
real F_alpha=A1*pow(a,1)+A2*pow(a,2)+A3*pow(a,3)+A4*pow(a,4)+ A5*pow(a,5)+A6*pow(a,6)+A7*pow(a,7)+A8*pow(a,8);

F_STORAGE_R(f,t,SV_DPMS_EROSION)=(m*K*V*F_alpha)/(pt*at);;
}
Hi there pakk

Thank you so much for your reply! I really appreciate it. I will implement these changes now and let you know how I get on. Once again thank you so much!

Kind regards
Taz
Taz-CFD is offline   Reply With Quote

Old   June 12, 2016, 16:33
Post
  #7
Member
 
Join Date: Jun 2011
Posts: 86
Rep Power: 15
mali28 is on a distinguished road
Just a minor correction. It should be:

F_STORAGE_R(f,t,SV_DPMS_EROSION)+=(m*K*V*F_alpha)/(pt*at);

You have to remove the density of the wall from the denominator in the above equation if you want the unit to be the same as reported in
Fluent.
mali28 is offline   Reply With Quote

Old   June 20, 2018, 13:12
Default Did you get it?
  #8
New Member
 
Edilberto
Join Date: Jun 2018
Posts: 8
Rep Power: 8
edilbertolg is on a distinguished road
Hi, I was wondering if you could get the correct coding for DNV erosion prediciton... I am trying to use your code but I get errors
edilbertolg is offline   Reply With Quote

Old   June 21, 2018, 05:09
Post Double
  #9
New Member
 
ASA
Join Date: Mar 2017
Location: USA
Posts: 6
Rep Power: 9
haghasa is on a distinguished road
One more thing to consider is the data structure in C

its a better practice to always stick to "real" format, both for double (~ for double precision) and float (single precision) datatypes

For example:
change
float A1 =9.37;
to
real A1 = 9.37;

and try to define your constant numbers in the same format too...

change
pow(0.026,2)
to
pow(0.026,2.)

pay attention to the difference between 2 and 2. (=2.0)
haghasa is offline   Reply With Quote

Old   May 16, 2019, 11:56
Default
  #10
New Member
 
James Thor
Join Date: May 2019
Posts: 13
Rep Power: 7
Ya Hong is on a distinguished road
Quote:
Originally Posted by edilbertolg View Post
Hi, I was wondering if you could get the correct coding for DNV erosion prediciton... I am trying to use your code but I get errors
Do you already know the correct program, can you tell me? I really need it right now.
Ya Hong is offline   Reply With Quote

Old   May 16, 2019, 12:02
Default
  #11
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
What is not correct about the code that is given above? If you really need it now, then try it. If you get errors, share them.
pakk is offline   Reply With Quote

Reply

Tags
dnv, dpm, erosion, fluent, udf

Thread Tools Search this Thread
Search this Thread:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Erosion Models Owen_V Main CFD Forum 0 March 26, 2015 20:17
FLUENT Erosion DPM (Methane with Sand) - Strange Erosion Contours chongjqw FLUENT 3 February 22, 2015 22:17
FLUENT Erosion DPM - Strange Erosion Contours chongjqw FLUENT 0 February 7, 2014 03:43
DPM - Erosion model pipin FLUENT 2 November 18, 2013 06:02
Erosion problem Ko Siemens 2 September 24, 2003 08:48


All times are GMT -4. The time now is 23:57.