Skip to content

Variables overrides

When a variable is defined in Allsolve, an initial value is provided which serves as the default for a simulation. In some simulations, you might want to override this default value for one or more variables. For example:

  • override the variable’s value to a vector/list of different values to run a parametric sweep simulation.
  • override the variable’s value to another scalar value to run a simulation to do a sanity check of the simulation setup, especially for a large scale simulation.

The Variable overrides in the Properties section of Allsolve allows you to override a variable’s value. Variable override

In line with the two examples above, there are two types of variable overrides available:

In both these types, Sweep or Override, you can select one or more variables from the drop-down list and provide an expression for overriding. In this context, such an expression is called an override expression. If the override expression is a vector/list then it is referred as override vector.

Any number of Variable overrides can be created and these would available, by their name, in the simulation Inputs. However, only one of them can be selected. For the variables in this selected Inputs, the override epxression is considered during the simulation. Needless to say that, for the rest of the variables their default initial values would be used.

In Overrides, the override expression provided for each variable must evaluate to scalar value. Hence, if a vector/list is provided instead, it is not be accepted as a valid override expression by Allsolve. Override

Sweeps are generic and can accommodate both a vector/list and a scalar value. Usually, the override expression provided here is a vector/list. However, providing a scalar expression is still a valid override vector, since a scalar is considered as a vector/list with a length of one.

More on sweeps

With sweeps, you can easily run multiple variations of your model in one go, varying one or more defined variables. If in the simulation inputs

  1. a variable override of type sweep is selected and
  2. any of the override expressions in that sweep are a vector/list, then

parallel subsimulations are run for each value in the vector/list.

Univariate sweeps

In a univariate (1-variable) sweep, just one variable is selected in the Overrides list by clicking + Add override.

  1. If the vector/list is small, the override expression can be entered using square brackets:

    Sweep

  2. Larger vectors can be entered using the linspace or logspace functions:

    linspace logspace

Multivariate sweeps

If the simulation requires a parametric sweep over two or more variables, then a multivariate sweep setup is needed. It typically involves selecting more than one variable in the Overrides list by clicking + Add override.

Multivariate sweeps run by aligning indices between the override vectors, so that subsimulation i takes the value in index i of each override vector. For this reason, when using multivariate sweeps, lengths of override vectors must match.

2-variable sweeps

For example, consider a solid mechanics simulation intended to run for the following list of pairs of Young’s modulus E and Poisson’s ratio nu:

(150e9, 0.2), (150e9, 0.25), (160e9, 0.2), (160e9, 0.25)

Here the simulation needs to be swept over two variables: Young’s modulus E and Poisson’s ratio nu. To perform this 2-variable sweep simulation:

  • add a Variable override of type Sweep.

  • select the variables E and nu for override.

  • provide the override vectors as in the table below.

    VariableOverride vector
    E[150e9, 150e9, 160e9, 160e9]
    nu[0.2, 0.25, 0.2, 0.25]

Note, that the length of the E and nu override vectors match (4 in this case).

Now consider a mechanical warpage sweep simulation also with two variables: temperature T and coefficient of thermal expansion CTE. Assume the ranges of T = [25, 50, 75, 100, 125, 150] and CTE = [1e-6, 2e-6, 3e-6, 4e-6, 5e-6] and that it is required to run the sweep simulation for all possible resulting pairs of (T, CTE) as in the image below: 2 Variable Sweep

With 6 different values of T and 5 different values of CTE, this results in a total of 6 x 5 = 30 pairs of (T, CTE). The override vectors with 30 elements each are provided as follows:

VariableOverride vector
T[25,25,25,25,25, 50,50,50,50,50, 75,75,75,75,75, 100,100,100,100,100, 125,125,125,125,125, 150,150,150,150,150]
CTE[1,2,3,4,5, 1,2,3,4,5, 1,2,3,4,5, 1,2,3,4,5, 1,2,3,4,5, 1,2,3,4,5 ]

Providing these lists of 30 elements manually for each of the two variables can be quite tedious. If there are more than two variables with many different values to sweep, it becomes even more painstaking to enter all the vector/list elements. To simplify providing these long override vectors, it is recommended to use the repelem and repmat functions.

For example, the same override vectors, as earlier, for T and CTE can now be obtained with a much simpler syntax as shown below:

VariableOverride vector
Trepelem([25, 50, 75, 100, 125, 150], 5)
CTErepmat([1e-6, 2e-6, 3e-6, 4e-6, 5e-6], 1, 6)

As another example, let’s say you have two defined variables v1 and v2 whose sweep values are as below and that you would like to run a parametric sweep for each possible resulting pairs of (v1, v2):

VariableSweep valuesLength
v1[1, 2]l1 = 2
v2[10, 20, 30]l2 = 3

To do so, the override vectors are defined with repelem and repmat as follows:

VariableOverride vectorResult
v1repelem([1, 2], 3)[1, 1, 1, 2, 2, 2]
v2repmat([10, 20, 30], 1, 2)[10, 20, 30, 10, 20, 30]

Vectors can be entered into repelem/repmat arguments with the linspace or logspace functions: Vector argument 1 with linspace Vector argument 2 with linspace

The generalized expression for a 2-variable sweep is:

VariableOverride vector
v1repelem(v1, l2)
v2repmat(v2, 1, l1)

3-variable sweeps

Let’s add a third variable to the sweep, v3:

VariableSweep valuesLength
v1[1, 2]l1 = 2
v2[10, 20, 30]l2 = 3
v3[100, 200, 300, 400]l3 = 4

To define the override vectors, it is recommended to use a combination of the repelem and repmat functions:

VariableOverride vector
o1repelem([1, 2], 3 * 4)
o2repelem(repmat([10, 20, 30], 1, 2), 4)
o3repmat([100, 200, 300, 400], 1, 2 * 3)

The generalized expression for a 3-variable sweep is:

VariableOverride vector
o1repelem(v1, l2 * l3)
o2repelem(repmat(v2, 1, l1), l3)
o3repmat(v3, 1, l1 * l2)

4-variable sweeps

Let’s add a 4th variable to the sweep, v4:

VariableSweep valuesLength
v1[1, 2]l1 = 2
v2[10, 20, 30]l2 = 3
v3[100, 200, 300, 400]l3 = 4
v4[1000, 2000, 3000, 4000, 5000]l4 = 5

To define the override vectors, it is recommended to use a combination of the repelem and repmat functions:

VariableOverride vector
o1repelem([1, 2], 3 * 4 * 5)
o2repelem(repelem(repmat([10, 20, 30], 2), 4), 5)
o3repelem(repmat(repmat([100, 200, 300, 400], 1, 2), 1, 3), 5)
o3repmat([1000, 2000, 3000, 4000, 5000], 1, 2 * 3 * 4)

The generalized expression for a 4-variable sweep is:

VariableOverride vector
o1repelem(v1, l2 * l3 * l4)
o2repelem(repelem(repmat(v2, l1), l3), l4)
o3repelem(repmat(repmat(v3, 1, l1), 1, l2), l4)
o3repmat(v4, 1, l1 * l2 * l3)

You might see a pattern emerging at this point. You’re not likely to need more than 4 override vectors in any simulation, but if you do, the override vector definitions will follow the same logic of combining repelem/repmat.

Sweeps over functions

Consider a simple heat conduction problem for which it is required to run the simulation for different values of thermal conductivity K, for example 5, 10 and 15.

Heat conduction model

In Allsolve, this is achieved by doing a univariate parametric sweep and the typical workflow is as follows:

  1. Define a variable, say Cu_K, and provide an initial value:

    image

  2. Add a suitable material from the library and in the material properties set the thermal conductivity to Cu_K:

    image

  3. In Variable overrides, we define a Sweep and provide a list of different values to sweep over Cu_K.

    image

  4. We set the defined sweep as an input in the simulation.

    image

  5. Doing a line plot along the axis, we can see the temperature distribution for different values of thermal conductivity [5, 10, 15].

    image

In the above case, for each of the sweep simulation, the thermal conductivity was assumed to be spatially constant since it was independent of temperature. However, the thermal conductivity is often a function of temperature K = K(T) and hence can become field dependent instead of having a single constant value.

  • The graph below shows the interpolated function of temperature dependent thermal conductivity for Residual-resistance ratio (RRR) equal to 30:

    image

  • Now, we can set the thermal conductivity in the material properties as follows.

    image

  • Now let’s say we have temperature dependent thermal conductivity for three different RRR values 30, 300 and 3000, each defined as an Interpolated function. We are interested to perform a sweep over these interpolated functions.

    image

With interpolated functions, it is not possible to create a Sweep by provide an override vector as [Cu_K_RRR30(T), Cu_K_RRR300(T), Cu_K_RRR3000(T)]. The values in the override vectors must be evaluable before simulation runtime, but interpolated functions are only evaluable during simulation runtime, when the temperature data is available.

Instead, the below approach is followed:

  1. Define a variable, say sweep_index, and provide 0 as an initial value.

  2. In material properties, Thermal conductivity, use the comp() function as comp(sweep_index, [Cu_K_RRR30(T); Cu_K_RRR300(T); Cu_K_RRR3000(T)]). image

  3. In Variable overrides, we define a new Sweep for the variable sweep_index and provide the values [0, 1, 2].

  4. In the simulation inputs, we select Sweep over sweep_index.

  5. Now during the sweep simulation, an interpolated function will be chosen depending on sweep_index. image