|
[Sponsors] |
Modelling porosity as a function of temperature |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
January 2, 2015, 11:29 |
Modelling porosity as a function of temperature
|
#1 |
New Member
Anonymous Joe
Join Date: Jun 2013
Posts: 7
Rep Power: 13 |
In my case i want to model the porosity as a function of temperature. my code looks like this:
Code:
#include "udf.h" DEFINE_PROFILE{dir1, t, i} { cell_t c; begin_c_loop(c,t) real temp = C_T(c,t); if (temp > 1300.) C_PROFILE(c,t,i) = 13.7 - (temp - 1300) * 0.0015 + pow(temp - 1300,2.) *0.0000075; else if (temp > 1500.) C_PROFILE(c,t,i) = 0.01; else C_PROFILE(c,t,i) = 13.7; end_c_loop(c,t) } DEFINE_PROFILE{dir2, t, i} { cell_t c; begin_c_loop(c,t) real temp = C_T(c,t); if (temp > 1300.) C_PROFILE(c,t,i) = 13.7 - (temp - 1300) * 0.0015 + pow((temp - 1300),2.0) *0.0000075; else if (temp > 1500.) C_PROFILE(c,t,i) = 0.01; else C_PROFILE(c,t,i) = 13.7; end_c_loop(c,t) } New_UDF.c.8748.5.c: line 8: parse error. which is a little bit confusing. thx for your help |
|
January 5, 2015, 11:14 |
|
#2 | |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
- the accolades should be replaced with parentheses
- you should not use "temp" because it shadows previous definition Quote:
|
||
January 7, 2015, 06:27 |
|
#3 |
New Member
Anonymous Joe
Join Date: Jun 2013
Posts: 7
Rep Power: 13 |
thx for your help - now it seems to work !
|
|
January 13, 2015, 04:33 |
|
#4 |
New Member
Anonymous Joe
Join Date: Jun 2013
Posts: 7
Rep Power: 13 |
Is this formulation of the UDF also valid for transient simulations ?
|
|
January 13, 2015, 07:48 |
|
#5 |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
Yes it is valid.
|
|
January 13, 2015, 09:43 |
|
#6 |
New Member
Anonymous Joe
Join Date: Jun 2013
Posts: 7
Rep Power: 13 |
Thx, i only have one problem left, i want to model more or less a simplified melting process of a porous media. The lines i posted are only a part of my code.
So far the melting is built up correctly, but when for some reason the temperatur in my cell decreases, the whole thing is reversible, which in my case is not realistic, as the molten liquid, flows to the bottom. I want to ensure, that once my cell reached a certain temperature, the porosity cannot decrease again. |
|
January 13, 2015, 20:30 |
|
#7 |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
I don't understand why you code dir1 and dir2 since the equation/conditions are the same. Code only one DEFINE_PROFILE and load the same property for both directions.
Porosity should be between 0 and 1, values like 13.7 and the jump at 1500 look weird. Regarding the reversibility problem, you will have to store previous timestep values in a UDMI and compare them with current timestep values. Then write some if condition that keeps the porosity constant if T current timestep < T previous timestep. See this post for an example: http://www.cfd-online.com/Forums/flu...tml#post372530 |
|
January 14, 2015, 04:26 |
|
#8 |
New Member
Anonymous Joe
Join Date: Jun 2013
Posts: 7
Rep Power: 13 |
First of all thanks for your help.
As i mentioned this is only a part of my code, i don´t wanted to upload the whole thing here because it´s to long. In the code i also modelled the pressure drop. Actually i copied the line for the inertial resistance. This is not identical in all directions in my case at the beginning. Therefore i had to use two values. Nevertheless the code for the porosity looks exactly the same onle the values change, they have to be between 0 and 1, as allready mentoined by you. Thanks for the help regarding the reversibility problem. I will have a closer look on this. |
|
January 14, 2015, 05:56 |
|
#9 |
New Member
Anonymous Joe
Join Date: Jun 2013
Posts: 7
Rep Power: 13 |
Dear MacFly, thx for your help.
The condition you suggested will not work out: "Then write some if condition that keeps the porosity constant if T current timestep < T previous timestep" because this condition would only work for 1 timestep. if i have temperature decrease for more timesteps, the condition would only look for the last timestep and can´t know that my material is allready melted e.g. 10 timesteps ago. Therefor i suggested to take the porosity itself as condition. If the porisity 1 timestep ahead =1, then it should also be 1 in the next timestep. unfortunatly this doesnt work out so well yet, mainly to my lack of udf-experience. my actual version of the UDF now looks like this: Code:
DEFINE_PROFILE(por, t, i) { cell_t c; begin_c_loop(c,t) real val_temp = C_T(c,t); if (val_temp > 1500.) { C_PROFILE(c,t,i) = 1; C_UDMI(c,t,1) = 1; } else if (val_temp > 1300. && val_temp < 1500.) { C_PROFILE(c,t,i) = val_temp*0.000425 + 0.3575; C_UDMI(c,t,1) = val_temp*0.000425 + 0.3575; } else { C_PROFILE(c,t,i) = 0.91; C_UDMI(c,t,1) = 0.91; } C_UDMI(c,t,0) = C_UDMI(c,t,1) /*not working */ end_c_loop(c,t) } The next steps would be to make an if condition, to check if the porosity in the timestep before was 1 or not, if the value was 1, then overwrite the actual value of the cell with the value 1. |
|
January 14, 2015, 10:55 |
|
#10 |
Senior Member
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 27 |
If you need to know if material was already melted what about using a boolean variable?
__________________
Google is your friend and the same for the search button! |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[snappyHexMesh] How to define to right point for locationInMesh | Mirage12 | OpenFOAM Meshing & Mesh Conversion | 7 | March 13, 2016 15:07 |
[blockMesh] non-orthogonal faces and incorrect orientation? | nennbs | OpenFOAM Meshing & Mesh Conversion | 7 | April 17, 2013 06:42 |
[blockMesh] BlockMesh FOAM warning | gaottino | OpenFOAM Meshing & Mesh Conversion | 7 | July 19, 2010 15:11 |
latest OpenFOAM-1.6.x from git failed to compile | phsieh2005 | OpenFOAM Bugs | 25 | February 9, 2010 05:37 |
Compilation errors in ThirdPartymallochoard | feng_w | OpenFOAM Installation | 1 | January 25, 2009 07:59 |