implementations.convergence_controller_classes.adaptive_collocation module

class AdaptiveCollocation(controller, params, description, **kwargs)[source]

Bases: ConvergenceController

This convergence controller allows to change the underlying quadrature between iterations.

Supplying multiple quadrature rules will result in a change to a new quadrature whenever the previous one is converged until all methods given are converged, at which point the step is ended. Whenever the quadrature is changed, the solution is interpolated from the old nodes to the new nodes to ensure accelerated convergence compared to starting from the initial conditions.

Use this convergence controller by supplying parameters that the sweeper accepts as a list to the params. For instance, supplying ``` params = {

‘num_nodes’: [2, 3],

}

will use collocation methods like you passed to the sweeper_params in the description object, but will change the number of nodes to 2 before the first iteration and to 3 as soon as the 2-node collocation problem is converged. This will override whatever you set for the number of nodes in the sweeper_params, but you still need to set something to allow instantiation of the levels before this convergence controller becomes active. Make sure all lists you supply here have the same length.

Feel free to set logger_level = 15 in the controller parameters to get comprehensive text output on what exactly is happening.

This convergence controller has various applications.
  • You could try to obtain speedup by doing some inexactness. It is currently possible to set various residual tolerances, which will be passed to the levels, corresponding to the accuracy with which each collocation problem is solved.

  • You can compute multiple solutions to the same initial value problem with different order. This allows, for instance, to do adaptive time stepping.

When trying to obtain speedup with this, be ware that the interpolation is not for free. In particular, it is necessary to reevaluate the right hand side at all nodes afterwards.

check_parameters(controller, params, description, **kwargs)[source]

Check if we allow the scheme to solve the collocation problems to convergence.

Parameters:
  • controller (pySDC.Controller) – The controller

  • params (dict) – The params passed for this specific convergence controller

  • description (dict) – The description object used to instantiate the controller

Returns:

Whether the parameters are compatible str: The error message

Return type:

bool

matmul(A, b)[source]

Matrix vector multiplication, possibly MPI parallel. The parallel implementation performs a reduce operation in every row of the matrix. While communicating the entire vector once could reduce the number of communications, this way we never need to store the entire vector on any specific rank.

Parameters:
  • A (2d np.ndarray) – Matrix

  • b (list) – Vector

Returns:

Axb

Return type:

List

post_iteration_processing(controller, S, **kwargs)[source]

Switch to the next collocation method if the current one is converged.

Parameters:
  • controller (pySDC.Controller.controller) – The controller

  • S (pySDC.Step.step) – The current step

Returns:

None

post_spread_processing(controller, S, **kwargs)[source]

Overwrite the sweeper parameters with the first collocation parameters set up here.

Parameters:
  • controller (pySDC.Controller.controller) – The controller

  • S (pySDC.Step.step) – The current step

Returns:

None

reset_status_variables(controller, **kwargs)[source]

Reset the status variables between time steps.

Parameters:

controller (pySDC.Controller.controller) – The controller

Returns:

None

setup(controller, params, description, **kwargs)[source]

Record what variables we want to vary.

Parameters:
  • controller (pySDC.Controller.controller) – The controller

  • params (dict) – The params passed for this specific convergence controller

  • description (dict) – The description object used to instantiate the controller

Returns:

The updated params dictionary

Return type:

(dict)

setup_status_variables(controller, **kwargs)[source]

Add an index for which collocation method to use.

Parameters:

controller (pySDC.Controller.controller) – The controller

Returns:

None

switch_sweeper(S)[source]

Update to the next sweeper in line.

Parameters:

S (pySDC.Step.step) – The current step

Returns:

None