Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into travis_py35
Browse files Browse the repository at this point in the history
  • Loading branch information
renefritze committed Nov 3, 2016
2 parents 53c4cfe + 981ae28 commit 6ab06b1
Show file tree
Hide file tree
Showing 13 changed files with 172 additions and 291 deletions.
10 changes: 5 additions & 5 deletions docs/source/getting_started.rst
Expand Up @@ -114,13 +114,13 @@ First, we will import the most commonly used methods and classes of pyMOR
by executing:

>>> from pymor.basic import *
Loading pymor version 0.3.0
Loading pymor version 0.5.0

Next we will instantiate a class describing the analytical problem
we want so solve. In this case, a
:class:`~pymor.analyticalproblems.thermalblock.ThermalBlockProblem`:
:meth:`~pymor.analyticalproblems.thermalblock.thermal_block_problem`:

>>> p = ThermalBlockProblem(num_blocks=(3, 2))
>>> p = thermal_block_problem(num_blocks=(3, 2))

We want to discretize this problem using the finite element method.
We could do this by hand, creating a |Grid|, instatiating
Expand All @@ -129,8 +129,8 @@ operators for each subblock of the domain, forming a |LincombOperator|
to represent the affine decomposition, instantiating a
:class:`~pymor.operators.cg.L2ProductFunctionalP1` as right hand side, and
putting it all together into a |StationaryDiscretization|. However, since
:class:`~pymor.analyticalproblems.thermalblock.ThermalBlockProblem` derives
form :class:`~pymor.analyticalproblems.elliptic.EllipticProblem`, we can use
:meth:`~pymor.analyticalproblems.thermalblock.thermal_block_problem` returns
a :class:`~pymor.analyticalproblems.elliptic.EllipticProblem`, we can use
a predifined *discretizer* to do the work for us. In this case, we use
:func:`~pymor.discretizers.elliptic.discretize_elliptic_cg`:

Expand Down
2 changes: 1 addition & 1 deletion docs/source/substitutions.py
Expand Up @@ -61,7 +61,7 @@
.. |CacheRegion| replace:: :class:`~pymor.core.cache.CacheRegion`
.. |EllipticProblem| replace:: :class:`~pymor.analyticalproblems.elliptic.EllipticProblem`
.. |ParabolicProblem| replace:: :class:`~pymor.analyticalproblems.parabolic.ParabolicProblem`
.. |InstationaryProblem| replace:: :class:`~pymor.analyticalproblems.instationary.InstationaryProblem`
.. |InstationaryAdvectionProblem| replace:: :class:`~pymor.analyticalproblems.advection.InstationaryAdvectionProblem`
.. |RectDomain| replace:: :class:`~pymor.domaindescriptions.basic.RectDomain`
Expand Down
12 changes: 6 additions & 6 deletions src/pymor/analyticalproblems/burgers.py
Expand Up @@ -37,10 +37,10 @@ def burgers_problem(v=1., circle=True, initial_data_type='sin', parameter_range=
assert initial_data_type in ('sin', 'bump')

if initial_data_type == 'sin':
initial_data = ExpressionFunction('0.5 * (sin(2 * pi * x[..., 0]) + 1.)', 1, ())
initial_data = ExpressionFunction('0.5 * (sin(2 * pi * x) + 1.)', 1, ())
dirichlet_data = ConstantFunction(dim_domain=1, value=0.5)
else:
initial_data = ExpressionFunction('(x[..., 0] >= 0.5) * (x[..., 0] <= 1) * 1.', 1, ())
initial_data = ExpressionFunction('(x >= 0.5) * (x <= 1) * 1.', 1, ())
dirichlet_data = ConstantFunction(dim_domain=1, value=0.)

return InstationaryAdvectionProblem(
Expand All @@ -55,10 +55,10 @@ def burgers_problem(v=1., circle=True, initial_data_type='sin', parameter_range=

rhs=None,

flux_function=ExpressionFunction("sign(x) * abs(x)**mu['exponent'] * v",
flux_function=ExpressionFunction('sign(x) * abs(x)**exponent * v',
1, (1,), {'exponent': ()}, {'v': v}),

flux_function_derivative=ExpressionFunction("mu['exponent'] * sign(x) * abs(x)**(mu['exponent']-1) * v",
flux_function_derivative=ExpressionFunction('exponent * sign(x) * abs(x)**(exponent-1) * v',
1, (1,), {'exponent': ()}, {'v': v}),

parameter_space=CubicParameterSpace({'exponent': 0}, *parameter_range),
Expand Down Expand Up @@ -114,10 +114,10 @@ def burgers_problem_2d(vx=1., vy=1., torus=True, initial_data_type='sin', parame

rhs=None,

flux_function=ExpressionFunction("sign(x) * abs(x)**mu['exponent'] * v",
flux_function=ExpressionFunction("sign(x) * abs(x)**exponent * v",
1, (2,), {'exponent': ()}, {'v': np.array([vx, vy])}),

flux_function_derivative=ExpressionFunction("mu['exponent'] * sign(x) * abs(x)**(mu['exponent']-1) * v",
flux_function_derivative=ExpressionFunction("exponent * sign(x) * abs(x)**(exponent-1) * v",
1, (2,), {'exponent': ()}, {'v': np.array([vx, vy])}),

parameter_space=CubicParameterSpace({'exponent': 0}, *parameter_range),
Expand Down
56 changes: 56 additions & 0 deletions src/pymor/analyticalproblems/instationary.py
@@ -0,0 +1,56 @@
# -*- coding: utf-8 -*-
# This file is part of the pyMOR project (http://www.pymor.org).
# Copyright 2013-2016 pyMOR developers and contributors. All rights reserved.
# License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)

from pymor.core.interfaces import ImmutableInterface


class InstationaryProblem(ImmutableInterface):
"""Instationary problem description.
This class desciribes an instationary problem of the form ::
| ∂_t u(x, t, μ) + A(u(x, t, μ), t, μ) = f(x, t, μ),
| u(x, 0, μ) = u_0(x, μ)
where A, f are given by the problem's `stationary_part` and
t is allowed to vary in the interval [0, T].
Parameters
----------
stationary_part
The stationary part of the problem.
initial_data
|Function| providing the initial values u_0.
T
The final time T.
parameter_space
|ParameterSpace| for the problem.
name
Name of the problem.
Attributes
----------
T
stationary_part
parameter_space
name
"""

with_arguments = None # with_arguments is an read-only property in the base class
_own_with_arguments = frozenset({'stationary_part', 'initial_data', 'T', 'parameter_space', 'name'})

def __init__(self, stationary_part, initial_data, T=1., parameter_space=None, name=None):

self.stationary_part = stationary_part
self.initial_data = initial_data
self.T = T
self.parameter_space = parameter_space or stationary_part.parameter_space
self.name = name or ('instationary_' + stationary_part.name)
self.with_arguments = self._own_with_arguments.union(stationary_part.with_arguments)

def with_(self, **kwargs):
arguments = {kwargs.pop(k, getattr(self, k)) for k in self._own_with_arguments}
arguments['stationary_part'] = arguments['stationary_part'].with_(**kwargs)
return InstationaryProblem(**arguments)
184 changes: 0 additions & 184 deletions src/pymor/analyticalproblems/parabolic.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/pymor/basic.py
Expand Up @@ -22,7 +22,7 @@
from pymor.analyticalproblems.burgers import burgers_problem, burgers_problem_2d
from pymor.analyticalproblems.elliptic import EllipticProblem
from pymor.analyticalproblems.helmholtz import helmholtz_problem
from pymor.analyticalproblems.parabolic import ParabolicProblem
from pymor.analyticalproblems.instationary import InstationaryProblem
from pymor.analyticalproblems.thermalblock import thermal_block_problem

from pymor.core.cache import clear_caches, enable_caching, disable_caching
Expand Down

0 comments on commit 6ab06b1

Please sign in to comment.