# DerivedVariables¶

# Derived Variables¶

Derived variables are those defined in terms of variables read in from the file. Use of derived variables allows one to rename variables or set groups as vectors. One can also do variable transformations.

**Jump to**

- Variables and their metadata
- Variables that are combined with their meshes
- Data ordering
- Variables defined in terms of other variables
- Multidomain metadata
- Other metadata

**Accessing a variable by a different name**

```
Group anygroupname0 {
ATT vsType = "vsVars" // Required string
ATT vsMesh = "resultCartGrid" // [Optional string] The new variable can be associated with a different,
// though necessarily compatible, mesh.
ATT E = "YeeElecField" // Declares a new variable "E" that is equivalent to "YeeElecField"
}
```

This shows how one can use a different name for a variable. This can be useful, as some visualization tools label plots using the variable name. By default the variable is associated with the same mesh as the original variable. However, use of vsMesh allows one to associate this variable with a new mesh. This can be useful, e.g., when one wants to view the original variable on some mesh but the new variable on the transformed mesh. One use case is where one defines a uniform mesh in (r, phi, z) and by transformation gets an irregular structured mesh in (x, y, z) as shown in an example on the page on meshes.

**Defining a scalar as one component of an array**

```
Group anygroupname1 {
ATT vsType = "vsVars"
ATT weight = "electrons_6"
}
```

**Defining a vector from three scalar variables**

Below are two examples, one for fields and one for particles.

```
Group anygroupname2 {
ATT vsType = "vsVars" // Required string
ATT Evec = "{YeeElecField_0, YeeElecField_1, YeeElecField_2}" // Required string showing actual
// construction
}
```

```
Group anygroupname3 {
ATT vsType = "vsVars" // Required string
ATT velocity = "{electrons_3, electrons_4, electrons_5}" // Definition for particle variables
}
```

All components must live on the same mesh. The braces must contain 2 or 3 components for a 2D mesh and it must contain 3 components for a 3D mesh.

**Defining an array from more than three scalar variables**

For now we see no reason to have collections of variables that are not vectors.

**Defining a scalar from a mathematical expression**

```
Group anygroupname5 {
ATT vsType = "vsVars" // Required string
ATT elecEnergyDensity = "0.5*8.854e-12*(E_0*E_0 + E_1*E_1 + E_2*E_2)" // Required string definition
}
```

Definitions in terms of simple math as understood by the final visualization tool are supported.

Updated by Ted Sume over 4 years ago · 2 revisions