pymordemos package

Submodules

analyze_pickle module

Analyze pickled data demo.

Usage:
analyze_pickle.py histogram [–detailed=DETAILED_DATA] [–error-norm=NORM] REDUCED_DATA SAMPLES analyze_pickle.py convergence [–detailed=DETAILED_DATA] [–error-norm=NORM] [–ndim=NDIM] REDUCED_DATA SAMPLES analyze_pickle.py (-h | –help)

This demo loads a pickled reduced discretization, solves for random parameters, estimates the reduction errors and then visualizes these estimates. If the detailed discretization and the reductor are also provided, the estimated error is visualized in comparison to the real reduction error.

The needed data files are created by the thermal block demo, by setting the ‘–pickle’ option.

Arguments:

REDUCED_DATA File containing the pickled reduced discretization.

SAMPLES Number of parameter samples to test with.

Options:
--detailed=DETAILED_DATA
 File containing the high-dimensional discretization and the reductor.
--error-norm=NORM
 Name of norm in which to compute the errors.
--ndim=NDIM Number of reduced basis dimensions for which to estimate the error.

pymordemos.analyze_pickle.analyze_pickle_convergence(args)[source]

pymordemos.analyze_pickle.analyze_pickle_demo(args)[source]

pymordemos.analyze_pickle.analyze_pickle_histogram(args)[source]

burgers module

Burgers demo.

Solves a two-dimensional Burgers-type equation. See pymor.analyticalproblems.burgers for more details.

Usage:
burgers.py [-hp] [–grid=NI] [–grid-type=TYPE] [–initial-data=TYPE] [–lxf-lambda=VALUE] [–nt=COUNT]
[–not-periodic] [–num-flux=FLUX] [–vx=XSPEED] [–vy=YSPEED] EXP
Arguments:
EXP Exponent
Options:
--grid=NI Use grid with (2*NI)*NI elements [default: 60].
--grid-type=TYPE
 Type of grid to use (rect, tria) [default: rect].
--initial-data=TYPE
 Select the initial data (sin, bump) [default: sin]
--lxf-lambda=VALUE
 Parameter lambda in Lax-Friedrichs flux [default: 1].
--nt=COUNT Number of time steps [default: 100].
--not-periodic Solve with dirichlet boundary conditions on left and bottom boundary.
--num-flux=FLUX
 Numerical flux to use (lax_friedrichs, engquist_osher) [default: lax_friedrichs].
-h, --help Show this message.
--vx=XSPEED Speed in x-direction [default: 1].
--vy=YSPEED Speed in y-direction [default: 1].

pymordemos.burgers.burgers_demo(args)[source]

burgers_ei module

Burgers with EI demo.

Model order reduction of a two-dimensional Burgers-type equation (see pymor.analyticalproblems.burgers) using the reduced basis method with empirical operator interpolation.

Usage:
burgers_ei.py [options] EXP_MIN EXP_MAX EI_SNAPSHOTS EISIZE SNAPSHOTS RBSIZE
Arguments:

EXP_MIN Minimal exponent

EXP_MAX Maximal exponent

EI_SNAPSHOTS Number of snapshots for empirical interpolation.

EISIZE Number of interpolation DOFs.

SNAPSHOTS Number of snapshots for basis generation.

RBSIZE Size of the reduced basis

Options:
--cache-region=REGION
 Name of cache region to use for caching solution snapshots (NONE, MEMORY, DISK, PERSISTENT) [default: DISK]
--grid=NI Use grid with (2*NI)*NI elements [default: 60].
--grid-type=TYPE
 Type of grid to use (rect, tria) [default: rect].
--initial-data=TYPE
 Select the initial data (sin, bump) [default: sin]
--lxf-lambda=VALUE
 Parameter lambda in Lax-Friedrichs flux [default: 1].
--not-periodic Solve with dirichlet boundary conditions on left and bottom boundary.
--nt=COUNT Number of time steps [default: 100].
--num-flux=FLUX
 Numerical flux to use (lax_friedrichs, engquist_osher) [default: lax_friedrichs].
-h, --help Show this message.
-p, --plot-err Plot error.
--plot-ei-err Plot empirical interpolation error.
--plot-error-landscape
 Calculate and show plot of reduction error vs. basis sizes.
--plot-error-landscape-N=COUNT
 Number of basis sizes to test [default: 10]
--plot-error-landscape-M=COUNT
 Number of collateral basis sizes to test [default: 10]
--plot-solutions
 Plot some example solutions.
--test=COUNT Use COUNT snapshots for stochastic error estimation [default: 10].
--vx=XSPEED Speed in x-direction [default: 1].
--vy=YSPEED Speed in y-direction [default: 1].
--ipython-engines=COUNT
 If positive, the number of IPython cluster engines to use for parallel greedy search. If zero, no parallelization is performed. [default: 0]
--ipython-profile=PROFILE
 IPython profile to use for parallelization.

pymordemos.burgers_ei.main(args)[source]

elliptic module

Simple demonstration of solving the Poisson equation in 2D using pyMOR’s builtin discretizations.

Usage:
elliptic.py [–fv] [–rect] PROBLEM-NUMBER DIRICHLET-NUMBER NEUMANN-NUMBER NEUMANN-COUNT
Arguments:

PROBLEM-NUMBER {0,1}, selects the problem to solve

DIRICHLET-NUMBER {0,1,2}, selects the Dirichlet data function

NEUMANN-NUMBER {0,1}, selects the Neumann data function

NEUMANN-COUNT 0: no neumann boundary
1: right edge is neumann boundary 2: right+top edges are neumann boundary 3: right+top+bottom edges are neumann boundary
Options:
-h, --help Show this message.
--fv Use finite volume discretization instead of finite elements.
--rect Use RectGrid instead of TriaGrid.

pymordemos.elliptic.elliptic_demo(args)[source]

elliptic2 module

Simple demonstration of solving the Poisson equation in 2D using pyMOR’s builtin discretizations.

Usage:
elliptic2.py [–fv] PROBLEM-NUMBER N
Arguments:

PROBLEM-NUMBER {0,1}, selects the problem to solve

N Triangle count per direction

Options:
-h, --help Show this message.
--fv Use finite volume discretization instead of finite elements.

pymordemos.elliptic2.elliptic2_demo(args)[source]

elliptic_oned module

Proof of concept for solving the Poisson equation in 1D using linear finite elements and our grid interface

Usage:
elliptic_oned.py [–fv] PROBLEM-NUMBER N
Arguments:

PROBLEM-NUMBER {0,1}, selects the problem to solve

N Grid interval count

Options:
-h, --help Show this message.
--fv Use finite volume discretization instead of finite elements.

pymordemos.elliptic_oned.elliptic_oned_demo(args)[source]

elliptic_unstructured module

Simple demonstration of solving the Poisson equation in 2D on a circular sector domain of radius 1 using an unstructured mesh.

Note that Gmsh (http://geuz.org/gmsh/) is required for meshing.

Usage:
elliptic_unstructured.py [–fv] ANGLE NUM_POINTS CLSCALE
Arguments:

ANGLE The angle of the circular sector.

NUM_POINTS The number of points that form the arc of the circular sector.

CLSCALE Mesh element size scaling factor.

Options:
-h, --help Show this message.
--fv Use finite volume discretization instead of finite elements.

pymordemos.elliptic_unstructured.elliptic_gmsh_demo(args)[source]

parabolic module

Simple demonstration of solving parabolic equations using pyMOR’s builtin discretization toolkit.

Usage:
parabolic.py [options] heat TOP parabolic.py [options] dar SPEED
Arguments:
TOP The heat diffusion coefficient for the top bars. SPEED The advection speed.
Options:
-h, --help Show this message.
--fv Use finite volume discretization instead of finite elements.
--rect Use RectGrid instead of TriaGrid.
--grid=NI Use grid with NIxNI intervals [default: 100].
--nt=COUNT Number of time steps [default: 100].

pymordemos.parabolic.parabolic_demo(args)[source]

parabolic_mor module

Reduced basis approximation of the heat equation.

Usage:
parabolic_mor.py [options] BACKEND ALG SNAPSHOTS RBSIZE TEST
Arguments:

BACKEND Discretization toolkit to use (pymor, fenics).

ALG The model reduction algorithm to use
(greedy, adaptive_greedy, pod).
SNAPSHOTS greedy/pod: number of training set parameters
adaptive_greedy: size of validation set.

RBSIZE Size of the reduced basis.

TEST Number of test parameters for reduction error estimation.


pymordemos.parabolic_mor.discretize_fenics()[source]

pymordemos.parabolic_mor.discretize_pymor()[source]

pymordemos.parabolic_mor.main(BACKEND, ALG, SNAPSHOTS, RBSIZE, TEST)[source]

pymordemos.parabolic_mor.reduce_adaptive_greedy(d, reductor, validation_mus, basis_size)[source]

pymordemos.parabolic_mor.reduce_greedy(d, reductor, snapshots, basis_size)[source]

pymordemos.parabolic_mor.reduce_pod(d, reductor, snapshots, basis_size)[source]

thermalblock module

Thermalblock demo.

Usage:
thermalblock.py [options] XBLOCKS YBLOCKS SNAPSHOTS RBSIZE thermalblock.py -h | –help
Arguments:

XBLOCKS Number of blocks in x direction.

YBLOCKS Number of blocks in y direction.

SNAPSHOTS naive: ignored

greedy/pod: Number of training_set parameters per block
(in total SNAPSHOTS^(XBLOCKS * YBLOCKS) parameters).

adaptive_greedy: size of validation set.

RBSIZE Size of the reduced basis

Options:
--adaptive-greedy-rho=RHO
 See pymor.algorithms.adaptivegreedy [default: 1.1].
--adaptive-greedy-gamma=GAMMA
 See pymor.algorithms.adaptivegreedy [default: 0.2].
--adaptive-greedy-theta=THETA
 See pymor.algorithms.adaptivegreedy [default: 0.]
--alg=ALG The model reduction algorithm to use (naive, greedy, adaptive_greedy, pod) [default: greedy].
--cache-region=REGION
 Name of cache region to use for caching solution snapshots (none, memory, disk, persistent) [default: none].
--extension-alg=ALG
 Basis extension algorithm (trivial, gram_schmidt) to be used [default: gram_schmidt].
--fenics Use FEniCS discretization.
--grid=NI Use grid with 4*NI*NI elements [default: 100].
-h, --help Show this message.
--ipython-engines=COUNT
 If positive, the number of IPython cluster engines to use for parallel greedy search. If zero, no parallelization is performed. [default: 0]
--ipython-profile=PROFILE
 IPython profile to use for parallelization.
--list-vector-array
 Solve using ListVectorArray[NumpyVector] instead of NumpyVectorArray.
--order=ORDER Polynomial order of the Lagrange finite elements to use in FEniCS discretization [default: 1].
--pickle=PREFIX
 Pickle reduced discretizaion, as well as reductor and high-dimensional discretization to files with this prefix.
--plot-err Plot error.
--plot-solutions
 Plot some example solutions.
--plot-error-sequence
 Plot reduction error vs. basis size.
--product=PROD Product (euclidean, h1) w.r.t. which to orthonormalize and calculate Riesz representatives [default: h1].
--reductor=RED Reductor (error estimator) to choose (traditional, residual_basis) [default: residual_basis]
--test=COUNT Use COUNT snapshots for stochastic error estimation [default: 10].
--greedy-without-estimator
 Do not use error estimator for basis generation.

pymordemos.thermalblock.discretize_fenics(xblocks, yblocks, grid_num_intervals, element_order)[source]

pymordemos.thermalblock.discretize_pymor(xblocks, yblocks, grid_num_intervals, use_list_vector_array)[source]

pymordemos.thermalblock.main(args)[source]

pymordemos.thermalblock.parse_arguments(args)[source]

pymordemos.thermalblock.reduce_adaptive_greedy(d, reductor, validation_mus, extension_alg_name, max_extensions, use_estimator, rho, gamma, theta, pool)[source]

pymordemos.thermalblock.reduce_greedy(d, reductor, snapshots_per_block, extension_alg_name, max_extensions, use_estimator, pool)[source]

pymordemos.thermalblock.reduce_naive(d, reductor, basis_size)[source]

pymordemos.thermalblock.reduce_pod(d, reductor, snapshots_per_block, basis_size)[source]

thermalblock_adaptive module

Modified thermalblock demo using adaptive greedy basis generation algorithm.

Usage:
thermalblock_adaptive.py [options] RBSIZE thermalblock_adaptive.py -h | –help
Arguments:
RBSIZE Size of the reduced basis
Options:
-h, --help Show this message.
--without-estimator
 Do not use error estimator for basis generation.
--extension-alg=ALG
 Basis extension algorithm (trivial, gram_schmidt) to be used [default: gram_schmidt].
--grid=NI Use grid with 2*NI*NI elements [default: 100].
--pickle=PREFIX
 Pickle reduced discretizaion, as well as reductor and high-dimensional discretization to files with this prefix.
-p, --plot-err Plot error.
--plot-solutions
 Plot some example solutions.
--plot-error-sequence
 Plot reduction error vs. basis size.
--product=PROD Product (euclidean, h1) w.r.t. which to orthonormalize and calculate Riesz representatives [default: h1].
--reductor=RED Reductor (error estimator) to choose (traditional, residual_basis) [default: residual_basis]
--test=COUNT Use COUNT snapshots for stochastic error estimation [default: 10].
--ipython-engines=COUNT
 If positive, the number of IPython cluster engines to use for parallel greedy search. If zero, no parallelization is performed. [default: 0]
--ipython-profile=PROFILE
 IPython profile to use for parallelization.
--cache-region=REGION
 Name of cache region to use for caching solution snapshots (NONE, MEMORY, DISK, PERSISTENT) [default: NONE]
--list-vector-array
 Solve using ListVectorArray[NumpyVector] instead of NumpyVectorArray.
--visualize-refinement
 Visualize the training set refinement indicators.
--validation-mus
 Size of validation set. [default: 0]
--rho=VALUE Maximum allowed ratio between error on validation set and on training set [default: 1.1].
--gamma=VALUE Weight factor for age penalty term in refinement indicators [default: 0.2].
--theta=VALUE Ratio of elements to refine [default: 0.].

pymordemos.thermalblock_adaptive.thermalblock_demo(args)[source]

thermalblock_gui module

Thermalblock with GUI demo

Usage:
thermalblock_gui.py [-h] [–product=PROD] [–grid=NI] [–testing]
[–help] XBLOCKS YBLOCKS SNAPSHOTS RBSIZE
Arguments:

XBLOCKS Number of blocks in x direction.

YBLOCKS Number of blocks in y direction.

SNAPSHOTS Number of snapshots for basis generation per component.
In total SNAPSHOTS^(XBLOCKS * YBLOCKS).

RBSIZE Size of the reduced basis

Options:
--grid=NI Use grid with 2*NI*NI elements [default: 60].
--product=PROD Product (euclidean, h1) w.r.t. which to orthonormalize and calculate Riesz representatives [default: h1].
--testing load the gui and exit right away (for functional testing)
-h, --help Show this message.

class pymordemos.thermalblock_gui.AllPanel(parent, reduced_sim, detailed_sim)[source]

Bases: object


class pymordemos.thermalblock_gui.DetailedSim(args)[source]

Bases: pymordemos.thermalblock_gui.SimBase

Methods

DetailedSim solve

class pymordemos.thermalblock_gui.ParamRuler(parent, sim)[source]

Bases: object

Methods

ParamRuler enable

class pymordemos.thermalblock_gui.RBGui(args)[source]

Bases: QMainWindow


class pymordemos.thermalblock_gui.ReducedSim(args)[source]

Bases: pymordemos.thermalblock_gui.SimBase

Methods

ReducedSim solve

class pymordemos.thermalblock_gui.SimBase(args)[source]

Bases: object


class pymordemos.thermalblock_gui.SimPanel(parent, sim)[source]

Bases: object

Methods

SimPanel solve_update

thermalblock_simple module

Simplified version of the thermalblock demo.

Usage:
thermalblock_simple.py [options] MODEL ALG SNAPSHOTS RBSIZE TEST
Arguments:

MODEL High-dimensional model (pymor, fenics, ngsolve, pymor-text).

ALG The model reduction algorithm to use
(naive, greedy, adaptive_greedy, pod).

SNAPSHOTS naive: ignored

greedy/pod: Number of training_set parameters per block
(in total SNAPSHOTS^(XBLOCKS * YBLOCKS) parameters).

adaptive_greedy: size of validation set.

RBSIZE Size of the reduced basis.

TEST Number of parameters for stochastic error estimation.


pymordemos.thermalblock_simple.discretize_fenics()[source]

pymordemos.thermalblock_simple.discretize_ngsolve()[source]

pymordemos.thermalblock_simple.discretize_pymor()[source]

pymordemos.thermalblock_simple.discretize_pymor_text()[source]

pymordemos.thermalblock_simple.main()[source]

pymordemos.thermalblock_simple.reduce_adaptive_greedy(d, reductor, validation_mus, basis_size)[source]

pymordemos.thermalblock_simple.reduce_greedy(d, reductor, snapshots, basis_size)[source]

pymordemos.thermalblock_simple.reduce_naive(d, reductor, basis_size)[source]

pymordemos.thermalblock_simple.reduce_pod(d, reductor, snapshots, basis_size)[source]