This Beautiful Banner is included in Essentials!
Kobbegårdsvägen 7

Simcenter STAR-CCM+ field function syntax, part 1

Simcenter STAR-CCM+ field function syntax, part 1

In this week’s blog post we will look at the syntax used in field functions in Simcenter STAR-CCM+. It can be extremely useful to know how to create for instance your own spatial limitations. A question we sometimes get is how to initialise temperature in part of a region or how to create a heat source that only occupy part of a region. So instead of recreating your domains and changing regions, you can specify a field function for a subset of your region or regions to accomplish this.

Documentation

The documentation contains and describes the different operators and expression you can use for your field functions. In the table below you can find what logical operators are available.

 

 

 

 

 

 

 

Aside from the arithmetic operators, +, -, * and / (plus, minus, multiplication, division) the logical operators are key in creating your own useful field functions and expressions. For more examples and for more information look under “Expression Syntax” in the Simcenter STAR-CCM+.

Example

In this blog post we will focus on a simple solid block and show how we can use field functions with operators to initialize the temperature for that block. The block originates from origin and measures one meter in all three directions: a box with a volume 1 cubic meter [m3].

 

 

 

 

 

 

 

 

 

 

 

 

We have defined an evaluation plane located on the XY-plane at z=0.5, at the center of our domain. And at this plane we will look at the result after initialization using our field function.

So, instead of initializing our block with a constant temperature we will select the option “field function” under initial conditions under our physics continua node. Next step is then to create the field function that defines the initialization temperature for our domain.

Basic syntax

For our first example here, we will create a field function that makes the centre half of the volume (in X-direction) have a temperature at 320 K and the rest (one quarters on each side) have an initial temperature of 300 K. We will then visualize this by initializing our scene and see if our field function is successful.

To create a field function you go to tools, field functions and right click. For this type of field function, you select a scalar field function. You can change its name and its function name (the name that will be called upon if you use it in the syntax for e.g. another field function).

Our field function is written as shown below. A basic if-statement. A useful tool is the preview window in the field function editor. It can help you show if the expression you wrote is correct. Looking at the example below it seems correct with a value of 320 for X-coordinate between 0.25 and 0.75.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

So, by writing our expression: “$${Position}[0] > 0.25 && $${Position}[0] < 0.75 ? 320 : 300”, we say if coordinate X (0=X, 1=Y, 2=Z) is both above 0.25 and below 0.75 set a value of 320, else 300. The “?” denotes the if, the “&&” denotes the both (make sure both criteria are fulfilled) and the “:” denotes the else. A simplification of the expression is provided in the picture below.

 

 

 

 

 

We then use this as the initial condition for temperature in our physics continua. And as we can see in the picture below (even if we have a small gradient) the initial temperature is 20 K higher in the center part of the block.

 

 

 

 

 

 

 

 

 

Assume we want the same thing in the Y-coordinate as well. What shall we do with our field function to obtain that? Basically, by using some more and-operators (&&) for also the Y-coordinate. The resulting field function and initialized temperature is shown below.

Syntax in a local coordinate system

Assume we want a sphere in the center of our block and do the same thing here. Basically, an initial temperature in the center with radius 0.25. It is hard to limit ourselves to X,Y and Z coordinates to obtain this. The best option is instead to use a spherical coordinate system with its origin in the center of the block. This can easily be created under local coordinate systems. We define a local coordinate system under “Coordinate Systems à Laboratory à Local coordinate Systems” and we call it “spherical”. Sets its origin to [0.5 0.5 0.5] based on our initial cartesian coordinate system. The beauty of the syntax here is that we only need to specify our if-statement in one coordinate, the radial coordinate from our center point. The syntax in the field function seen in the he picture below is used to initialize the temperature in the sphere, which can also be seen in the picture.

I hope this has been useful to you as a reader. At a later time, we will continue this syntax series to see how to create our own useful field functions. If you have any questions, as usual, don’t hesitate to contact us at support@volupe.com.

Read also:
STAR-CCM+ field function syntax, part 2
Using sliding sample window
Finding the center of a circle in Simcenter STAR-CCM+
How to transform Display views
Wizards and add-ons in Simcenter STAR-CCM+ part 1

 

Related Posts