[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5. Short examples

5.1 Constant expression examples  
5.2 Group examples  
5.3 Function examples  
5.4 Constraint examples  
5.5 FunctionSpace examples  
5.6 Jacobian examples  
5.7 Integration examples  
5.8 Formulation examples  
5.9 Resolution examples  
5.10 PostProcessing examples  
5.11 PostOperation examples  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1 Constant expression examples

The simplest constant expression consists of an integer or a real number as in

 
21
-3

or

 
-3.1415
27e3
-290.53e-12

Using operators and the classic math functions, constant-ids can be defined:

 
c1 = Sin[2/3*3.1415] * 5000^2;
c2 = -1/c1;


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.2 Group examples

Let us assume that some elements in the input mesh have the region numbers 1000, 2000 and 3000. In the definitions

 
Group {
  Air = Region[1000]; Core = Region[2000]; Inductor = Region[3000];
  NonConductingDomain = Region[{Air, Core}];
  ConductingDomain    = Region[{Inductor}];
}

Air, Core, Inductor are identifiers of elementary region groups while NonConductingDomain and ConductingDomain are global region groups.

Groups of function type contain lists of entities built on the region groups appearing in their arguments. For example,

 
NodesOf[NonConductingDomain]

represents the group of nodes of geometrical elements belonging to the regions in NonConductingDomain and

 
EdgesOf[DomainC, Not SkinDomainC]

represents the group of edges of geometrical elements belonging to the regions in DomainC but not to those of SkinDomainC.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.3 Function examples

A physical characteristic is a piecewise defined function. The magnetic permeability mu[] can for example be defined in the considered regions by

 
Function {
  mu[Air] = 4.e-7*Pi; 
  mu[Core] = 1000.*4.e-7*Pi;
}

A nonlinear characteristic can be defined through an expression with arguments, e.g.,

 
Function {
  mu0 = 4.e-7*Pi;
  a1 = 1000.; b1 = 100.; // Constants
  mu[NonlinearCore] = mu0 + 1./(a1+b1*Norm[$1]^6);
}

where function mu[] in region NonLinearCore has one argument $1 which has to be the magnetic flux density. This function is actually called when writing the equations of a formulation, which permits to directly extend it to a nonlinear form by adding only the necessary arguments. For example, in a magnetic vector potential formulation, one may write mu[{Curl a}] instead of mu[] in Equation terms (see section 5.8 Formulation examples). Multiple arguments can be specified in a similar way: writing mu[{Curl a},{T}] in an Equation term will provide the function mu[] with two usable arguments, $1 (the magnetic flux density) and $2 (the temperature).

It is also possible to directly interpolate one-dimensional functions from tabulated data. In the following example, the function f(x) as well as its derivative f'(x) are interpolated from the (x,f(x)) couples (0,0.65), (1,0.72), (2,0.98) and (3,1.12):

 
Function {
  couples = {0, 0.65 , 1, 0.72 , 2, 0.98 , 3, 1.12};
  f[] = InterpolationLinear[$1]{List[couples]};
  dfdx[] = dInterpolationLinear[$1]{List[couples]};
}

The function f[] may then be called in an Equation term of a Formulation with one argument, x. Notice how the list of constants List[couples] is supplied as a list of parameters to the built-in function InterpolationLinear (see section 2.2 Constants, as well as 2.4 Functions). In order to facilitate the construction of such interpolations, the couples can also be specified in two separate lists, merged with the alternate list ListAlt command (see section 2.2 Constants):

 
Function {
  data_x = {0, 1, 2, 3};
  data_f = {0.65, 0.72, 0.98, 1.12};
  f[] = InterpolationLinear[$1]{ListAlt[data_x, data_f]};
  dfdx[] = dInterpolationLinear[$1]{ListAlt[data_x, data_f]};
}

In order to optimize the evaluation time of complex expressions, registers may be used (see section 2.7 Registers). For example, the evaluation of g[] = f[$1]*Sin[f[$1]^2] would require two (costly) linear interpolations. But the result of the evaluation of f[] may be stored in a register (for example the register 0) with

 
g[] = f[$1]#0 * Sin[#0^2];

thus reducing the number of evaluations of f[] (and of the argument $1) to one.

A function can also be time dependent, e.g.,

 
Function {
  Freq = 50.; Phase = 30./180.*Pi; // Constants
  TimeFct_Sin[] = Sin [ 2.*Pi*Freq * $Time + Phase ];
  TimeFct_Exp[] = Exp [ - $Time / 0.0119 ];
  TimeFct_ExtSin[] = F_Sin_wt_p [] {2.*Pi*Freq, Phase};
}

Note that TimeFct_ExtSin[] is identical to TimeFct_Sin[] in a time domain analysis, but also permits to define phasors implicitely in the case of harmonic analyses.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4 Constraint examples

Constraints are referred to in FunctionSpaces and are usually used for boundary conditions (Assign type). For example, essential conditions on two surface regions, Surf0 and Surf1, will be first defined by

 
Constraint {
  { Name DirichletBoundaryCondition1; Type Assign;
    Case {
      { Region Surf0; Value 0.; }
      { Region Surf1; Value 1.; }
    }
  }
}

The way the Values are associated with Regions (with their nodes, their edges, their global regions, ...) is defined in the FunctionSpaces which use the Constraint. In other words, a Constraint defines data but does not define the method to process them. A time dependent essential boundary condition on Surf1 would be introduced as (cf. 5.3 Function examples for the definition of TimeFct_Exp[]):

 
      { Region Surf1; Value 1.; TimeFunction 3*TimeFct_Exp[] }

It is important to notice that the time dependence cannot be introduced in the Value field, since the Value is only evaluated once during the pre-processing.

Other constraints can be referred to in Formulations. It is the case of those defining electrical circuit connections (Network type), e.g.,

 
Constraint {
  { Name ElectricalCircuit; Type Network; 
    Case Circuit1 {
      { Region VoltageSource; Branch {1,2}; }
      { Region PrimaryCoil; Branch {1,2}; }
    }
    Case Circuit2 {
      { Region SecondaryCoil; Branch {1,2}; }
      { Region Charge; Branch {1,2}; }
    }
  }
}

which defines two non-connected circuits (Circuit1 and Circuit2), with an independent numbering of nodes: region VoltageSource is connected in parallel with region PrimaryCoil, and region SecondaryCoil is connected in parallel with region Charge.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5 FunctionSpace examples

Various discrete function spaces can be defined in the frame of the finite element method.

5.5.1 Nodal finite element spaces  
5.5.2 High order nodal finite element space  
5.5.3 Nodal finite element space with floating potentials  
5.5.4 Edge finite element space  
5.5.5 Edge finite element space with gauge condition  
5.5.6 Coupled edge and nodal finite element spaces  
5.5.7 Coupled edge and nodal finite element spaces for multiply connected domains  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.1 Nodal finite element spaces

The most elementary function space is the nodal finite element space, defined on a mesh of a domain W and denoted S0(W) (associated finite elements can be of various geometries), and associated with essential boundary conditions (Dirichlet conditions). It contains 0-forms, i.e., scalar fields of potential type:

v = Sum [ vn * sn, for all n in N ], v in S0(W)

where N is the set of nodes of W, sn is the nodal basis function associated with node n and vn is the value of v at node n. It is defined by

 
FunctionSpace {
  { Name Hgrad_v; Type Form0;
    BasisFunction {
      { Name sn; NameOfCoef vn; Function BF_Node;
        Support Domain; Entity NodesOf[All]; }
    }
    Constraint {
      { NameOfCoef vn; EntityType NodesOf;
        NameOfConstraint DirichletBoundaryCondition1; }
    }
  }
}

Function sn is the built-in basis function BF_Node associated with all nodes (NodesOf) in the mesh of W (Domain). Previously defined Constraint DirichletBoundaryCondition1 (see section 5.4 Constraint examples) is used as boundary condition.

In the example above, Entity NodesOf[All] is preferred to Entity NodesOf[Domain]. In this way, the list of all the nodes of Domain will not have to be generated. All the nodes of each geometrical element in Support Domain will be directly taken into account.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.2 High order nodal finite element space

Higher order finite elements can be directly taken into account by BF_Node. Hierarchical finite elements for 0-forms can be used by simply adding other basis functions (associated with other geometrical entities, e.g., edges and facets) to BasisFunction, e.g.,

 
    ...
    BasisFunction {
      { Name sn; NameOfCoef vn; Function BF_Node;
        Support Domain; Entity NodesOf[All]; }
      { Name s2; NameOfCoef v2; Function BF_Node_2E;
        Support Domain; Entity EdgesOf[All]; }
    }
    ...


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.3 Nodal finite element space with floating potentials

A scalar potential with floating values vf on certain boundaries Gf, f in Cf, e.g., for electrostatic problems, can be expressed as

v = Sum [ vn * sn, for all n in Nv ] + Sum [ vf * sf, for all f in Cf ], v in S0(W)

where Nv is the set of inner nodes of W and each function sf is associated with the group of nodes of boundary Gf, f in Cf (SkinDomainC); sf is the sum of the nodal basis functions of all the nodes of Cf. Its function space is defined by

 
FunctionSpace {
  { Name Hgrad_v_floating; Type Form0;
    BasisFunction {
      { Name sn; NameOfCoef vn; Function BF_Node;
        Support Domain; Entity NodesOf[All, Not SkinDomainC]; }
      { Name sf; NameOfCoef vf; Function BF_GroupOfNodes; 
        Support Domain; Entity GroupsOfNodesOf[SkinDomainC]; }
    }
    GlobalQuantity {
      { Name GlobalElectricPotential; Type AliasOf; NameOfCoef vf; }
      { Name GlobalElectricCharge; Type AssociatedWith; 
        NameOfCoef vf; }
    }
    Constraint { ... }
  }
}

Two global quantities have been associated with this space: the electric potential GlobalElectricPotential, being an alias of coefficient vf, and the electric charge GlobalElectricCharge, being associated with coefficient vf.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.4 Edge finite element space

Another space is the edge finite element space, denoted S1(W), containing 1-forms, i.e., curl-conform fields:

h = Sum [ he * se, for all e in E ], h in S1(W)

where E is the set of edges of W, se is the edge basis function for edge e and he is the circulation of h along edge e. It is defined by

 
FunctionSpace {
  { Name Hcurl_h; Type Form1;
    BasisFunction {
      { Name se; NameOfCoef he; Function BF_Edge;
        Support Domain; Entity EdgesOf[All]; }
    }
    Constraint { ... }
  }
}


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.5 Edge finite element space with gauge condition

A 1-form function space containing vector potentials can be associated with a gauge condition, which can be defined as a constraint, e.g., a zero value is fixed for all circulations along edges of a tree (EdgesOfTreeIn) built in the mesh (Domain), having to be complete on certain boundaries (StartingOn Surf):

 
Constraint {
  { Name GaugeCondition_a_Mag_3D; Type Assign;
    Case {
      { Region Domain; SubRegion Surf; Value 0.; }
    }
  }
}

FunctionSpace {
  { Name Hcurl_a_Gauge; Type Form1;
    BasisFunction {
      { Name se; NameOfCoef ae; Function BF_Edge;
        Support Domain; Entity EdgesOf[All]; }
    }
    Constraint {
      { NameOfCoef ae;
        EntityType EdgesOfTreeIn; EntitySubType StartingOn;
        NameOfConstraint GaugeCondition_a_Mag_3D; }
      ...
    }
  }
}


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.6 Coupled edge and nodal finite element spaces

A 1-form function space, containing curl free fields in certain regions WcC (DomainCC) of W, which are the complementary part of Wc (DomainC) in W, can be explicitly characterized by

h = Sum [ hk * sk, for all e in Ec ] + Sum [ phin * vn, for all n in NcC ], h in S1(W)

where Ec is the set of inner edges of W, NcC is the set of nodes inside WcC and on its boundary dWcC, sk is an edge basis function and vn is a vector nodal function. Such a space, coupling a vector field with a scalar potential, can be defined by

 
FunctionSpace {
  { Name Hcurl_hphi; Type Form1;
    BasisFunction {
      { Name sk; NameOfCoef hk; Function BF_Edge; 
        Support DomainC; Entity EdgesOf[All, Not SkinDomainC]; }
      { Name vn; NameOfCoef phin; Function BF_GradNode; 
        Support DomainCC; Entity NodesOf[All]; }
      { Name vn; NameOfCoef phic; Function BF_GroupOfEdges; 
        Support DomainC; Entity GroupsOfEdgesOnNodesOf[SkinDomainC];}
    }
    Constraint {
      { NameOfCoef hk;
        EntityType EdgesOf; NameOfConstraint MagneticField; }
      { NameOfCoef phin;
        EntityType NodesOf; NameOfConstraint MagneticScalarPotential; }
      { NameOfCoef phic;
        EntityType NodesOf; NameOfConstraint MagneticScalarPotential; }
    }
  }
}

This example points out the definition of a piecewise defined basis function, e.g., function vn being defined with BF_GradNode in DomainCC and BF_GroupOfEdges in DomainC. This leads to an easy coupling between these regions.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5.7 Coupled edge and nodal finite element spaces for multiply connected domains

In case a multiply connected domain WcC is considered, basis functions associated with cuts (SurfaceCut) have to be added to the previous basis functions, which gives the function space below:

 
Group {
  _TransitionLayer_SkinDomainC_ =
    ElementsOf[SkinDomainC, OnOneSideOf SurfaceCut];
}

FunctionSpace {
  { Name Hcurl_hphi; Type Form1;
    BasisFunction {

      ... same as above ...

      { Name sc; NameOfCoef Ic; Function BF_GradGroupOfNodes;
        Support ElementsOf[DomainCC, OnOneSideOf SurfaceCut];
        Entity GroupsOfNodesOf[SurfaceCut]; }
      { Name sc; NameOfCoef Icc; Function BF_GroupOfEdges;
        Support DomainC;
        Entity GroupsOfEdgesOf
                 [SurfaceCut,
                  InSupport _TransitionLayer_SkinDomainC_]; }
    }
    GlobalQuantity {
      { Name I; Type AliasOf       ; NameOfCoef Ic; }
      { Name U; Type AssociatedWith; NameOfCoef Ic; }
    }
    Constraint {

      ... same as above ...

      { NameOfCoef Ic;
        EntityType GroupsOfNodesOf; NameOfConstraint Current; }
      { NameOfCoef Icc;
        EntityType GroupsOfNodesOf; NameOfConstraint Current; }
      { NameOfCoef U;
        EntityType GroupsOfNodesOf; NameOfConstraint Voltage; }
    }
  }
}

Global quantities associated with the cuts, i.e., currents and voltages if h is the magnetic field, have also been defined.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6 Jacobian examples

A simple Jacobian method is for volume transformations (of n-D regions in n-D geometries; n = 1, 2 or 3), e.g., in region Domain,

 
Jacobian {
  { Name Vol;
    Case {
      { Region Domain; Jacobian Vol; }
    }
  }
}

Jacobian VolAxi would define a volume Jacobian for axisymmetrical problems.

A Jacobian method can also be piecewise defined, in DomainInf, where an infinite geometrical transformation has to be made using two constant parameters (inner and outer radius of a spherical shell), and in all the other regions (All, being the default); in each case, a volume Jacobian is used. This method is defined by:

 
Jacobian {
  { Name Vol;
    Case {
      { Region DomainInf; Jacobian VolSphShell {Val_Rint, Val_Rext}; }
      { Region All; Jacobian Vol; }
    }
  }
}


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.7 Integration examples

A commonly used numerical integration method is the Gauss integration, with a number of integration points (NumberOfPoints) depending on geometrical element types (GeoElement), i.e.

 
Integration {
  { Name Int_1;
    Case { {Type Gauss;
            Case { { GeoElement Triangle   ; NumberOfPoints 4; }
                   { GeoElement Quadrangle ; NumberOfPoints 4; }
                   { GeoElement Tetrahedron; NumberOfPoints 4; }
                   { GeoElement Hexahedron ; NumberOfPoints 6; }
                   { GeoElement Prism      ; NumberOfPoints 9; } }
           }
         }
  }
}

The method above is valid for both 2D and 3D problems, for different kinds of elements.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.8 Formulation examples

5.8.1 Electrostatic scalar potential formulation  
5.8.2 Electrostatic scalar potential formulation with floating potentials and electric charges  
5.8.3 Magnetostatic 3D vector potential formulation  
5.8.4 Magnetodynamic 3D or 2D magnetic field and magnetic scalar potential formulation  
5.8.5 Nonlinearities, Mixed formulations, ...  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.8.1 Electrostatic scalar potential formulation

An electrostatic formulation using an electric scalar potential v, i.e.

( epsr grad v, grad vp ) W = 0, for all vp in S0(W),

is expressed by

 
Formulation {
  { Name Electrostatics_v; Type FemEquation;
    Quantity {
      { Name v; Type Local; NameOfSpace Hgrad_v; }
    }
    Equation { 
      Galerkin { [ epsr[] * Dof{Grad v} , {Grad v} ];
                 In Domain; Jacobian Vol; Integration Int_1; }
    }
  }
}

The density of the Galerkin term is a copy of the symbolic form of the formulation, i.e., the product of a relative permittivity function epsr[] by a vector of degrees of freedom (Dof{.}); the scalar product of this with the gradient of test function v results in a symmetrical matrix.

Note that another Quantity could be defined for test functions, e.g., vp defined by { Name vp; Type Local; NameOfSpace Hgrad_v; }. However, its use would result in the computation of a full matrix and consequently in a loss of efficiency.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.8.2 Electrostatic scalar potential formulation with floating potentials and electric charges

An extension of the formulation above can be made to take floating potentials and electrical charges into account (the latter being defined in FunctionSpace Hgrad_v_floating), i.e.

 
Formulation {
  { Name Electrostatics_v_floating; Type FemEquation;
    Quantity {
      { Name v; Type Local; NameOfSpace Hgrad_v_floating; }
      { Name V; Type Global; 
        NameOfSpace Hgrad_v_floating [GlobalElectricPotential]; }
      { Name Q; Type Global; 
        NameOfSpace Hgrad_v_floating [GlobalElectricCharge]; }
    }
    Equation { 
      Galerkin { [ epsr[] * Dof{Grad v} , {Grad v} ];
                 In Domain; Jacobian Vol; Integration Int_1; }
      GlobalTerm { [ - Dof{Q}/eps0 , {V} ]; In SkinDomainC; }
    }
  }
}

with the predefinition Function { eps0 = 8.854187818e-12; }.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.8.3 Magnetostatic 3D vector potential formulation

A magnetostatic 3D vector potential formulation

( nu curl a , curl ap ) W - ( js , ap ) Ws = 0, for all ap in S1(W) with gauge condition,

with a source current density js in inductors Ws, is expressed by

 
Formulation {
  { Name Magnetostatics_a_3D; Type FemEquation;
    Quantity {
      { Name a; Type Local; NameOfSpace Hcurl_a_Gauge; }
    }
    Equation { 
      Galerkin { [ nu[] * Dof{Curl a} , {Curl a} ];
                 In Domain; Jacobian Vol; Integration Int_1; }
      Galerkin { [ - SourceCurrentDensity[] , {a} ];
                 In DomainWithSourceCurrentDensity;
                 Jacobian Vol; Integration Int_1; }
    }
  }
}

Note that js is here given by a function SourceCurrentDensity[], but could also be given by data computed from another problem, e.g., from an electrokinetic problem (coupling of formulations) or from a fully fixed function space (constraints fixing the density, which is usually more efficient in time domain analyses).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.8.4 Magnetodynamic 3D or 2D magnetic field and magnetic scalar potential formulation

A magnetodynamic 3D or 2D h-phi formulation, i.e., coupling the magnetic field h with a magnetic scalar potential phi,

Dt ( mu h , hp ) W + ( ro curl h , curl hp ) Wc = 0, for all hp in S1(W),

can be expressed by

 
Formulation {
  { Name Magnetodynamics_hphi; Type FemEquation;
    Quantity {
      { Name h; Type Local; NameOfSpace Hcurl_hphi; }
    }
    Equation { 
      Galerkin { Dt [ mu[] * Dof{h} , {h} ];
                 In Domain; Jacobian Vol; Integration Int_1; }
      Galerkin { [ rho[] * Dof{Curl h} , {Curl h} ];
                 In DomainC; Jacobian Vol; Integration Int_1; }
    }
  }
}


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.8.5 Nonlinearities, Mixed formulations, ...

In case nonlinear physical characteristics are considered, arguments are used for associated functions, e.g., mu[{h}]. Several test functions can be considered in an Equation field. Consequently, mixed formulations can be defined.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.9 Resolution examples

5.9.1 Static resolution (electrostatic problem)  
5.9.2 Frequency domain resolution (magnetodynamic problem)  
5.9.3 Time domain resolution (magnetodynamic problem)  
5.9.4 Nonlinear time domain resolution (magnetodynamic problem)  
5.9.5 Coupled formulations  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.9.1 Static resolution (electrostatic problem)

A static resolution, e.g., for the electrostatic formulation (see section 5.8 Formulation examples), can be defined by

 
Resolution {
  { Name Electrostatics_v;
    System {
      { Name Sys_Ele; NameOfFormulation Electrostatics_v; }
    }
    Operation { 
      Generate[Sys_Ele]; Solve[Sys_Ele]; SaveSolution[Sys_Ele];
    }
  }
}

The generation (Generate) of the matrix of the system Sys_Ele will be made with the formulation Electrostatics_v, followed by its solving (Solve) and the saving of the solution (SaveSolution).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.9.2 Frequency domain resolution (magnetodynamic problem)

A frequency domain resolution, e.g., for the magnetodynamic h-phi formulation (see section 5.8 Formulation examples), is given by

 
Resolution {
  { Name Magnetodynamics_hphi;
    System {
      { Name Sys_Mag; NameOfFormulation Magnetodynamics_hphi;
        Frequency Freq; }
    }
    Operation {
      Generate[Sys_Mag]; Solve[Sys_Mag]; SaveSolution[Sys_Mag];
    }
  }
}

preceded by the definition of constant Freq, e.g.,

 
Function {
  Freq = 50.;
}


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.9.3 Time domain resolution (magnetodynamic problem)

A time domain resolution, e.g., for the same magnetodynamic h-phi formulation (see section 5.8 Formulation examples), is given by

 
Resolution {
  { Name Magnetodynamics_hphi_Time;
    System {
      { Name Sys_Mag; NameOfFormulation Magnetodynamics_hphi; }
    }
    Operation {
      InitSolution[Sys_Mag]; SaveSolution[Sys_Mag];
      TimeLoopTheta[Mag_Time0, Mag_TimeMax, Mag_DTime[], Mag_Theta[]] {
        Generate[Sys_Mag]; Solve[Sys_Mag]; SaveSolution[Sys_Mag]; 
      }
    }
  }
}

If, e.g., the Resolution above is preceded by the constant and function definitions below

 
Function {
  Tc = 10.e-3;
  Mag_Time0 = 0.; Mag_TimeMax = 2.*Tc; Mag_DTime[] = Tc/20.;
  Mag_Theta[] = 1./2.;
}

the performed time analysis will be a Crank-Nicolson scheme (theta-scheme with Theta = 0.5) with initial time 0 ms, end time 20 ms and time step 1 ms.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.9.4 Nonlinear time domain resolution (magnetodynamic problem)

In case a nonlinear problem is solved, an iterative loop has to be defined in an appropriate level of the recursive resolution operations, e.g., for the magnetodynamic problem above,

 
...
    Operation {
      InitSolution[Sys_Mag]; SaveSolution[Sys_Mag];
      TimeLoopTheta[Mag_Time0, Mag_TimeMax, Mag_DTime[], Mag_Theta[]] {
        IterativeLoop[NL_NbrMax, NL_Eps, NL_Relax] {
          GenerateJac[Sys_Mag]; SolveJac[Sys_Mag]; 
        }
        SaveSolution[Sys_Mag];
      }
    }
...

preceded by constant definitions, e.g.,

 
Function {
  NL_Eps = 1.e-4; NL_Relax = 1.; NL_NbrMax = 80;
}


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.9.5 Coupled formulations

A coupled problem, e.g., magnetodynamic (in frequency domain; Frequency Freq) - thermal (in time domain) coupling, with temperature dependent characteristics (e.g., rho[{T}], ...), can be defined by:

 
Resolution {
  { Name MagnetoThermalCoupling_hphi_T;
    System {
      { Name Sys_Mag; NameOfFormulation Magnetodynamics_hphi; 
        Frequency Freq; }
      { Name Sys_The; NameOfFormulation Thermal_T; }
    }
    Operation {
      InitSolution[Sys_Mag]; InitSolution[Sys_The];
      IterativeLoop[NL_NbrMax, NL_Eps, NL_Relax] {
        GenerateJac[Sys_Mag]; SolveJac[Sys_Mag];
        GenerateJac[Sys_The]; SolveJac[Sys_The];
      }
      SaveSolution[Sys_Mag]; SaveSolution[Sys_The];
    }
  }
}

Two systems of equations, Sys_Mag and Sys_The, will be solved iteratively until convergence (Criterion), using a relaxation factor (RelaxationFactor).

It can be seen through these examples that many resolutions can be linked or nested directly by the user, which gives a great freedom for coupled problems.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.10 PostProcessing examples

The quantities to be post-computed based on a solution of a resolution are defined, e.g., for the electrostatic problem (see section 5.8 Formulation examples; see section 5.9 Resolution examples), for the solution associated with the formulation Electrostatics_v, by

 
PostProcessing {
  { Name EleSta_v; NameOfFormulation Electrostatics_v;
    Quantity {
      { Name v; Value { Local { [ {v} ]; In Domain; } } }
      { Name e; Value { Local { [ -{Grad v} ]; In Domain; } } }
      { Name d; Value { Local { [ -eps0*epsr[] *{Grad v} ];
                                  In Domain; } } }
    }
  }
}

The electric scalar potential v (v), the electric field e (e) and the electric flux density d (d) can all be computed from the solution. They are all defined in the region Domain.

The quantities for the solution associated with the formulation Electrostatics_v_floating are defined by

 
PostProcessing {
  { Name EleSta_vf; NameOfFormulation Electrostatics_v_floating;
    Quantity {

      ... same as above ...

      { Name Q; Value { Local { [ {Q} ]; In SkinDomainC; } } }
      { Name V; Value { Local { [ {V} ]; In SkinDomainC; } } }
    }
  }
}

which points out the way to define post-quantities based on global quantities.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.11 PostOperation examples

The simplest post-processing operation is the generation of maps of local quantities, i.e., the display of the computed fields on the mesh. For example, using the PostProcessing defined in 5.10 PostProcessing examples, the maps of the electric scalar potential and of the electric field on the elements of the region Domain are defined as:

 
PostOperation {
  { Name Map_v_e; NameOfPostProcessing EleSta_v ;
     Operation {
       Print [ v, OnElementsOf Domain, File "map_v.pos" ];
       Print [ e, OnElementsOf Domain, File "map_e.pos" ];
     }
  }
}

It is also possible to display local quantities on sections of the mesh, here for example on the plane containing the points (0,0,1), (1,0,1) and (0,1,1):

 
Print [ v, OnSection { {0,0,1} {1,0,1} {0,1,1} }, File "sec_v.pos" ];

Finally, local quantities can also be interpolated on another mesh than the one on which they have been computed. Six types of grids can be specified for this interpolation: a single point, a set of points evenly distributed on a line, a set of points evenly distributed on a plane, a set of points evenly distributed in a box, a set of points defined by a parametric equation, and a set of elements belonging to a different mesh than the original one:

 
Print [ e, OnPoint {0,0,1} ];
Print [ e, OnLine { {0,0,1} {1,0,1} } {125} ];
Print [ e, OnPlane { {0,0,1} {1,0,1} {0,1,1} } {125, 75} ];
Print [ e, OnBox { {0,0,1} {1,0,1} {0,1,1} {0,0,2} } {125, 75, 85} ];
Print [ e, OnGrid {$A, $B, 1} { 0:1:1/125, 0:1:1/75, 0 } ];
Print [ e, OnGrid Domain2 ];

Many options can be used to modify the aspect of all these maps, as well as the default behaviour of the Print commands. See 4.10 Types for PostOperation, to get the list of all these options. For example, to obtain a map of the scalar potential at the barycenters of the elements on the boundary of the region Domain, in a table oriented format appended to an already existing file out.txt, the operation would be:

 
Print [ v, OnElementsOf Domain, Depth 0, Skin, Format Table, 
        File >> "out.txt" ];

Global quantities, which are associated with regions (and not with the elements of the mesh of these regions), are displayed thanks to the OnRegion operation. For example, the global potential and charge on the region SkinDomainC can be displayed with:

 
PostOperation {
  { Name Val_V_Q; NameOfPostProcessing EleSta_vf ;
     Operation {
       Print [ V, OnRegion SkinDomainC ];
       Print [ Q, OnRegion SkinDomainC ];
     }
  }
}


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

Back to geuz.org/getdp