KADATH SPECTRAL SOLVER

Tutorial 11 : Dealing With Components In Systems

This tutorial concerns the management of components in the systems of equations.

Position of the problem

Sometimes one needs to use different equation for different components of the fields. This can be done by specifying the components to be used, when passing the concerned equation to the System_of_eqs.

It also happens that the library lost track of some symmetries. For instance, assume the unknown is a metric. It is a symmetric tensor, resulting into a set of 6 unknown components. However, when the equations are complicated, Kadath can lose track of the symmetry and find itself considering a general tensor (hence 9 components). This would result in an inconsistency. In order to cope with that, one can force the code to consider only the "right" components.

// Assume a spherical space has been defined (put 9 points in theta and 8 in phi to be safe)
// Assume a Metric_tensor gmet has been defined
// Assume two Metric_tensor ginner and gouter used for the BC (as in tutorial 10).

// General metric
Metric_general met (gmet) ;

// The system
System_of_eqs syst (space, 1) ;
met.set_system (syst, "g") ;

// One can print thel number of unknowns
// This corresponds roughly to the number of coefficients of 6 components.
cout << "Number of unknowns : " << syst.get_nbr_unknowns() << endl ;

// Pass the constants
syst.add_cst ("gin", ginner) ;
syst.add_cst ("gout", gouter) ;

// Now the equations
// Let us use a "complicated" but symmetric bulk equation
syst.add_eq_bc (1, INNER_BC, "g_ij = gin_ij") ;
syst.add_eq_inside (1, "lap(g_ij) = g_ik * R_j^k + g_jk * R_i^k") ;
syst.add_eq_bc (1, OUTER_BC, "g_ij = gout_ij") ;

// Compute the initial errors
// This ensure that the code properly determines the number of conditions
Array<double> errors (syst.sec_member()) ;

// One can print the number of conditions arising from the equations
cout << "Wrong number of conditions : " << syst.get_nbr_conditions() << endl ;

What happens is that the code has lost track that the bulk equation was symmetric and so it is considered as a 9-component tensor, thus leading to too many conditions.

Using List_comp

In order to solve the issues raised above, one needs to specify, when defining a tensorial equation, which components to consider. This is done by explicitly describing the list of components by means of the class List_comp.

// Constructor with two arguments.
// First : the number of components to be considered.
// Second : the rank (i.e. the number of indices)
List_comp used (6, 2) ; // Here 6 components of a rank-2 tensor.

// Passing of the components by hand
used.set(0)->set(0) = 1 ; used.set(0)->set(1) = 1 ; // Component xx
used.set(1)->set(0) = 1 ; used.set(1)->set(1) = 2 ; // Component xy
used.set(2)->set(0) = 1 ; used.set(2)->set(1) = 3 ; // Component xz
used.set(3)->set(0) = 2 ; used.set(3)->set(1) = 2 ; // Component yy
used.set(4)->set(0) = 2 ; used.set(4)->set(1) = 3 ; // Component yz
used.set(5)->set(0) = 3 ; used.set(5)->set(1) = 3 ; // Component zz

Now when defining the system, one can pas this List_comp to the bulk equation that will now take into account only the right components. This will lead to a number of conditions consistent with the number of unknowns.

// Define a new system, systtwo, like the first one and just use
systtwo.add_eq_inside (1, "lap(g_ij) = g_ik * R_j^k + g_jk * R_i^k", used) ;

This can also be used for other types of equations (matching and boundary conditions), if needed.