|
[Sponsors] |
February 15, 2017, 06:58 |
Solidification and melting
|
#1 |
New Member
up
Join Date: Oct 2015
Posts: 10
Rep Power: 11 |
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; } |
|
February 15, 2017, 08:25 |
|
#2 |
Senior Member
Kevin
Join Date: Dec 2016
Posts: 138
Rep Power: 10 |
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; } |
|
February 17, 2017, 01:28 |
|
#3 |
New Member
up
Join Date: Oct 2015
Posts: 10
Rep Power: 11 |
I have changed the UDF, but I am getting again same error. Can anybody tell me the issue?
|
|
February 17, 2017, 05:57 |
|
#4 |
Senior Member
Kevin
Join Date: Dec 2016
Posts: 138
Rep Power: 10 |
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. |
|
February 17, 2017, 06:03 |
|
#5 |
New Member
up
Join Date: Oct 2015
Posts: 10
Rep Power: 11 |
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. |
|
February 17, 2017, 06:45 |
|
#6 |
Senior Member
Kevin
Join Date: Dec 2016
Posts: 138
Rep Power: 10 |
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? |
|
February 17, 2017, 09:16 |
|
#7 |
New Member
up
Join Date: Oct 2015
Posts: 10
Rep Power: 11 |
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; } |
|
February 17, 2017, 09:35 |
|
#8 | |
Senior Member
Kevin
Join Date: Dec 2016
Posts: 138
Rep Power: 10 |
Quote:
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. |
||
February 17, 2017, 11:18 |
|
#9 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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); One solution for this: first initialize (with constant thermal conductivity), and then attach the UDF. |
|
June 24, 2019, 08:21 |
Problem with solidification problem
|
#10 | |
Member
Join Date: Oct 2017
Posts: 52
Rep Power: 9 |
Quote:
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 ? |
||
|
|
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 |