Entering Ranges and Vector-Valued Expressions
You can enter ranges and vector-valued expressions such as extra grid-line coordinates using the following formats:
A delimited space-separated list using curly braces; for example, using it as an argument to a function such as a mathematical function or a user-defined function: cos({0 pi/4 pi/2}) or an1({1, 2, pi, 14/2}). The curly braces can also be used to create a scalar-vector multiplication such as {0, 1,2}*10 or as an elementwise array multiplication such as {0,1,2}*{10,11,13}, which results in the array {0,11,26}.
Equally-spaced values using the range function as in range(start value,step_size,end value). For example, range(0,0.2,3) creates the values 0, 0.2, 0.4,..., 2.6, 2.8, and 3.0. The step size is 1 if you provide only start and end values and skip the step value. You can also use the range function as input to a used-defined function, for example: an1(range(0,1,12)).
start_value can be either smaller or larger than end_value. In the latter case, the step size must be negative. For example, range(0,-5,-100) creates the values 0, 5, 10, ..., 95, 100, while range(0,5,-100) is an empty set of values.
Combine these formats in a single expression to create an array of values that contain an arbitrary number of segments with differently spaced values mixed with other freely specified values.
Examples Using the Range Function
range(a,(b-a)/(n-1),b) gives a list of n equally-spaced increasing values in the range [ab] if b >a or decreasing values in the range [ba] if a >b.
10^range(-3,3) gives the exponentially increasing sequence 103, 102, …, 103.
1^range(1,10) gives a sequence of length 10 where all elements equal 1. Multiplying the vector 1^range(1,n) by a constant value a gives a vector of n elements all equal to a.
0^range(1,5) gives the sequence 0 0 0 0 0.
Using Ranges to Generate Arrays
A convenient way to generate vectors of values is to use the Range dialog box, which you open by clicking the Range button () next to most of the fields that accept vectors of values.
In that dialog box, use the Entry method list to select the method to enter the values that define the range:
Select Step to define range using a specified step size. See Step and Number of Values.
Select Number of values to define range using a specified number of values. See Step and Number of Values.
Select Logarithmic to define a logarithmic range of values. See Logarithmic.
Select ISO preferred frequencies to define the range using an octave or other interval of ISO preferred frequencies. To show this option, click the Show More Options button () and select Advanced Study Options in the Show More Options dialog box. It also appears if the model contains a physics interface that requires the Acoustics Module.
Step and Number of Values
Step to enter a step size or Number of values to specify the number of values in the array. Specify the start value for an array of values in the Start field. Enter the step size in the Step field or the number of values in the Number of values field, depending on the setting in the Entry method list. Specify the end value for the array of values in the Stop field. By default, the spacing of the values is linear, but you can select a function to apply to all values. To do so, choose one of the available arithmetic and trigonometric functions as well as user-defined functions and functions from materials (with a single argument) from the Function to apply to all values list. For example, select exp10 to create an array of exponentially increasing values. The list includes the following functions:
The default value None, which means linear spacing using the range function directly with the values specified.
The exponential functions exp10 (base-10 exponential function) and exp (base-e exponential function), which create exponentially-spaced values using the specified range of values as powers of 10 and of the mathematical constant e, respectively.
The trigonometric functions cos (cosine) and sin (sine), which create sinusoidally varying values.
The square root function sqrt, which creates a vector with values that are the square roots of the values specified.
Logarithmic
Use this entry method to set up a logarithmic range of values (frequencies, for example). Enter the Start value (fmin in the expression below), the Stop value (fmax in the expression below), and the Steps per decade (N in the expression below). The range then becomes 10^{range(log10(fmin),1/(N-1),log10(fmax))}
ISO Preferred Frequencies
To show this option, click the Show More Options button () and select Advanced Study Options in the Show More Options dialog box. This method requires a license for the Acoustics Module. Use this entry method to set up ISO preferred frequencies — a list of frequencies defined based on the preferred numbers of ISO 3. Enter the Start frequency, the Stop frequency, and an Interval: Octave, 1/3 octave (the default), 1/6 octave, 1/12 octave, or 1/24 octave. For example, range of frequencies between 1 and 10 using an octave is {1, 2, 4, 8} and, using 1/3 octave, it is {1, 1.25, 1.6, 2, 2.5, 3.15, 4, 5, 6.3, 8, 10}.
Common Settings
Click Replace to replace the contents in the field with the values specified in the Range dialog box.
Click Add to add the range of values to the end of the existing values in the associated field. That way you can create more complex ranges.
For ranges that contain integer values only, an Integer Range dialog box opens instead of the normal Range dialog box. The Integer Range dialog box only contains Start, Step, and Stop fields, all of which must contain integer values.
Support For Ranges and Vector-Valued Expressions
The following modeling settings support ranges and vector-valued expressions:
Extra grid lines in the Settings window for Axis.
Interval coordinates when using the Settings window for Interval for 1D geometries.
The Copy, Move, and Rotate transforms for geometry modeling.
The times for output from the time-dependent solver and the list of parameter values in the Settings windows for study step nodes for time-dependent and stationary solvers and for parametric sweeps.
The contour levels, the streamline start-point coordinates, and the coordinates in arrow plots. Whenever you specify a number of coordinates in Settings windows for plots, the COMSOL Multiphysics software uses scalar expansion — if one component is the same for all coordinates, enter a single number in the corresponding text field. For example, to get 101 linearly spaced coordinates from y = 6 to y = 7 along x = 3, enter it as the single scalar 3 for x and then range(6,0.01,7) for y. Thus, you need not enter 101 similar values for x.
Because the range function returns a list of values, it is a vector-valued function that you cannot use in a definition of a variable, for example. Variables must return a scalar value.