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

Solidification and melting

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 15, 2017, 06:58
Default Solidification and melting
  #1
New Member
 
up
Join Date: Oct 2015
Posts: 10
Rep Power: 11
abhi12019 is on a distinguished road
Hello,

I am soliving a phase change problem for Al-Cu system where I am caculting the mixture heat capacity and mixture thermal conductivity from udf. I am also changing the liquid fraction through a source term. When I initialize the soluton I am getting error like : fatal signal(segmentation fault)

my UDF :
#include "udf.h"
#define cs 900
#define cl 1100
#define ks 200
#define kl 90
#define TL 919
#define TE 821
#define rho 2800
#define L 390000

DEFINE_PROPERTY(Heatcapacity_cp, c,t)
{

real sh;
Domain *d;
Thread *t1;
cell_t c1;
thread_loop_c(c,d)
{
begin_c_loop(c,t){
sh = cs*(1-C_LIQF(c,t))+cl*C_LIQF(c,t);

}
end_c_loop(c,t)
}
return sh;
}
DEFINE_PROPERTY(ThermalConductivity_k,c,t)
{

real k;
Domain *d;
/*Thread *t;
cell_t c;*/
thread_loop_c(c,d)
{
begin_c_loop(c,t){
k = ks*(1-C_LIQF(c,t))+kl*C_LIQF(c,t);

}
end_c_loop(c,t)
}
return k;
}
DEFINE_SOURCE(solidfication_source, c, t, dS, eqn){
real s, sp, sc, k, deltaH;
/*cell_t c;
Thread *t;*/
Domain *d;
thread_loop_c(c,d)
{
deltaH = rho*(cl-cs)*C_T(c,t)+rho*L;
k = (C_VOLUME(c,t)*deltaH)/(TL-TE);
begin_c_loop(c,t)
{
sc = k*(2*C_LIQF(c,t)-0.4*TL+0.2*TE-0.8*C_T(c,t));
sp = (0.8*deltaH*C_VOLUME(c,t)) / (TE-TL);
s = sc + sp*C_T(c,t);
}
end_c_loop(c,t)
dS[eqn] = 0;
}
return s;
}
abhi12019 is offline   Reply With Quote

Old   February 15, 2017, 08:25
Default
  #2
Senior Member
 
Kevin
Join Date: Dec 2016
Posts: 138
Rep Power: 10
KevinZ09 is on a distinguished road
No need to loop over cell threads in these macro's, they are already called from within a loop on cell threads. So you need to remove these loops. Plus, they have no clue to what thread you're pointing with your Domain *d pointer. Either way, you can simply do:

DEFINE_PROPERTY(Heatcapacity_cp, c,t)
{

real sh;
sh = cs*(1.-C_LIQF(c,t))+cl*C_LIQF(c,t);
return sh;
}
KevinZ09 is offline   Reply With Quote

Old   February 17, 2017, 01:28
Default
  #3
New Member
 
up
Join Date: Oct 2015
Posts: 10
Rep Power: 11
abhi12019 is on a distinguished road
I have changed the UDF, but I am getting again same error. Can anybody tell me the issue?
abhi12019 is offline   Reply With Quote

Old   February 17, 2017, 05:57
Default
  #4
Senior Member
 
Kevin
Join Date: Dec 2016
Posts: 138
Rep Power: 10
KevinZ09 is on a distinguished road
You're gonna need to give more details if you want any help. Did you change all three your UDFs or only one, because you're gonna need to change all three of them in a similar way as I indicated in my previous post.

Also, heat capacity has its own macro, called DEFINE_HEAT_CAPACITY, which you should use instead of DEFINE_PROPERTY. So you can't just hook the latter macro to your heat capacity as a consistency with enthalpy is required.
KevinZ09 is offline   Reply With Quote

Old   February 17, 2017, 06:03
Default
  #5
New Member
 
up
Join Date: Oct 2015
Posts: 10
Rep Power: 11
abhi12019 is on a distinguished road
I have changed all three UDFs as u said. In my model the heat capacity vary with liquid fraction, so that I have used DEFINE_PROPERTY macro.
Basically I want to change the mixture heat capacity changing with liquid fraction and also mixture thermal conductivity which is also changing with liquid fraction. I am also adding an energy source term(the last one).

my updated udf :
#include "udf.h"
#define cs 900
#define cl 1100
#define ks 200
#define kl 90
#define TL 919
#define TE 821
#define rho 2800
#define L 390000

DEFINE_PROPERTY(Heatcapacity_cp,c,t)
{
real sh,LF;
LF=C_LIQF(c,t);
sh = cs*(1-LF)+cl*LF;
return sh;
}
DEFINE_PROPERTY(ThermalConductivity_k,c,t)
{

real k,LF;
LF=C_LIQF(c,t);
k = ks*(1-LF)+kl*LF;
return k;
}
DEFINE_SOURCE(solidfication_source, c, t, dS, eqn)
{
real s, sp, sc, k, LF,CV,CT,deltaH;
LF=C_LIQF(c,t);
CV=C_VOLUME(c,t);
CT=C_T(c,t);
deltaH = rho*(cl-cs)*CT+rho*L;
k = (CV*deltaH)/(TL-TE);

sc = k*(2*LF-0.4*TL+0.2*TE-0.8*CT);
sp = (0.8*deltaH*CV) / (TE-TL);
s = sc + sp*CT;

dS[eqn] = 0;

return s;
}

but I am getting same error when I initialized the solution. Please help me.
abhi12019 is offline   Reply With Quote

Old   February 17, 2017, 06:45
Default
  #6
Senior Member
 
Kevin
Join Date: Dec 2016
Posts: 138
Rep Power: 10
KevinZ09 is on a distinguished road
As I said before, you HAVE to use the DEFINE_SPECIFIC_HEAT macro for temperature tempedent specific heats, you've got no choice. Using DEFINE_PROPERTY will not work. If you want it to be non-temperature dependent, but composition dependent, then set constant Cp's for the individual materials, and use the mixing law for your cp in the mixture material panel.

Not saying that's the only reason your model crashes, but could be one of them. It's hard to tell in advance with segmentation errors. You can always insert "message" statements to see where it goes wrong. Or hook the separate macro's individually to see which one causes the error.

Finally, why you set dS[eqn] = 0 and not dS[eqn] = sp?
KevinZ09 is offline   Reply With Quote

Old   February 17, 2017, 09:16
Default
  #7
New Member
 
up
Join Date: Oct 2015
Posts: 10
Rep Power: 11
abhi12019 is on a distinguished road
Hi,
As You said I have write the correct macro for specific heat but I am getting an error when interpret the udf as :
line 17: t: undeclared variable

my updated UDF :
#include "udf.h"
#define cs 900
#define cl 1100
#define ks 200
#define kl 90
#define TL 919
#define TE 821
#define rho 2800
#define L 390000

DEFINE_SPECIFIC_HEAT(Heatcapacity_cp, T, Tref,h,yi)
{
real cp,LF,TT;
TT=T-273.16;
//cell_t c;
//Thread *t;
//begin_c_loop(c,t){

LF=C_LIQF(c,t);

cp = cs*(1-LF)+cl*LF;
*h = cp*(TT-Tref); }
//end_c_loop(c,t)
return cp;
}
DEFINE_PROPERTY(ThermalConductivity_k,c,t)
{

real k,LF;
LF=C_LIQF(c,t);
k = ks*(1-LF)+kl*LF;
return k;
}
DEFINE_SOURCE(solidfication_source, c, t, dS, eqn)
{
real s, sp, sc, k, LF,CV,CT,deltaH;
LF=C_LIQF(c,t);
CV=C_VOLUME(c,t);
CT=C_T(c,t);
deltaH = rho*(cl-cs)*CT+rho*L;
k = (CV*deltaH)/(TL-TE);

sc = k*(2*LF-0.4*TL+0.2*TE-0.8*CT);
sp = (0.8*deltaH*CV) / (TE-TL);
s = sc + sp*CT;

dS[eqn] = sp;

return s;
}
abhi12019 is offline   Reply With Quote

Old   February 17, 2017, 09:35
Default
  #8
Senior Member
 
Kevin
Join Date: Dec 2016
Posts: 138
Rep Power: 10
KevinZ09 is on a distinguished road
Quote:
Originally Posted by abhi12019 View Post

DEFINE_SPECIFIC_HEAT(Heatcapacity_cp, T, Tref,h,yi)

LF=C_LIQF(c,t);
You don't, and can't, pass c or t as argument in the specific heat macro, so obviously these variables are undeclared, and unknown. Pretty much what the error is saying.

But as I said before, if you want your mixture to be composition dependent, you have use the mixing-law option for cp in the mixture material panel.
KevinZ09 is offline   Reply With Quote

Old   February 17, 2017, 11:18
Default
  #9
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
I guess that, even if you would remove the heat capacity udf, you would still get errors when you initialize.
The reason is that you use the following:
Code:
C_LIQF(c,t);
This macro reads the liquid fraction. When you initialize, the liquid fraction is not defined yet, so Fluent can not read it.

One solution for this: first initialize (with constant thermal conductivity), and then attach the UDF.
pakk is offline   Reply With Quote

Old   June 24, 2019, 08:21
Default Problem with solidification problem
  #10
Member
 
Join Date: Oct 2017
Posts: 52
Rep Power: 9
gouravjee is on a distinguished road
Quote:
Originally Posted by pakk View Post
I guess that, even if you would remove the heat capacity udf, you would still get errors when you initialize.
The reason is that you use the following:
Code:
C_LIQF(c,t);
This macro reads the liquid fraction. When you initialize, the liquid fraction is not defined yet, so Fluent can not read it.

One solution for this: first initialize (with constant thermal conductivity), and then attach the UDF.
Hii all,
Currently i am working on a solidification problem of a casting. i am solving scalar transport equation as a energy equation and using fluent momentum equations (stationary fluid and natural convection is there) with some extra source terms( UDFs)

Problem : When i put my cooling temperature above the melting temperature the code works fine but after putting temperature below melting point, it causes divergence error and shows some unreallistic values of velocity and temperature.
can you suggest me where might be the problem ?
gouravjee 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
solidification and melting with VOF: how to sink solid PCM as it melts? sakil2k3 FLUENT 32 November 15, 2019 07:27
melting or solidification model in CFX jasonchang CFX 5 January 31, 2018 07:33
Question about solidification and melting model aestas FLUENT 0 November 8, 2015 21:32
solidification and melting mojtaba-azadi FLUENT 2 November 30, 2011 11:27
Solidification and melting with CFX Don CFX 0 December 1, 2008 12:30


All times are GMT -4. The time now is 12:55.