Skip to content

Shared expressions

Quanscient Allsolve makes use of public variables called shared expressions, that are visible in the scope of a project. This means that once you have defined a shared expression, it can be used in all sections of the application.

You might see fx symbols ( ) in various places throughout the application.

fx symbol

They serve as a reminder to the user - wherever you see an symbol, shared expressions can be used. In the image above for example, shared expression Bext is used to define external field magnetic flux density in the Y-axis.

Definition

Shared expressions are defined in the Quanscient Allsolve Properties section. They consist of 3 parameters:

  • Name
    • A short but descriptive name, by which the shared expression is referred to.
      • freq
      • Bext
  • Description (optional)
    • A description of the shared expression in a few words, if it is not obvious from the name and expression.
      • fundamental frequency
      • external field magnetic flux density
  • Expression
    • The mathematical expression by which the shared expression is defined.
    • An expression can consist of:
      • other shared expressions
      • double precision numbers in integer, double or scientific format (42, -1.72901, 1.2e-18)
      • basic algebraic operators (+, -, *, …)
      • basic math constants (pi, mu0, …)
      • Quanscient variables (t, x, …)
      • predefined functions (sin, exp, …)

To see an exhaustive list of built-in shared expressions and further technical details, see Expressions.

Shared expression use cases

Shared expressions can be utilized in many different areas during simulation setup. These include:

  • Creating geometries.
  • Setting up material properties.
  • Setting up physics interactions.
  • Overriding other shared expressions.
  • Using shared expressions for parametric sweeps.
  • Custom value outputs.

Below are some general points and a practical example for each of these use cases.


Creating geometries

Shared expressions can be very useful for parametrization during modeling.

If you want to model a real world object with known dimensions, you can start out by inputting them as shared expressions, and then move on to modeling. If there is a need to later modify the model dimensions, you can simply edit the values of your shared expressions, and then rebuild the model.

Geometry creation example: Modeling a CMUT membrane disc

  1. Start out in the Properties section by defining the CMUT membrane thickness and radius as shared expressions. CMUT membrane thickness as a shared expression
  2. Then, proceed to the Model section and add a cylinder.
  3. Use your shared expressions as dimensions for the cylinder. CMUT membrane cylinder
  4. Once all necessary elements are built and you’re satisfied with your model, click Confirm model changes.

For a more detailed example case, see source: CMUT example case.


Setting up material properties

Material properties can also be defined using shared expressions, be it setting up a new material, or modifying a predefined material. Material properties can later be easily modified through shared expressions.

Material setup example 1: Setting up a new material for a clamped-clamped beam simulation

  1. Start out in the Model section by creating a beam volume using the box element.
  2. In the Properties section, create a new material and choose your beam volume as the target.
  3. Define the shared expressions density, poisson (Poisson’s ratio) and young (Young’s modulus).
  4. Add the Density and Elasticity matrix properties to your material.
  5. Use your shared expressions to define the property expressions. New material properties setup

For a more detailed example case, see source: Backbone curve of a clamped-clamped beam.

Material setup example 2: Modifying the premade YBCO material for a quench simulation

  1. In the Model section, create a thin sheet for the YBCO layer in your tape using the box element.
  2. In the Properties section, select the YBCO material from the materials database and assign it to your sheet volume. Premade YBCO material properties
  3. The current density in the YBCO material is predefined as a constant, YBCO_Jc. Premade YBCO powerlaw shared expression
  4. Here, we modify the YBCO_PowerLaw shared expression, so that the current density is now a function of temperature, Jc(T). Temperature T and current density function Jc are added as shared expressions. Modified YBCO powerlaw shared expression

For a more detailed example case, see source: Quench - Hello World Demo.


Setting up physics interactions

In addition to material properties, many physics interactions in the Physics section can be parametrized using shared expressions.

Physics interaction example: Steady state heat transfer

  1. In the Model section, create your model geometry with a box element. Model geometry
  2. In the Properties section, create a new material and assign it to your volume. Define material properties.
  3. Then, define shared expressions h (heat transfer coefficient) and Tamb (ambient temperature).
  4. In the Physics section, add the physics in the image below. Define the heat source expression as -h * (T - Tamb). Example image

For a detailed step-by-step tutorial, see source: Steady state heat transfer in solid materials - NAFEMS Benchmark.


Overriding other shared expressions

Sometimes you might want to modify the value of a shared expression for a specific simulation. Allsolve allows you to override a shared expression for a simulation, changing the value temporarily for the runtime of that simulation. This can be used in sensitivity analysis or debugging, for example, where it is useful to quickly test the effect of changing a single parameter without modifying the original simulation setup.


Using shared expressions for parametric sweeps

One of the most powerful applications of shared expressions is in sweep simulations.

Sweeps are an extension to overrides, and a sweep with a single value as the override expression is identical to an override. Only with sweeps, a vector of values can also be input as the override expression. In this case, a series of simulations is run with each override value in the vector.

The sweep override vector can be given in two formats:

  • Vectors with just a handful of terms can be given in square brackets.
    • [90, 95, 100, 105, 110]
  • Vectors with many terms can be generated with the linspace command.
    • linspace(90, 110, 5) generates the vector [90, 95, 100, 105, 110].
    • linspace(begin, end, n)
      • begin is the value of the first vector term.
      • end is the value of the last vector term.
      • n is the number of terms in the vector.
        • The range begin - end is divided into n equal steps.
    • Naturally, the parameters begin, end, and n can also be defined as shared expressions.

With sweeps, you can easily run multiple variations of your model in one go, varying one or more parameters. Parameters to be swept must be defined as shared expressions.

Sweep example: Pull-in analysis of a MEMS device

  1. In the Properties section, create the shared expression Vdc and other shared expressions, including the model dimensions.
  2. In the Model section, create the model geometry.
  3. In the Properties section, define the model materials.
  4. In the Physics section, define the simulation physics.
  5. In the Simulations section, create a new mesh.
  6. In the Simulations section, create a new simulation.
  7. Add a Vdc sweep input to your simulation. Example image

For a detailed step-by-step tutorial, see source: Pull-in analysis of a MEMS device.


Custom value outputs

Shared expressions can be used to define custom value outputs, which are single numerical values that can be extracted from your simulation results. Custom value outputs, along with field outputs, are the two main categories of simulation outputs in Quanscient Allsolve.

Custom value output example: Superconductor AC loss

  1. In the Properties section, create the necessary shared expressions.
  2. In the Model section, create the model geometry.
  3. In the Properties section, define the model materials.
  4. In the Physics section, define the simulation physics.
  5. In the Simulations section, create a new mesh.
  6. In the Simulations section, create a new simulation.
  7. Add the HeatPowerHTS custom value output to your simulation for AC loss results in the twisted HTS filaments. Example image

For a detailed step-by-step tutorial, see source: Superconductor AC Loss.