User sub routines (Groovy): How using paramSpatialCurrent[k,v]?

Example

Example Create a new 2D magneto static project. This is a plan project, with a depth of domain of 50 mm.
1

2

Define:

Creates a spatial quantity, a 3D vector:

  • Name it “ VECTOR_MUR ”,
  • Component values are

x = 5000,

y = 5,

z = 0.

Create a linear magnet “ MAGNET ” described by the Br module:

  • Remanent flux density (T) = 1.6
  • Relative permeability = 1.01

Create an user material “ MAT_1 ”:

  • Select “ User magnetic properties
  • In the tab “Spatial quantity”, select “ VECTOR_MUR

3

Attribute the material to the faces region

Attribute the region to the face…

Create face region “ MAGNET ”, “ AIR ” and “ STEEL

Assign the material “ MAT_1 ” to the “ STEEL ” region …

Assign the material “ MAGNET ” to the “ MAGNET ” region …

For the magnet region, give a magnetic direction (following axis x…)

Assign faces region to faces…

and so on….

4

Click on the “ Edit user function ” to see and modify into the python editor the groovy sub routine “MaterialLaw.groovy”.

These files are in the directory: “....YOUR_FLUX_PROJECT.FLU\persistent\groovy

5

Type the following groovy (step 8) code in the sub routine public void compute (){} :

User parameter is paramSpatialCurrent“Vector_mur”. This is a double value type. The first component starts with the 0 pointer.

Note: In the key “Vector_mur” the first letter is writing with an upper case and the following, in lower case.
6
7 Solve the project

8

x= 5000,

y = 5,

z = 0.

9

Delete the previous results and modify the Vector_mur components:

x = 5,

y = 5000,

z = 0

solve again the flux project:

10