Tutorial

In this tutorial, we will model a round wire carrying a given current.

The wire will be designed in Salome as a cylinder. We will distinct:

  • 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.

The thermoelectric model will be used to model the electrical potential distribution and the temperature field.

1. Data

The cylinder is defined by its radius \(R\), its heigth \(H\). The cylinder symetry axis is \(Oz\).

Table 1. Geometrical Data

R [ \(m\) ]

H [ \(m\) ]

8.e-3

16.e3

Table 2. Input Data

Boundary

\(V\)

V0

0

V1

0.05

Table 3. Input Data

Boundary

\(h\) [ \(K/W/m^2\) ]

\(T_w\) [ \(K\) ]

Bord

8.e+4

293

2. Prerequisites

  • Linux OS,

  • Basic knowledge of unix commands,

  • Nvidia Graphic video card,

  • singularity

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. Create Geometry and a Mesh

  • Start Salome using singularity container:

singularity exec --nv -B /opt/DISTENE:/opt/DISTENE:ro \
  ${STORAGE}/hifimagnet-salome:8.5.0.simg salome
  • Select the GEOM module

  • Create a cylinder

  • Explode the faces of the cylinder

  • Rename the faces

  • Mark the cylinder object as selected

  • Switch to the SMESH module

  • Create a Mesh

  • Create 2D Mesh hypothesis with MG-CADSurf

  • Create 3D Mesh hypothesis with MG-Tetra

  • Compute the mesh

  • Create Groups from geometry

  • Export the mesh in MED format

  • Convert MED mesh to GMSH format mesh:

gmsh -3 -bin cylindre.med -o cylindre.msh

5. Prepare Cfg and Json files

Now we need to setup the files that define the simulation:

  • a cfg file that defines the simulation:

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

conductor_volume=Cylinder_1

compute_magnetism=false
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
  • a json model file that defines the material and boundary conditions:

{
    "Name": "CoupledCart",
    "ShortName":"MSC",
    "Models":
    {
        "equations": "thermoelectric-linear"
    },
    "Materials":
    {
        "Cylinder_1":
        {
            "name":"Copper",
            "filename":"$cfgdir/Cu.json"
        }
    },
    "BoundaryConditions":
    {
        "potential":
        {
            "Dirichlet":
            {
                "V0":
                {
                    "expr1":"0.",
		    "expr2":"Cylinder_1"
                },
                "V1":
                {
                    "expr1":"0.05",
		    "expr2":"Cylinder_1"
                }
            }
        },
        "temperature":
        {
            "Robin":
            {
                "R":
                {
                    "expr1":"80000",
                    "expr2":"293"
                }
            }
        }
    },
    "PostProcess":
    {
        "Exports":
        {
            "fields": ["temperature","potential","joules","current"]
        }
    }
}
  • a json file that defines the physical properties of the material:

{
    "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"
}

6. Run a linear ThermoElectric Simulation

  • Create a directory for storing the results

mkdir Linear
  • Run the simulation

singularity exec -B ${PWD}/Linear:/feel \
 ${STORAGE}/hifimagnet-hifimagnet_v0.105.img \
  feelpp_hfm_thermoelectric_model_3D_V1T1_N1 --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}/Linear:/feel \
 ${STORAGE}/hifimagnet-hifimagnet_v0.105.img \
  feelpp_hfm_thermoelectric_model_3D_V1T1_N1 --config-file cylinder.cfg > log 2>&1

7. Post-processing

  • Move to the directory where the results are stored

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

  • Load the electric case

  • Load the thermoelectric case

  • Check the value of the total current:

\[(V1-V0) = R I \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.

8. To go further

In this final section, we will move to more realistic models and simulations use cases:

  • In a first section we will see how to perform nonlinear simulation.

  • Then we will see how to run simulation with an imposed total current.

  • Finally we will show how to run simulation in parallel (aka on a SMP machine or cluster).

8.1. Run a nonlinear ThermoElectric Simulation

  • Prepare a new cfg file

To perform non-linear thermoelectric simulation, you have to:

  • edit or create a new cfg file; switch from linear to picard resolution in the cfg file,

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

conductor_volume=Cylinder_1

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

[thermoelectric]
model_json=$cfgdir/nl-thermoelec.json
weakdir=false
resolution=picard

[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

To control the non linear algorithm, you can add the following lines in the cfg file after the definition of the resolution method to be used:

itmax_picard=20
eps_potential=1.e-4
eps_temperature=1.e-4
  • Create a new json model file: nl-thermoelec.json

The new nl-thermoelec.json is almost similar to thermoelec.json except for the line defining the equations :

{
    "Name": "CoupledCart",
    "ShortName":"MSC",
    "Models":
    {
        "equations": "thermoelectric-nonlinear"
    },
    "Materials":
    {
        "Cylinder_1":
        {
            "name":"Copper",
            "filename":"$cfgdir/Cu.json"
        }
    },
    "BoundaryConditions":
    {
        "potential":
        {
            "Dirichlet":
            {
                "V0":
                {
                    "expr1":"0.",
		    "expr2":"Cylinder_1"
                },
                "V1":
                {
                    "expr1":"0.05",
		    "expr2":"Cylinder_1"
                }
            }
        },
        "temperature":
        {
            "Robin":
            {
                "R":
                {
                    "expr1":"80000",
                    "expr2":"293"
                }
            }
        }
    },
    "PostProcess":
    {
        "Exports":
        {
            "fields": ["temperature","potential","joules","current"]
        }
    }
}
  • Create a directory for storing the results

mkdir NonLinear
  • Run the simulation

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

8.2. Enforcing the total current

One may want to force the total current \(I\) in the wire. To do so:

  • edit or create an new cfg file,

  • in the [thermoelectric] section, add the lines:

[thermoelectric]
model_json=$cfgdir/nl-thermoelec.json
weakdir=false
resolution=picard
update_intensity=true
marker_intensity=V1
target_intensity=-21513
eps_intensity=5.e-3

Then, as usual:

  • create a new directory ImposedCurrent for the result

  • run the simulation using the newly created directory as the new /feel

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

8.3. Run a parallel ThermoElectric Simulation

For large mesh size, it may be convenient to run the simulation in parallel. As an example, we will prepare the data to run on 4 procs.

To do so you need to:

  • partition the mesh into 4 parts:

singularity exec ${STORAGE}/hifimagnet-hifimagnet_v0.105.img \
 feelpp_mesh_partitioner --ifile cylindre.msh --ofile cylindre_p --part 4

This command creates a mesh that can be used to run the simulation on 4 processors. The output parallel mesh consists actually in a set of two files:

  • cylindre_p.json

  • cylindre_p.h5

Then, as usual:

  • edit or a create a new cfg file;

dim=3
geofile=cylindre_p.json
geofile-path=$cfgdir
...
  • create a new directory for the results

  • run the simulation on 4 processors using the command bellow:

singularity exec -B ${PWD}/Parallel:/feel \
 ${STORAGE}/hifimagnet-hifimagnet_v0.105.img \
  mpirun -np 4 feelpp_hfm_thermoelectric_model_3D_V1T1_N1 --config-file cylinder.cfg