Tutorial

In this tutorial, we will model the magnetic field created by a round wire carrying a given current. The geometry has been introduced "here. The current density \(\mathbf j\) has been computed using the Thermo-Electric model.

  • the wire, represented by a cylinder,

  • the air region also represented by a cylinder.

We recall the definitions:

  • the plane circles (V0 and V1) on which will be applied some electric potential

  • the cylindrical surface (Bord) on which we will apply some cooling boundary conditions.

and for the air:

  • the plane circles (Sym0 and Sym1) on which will be applied some symetry boundary condition for the magnetostatic problem,

  • the cylindrical surface of the air region (Inf) on which we will apply infinity boundary condition for the magnetostatic problem.

1. Data

Table 1. Magnetostatic Boundary conditions

Inf

\(\mathbf{A}=\mathbf{0}\)

Sym0

\(\mathbf{A}_X =0\), \(\mathbf{A}_Y =0\)

V0

\(\mathbf{A}_X =0\), \(\mathbf{A}_Y =0\)

Sym1

\(\mathbf{A}_X =0\), \(\mathbf{A}_Y =0\)

V1

\(\mathbf{A}_X =0\), \(\mathbf{A}_Y =0\)

2. Prerequisites

  • Linux OS,

  • Basic knowledge of unix commands,

  • Nvidia Graphic video card,

  • singularity

  • Thermoelectric model tutorial

3. Setup study

  • Start a terminal

  • Create a directory to hold the study

  • Move to the created directory

  • Create an STORAGE environment variable pointing to the directory holding singularity images:

export STORAGE=/home/singularity

4. Prepare Cfg and Json files

Now we need to setup the files that define the simulation. As before we would need a cfg file to define the simulation, 2 json model files to respectively defines the thermoelectric and magnetostatic problem and finally 2 json files for the material properties (respectively for the wire and the air).

We will use and eventually modify the files used in the previous tutorial for the thermoelectric model.

4.1. cfg file definition

In the cfg we need to specify that we wil run the thermoelectric and magnetostic problem. To do so, we need to:

  • set the compute_magnetism flag to true,

  • add a section (namely |magnetostatic]) for the Magnetostatic model definition,

  • add a section (namely [ms]) for the Magnetostatic solver definition.

dim=3
geofile=cylindre.msh
geofile-path=$cfgdir

conductor_volume=Cylinder_1

compute_magnetism=true
compute_bg_magfield=false
compute_bg_magfield_bmap=false
compute_elasticity=false

[thermoelectric]
model_json=$cfgdir/thermoelec.json
weakdir=false
resolution=linear

[electro]
pc-type=boomeramg #gamg
#ksp-monitor=true
ksp-rtol=1e-7
ksp-atol=1e-5
ksp-maxit=2000
ksp-use-initial-guess-nonzero=1

[thermal]
pc-type=boomeramg #gamg
#ksp-monitor=true
ksp-rtol=1e-8
ksp-atol=1e-6
ksp-use-initial-guess-nonzero=1

[magnetostatic]
model_json=$cfgdir/magnetostatic.json
weakdir=false

[ms]
pc-type=boomeramg #gamg
ksp-monitor=true
ksp-rtol=1e-7
ksp-atol=1e-5
ksp-use-initial-guess-nonzero=1

4.2. json model for Magnetostatic

  • a json model file that defines the material and boundary conditions:

{
    "Name": "CoupledCart",
    "ShortName":"MSC",
    "Models":
    {
        "equations": "coupled-cart"
    },
    "Materials":
    {
        "Cylinder_1":
        {
            "name":"Copper",
            "filename":"$cfgdir/Cu.json"
        },
        "Air_1":
        {
            "name":"Air",
            "filename":"$cfgdir/Air.json"
        }
    },
    "BoundaryConditions":
    {
        "magnetic_potential":
        {
            "Dirichlet":
            {
                "R_inf":
                {
                    "expr":"{0,0,0}:x:y:z"
                }
	    },
            "DirichletX":
            {
                "Sym0":
                {
                    "expr":"0:x:y:z"
                },
                "Sym1":
                {
                    "expr":"0:x:y:z"
                },
                "V0":
                {
                    "expr":"0:x:y:z"
                },
                "V1":
                {
                    "expr":"0:x:y:z"
                }
	    },
            "DirichletY":
            {
                "Sym0":
                {
                    "expr":"0:x:y:z"
                },
                "Sym1":
                {
                    "expr":"0:x:y:z"
                },
                "V0":
                {
                    "expr":"0:x:y:z"
                },
                "V1":
                {
                    "expr":"0:x:y:z"
                }
        }
    },
    "PostProcess":
    {
        "Exports":
        {
            "fields": ["magneticPotential","magneticField"]
        }
    }
}

4.3. json files for material physical properties

In the case, we need to add the definition of the relative magnetic permeabilty \(\mu\). to the material used before:

{
    "name":"Cu",
    "sigma0":"50.e+6",
    "k0":"330",
    "T0":"293",
    "alpha":"3.4e-3",
    "sigma":"sigma0/(1+alpha*(T-T0)):sigma0:alpha:T:T0",
    "k":"k0*T/((1+alpha*(T-T0))*T0):k0:T:alpha:T0",
    "mu_mag": "1"
}

and add a file for the air:

{
    "name":"Air",
    "mu_mag": "1"
}

5. Run a Coupled Simulation

  • Create a directory for storing the results

mkdir Coupled
  • Run the simulation

singularity exec -B ${PWD}/Coupled:/feel \
 ${STORAGE}/hifimagnet-hifimagnet_v0.105.img \
  feelpp_hfm_coupledcartmodel_3DP1N1 --config-file cylinder.cfg

Checkout the output of the above command for any errors. You can save the output to a file log using the redirection:

singularity exec -B ${PWD}/Coupled:/feel \
 ${STORAGE}/hifimagnet-hifimagnet_v0.105.img \
  feelpp_hfm_coupledcartmodel_3DP1N1 --config-file cylinder.cfg > log 2>&1

6. Post-processing

  • Move to the directory where the results are stored

cd Coupled/.../exports/ensightgold
  • Start ensight102

  • Load the electric case

  • Load the thermoelectric case

  • Load the magnetostatic case

  • Check the value of the total current:

\[(V1-V0) = R I \qquad \text{where} R = \frac{1}{sigma} \frac{H}{\pi R^2}\]
  • Plot the electric potential distribution along the wire axis,

  • Plot the temperature distribution along the wire radial axis.

  • Plot the magnetic field distribution along the radial axis.