def run_3d_apriori():
    '''Automatically choose deflation vectors with a priori bound.'''
    numpy.random.seed(0)

    def vector_factory_generator(_):
        return krypy.recycling.factories.RitzFactory(
            subsets_generator=krypy.recycling.generators.RitzSmall(
                max_vectors=20,
                ),
            subset_evaluator=krypy.recycling.evaluators.RitzApriori(
                Bound=krypy.utils.BoundMinres,
                deflweight=2.
                ),
            #print_results='values'
            )
    recycling_solver = pynosh_helper.run(
        'exp_pynosh_3d.vtu',
        RecyclingSolver=DiagRecMinres,
        recycling_solver_kwargs={'maxiter': 280},
        vector_factory_generator=vector_factory_generator
        )
    plot_resnorms(recycling_solver, 'quad bound + a priori strategy (2d)',
                  xlim=(0, 280), ylabel=None)

    return recycling_solver
def run_3d_approx():
    '''Automatically choose deflation vectors with approximate Krylov.'''
    numpy.random.seed(0)

    def vector_factory_generator(_):
        return krypy.recycling.factories.RitzFactory(
            subsets_generator=krypy.recycling.generators.RitzSmall(
                max_vectors=20,
                ),
            subset_evaluator=krypy.recycling.evaluators.RitzApproxKrylov(
                mode='extrapolate',
                pseudospectra=False,
                deflweight=2.
                ),
            #print_results='values'
            )
    recycling_solver = pynosh_helper.run(
        'exp_pynosh_3d.vtu',
        RecyclingSolver=DiagRecMinres,
        recycling_solver_kwargs={'maxiter': 280},
        vector_factory_generator=vector_factory_generator
        )
    plot_resnorms(recycling_solver, 'approximate Krylov strategy (2d)',
                  xlim=(0, 280), ylabel=None)

    return recycling_solver
Ejemplo n.º 3
0
def run_2d_vanilla():
    '''No deflation.'''
    numpy.random.seed(0)
    recycling_solver = pynosh_helper.run(
        'exp_pynosh_2d.vtu',
        RecyclingSolver=DiagRecMinres,
        recycling_solver_kwargs={'explicit_residual': True})
    plot_resnorms(recycling_solver, 'no recycling (2d)')
    plot_ritz_values(recycling_solver, 'Ritz values (2d)')

    # rerun without explicit residual for timings
    numpy.random.seed(0)
    recycling_solver = pynosh_helper.run(
        'exp_pynosh_2d.vtu',
        RecyclingSolver=DiagRecMinres,
    )
    return recycling_solver
def run_2d_vanilla():
    '''No deflation.'''
    numpy.random.seed(0)
    recycling_solver = pynosh_helper.run(
        'exp_pynosh_2d.vtu',
        RecyclingSolver=DiagRecMinres,
        recycling_solver_kwargs={'explicit_residual': True}
        )
    plot_resnorms(recycling_solver, 'no recycling (2d)')
    plot_ritz_values(recycling_solver, 'Ritz values (2d)')

    # rerun without explicit residual for timings
    numpy.random.seed(0)
    recycling_solver = pynosh_helper.run(
        'exp_pynosh_2d.vtu',
        RecyclingSolver=DiagRecMinres,
        )
    return recycling_solver
def run_3d_vanilla():
    '''No deflation.'''
    numpy.random.seed(0)
    recycling_solver = pynosh_helper.run(
        'exp_pynosh_3d.vtu',
        RecyclingSolver=DiagRecMinres,
        recycling_solver_kwargs={'maxiter': 280}
        )
    plot_resnorms(recycling_solver, 'no recycling (3d)',
                  xlim=(0, 280), ylabel=None)
    plot_ritz_values(recycling_solver, 'Ritz values (3d)')

    return recycling_solver
Ejemplo n.º 6
0
def run_3d_vanilla():
    '''No deflation.'''
    numpy.random.seed(0)
    recycling_solver = pynosh_helper.run(
        'exp_pynosh_3d.vtu',
        RecyclingSolver=DiagRecMinres,
        recycling_solver_kwargs={'maxiter': 280})
    plot_resnorms(recycling_solver,
                  'no recycling (3d)',
                  xlim=(0, 280),
                  ylabel=None)
    plot_ritz_values(recycling_solver, 'Ritz values (3d)')

    return recycling_solver
Ejemplo n.º 7
0
def run_2d_fixed():
    '''Always choose 12 Ritz vectors with Ritz values of smallest magnitude.'''
    numpy.random.seed(0)

    def vector_factory_generator(_):
        return krypy.recycling.factories.RitzFactorySimple(n_vectors=12,
                                                           which='sm')

    recycling_solver = pynosh_helper.run(
        'exp_pynosh_2d.vtu',
        RecyclingSolver=DiagRecMinres,
        vector_factory_generator=vector_factory_generator)
    plot_resnorms(recycling_solver, '12 deflation vectors (2d)')

    return recycling_solver
def run_2d_fixed():
    '''Always choose 12 Ritz vectors with Ritz values of smallest magnitude.'''
    numpy.random.seed(0)

    def vector_factory_generator(_):
        return krypy.recycling.factories.RitzFactorySimple(
            n_vectors=12,
            which='sm'
            )
    recycling_solver = pynosh_helper.run(
        'exp_pynosh_2d.vtu',
        RecyclingSolver=DiagRecMinres,
        vector_factory_generator=vector_factory_generator
        )
    plot_resnorms(recycling_solver, '12 deflation vectors (2d)')

    return recycling_solver
Ejemplo n.º 9
0
def run_3d_fixed():
    '''Always choose 12 Ritz vectors with Ritz values of smallest magnitude.'''
    numpy.random.seed(0)

    def vector_factory_generator(_):
        return krypy.recycling.factories.RitzFactorySimple(n_vectors=12,
                                                           which='sm')

    recycling_solver = pynosh_helper.run(
        'exp_pynosh_3d.vtu',
        RecyclingSolver=DiagRecMinres,
        recycling_solver_kwargs={'maxiter': 280},
        vector_factory_generator=vector_factory_generator)
    plot_resnorms(recycling_solver,
                  '12 deflation vectors (3d)',
                  xlim=(0, 280),
                  ylabel=None)

    return recycling_solver
def run_3d_fixed():
    '''Always choose 12 Ritz vectors with Ritz values of smallest magnitude.'''
    numpy.random.seed(0)

    def vector_factory_generator(_):
        return krypy.recycling.factories.RitzFactorySimple(
            n_vectors=12,
            which='sm'
            )
    recycling_solver = pynosh_helper.run(
        'exp_pynosh_3d.vtu',
        RecyclingSolver=DiagRecMinres,
        recycling_solver_kwargs={'maxiter': 280},
        vector_factory_generator=vector_factory_generator
        )
    plot_resnorms(recycling_solver, '12 deflation vectors (3d)',
                  xlim=(0, 280), ylabel=None)

    return recycling_solver
Ejemplo n.º 11
0
def run_2d_apriori():
    '''Automatically choose deflation vectors with a priori bound.'''
    numpy.random.seed(0)

    def vector_factory_generator(_):
        return krypy.recycling.factories.RitzFactory(
            subsets_generator=krypy.recycling.generators.RitzSmall(
                max_vectors=15, ),
            subset_evaluator=krypy.recycling.evaluators.RitzApriori(
                Bound=krypy.utils.BoundMinres, deflweight=2.),
            #print_results='values'
        )

    recycling_solver = pynosh_helper.run(
        'exp_pynosh_2d.vtu',
        RecyclingSolver=DiagRecMinres,
        vector_factory_generator=vector_factory_generator)
    plot_resnorms(recycling_solver, 'quad bound + a priori strategy (2d)')

    return recycling_solver
Ejemplo n.º 12
0
def run_2d_approx():
    '''Automatically choose deflation vectors with approximate Krylov.'''
    numpy.random.seed(0)

    def vector_factory_generator(_):
        return krypy.recycling.factories.RitzFactory(
            subsets_generator=krypy.recycling.generators.RitzSmall(
                max_vectors=15, ),
            subset_evaluator=krypy.recycling.evaluators.RitzApproxKrylov(
                mode='extrapolate', pseudospectra=False, deflweight=2.),
            #print_results='values'
        )

    recycling_solver = pynosh_helper.run(
        'exp_pynosh_2d.vtu',
        RecyclingSolver=DiagRecMinres,
        vector_factory_generator=vector_factory_generator)
    plot_resnorms(recycling_solver, 'approximate Krylov strategy (2d)')

    return recycling_solver