Victor S. Borisov, Maria V. Vasilieva, and Alexandr E. Kolesov

11 Numerical study of applied problems

Abstract: In this chapter, we perform numerical studies of applied problems to illustrate features of the software considered above. The analysis of each problem begins with the formulation of a problem. Next, we generate the corresponding geometry and computational mesh. After that, we construct a suitable finite element discretization in space and apply an appropriate time-stepping technique for time-dependent problems using the FEniCs framework. Finally, we solve an obtained discrete problem and analyze results. Below, two-dimensional problems of melting/freezing, flow of an incompressible fluid, thermoelasticity processes, and the Joule heating phenomenon are studied numerically.

11.1 Heat transfer with phase transitions

Here the Stefan problem, which describes unsteady heat distribution with phase transitions, is solved numerically. We discuss a process of artificially freezing soils using vertical freezing canals as a model problem.

11.1.1 Mathematical model

A mathematical model describing temperature distribution with phase transition between solid and liquid phases at some given phase transition temperature T* in a domain Ω = Ω- u Ω+ ∪ S is presented below.

Here Ω+(t) is a domain occupied by the liquid phase (melted zone), where the temperature is higher than the phase transition temperature

e9783110359947_i0483.jpg

and Ω-(t) is a domain occupied by the solid phase (frozen zone)

e9783110359947_i0484.jpg

The phase transition takes place at the phase interface S = S(t) (Figure 11.1).

We use the classic Stefan model, which describes thermal processes accompanied by phase transformations, as well as latent heat absorption and release, for modeling heat transfer processes with phase changes:

e9783110359947_i0485.jpg

(11.1)

where L is the specific heat of phase transition.

e9783110359947_i0486.jpg

Fig. 11.1. Computational domain.

We have the following relations for the equation coefficients:

e9783110359947_i0487.jpg

where ρ+, c+ and ρ-, c- are the density and specific heat capacity of melted and frozen zones respectively.

As we are considering the process of heat distribution in a porous medium, we have the following coefficients:

e9783110359947_i0488.jpg

where m represents porosity. The sc, w, i indexes denote soil skeleton, water, and ice respectively.

We have similar relations for the thermal conductivity coefficients in the melted and frozen zone:

e9783110359947_i0489.jpg

In practice, a phase transition does not happen instantly and can occur within a small temperature interval [T* - Δ, T* + Δ]. As the function ϕ, we take ϕΔ

e9783110359947_i0490.jpg

In this case, we obtain the following equation for the temperature in the domain Ω:

The equation (11.2) is the standard nonlinear parabolic equation.

The equation (11.2) is supplemented with the initial

e9783110359947_i0492.jpg

(11.3)

and boundary conditions

e9783110359947_i0493.jpg

(11.4)

Here Γ1 is an interface with a freezing canal.

11.1.2 Finite element discretization

Discretization of the problems (11.2)-(11.4) in space is carried out via the finite element method. On multiplying the temperature equation by a test function v and integrating by parts, we obtain

e9783110359947_i0494.jpg

(11.5)

Here

e9783110359947_i0495.jpg

where H(Ω) is the Sobolev space consisting of functions v such that V2 and |∇v|2 have finite integrals over Ω.

For simplicity, we define a uniform time grid thus:

e9783110359947_i0496.jpg

and apply the standard backward Euler (fully implicit) scheme for time-stepping. We use the simplest linearization where coefficients depend on the previous time level value of the function to linearize the equation:

e9783110359947_i0497.jpg

(11.6)

where T“ = T(tn)V. In order to perform calculations, we must go from the continuous variational problem (11.6) to a discrete one. In doing so, we introduce finite dimensional spaces Vh,e9783110359947_i0498.jpg and define the following problem: find ThVh, such that

e9783110359947_i0499.jpg

(11.7)

where e9783110359947_i0500.jpg. Note that the choice of the space e9783110359947_i0501.jpg follows directly from the type of finite elements used.

11.1.3 Numerical implementation

Let us consider a problem in 2D formulation. Due to the peculiarities of FEniCs, making the transition to 3D formulation is no problem.

The process of numerical solution consists of the following steps:

  • – building a geometry and generating meshes;
  • – the numerical implementation of the constructed algorithm in FEniCS;
  • – visualizing obtained results.

To build a 2D geometrical model and generate a mesh using the previously discussed Gmsh, we define the geometry of our domain in the following geo-file:

e9783110359947_i0502.jpg
e9783110359947_i0503.jpg

We open this file in Gmsh and click the 2D button (if necessary we can refine our meshes) to generate a mesh. Next, we save the generated mesh in the msh format in the rock.msh file. To use this mesh in FEniCs, we convert it by applying the dolfin-convert utility.

e9783110359947_i0504.jpg

The implementation of the computational algorithm is performed by means of FEniCS. We describe our problem in the Temperature. ufl file, where we define the bilinear and linear forms of the variational formulation (11.7):

e9783110359947_i0505.jpg
e9783110359947_i0506.jpg

From Temperature. ufl, using the command

e9783110359947_i0507.jpg

we generate the Temperature. h file to use in the main program.

The program for calculations is written in c++. In the main. cpp file, we include the dolfin. h library and generated header file Temperature. h:

Listing 11.1.

e9783110359947_i0508.jpg

We create the computational mesh from the rock. xml file as well as the mesh function with boundary part marks from the rock_facet_region. xml file:

Listing 11.2.

e9783110359947_i0509.jpg

Next, we define the function space for the temperature:

Listing 11.3.

e9783110359947_i0510.jpg

Further, we create the functions T and T0:

Listing 11.4.

e9783110359947_i0511.jpg

The latter function is used to store the value corresponding to the previous time level.

Now we define constants for the time step, the temperature of the freezing canal, and various coefficients of the equation:

Listing 11.5.

e9783110359947_i0512.jpg

We create the Dirichlet boundary condition using the mesh function, where we specify the temperature of the freezing canal:

Listing 11.6.

e9783110359947_i0513.jpg

Then we define the initial temperature distribution:

Listing 11.7.

e9783110359947_i0514.jpg

Next, we create the bilinear and linear forms and prescribe their coefficients:

Listing 11.8.

e9783110359947_i0515.jpg

To solve the problem, we should define the matrix, the vector on the right and the linear solver. Here we choose the gmres method with the ilu (default) preconditioner:

Listing 11.9.

e9783110359947_i0516.jpg

To visualize the results, e.g. in ParaView, we will save them as a vtk file:

Listing 11.10.

e9783110359947_i0517.jpg

We use the time loop with the constant time step for integration in time:

Listing 11.11.

e9783110359947_i0518.jpg

Further, we assemble the matrix and vector, apply the boundary condition to them, and calculate the temperature:

Listing 11.12.

e9783110359947_i0519.jpg

The results of the current time level are written in the file:

Listing 11.13.

e9783110359947_i0520.jpg

At the end of the loop, the value of the current time level is assigned to the value of the previous time level, and we move to the next time level:

Listing 11.14.

e9783110359947_i0521.jpg

11.1.4 Predictions

Here we present the results of the numerical simulation of the artificial freezing process. Calculations are conducted in the geometrical domain which is 2 meters long in both directions. The freezing canal has a radius of 0.1 meter and is located on the right of the domain. The computational mesh consists of 15,064 triangle cells. The time step is τ = 0.1 day. The temperature distribution after 1, 10, and 30 days is shown in Figure 11.2.

e9783110359947_i0522.jpg

Fig. 11.2. Temperature distribution after 1,10, and 30 days (from left to right).

It is interesting to compare the zero isotherms (T = 0) obtained on three computational meshes with (a) 920, (b) 3,768, and (c) 15,064 cells presented in Figure 11.3.

e9783110359947_i0523.jpg

Fig. 11.3. Meshes. From left to right: (a) 920; (b) 3,768; (c) 15,064.

Below, we present a comparison of the temperature dynamics (the isotherm T = 0 after various periods of time: 1, 5, 10, 20, 30 days) for different values of the time step τ (Figure 11.4). Calculations are performed for Δ = 1 using the mesh with 15,064 cells. The value of the time step greatly affects the solution error; calculation with the minimal time step τ = 0.1 gives the most accurate solution.

e9783110359947_i0524.jpg

Fig. 11.4. Comparison of the temperature for different moments (in days) with different time steps r: 0.1 (blue), 0.25 (green), and 0.5 (red).

The effect of smearing the phase transition on the error of the solution is shown in Figure 11.5. The comparison is performed for the mesh with 15,064 cells and τ = 0.1 day. It is easy to observe that the large interval of smearing leads to a loss of accuracy.

e9783110359947_i0525.jpg

Fig. 11.5. Comparison of the temperature for different moments (in days) with different Δ: 1.0 (blue), 1.5 (green), and 2.0 (red).

Figure 11.6 demonstrates the influence of mesh size on the error of the solution. The calculations are performed for τ = 0.1 day and Δ = 1. The figure illustrates the convergence of the solution by refining the computational mesh.

e9783110359947_i0526.jpg

Fig. 11.6. Comparison of the temperature for different moments (in days) with different meshes: 920 cells (blue), 3,788 cells (green), and 15,064 cells (red).

11.2 Lid-driven cavity flow

The present section deals with the solution of a 2D problem of an incompressible fluid flow. Namely, a laminar flow in a square cavity with a moving lid is investigated numerically.

11.2.1 Incompressible Navier-Stokes equations

In the domain Ω presented in Figure 11.7, we consider a fluid flow governed by the Navier-Stokes equations:

e9783110359947_i0527.jpg

(11.8)

Here u(x, t) is the velocity and p(x, t) stands for the pressure. As for the Reynolds number

e9783110359947_i0528.jpg

v is the reference value of the velocity, L is the length of the square cavity walls, and v denotes the kinematic viscosity. The Reynolds number is a dimensionless value defining the ratio of nonlinear and dissipative terms. Flow behavior changes essentially depending on its value. Thus, if the Reynolds number is more than the critical value, flow becomes turbulent instead of laminar.

We set nonzero velocity to bring the fluid into motion at the rigid top of the cavity Γ1. Other boundaries of the cavity Γ2 are fixed rigid walls, i.e. no-slip and no-permeability conditions are imposed on them. Therefore, we supplement our system (11.8) with the following boundary conditions:

e9783110359947_i0529.jpg

(11.9)

e9783110359947_i0530.jpg

Fig. 11.7. Computational domain.

Finally, we specify the initial conditions:

e9783110359947_i0531.jpg

11.2.2 Variational formulation

There are many methods to approximate the system of equations in time (11.8). For simplicity, we define a uniform time grid

e9783110359947_i0532.jpg

Here we employ the Douglas-Rachford splitting scheme with nonlinear coefficients taken from the previous time level:

e9783110359947_i0533.jpg

(11.10)

e9783110359947_i0534.jpg

(11.11)

e9783110359947_i0535.jpg

(11.12)

We calculate un+1 and pn+1 at the current time level in three steps:

  • – calculate the intermediate velocity;
  • – evaluate the new pressure pn+1;
  • – compute the final velocity un+1.

Let us rewrite these problems in variational forms. For velocity, we define the Sobolev space V(Ω), consisting of vector functions u such that u2, (div u)2 , and |grad u|2 have finite integrals over Ω:

e9783110359947_i0536.jpg

where g is the Dirichlet boundary condition. Similarly, we define the following space for pressure:

e9783110359947_i0537.jpg

On multiplying (11.10) by the test function v and integrating by parts, we get the variational problem: find u* ∈ V such that

e9783110359947_i0538.jpg

(11.13)

Next, we subtract (11.10) from (11.11) and take the divergence:

e9783110359947_i0539.jpg

Since div un+1 = 0, the term with un+1 disappears. By multiplying the obtained equation by the test function q and integrating over Ω, we arrive at the problem: find pn+1Q such that

e9783110359947_i0540.jpg

(11.14)

We again subtract (11.10) from (11.11). Next, we multiply the resulting equation by v and integrate over the domain. We arrive at the problem: find un+1V such that

e9783110359947_i0541.jpg

(11.15)

To go from variational problems (11.13)–(11.15) to discrete ones, we define the finite dimensional spaces Vh, e9783110359947_i0542.jpg, Qh, and e9783110359947_i0543.jpg contained in V, e9783110359947_i0544.jpg, Q, and e9783110359947_i0545.jpg, respectively.

First, we search e9783110359947_i0546.jpg such that

e9783110359947_i0547.jpg

(11.16)

The second discrete problem is to find e9783110359947_i0548.jpg such that

e9783110359947_i0549.jpg

(11.17)

And finally, find e9783110359947_i0550.jpg such that

e9783110359947_i0551.jpg

(11.18)

As for the spaces Vh and Qh, we use the standard Lagrange spaces of second and first order, respectively.

11.2.3 Numerical algorithm

Gmsh is employed to create a 2D geometrical model and generate meshes. The geometry of our domain is written in the file cavity. geo:

e9783110359947_i0552.jpg

For further application, we convert the obtained mesh using dol fin-convert:

e9783110359947_i0553.jpg

The numerical algorithm is implemented using FEniCS. The problem statement is described in the file step. ufl, where we define linear and bilinear forms from (11.16)- (11.18):

e9783110359947_i0554.jpg

From this ufl-file, we generate a class to apply it in the main source code:

e9783110359947_i0555.jpg

As usual, the program is written in the C++ programming language. We include the library dolfin. h and the header file step. h generated above in this program:

Listing 11.15.

e9783110359947_i0556.jpg

Next, we create the computational mesh from the file cavity.xml, and the mesh function with boundary marks from the file cavity_facet_region. xml:

Listing 11.16.

e9783110359947_i0557.jpg

We then define spaces for velocity and pressure:

Listing 11.17.

e9783110359947_i0558.jpg

We initialize the function for the previous time level u0, p0, for intermediate velocity ut, and unknown functions u and p:

Listing 11.18.

e9783110359947_i0559.jpg

We should specify constant values for the time step tau, Reynolds number Re, boundary conditions onezero, and zerozero:

Listing 11.19.

e9783110359947_i0560.jpg

Further, we create the Dirichlet boundary conditions:

Listing 11.20.

e9783110359947_i0561.jpg

We introduce the bilinear and linear forms and preset their coefficients:

Listing 11.21.

e9783110359947_i0562.jpg

Next, it is necessary to define matrices and vectors of linear systems. We also specify linear solvers which use the gmres method with the default preconditioner:

Listing 11.22.

e9783110359947_i0563.jpg

The VTK format is chosen to save computed results for further post-processing:

Listing 11.23.

e9783110359947_i0564.jpg

The loop in time with the constant time step is arranged for the time-integration.

Listing 11.24.

e9783110359947_i0565.jpg

We calculate the intermediate velocity after assembling the matrix and vector and applying boundary conditions:

Listing 11.25.

e9783110359947_i0566.jpg

Next, we evaluate the new pressure. Note that we do not apply any boundary conditions:

Listing 11.26.

e9783110359947_i0567.jpg

And finally, we compute the final velocity:

Listing 11.27.

e9783110359947_i0568.jpg

After this, we write the results into the files:

Listing 11.28.

e9783110359947_i0569.jpg

We assign the value of the current time level to the functions corresponding to the previous time level and move to the next time level.

Listing 11.29.

e9783110359947_i0570.jpg

11.2.4 Computational experiments

The results of numerical experiments for this fluid flow problem are presented below. Calculations are conducted using the mesh with 3,794 cells (see Figure 11.8) and the time step τ = 0.01. The final time is T = 20.

e9783110359947_i0571.jpg

Fig. 11.8. Computational mesh.

The velocity vector field for Re = 1000 at the final moment treated as the steady-state solution is shown in Figure 11.9. The velocity components are depicted in Figure 11.10.

We employ the Stream Tracer With Custom Source filter of ParaView to show streamlines. The process of vortex formation for Re = 1000 is shown in Figure 11.11 for different moments in time.

The velocities at the final time t = 20 for different Reynolds numbers 10, 100, and 1000 are presented in Figure 11.12. It is easy to see that an increase of the Reynolds number changes vortex behavior due to the greater influence of convective terms of the Navier-Stokes equations.

e9783110359947_i0572.jpg

Fig. 11.9. Velocity vector field.

e9783110359947_i0573.jpg

Fig. 11.10. Velocity components.

e9783110359947_i0574.jpg

Fig. 11.11. Streamlines for Re = 1000 at different moments.

e9783110359947_i0575.jpg

Fig. 11.12. Streamlines for Re = 10, Re = 100, Re = 1000 (from left to right).

11.3 Steady thermoelasticity problem

We now consider a steady linear system of equations for the temperature and thermoelastic displacements which describe the state of a body and arising stresses. We investigate the stress state of a two-layer plate under the influence of temperature fields as a model problem.

11.3.1 Governing equations

Displacement u, strain ε, and stress σ occur in an elastic body under mechanical and thermal effects. External (surface or volume) forces which impact the body are treated as mechanical effects, whereas for thermal influences, we mean heat exchange processes between the body surface and environment, and release or absorption of heat by the sources inside the body.

e9783110359947_i0576.jpg

Fig. 11.13. Computational domain.

The mathematical model of the thermoelastic state of the body in a domain Ω = Ω1 ∪ Ω2 involves the following coupled system of equations for the displacement u and temperature T:

Here µ, λ, denote Lame constants, k is the heat conduction coefficient, T0 stands for the constant absolute temperature at which the body is in an initial state of equilibrium, and α = αT(3λ + 2µ), where αT is the linear thermal expansion coefficient.

Let us supplement equations (11.19) with appropriate boundary conditions for temperature:

e9783110359947_i0578.jpg

(11.20)

where Tair is the ambient temperature and y denotes the convective heat transfer coefficient.

As for boundary conditions for the displacement, we define the point fixation, i.e. in the upper lefthand corner

e9783110359947_i0579.jpg

in the upper righthand corner

e9783110359947_i0580.jpg

and the remaining surfaces are free σ = 0.

11.3.2 Finite element technique

It is necessary to create a finite element discretization in space to numerically solve the problem (11.19)-(11.20). We integrate the equations over the domain Ω and apply Green’s formula, which results in

e9783110359947_i0581.jpg

(11.21)

where

e9783110359947_i0582.jpg

where H(Ω) is the Sobolev space.

We proceed from the continuous variational problem (11.21) to the discrete one. Let us define the finite-dimensional spaces VhV, Qh ⊂ Q and e9783110359947_i0583.jpg and formulate a discrete problem on them: find ThQh, uh,Vh such that

e9783110359947_i0584.jpg

(11.22)

As for spaces Vh and Qh, the standard spaces of Lagrange polynomials of the second and first degree, respectively, are used.

11.3.3 Algorithm of calculations

The problem being considered is solved using the finite element platform FEniCS. We use the Gmsh software to build a 2D geometrical model and generate a mesh. The geometry of the computational domain is defined by the following geo-file:

e9783110359947_i0585.jpg

We generate the computational mesh block. msh from the file block. geo, and then convert it to the xml format using the dol fin-convert utility.

The variational formulation of the problem is described in the file ThermoElasticity. ufl, where we define bilinear and linear forms for displacement, temperature and stress. At the beginning, we introduce spaces to search for functions:

e9783110359947_i0586.jpg
e9783110359947_i0587.jpg

Let us define constants for the coefficients of equations and boundary conditions:

e9783110359947_i0588.jpg

Functions are also introduced for deformation and stress:

e9783110359947_i0589.jpg

The functions T and q, bilinear and linear forms for temperature are defined as

e9783110359947_i0590.jpg

Also, the functions u and v are introduced for displacement evaluation and bilinear and linear forms are specified:

e9783110359947_i0591.jpg

We define the necessary functions and forms to compute the arising stresses:

e9783110359947_i0592.jpg

From the file ThermoElasticity. ufl by calling the command

e9783110359947_i0593.jpg

we generate the file ThermoElasticity. h to import into the main program.

For the numerical solution, we include dolfin.h library, the header file ThermoElasticity.h generated earlier and define the class PinPoint for (the upper left and right) point allocation to define Dirichlet boundary conditions on them:

Listing 11.30.

e9783110359947_i0594.jpg

We create an object for the computational grid from the block.xml file, an object with marks for computational domain boundaries and the file containing subdomains marks:

Listing 11.31.

e9783110359947_i0595.jpg

Next, we introduce spaces for the temperature and displacement:

Listing 11.32.

e9783110359947_i0596.jpg

We create the unknowns T and u:

Listing 11.33.

e9783110359947_i0597.jpg

Further, we define equation coefficients and boundary condition parameters:

Listing 11.34.

e9783110359947_i0598.jpg

It is necessary to specify Dirichlet boundary conditions for displacement (the upper left and upper right points of fixation) and for temperature (a constant temperature on the upper and lower boundaries):

Listing 11.35.

e9783110359947_i0599.jpg
e9783110359947_i0600.jpg

Next, we create objects for bilinear and linear forms and indicate necessary objects of functions or constants:

Listing 11.36.

e9783110359947_i0601.jpg

We create objects for matrices and vectors and define linear solvers (by default, it is the direct ILU-factorization method):

Listing 11.37.

e9783110359947_i0602.jpg

Further, we assemble matrices and vectors, apply Dirichlet boundary conditions and calculate temperature and displacement:

Listing 11.38.

e9783110359947_i0603.jpg
e9783110359947_i0604.jpg

For visualization of the following results, function values are saved in vtk-format, which can be visualized using the ParaView program:

Listing 11.39.

e9783110359947_i0605.jpg

For visualization of the arising stresses, functions and forms (bilinear and linear) are defined and the results are saved in the file:

Listing 11.40.

e9783110359947_i0606.jpg

11.3.4 Numerical results

We now discuss the numerical results of the above problem. Computations were carried out for a plate 0.02 meters long and consisting of two layers 0.01 and 0.002 meters thick, respectively. The computational grid depicted in Fig. 11.14 has 21,952 triangular cells.

e9783110359947_i0607.jpg

Fig. 11.14. Computational grid.

Distributions of temperature and displacements are presented in Figures 11.15, 11.16, and 11.17, respectively. Arising stresses are shown in Figure 11.18.

e9783110359947_i0608.jpg

Fig. 11.15. Temperature distribution.

e9783110359947_i0609.jpg

Fig. 11.16. Displacement distribution along the x axis.

e9783110359947_i0610.jpg

Fig. 11.17. Displacement distribution along the y axis.

e9783110359947_i0611.jpg

Fig. 11.18. Stress distribution (von Mizes) along the x direction (from left to right).

11.4 Joule heating problem

The numerical solution of an unsteady problem of Joule heating is presented here. This process is described by a system of equations for temperature and electric potential.

11.4.1 Problem formulation

Let us consider a problem of electric current flowing through a conductor, where heat loss is significant due to current transmission. On the one hand, increasing the conductor temperature is governed by the Joule heating law; on the other hand, the electrical properties of the conductor depend on the temperature.

We consider stationary electric fields, which are induced by currents flowing in a continuum. Let j = j(x) be the electric current density at the point x. This field satisfies the equation

e9783110359947_i0612.jpg

(11.23)

For the electric field intensity E, we have

e9783110359947_i0613.jpg

(11.24)

These equations must be supplemented by a relation which couples j and E. From Ohm’s law for an immobile medium, we get

e9783110359947_i0614.jpg

(11.25)

where σ is the electrical conductivity coefficient.

According to (11.24), the electric field has a potential, and it is therefore possible to describe it introducing the potential φ such that

e9783110359947_i0615.jpg

(11.26)

Substituting (11.26) in (11.25) and taking (11.23) into account, we get the elliptic equation for electric potential:

e9783110359947_i0616.jpg

(11.27)

Here

e9783110359947_i0617.jpg

where u is the temperature.

The time-dependent temperature field is governed by the equation

e9783110359947_i0618.jpg

(11.28)

where c is the volumetric heat capacity of a conducting medium and k stands for the heat conduction coefficient.

When current flowing through a conductor generates heat, the value at a particular point depends on the current and electric field intensity and equals (Joule’s law):

e9783110359947_i0619.jpg

(11.29)

Therefore, the system of equations describing thermoelectric processes may be written in the following form:

for x ∈ Ω, Ω = Ω1 ∪ Ω2 and t ∈ [0, T] (see Figure 11.19).

The system of equations (11.30) is supplemented with the initial

e9783110359947_i0621.jpg
e9783110359947_i0622.jpg

Fig. 11.19. Computational domain.

and the boundary conditions for the temperature:

e9783110359947_i0623.jpg

as well as boundary conditions for the potential:

e9783110359947_i0624.jpg

Here ΓD is the boundary, where potential is defined (ΓD = Γ1Γ6), ΓR denotes the boundary that exchanges heat with the environment, Tair is the air temperature of the environment, and α stands for an empirical coefficient of heat transfer R = Γ1Γ2Γ3Γ4).

11.4.2 Discrete problem

We need to perform discretization of the system of equations (11.30) using the finite element method. Multiply the potential equation by the test function v and integrate using Green’s formula; this results in the equation

e9783110359947_i0625.jpg

(11.31)

Similarly, by multiplying the temperature equation by the test function q and integrating it over the computational domain, we get

e9783110359947_i0626.jpg

(11.32)

Here

e9783110359947_i0627.jpg

where H(Ω) is the Sobolev space consisting of functions v such that V2 and |∇v|2 have finite integrals over Ω.

We apply the backward Euler (fully implicit) scheme to approximate the temperature equation in time.

e9783110359947_i0628.jpg

(11.33)

e9783110359947_i0629.jpg

(11.34)

Now we must proceed from the continuous variational problem (11.33)-(11.34) to the discrete one. We introduce finite-dimensional spaces VhV, QhQ and e9783110359947_i0630.jpg, e9783110359947_i0631.jpg, and define the discrete problem on them: find uh, ∈ Qh, φhVh, such that

e9783110359947_i0632.jpg

(11.35)

e9783110359947_i0633.jpg

(11.36)

As for spaces Vh and Qh, we use default Lagrange polynomial spaces.

11.4.3 Computational algorithm

We build a computational domain and generate a mesh using the Gmsh software to solve the above problem numerically. The computational domain is 5 mm long in both directions and includes the domain Ω1 as the electricity conducting element, which is 1 mm thick and 2 mm long. Next is the cup, which is 0.3 mm thick, and the domain Ω2 occupied by a conducting fluid which is heated by passing the electric current through it:

e9783110359947_i0634.jpg

The domain is built by setting dots and lines to define surfaces:

e9783110359947_i0635.jpg
e9783110359947_i0636.jpg

Next, boundary conditions and subdomains are marked:

e9783110359947_i0637.jpg

We generate a 2D mesh for the domain and save it in the file mesh.msh. Then we convert the generated mesh into the xml-format:

e9783110359947_i0638.jpg

The numerical algorithm is implemented in the FEniCS framework. The problem statement is described in the ufl-file, where we define linear and bilinear forms:

e9783110359947_i0639.jpg
e9783110359947_i0640.jpg

The above ufl-file includes definitions of three bilinear and three linear forms for evaluating temperature and electric potential as well as for the visualization of the influence of the electric potential on heat.

We generate the header file Joule. h from the ufl-file in order to import it into the main source code:

e9783110359947_i0641.jpg

It is also necessary to include the dolfin.h library in addition to the header file Joule.h:

Listing 11.41.

e9783110359947_i0642.jpg

We create an object for the computational mesh taken from the file mesh. xml, an object with marks for computational domain boundaries and an object including marks for subdomains Ω1 and Ω2:

Listing 11.42.

e9783110359947_i0643.jpg

Next, we introduce spaces for the temperature and electric potential:

Listing 11.43.

e9783110359947_i0644.jpg

We also create functions T and phi for the required solution, and the function for storing temperature values corresponding to the previous time level:

Listing 11.44.

e9783110359947_i0645.jpg

Further, we define constants for the time step, environment temperature, and equation coefficients:

Listing 11.45.

e9783110359947_i0646.jpg

It is also necessary to create Dirichlet boundary conditions for the electric potential. The appropriate space, boundary value, and object with boundary marks are specified in the parameters:

Listing 11.46.

e9783110359947_i0647.jpg

Now we define the initial temperature distribution:

Listing 11.47.

e9783110359947_i0648.jpg

Next, we create objects for bilinear and linear forms. We must introduce the appropriate functions or constants for each object from the forms:

Listing 11.48.

e9783110359947_i0649.jpg

Further, we create objects for matrices and vectors for evaluating mesh functions, specify linear solvers (gmres is applied as the iterative solver for both searching variables):

Listing 11.49.

e9783110359947_i0650.jpg

The values from each time level are saved as files in the vtk format for post-processing of the results, and can be visualized by ParaView:

Listing 11.50.

e9783110359947_i0651.jpg

Time-integration is carried out with a uniform time step. We display the current step on the screen:

Listing 11.51.

e9783110359947_i0652.jpg

Then matrices and vectors are assembled, boundary conditions are applied, and temperature and electric potential are evaluated at the new time level:

Listing 11.52.

e9783110359947_i0653.jpg

Results for the current time level are saved into the files:

Listing 11.53.

e9783110359947_i0654.jpg

At the end of the time step calculations, the values from the current time level are assigned to the objects storing the previous time level values:

Listing 11.54.

e9783110359947_i0655.jpg

We compute the auxiliary function f = σ| grad φ|2 to visualize the released heat:

Listing 11.55.

e9783110359947_i0656.jpg

11.4.4 Numerical simulations

The numerical results obtained for the above problem are presented below. Computations were carried out on the grid with 7,845 triangular cells shown in Figure 11.20 with the time step equalling τ = 1 minute up to the final time Tmax = 60 minute. On boundary Γ1, the Dirichlet boundary condition φ = 1 is imposed for the electric potential, and on boundary Γ6, the potential value is treated as zero. Robin boundary conditions are specified on boundaries Γ1, Γ2, and Γ4 for the temperature, where heat exchange from iron to the environment with the temperature Tair = 22.0 is imposed. Heat exchange with a lower coefficient of convective heat transfer is given on boundary Γ3.

Computational results for temperature, electrical potential and function f are depicted in Figures 11.21, 11.23 and 11.24, respectively. Figure 11.22 shows the time-histories for the maximal and minimal temperatures which illustrate the evolution of the temperature to a quasi-stationary state.

e9783110359947_i0657.jpg

Fig. 11.20. Computational grid.

e9783110359947_i0658.jpg

Fig. 11.21. Temperature distribution after 1, 2 and 3 hours (from left to right).

e9783110359947_i0659.jpg

Fig. 11.22. Maximal and minimal temperature time-histories.

e9783110359947_i0660.jpg

Fig. 11.23. Electric potential distribution after 3 hours.

e9783110359947_i0661.jpg

Fig. 11.24. Distribution of the f = σ| grad φ|2 function.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset