CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   STAR-CCM+ (https://www.cfd-online.com/Forums/star-ccm/)
-   -   Field Function relating to temperature. Please Help (https://www.cfd-online.com/Forums/star-ccm/96991-field-function-relating-temperature-please-help.html)

kj878 February 6, 2012 17:34

Field Function relating to temperature. Please Help
 
:confused:

So I'm fairly knew to StarCCM and I need to set up my initial conditions such that my wall temperature changes linearly from one end to the other. I believe I have to write a field function to do this but. Unfortunately I have zero experience in writing programs/codes and I have no idea how to write field function formula for my problem.

Wont someone be kind enough to help me write a field function?

My problem statement is a fluid flowing through a pipe, length say 1m and the temperature of the wall varies through the length.

From L=0 to L=.5 I need my wall temp to be at 150C. From L=.5 to L=.75, the wall temp needs to drop from 150C to 70C, linearly. Similarly, from L=.75 to L=1m, the wall temp needs to drop from 70C to 35C, linearly as well.

Can someone please help me with this??
Many thanks in advance!

sanjay February 6, 2012 23:04

why don't you work out an tutorial in CCM+, it might help you.

regards
www.aerosapien.blogspot.com

kj878 February 7, 2012 00:38

Quote:

Originally Posted by sanjay (Post 343023)
why don't you work out an tutorial in CCM+, it might help you.

regards
www.aerosapien.blogspot.com

that was the first thing I did was to find tutorials that I could use to relate to my work. however, I was able to find a good tutorial on field functions. If you could direct me to one, it would be greatly appreciated.
THanks!

willimanili February 7, 2012 06:10

You can easily create an Surface Standard Deviation report for your boundary and the value for which you would like to calculate the variance. So with this report you have already the standard deviation. Now create your own field function which gives you the square of the reports result ( the definition should be kind of: pow($SurfaceStandardDeviationReport,2) ). Now you can create an report which gives you the result for your fieldfunction which is the variance you are searching for.

kj878 February 7, 2012 11:30

Quote:

Originally Posted by willimanili (Post 343090)
You can easily create an Surface Standard Deviation report for your boundary and the value for which you would like to calculate the variance. So with this report you have already the standard deviation. Now create your own field function which gives you the square of the reports result ( the definition should be kind of: pow($SurfaceStandardDeviationReport,2) ). Now you can create an report which gives you the result for your fieldfunction which is the variance you are searching for.

Thank you for your input but I'm afraid you misunderstood my problem statement.
I dont need a statistical report such as calculating the variance or the standard deviation. but I need to set the initial conditions of the walls in my pipe certain values.

the question I have is, how can I set the wall temperatures such that it changes linearly from one end to the other.

more specifically, if I have a wall 1m long, I need:
From L=0 to L=.5 I need my wall temp to be at 150C. From L=.5 to L=.75, the wall temp needs to drop from 150C to 70C, linearly. Similarly, from L=.75 to L=1m, the wall temp needs to drop from 70C to 35C, linearly as well.

Thanks anyway for your help, but it wasn't what I was looking. (at least now I know how to calculate the SD and the variance.)

rwryne February 7, 2012 12:44

Quote:

Originally Posted by kj878 (Post 343163)
Thank you for your input but I'm afraid you misunderstood my problem statement.
I dont need a statistical report such as calculating the variance or the standard deviation. but I need to set the initial conditions of the walls in my pipe certain values.

the question I have is, how can I set the wall temperatures such that it changes linearly from one end to the other.

more specifically, if I have a wall 1m long, I need:
From L=0 to L=.5 I need my wall temp to be at 150C. From L=.5 to L=.75, the wall temp needs to drop from 150C to 70C, linearly. Similarly, from L=.75 to L=1m, the wall temp needs to drop from 70C to 35C, linearly as well.

Thanks anyway for your help, but it wasn't what I was looking. (at least now I know how to calculate the SD and the variance.)


Youll just need to use some embedded if statements. I assume you know the syntax, but just in case:

Code:

<Test Condition> ? <statement if true> : <statement if false>
The easiest way to do this without making a super long single field function is to make 4 field functions:

TempSegA : for first piece
TempSegB : for second piece
TempSegC : for third piece
TempAll : sum of above, appled as IC.

Make sure the units for all of the above field functuions are temperature.

I am assuming L is in the x-direction, and the numbers for L are in meters.

Just to show where I got values below,

Slope of Seg B: (70-150)/(.75-.5) = -320
Slope of Seg C: (35-70)/(1-.75) = -140

TempSegA function:
$Position[0] < 0.5 ? 423.15 : 0
TempSegB function:
$Position[0] > 0.5 ? $Position[0] <=0.75 ? 423.15 -320*($Position[0]-0.5) : 0 : 0
TempSegC function:
$Position[0] > .75 ? $Position[0] <=1? 343.15 -140*($Position[0]-0.75) : 0 : 0


TempAll function:

$TempSegA + $TempSegB + $TempSegC

Now set TempAll as your IC and initialize

kj878 February 7, 2012 15:46

Quote:

Originally Posted by rwryne (Post 343173)
Youll just need to use some imbedded if statements. I assume you know the syntax, but just in case:

Code:

<Test Condition> ? <statement if true> : <statement if false>
The easiest way to do this without making a super long single field function is to make 4 field functions:

TempSegA : for first piece
TempSegB : for second piece
TempSegC : for third piece
TempAll : sum of above, appled as IC.

Make sure the units for all of the above field functuions are temperature.

I am assuming L is in the x-direction, and the numbers for L are in meters.

Just to show where I got values below,

Slope of Seg B: (70-150)/(.75-.5) = -320
Slope of Seg C: (35-70)/(1-.75) = -140

TempSegA function:
$Position[0] < 0.5 ? 423.15 : 0
TempSegB function:
$Position[0] > 0.5 ? $Position[0] <=0.75 ? 423.15 -320*($Position[0]-0.5) : 0 : 0
TempSegC function:
$Position[0] > .75 ? $Position[0] <=1? 343.15 -140*($Position[0]-0.75) : 0 : 0


TempAll function:

$TempSegA + $TempSegB + $TempSegC

Now set TempAll as your IC and initialize

PERFECT!
Many many thanks!
I will try this right away.

rwryne February 7, 2012 16:17

Quote:

Originally Posted by kj878 (Post 343207)
PERFECT!
Many many thanks!
I will try this right away.

There are probably a few small issues, you should be able to work them out. I am very much a "test as you write it" type of coder, and I did not test these.

Let me know if there are any issues!

-Ryne

kj878 February 7, 2012 17:38

Quote:

Originally Posted by rwryne (Post 343217)
There are probably a few small issues, you should be able to work them out. I am very much a "test as you write it" type of coder, and I did not test these.

Let me know if there are any issues!

-Ryne

Hey, I just typed the code and tried it and I'm not sure its working correctly.

The wall temperature is dropping to 0 Kelvin everywhere.

ps. I already had the walls divided into three separate regions so I assigned the field function to the corresponding wall section. since the 1st segment is always 150C, i just assigned it as a constant.
next two segments, i assigned their individual field function respectively but its results as 0. :/

rwryne February 7, 2012 21:37

Quote:

Originally Posted by kj878 (Post 343230)
Hey, I just typed the code and tried it and I'm not sure its working correctly.

The wall temperature is dropping to 0 Kelvin everywhere.

ps. I already had the walls divided into three separate regions so I assigned the field function to the corresponding wall section. since the 1st segment is always 150C, i just assigned it as a constant.
next two segments, i assigned their individual field function respectively but its results as 0. :/

You made sure to apply these field functions as the temperature for these boundaries, right?

If so, did you make sure to clear the current solution and hit Solution->Initialize?

willimanili February 8, 2012 02:39

First of all sry for the misunderstanding, but it thought you where asking for the temperature variance at your walls.

So Ryne gave you already the solution. By the way good advice to use more than one long fielfunction.

Check the coordinate system where the fieldfunctions are corresponding to. Is it at the right position? Is the x-axis parallel to the tube length? Does the origin of the coordinate system fits your test condition?

kj878 February 8, 2012 11:50

Quote:

Originally Posted by willimanili (Post 343277)
First of all sry for the misunderstanding, but it thought you where asking for the temperature variance at your walls.

So Ryne gave you already the solution. By the way good advice to use more than one long fielfunction.

Check the coordinate system where the fieldfunctions are corresponding to. Is it at the right position? Is the x-axis parallel to the tube length? Does the origin of the coordinate system fits your test condition?

Ya I read the original post and changed the wording a bit, I can see why someone could sees as if I was looking for The variance.


Ya the coordinate system is kinda of messed up. The origin is located at L/2. So 1st segment would be from -.5 to 0, second from 0 to .25 and the last bit .25 to 5. But I changed the field function coding accordingly.

Quote:

Originally Posted by rwryne (Post 343240)
You made sure to apply these field functions as the temperature for these boundaries, right?

If so, did you make sure to clear the current solution and hit Solution->Initialize?

Yes and Yes.
I will try to work on it more a little bit and see if I can get it to work.
Right now Im just running my analysis with the three sections assigned with an average constant temperature. But in order to get a more accurate result, I want to need to have a wall section where the temperature drops, as is in real life.


For those who are wondering, I am trying to melt/solidify a fluid going through a pipe and measure the shear force from the fluid while going through the said pipe.
It is to simulate a process called Pultrusion, where there are materials being pulled through a die, melted to consolidated and weld the materials together and freeze it in the die to form the shape of the said die.

kj878 February 8, 2012 16:13

finally got it!

it was a combination of bunch of syntax mistakes and funky coordinate system that threw me off.

took me 3 days figure out how to write :/

thanks everyone!


All times are GMT -4. The time now is 13:27.