@@ -0,0 +1,3149 @@
+# -*- coding: utf-8 -*-%0A# This file is part of the pyMor project (http://www.pymor.org).%0A# Copyright Holders: Felix Albrecht, Rene Milk, Stephan Rave%0A# License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)%0A%0Afrom __future__ import absolute_import, division, print_function%0A%0Aimport numpy as np%0A%0Aimport pymor.core as core%0Afrom pymor.tools import Named%0Afrom pymor.domaindescriptions import RectDomain, TorusDomain, BoundaryType%0Afrom pymor.functions import ConstantFunction, GenericFunction%0Afrom pymor.analyticalproblems.advection import InstationaryAdvectionProblem%0Afrom pymor.parameters.spaces import CubicParameterSpace%0A%0A%0Aclass BurgersProblem(InstationaryAdvectionProblem):%0A%0A    def __init__(self, vx = 1., vy = 1., torus=True, initial_data='sin', parameter_range=(1., 2.)):%0A%0A        assert initial_data in ('sin', 'bump')%0A%0A        def burgers_flux(U, mu):%0A            U_exp = np.sign(U) * np.power(np.abs(U), mu%5B'exponent'%5D)%0A            R = np.empty(U.shape + (2,))%0A            R%5B...,0%5D = U_exp * vx%0A            R%5B...,1%5D = U_exp * vy%0A            return R%0A%0A        def burgers_flux_derivative(U, mu):%0A            U_exp = mu%5B'exponent'%5D * (np.sign(U) * np.power(np.abs(U), mu%5B'exponent'%5D-1))%0A            R = np.empty(U.shape + (2,))%0A            R%5B...,0%5D = U_exp * vx%0A            R%5B...,1%5D = U_exp * vy%0A            return R%0A%0A        flux_function = GenericFunction(burgers_flux, dim_domain=0, dim_range=2,%0A                                        parameter_type=%7B'exponent': 0%7D, name='burgers_flux')%0A        flux_function.rename_parameter(%7B'.exponent': 'exponent'%7D)%0A%0A        flux_function_derivative = GenericFunction(burgers_flux_derivative, dim_domain=0, dim_range=2,%0A                                                   parameter_type=%7B'exponent': 0%7D, name='burgers_flux')%0A        flux_function_derivative.rename_parameter(%7B'.exponent': 'exponent'%7D)%0A%0A        if initial_data == 'sin':%0A            def initial_data(x):%0A                return 0.5 * (np.sin(2 * np.pi * x%5B..., 0%5D) * np.sin(2 * np.pi * x%5B..., 1%5D) + 1.)%0A            dirichlet_data=ConstantFunction(dim_domain=2, dim_range=1, value=0.5)%0A        else:%0A            def initial_data(x):%0A                return (x%5B..., 0%5D %3E= 0.5) * (x%5B..., 0%5D %3C= 1) * 1%0A            dirichlet_data=ConstantFunction(dim_domain=2, dim_range=1, value=0)%0A%0A        initial_data = GenericFunction(initial_data, dim_domain=2, dim_range=1)%0A%0A        domain = TorusDomain(%5B%5B0, 0%5D, %5B2, 1%5D%5D) if torus else RectDomain(%5B%5B0, 0%5D, %5B2, 1%5D%5D, right=None,%0A                top=None)%0A%0A        super(BurgersProblem, self).__init__(domain=domain,%0A                                             rhs=ConstantFunction(value=0, dim_domain=2),%0A                                             flux_function=flux_function,%0A                                             flux_function_derivative=flux_function_derivative,%0A                                             initial_data=initial_data,%0A                                             dirichlet_data=dirichlet_data,%0A                                             T=0.3, name='Burgers Problem')%0A%0A        self.parameter_space = CubicParameterSpace(%7B'exponent': 0%7D, *parameter_range)%0A

add BurgersProblem