Example #1
0
    def testBasic(self):
        f, s = mms.evaluate('div(grad(u))', 'x**3')
        fs = mms.fparser(f)
        self.assertEqual(fs, '6*x')

        ss = mms.fparser(s)
        self.assertEqual(ss, 'x^3')
Example #2
0
    def testBasic(self):
        f,s = mms.evaluate('div(grad(u))', 'x**3')
        fs = mms.fparser(f)
        self.assertEqual(fs, '6*x')

        ss = mms.fparser(s)
        self.assertEqual(ss, 'x^3')
Example #3
0
    def testEvaluateWithVectorFunction(self):
        f, _ = mms.evaluate('div(h*u)', 'cos(x*t)', vectorfunctions=['h'])
        s = mms.fparser(f)

        self.assertEqual(s, '-t*h_x(R.x, R.y, R.z, t)*sin(x*t) + ' \
                            'cos(x*t)*Derivative(h_x(R.x, R.y, R.z, t), R.x) + ' \
                            'cos(x*t)*Derivative(h_y(R.x, R.y, R.z, t), R.y) + ' \
                            'cos(x*t)*Derivative(h_z(R.x, R.y, R.z, t), R.z)')
Example #4
0
    def testEvaluateWithKwargs(self):
        f, _ = mms.evaluate('div(h*u)',
                            'cos(x*t)*e_i',
                            scalars=['k'],
                            h='k*x*x')
        s = mms.fparser(f)

        self.assertEqual(s, '-x^2*k*t*sin(x*t) + 2*x*k*cos(x*t)')
Example #5
0
    def testEvaluateVectorFunction(self):
        f, e = mms.evaluate('div(u.outer(u))', 'cos(x*t)*e_i')

        s = mms.fparser(f)
        self.assertEqual(s, '[-2*t*sin(x*t)*cos(x*t), 0, 0]')

        s = mms.fparser(e)
        self.assertEqual(s, '[cos(x*t), 0, 0]')
Example #6
0
    def testCylindricalEvaluate(self):
        f, _ = mms.evaluate('div(u)',
                            'r*phi*z*(e_i+e_j+e_k)',
                            transformation='cylindrical',
                            coordinate_names=('r', 'phi', 'z'))
        s = mms.fparser(f)

        self.assertEqual(s, 'phi*r + 2*phi*z + z')
Example #7
0
    def testHit(self):
        f,s = mms.evaluate('a*div(k*grad(u))', 'x**3', scalars=['k', 'a'])
        n = str(mms.build_hit(f, 'force', a=42))

        self.assertIn('[force]', n)
        self.assertIn('type = ParsedFunction', n)
        self.assertIn("value = '6*x*a*k'", n)
        self.assertIn("vars = 'a k'", n)
        self.assertIn("vals = '42 1.0'", n)
Example #8
0
    def testHit(self):
        f, s = mms.evaluate('a*div(k*grad(u))', 'x**3', scalars=['k', 'a'])
        n = mms.build_hit(f, 'force', a=42).render()

        self.assertIn('[force]', n)
        self.assertIn('type = ParsedFunction', n)
        self.assertIn("value = '6*x*a*k'", n)
        self.assertIn("vars = 'a k'", n)
        self.assertIn("vals = '42 1.0'", n)
Example #9
0
    def testEvaluate(self):
        f,_ = mms.evaluate('diff(h, t) + div(u*h) + div(grad(r*h))',
                         'cos(x*y*t)', variable='h', scalars=['r'], vectors=['u'])

        s = mms.fparser(f)
        self.assertEqual(s, '-x^2*r*t^2*cos(x*y*t) - x*y*sin(x*y*t) - x*t*u_y*sin(x*y*t) - ' \
                            'y^2*r*t^2*cos(x*y*t) - y*t*u_x*sin(x*y*t)')

        s = mms.moosefunction(f)
        self.assertEqual(s, '-std::pow(p(0), 2)*_r*std::pow(t, 2)*std::cos(p(0)*p(1)*t) - ' \
                            'p(0)*p(1)*std::sin(p(0)*p(1)*t) - p(0)*t*_u(1)*std::sin(p(0)*p(1)*t) ' \
                            '- std::pow(p(1), 2)*_r*std::pow(t, 2)*std::cos(p(0)*p(1)*t) - ' \
                            'p(1)*t*_u(0)*std::sin(p(0)*p(1)*t)')
Example #10
0
    def testEvaluate(self):
        f, _ = mms.evaluate('diff(h, t) + div(u*h) + div(grad(r*h))',
                            'cos(x*y*t)',
                            variable='h',
                            scalars=['r'],
                            vectors=['u'])

        s = mms.fparser(f)
        self.assertEqual(s, '-x^2*r*t^2*cos(x*y*t) - x*y*sin(x*y*t) - x*t*u_y*sin(x*y*t) - ' \
                            'y^2*r*t^2*cos(x*y*t) - y*t*u_x*sin(x*y*t)')

        s = mms.moosefunction(f)
        self.assertEqual(s, '-std::pow(p(0), 2)*_r*std::pow(t, 2)*std::cos(p(0)*p(1)*t) - ' \
                            'p(0)*p(1)*std::sin(p(0)*p(1)*t) - p(0)*t*_u(1)*std::sin(p(0)*p(1)*t) ' \
                            '- std::pow(p(1), 2)*_r*std::pow(t, 2)*std::cos(p(0)*p(1)*t) - ' \
                            'p(1)*t*_u(0)*std::sin(p(0)*p(1)*t)')
Example #11
0
    def __init__(self, methodName='runTest'):
        super(TestContinuity, self).__init__(methodName)
        exact_soln = 'sin(pi*x) * sin(pi*y) * sin(pi*z)'
        f, exact = mms.evaluate('-div(grad(T)) + T', exact_soln, variable='T')
        x, y, z = sympy.symbols('x y z')
        u = eval(
            str(exact).replace('R.x', 'x').replace('R.y',
                                                   'y').replace('R.z', 'z'))
        du_dx = sympy.diff(u, x)
        lm = du_dx
        self.function_args = [
            'Functions/forcing_function/value="' + mms.fparser(f) + '"',
            'Functions/exact_soln_primal/value="' + mms.fparser(exact) + '"',
            'Functions/exact_soln_lambda/value="' + mms.fparser(lm) + '"'
        ]
        self.gold_values = {
            'p1p0_hex-u_0.1': 1.9305390060119176,
            'p1p0_hex-lm_0.1': 1.0272242755193284,
            'p1p0_hex_non-u_0.1': 2.0694003778178534,
            'p1p0_hex_non-lm_0.1': 1.0719372819043176,
            'p1p1_hex-u_0.1': 1.90978686865625,
            'p1p1_hex-lm_0.1': 3.0413581999654924,
            'p1p1_hex_non-u_0.1': 1.9421386178496052,
            'p1p1_hex_non-lm_0.1': 2.001745263935625,
            'p1p1dual_hex-u_0.1': 1.8956170085743176,
            'p1p1dual_hex-lm_0.1': 1.4802316459242533,
            'p1p1dual_hex_non-u_0.1': 1.9009463364413586,
            'p1p1dual_hex_non-lm_0.1': 1.4766123810566583,
            'p2p0_hex-u_0.1': 3.044201176042964,
            'p2p0_hex-lm_0.1': 1.019296943618726,
            'p2p0_hex_non-u_0.1': 2.9750765225049074,
            'p2p0_hex_non-lm_0.1': 1.019447305041749,
            'p2p1_hex-u_0.1': 2.9717861674588906,
            'p2p1_hex-lm_0.1': 2.032637929038658,
            'p2p1_hex_non-u_0.1': 2.9413624940907344,
            'p2p1_hex_non-lm_0.1': 2.0321190357379546,
            'p2p2_hex-u_0.1': 2.939071712671479,
            'p2p2_hex-lm_0.1': 3.0514171179331036,
            'p2p2_hex_non-u_0.1': 2.90086020890949,
            'p2p2_hex_non-lm_0.1': 2.130510552719881
        }

        self.tolerance = 1e-3
Example #12
0
    def testExceptions(self):

        try:
            mms.evaluate('div(h*u)', 'cos(x*t)*e_i', scalars=['R'], h='k*x*x')
        except SyntaxError as e:
            self.assertIn("name 'R'", str(e))

        try:
            mms.evaluate('div(h*u)', 'cos(x*t)*e_i', scalars=['x'], h='k*x*x')
        except SyntaxError as e:
            self.assertIn("name 'x'", str(e))

        try:
            mms.evaluate('div(h*u)', 'cos(x*t)*e_i', scalars=['t'], h='k*x*x')
        except SyntaxError as e:
            self.assertIn("name 't'", str(e))

        try:
            mms.evaluate('div(h*u)',
                         'cos(x*t)*e_i',
                         scalars=['e_k'],
                         h='k*x*x')
        except SyntaxError as e:
            self.assertIn("name 'e_k'", str(e))
Example #13
0
    def __init__(self, methodName='runTest'):
        super(TestContinuity, self).__init__(methodName)

        exact_soln = 'sin(pi*x/2) + cos(pi*y/2) + cos(pi*x/2)*sin(pi*y/2)'
        f, exact = mms.evaluate('-div(grad(T)) + T', exact_soln, variable='T')

        x,y = sympy.symbols('x y')

        u = eval(str(exact).replace('R.x','x').replace('R.y','y'))

        du_dx = sympy.diff(u, x)

        # lambda = normals_secondary * diff_secondary * grad_u_secondary
        lm = 1 * 1 * du_dx

        self.function_args = [
            'Functions/forcing_function/value="' + mms.fparser(f) + '"',
            'Functions/exact_soln_primal/value="' + mms.fparser(exact) + '"',
            'Functions/exact_soln_lambda/value="' + mms.fparser(lm) + '"']

        # self.gold_values = {}
        self.gold_values = {
            'p2p2-2-to-2-u_same_0' : 2.998634817909304,
            'p2p2-2-to-2-lm_same_0' : 3.1044084969914914,
            'p2p2-2-to-2-u_same_0.1' : 2.9921663752381713,
            'p2p2-2-to-2-lm_same_0.1' : 3.0013385403667137,
            'p2p2-5-to-2-u_coarse_primary_0' : 2.9997890026770926,
            'p2p2-5-to-2-lm_coarse_primary_0' : 2.0108573719845966,
            'p2p2-5-to-2-u_coarse_secondary_0' : 2.9950460951663347,
            'p2p2-5-to-2-lm_coarse_secondary_0' : 2.5166142835950485,
            'p2p2-5-to-2-u_coarse_primary_0.1' : 2.9939611035980707,
            'p2p2-5-to-2-lm_coarse_primary_0.1' : 1.9917147987299368,
            'p2p2-5-to-2-u_coarse_secondary_0.1' : 2.984744760123336,
            'p2p2-5-to-2-lm_coarse_secondary_0.1' : 2.5199014186060733,
            'p2p1-2-to-2-u_same_0' : 2.999509642372042,
            'p2p1-2-to-2-lm_same_0' : 2.0029054061613767,
            'p2p1-2-to-2-u_same_0.1' : 2.9927517172776374,
            'p2p1-2-to-2-lm_same_0.1' : 2.0028862537146783,
            'p2p1-5-to-2-u_coarse_primary_0' : 2.999609849486302,
            'p2p1-5-to-2-lm_coarse_primary_0' : 1.9829370834328883,
            'p2p1-5-to-2-u_coarse_secondary_0' : 2.999287138706176,
            'p2p1-5-to-2-lm_coarse_secondary_0' : 2.0033149322329113,
            'p2p1-5-to-2-u_coarse_primary_0.1' : 2.993889703627252,
            'p2p1-5-to-2-lm_coarse_primary_0.1' : 1.9883973118675258,
            'p2p1-5-to-2-u_coarse_secondary_0.1' : 2.9883615175154254,
            'p2p1-5-to-2-lm_coarse_secondary_0.1' : 2.003296665788549,
            'p2p0-2-to-2-u_same_0' : 3.0040747968605213,
            'p2p0-2-to-2-lm_same_0' : 1.0084238164344301,
            'p2p0-2-to-2-u_same_0.1' : 2.9738396134277854,
            'p2p0-2-to-2-lm_same_0.1' : 1.006655545137675,
            'p2p0-5-to-2-u_coarse_primary_0' : 2.999005720972765,
            'p2p0-5-to-2-lm_coarse_primary_0' : 1.006063662172058,
            'p2p0-5-to-2-u_coarse_secondary_0' : 2.725783281979175,
            'p2p0-5-to-2-lm_coarse_secondary_0' : 1.00795578413039,
            'p2p0-5-to-2-u_coarse_primary_0.1' : 2.990919278609015,
            'p2p0-5-to-2-lm_coarse_primary_0.1' : 1.0027757510416793,
            'p2p0-5-to-2-u_coarse_secondary_0.1' : 2.7410956848417696,
            'p2p0-5-to-2-lm_coarse_secondary_0.1' : 1.0068819161885127,
            'p1p1-2-to-2-u_same_0' : 1.9976222558440346,
            'p1p1-2-to-2-lm_same_0' : 2.011332498808176,
            'p1p1-2-to-2-u_same_0.4' : 2.192010143004469,
            'p1p1-2-to-2-lm_same_0.4' : 1.9847827143779497,
            'p1p1-5-to-2-u_coarse_primary_0' : 1.9992491291760002,
            'p1p1-5-to-2-lm_coarse_primary_0' : 0.9986030842919351,
            'p1p1-5-to-2-u_coarse_secondary_0' : 1.999544699253089,
            'p1p1-5-to-2-lm_coarse_secondary_0' : 1.971155450737158,
            'p1p1-5-to-2-u_coarse_primary_0.4' : 2.1095731087882266,
            'p1p1-5-to-2-lm_coarse_primary_0.4' : 0.9807155521591079,
            'p1p1-5-to-2-u_coarse_secondary_0.4' : 2.188809611484894,
            'p1p1-5-to-2-lm_coarse_secondary_0.4' : 1.8873233690453122,
            'p1p0-2-to-2-u_same_0' : 1.997711692307121,
            'p1p0-2-to-2-lm_same_0' : 1.001565938454369,
            'p1p0-2-to-2-u_same_0.4' : 2.1916263122904245,
            'p1p0-2-to-2-lm_same_0.4' : 1.0033834748271102,
            'p1p0-5-to-2-u_coarse_primary_0' : 2.0034278183745324,
            'p1p0-5-to-2-lm_coarse_primary_0' : 1.0440256530245198,
            'p1p0-5-to-2-u_coarse_secondary_0' : 2.001068175514392,
            'p1p0-5-to-2-lm_coarse_secondary_0' : 1.0116336217198654,
            'p1p0-5-to-2-u_coarse_primary_0.4' : 2.109020679157957,
            'p1p0-5-to-2-lm_coarse_primary_0.4' : 0.9979231357062565,
            'p1p0-5-to-2-u_coarse_secondary_0.4' : 2.1903147362107327,
            'p1p0-5-to-2-lm_coarse_secondary_0.4' : 1.0053519515138674
        }

        self.tolerance = 1e-3
Example #14
0
    def testEvaluateWithScalarFunction(self):
        f, _ = mms.evaluate('diff(h*u, t)', 'cos(x*t)', functions=['h'])
        s = mms.fparser(f)

        self.assertEqual(s, '-x*h(R.x, R.y, R.z, t)*sin(x*t) + ' \
                            'cos(x*t)*Derivative(h(R.x, R.y, R.z, t), t)')
Example #15
0
#!/usr/bin/env python
#* This file is part of the MOOSE framework
#* https://www.mooseframework.org
#*
#* All rights reserved, see COPYRIGHT for full restrictions
#* https://github.com/idaholab/moose/blob/master/COPYRIGHT
#*
#* Licensed under LGPL 2.1, please see LICENSE for details
#* https://www.gnu.org/licenses/lgpl-2.1.html

import mms
fs, ss = mms.evaluate('-div(grad(u))', 'sin(2*pi*x)*sin(2*pi*y)')
mms.print_fparser(fs)

mms.print_hit(fs, 'force')
mms.print_hit(ss, 'exact')

ft, st = mms.evaluate('diff(u,t) - div(grad(u))', 't**3*x*y')
mms.print_fparser(ft)

mms.print_hit(ft, 'force')
mms.print_hit(st, 'exact')
#!/usr/bin/env python3

import mms
import sympy

u = 'sin(pi * x / 2)'
vel = u + '* e_i'
p = 'cos(pi * x / 2)'

f_u, e_u = mms.evaluate(
    'div(vel*rho*u) - div(mu * grad(u)) + grad(p).dot(e_i)',
    u,
    variable='u',
    vel=vel,
    p=p,
    scalars=['mu', 'rho'])
f_p, e_p = mms.evaluate('div(vel*rho)',
                        p,
                        variable='p',
                        vel=vel,
                        scalars=['rho'])

rho = sympy.Symbol('rho')

e_rhou = e_u * rho

mms.print_hit(e_u, 'exact_u')
mms.print_hit(e_rhou, 'exact_rhou', rho='${rho}')
mms.print_hit(f_u, 'forcing_u', mu='${mu}', rho='${rho}')

mms.print_hit(e_p, 'exact_p')
Example #17
0
import mms
import sympy

u = 'cos(pi * x / 2) * sin(pi * y / 2)'
v = 'sin(pi * x / 4) * cos(pi * y / 2)'
vel = u + '* e_i + ' + v + ' * e_j'

p = 'cos(pi * x / 4) * sin(3 * pi * y / 2)'

temp = 'sin(pi * x / 4) * cos(pi * y / 2)'

f_u, e_u = mms.evaluate(
    'div(vel*rho*u) - div(mu * grad(u)) + grad(p).dot(e_i)',
    u,
    variable='u',
    vel=vel,
    p=p,
    scalars=['mu', 'rho'])
f_v, e_v = mms.evaluate(
    'div(vel*rho*v) - div(mu * grad(v)) + grad(p).dot(e_j)',
    v,
    variable='v',
    vel=vel,
    p=p,
    scalars=['mu', 'rho'])
f_p, e_p = mms.evaluate('div(vel*rho)',
                        p,
                        variable='p',
                        vel=vel,
                        scalars=['rho'])
Example #18
0
#!/usr/bin/env python3

import mms
import sympy

u = 'cos(x)'
p = 'sin(x)'
vel = u + '* e_i'

f_u, e_u = mms.evaluate(
    'div(vel*rho*u) - div(mu * grad(u)) + grad(p).dot(e_i)',
    u,
    variable='u',
    vel=vel,
    p=p,
    scalars=['mu', 'rho'])
f_p, e_p = mms.evaluate('div(vel*rho)',
                        p,
                        variable='p',
                        vel=vel,
                        scalars=['rho'])
# flux_u_left,_ = mms.evaluate('(vel*rho*u - mu * grad(u)).dot(-e_i)', u, variable='u', vel=vel, scalars=['mu', 'rho'])
# flux_u_right,_ = mms.evaluate('(vel*rho*u - mu * grad(u)).dot(e_i)', u, variable='u', vel=vel, scalars=['mu', 'rho'])
flux_u_left, _ = mms.evaluate('(vel*rho*u).dot(-e_i)',
                              u,
                              variable='u',
                              vel=vel,
                              scalars=['mu', 'rho'])
flux_u_right, _ = mms.evaluate('(vel*rho*u).dot(e_i)',
                               u,
                               variable='u',
Example #19
0
import sympy

u = 'cos(pi * x / 2) * sin(pi * y / 2)'
v = 'sin(pi * x / 4) * cos(pi * y / 2)'
vel = u + '* e_i + ' + v + ' * e_j'

p = 'cos(pi * x / 4) * sin(3 * pi * y / 2)'

# Select porosity spatial dependence
porosity = '1 - 0.5 * 1 / (1 + exp(-30*(x-1))) - 0.01 * y'
porosity = '0.8'

f_u, e_u = mms.evaluate('div(vel*rho*u) - div(mu*grad(u)) + grad(p).dot(e_i)',
                        u,
                        variable='u',
                        vel=vel,
                        p=p,
                        porosity=porosity,
                        scalars=['mu', 'rho'])
f_v, e_v = mms.evaluate('div(vel*rho*v) - div(mu*grad(v)) + grad(p).dot(e_j)',
                        v,
                        variable='v',
                        vel=vel,
                        p=p,
                        porosity=porosity,
                        scalars=['mu', 'rho'])
f_p, e_p = mms.evaluate('div(vel*rho)',
                        p,
                        variable='p',
                        vel=vel,
                        scalars=['rho'])
Example #20
0
#!/usr/bin/env python3

import mms

f, e = mms.evaluate('-div(grad(u))',
                    '1.1*sin(0.9*x)*cos(1.2*y)',
                    variable='u',
                    transformation='cylindrical',
                    coordinate_names=('x', 'phi', 'y'))

mms.print_hit(e, 'exact')
mms.print_hit(f, 'forcing')
vel = 'u * e_i'
mass_flux = 'rho_u * e_i'
e = 'rho_et / rho - 0.5 * vel.dot(vel)'
# 0.4 = gamma - 1
p = '0.4 * e * rho'
rho_ht = 'rho_et + p'
ht = 'rho_ht / rho'
gamma = 1.4
R = 8.3145
molar_mass = 29.0e-3
R_specific = R / molar_mass
cp = gamma * R_specific / (gamma - 1.)
cv = cp / gamma
T = 'e / ' + str(cv)

f_rho, e_rho = mms.evaluate('div(mass_flux)', rho, variable='rho', rho_u=rho_u, mass_flux=mass_flux)
f_rho_u, e_rho_u = mms.evaluate('div(mass_flux * u) + grad(p).dot(e_i)', rho_u, variable='rho_u', rho=rho, rho_u=rho_u, mass_flux=mass_flux, u=u, rho_et=rho_et, vel=vel, e=e, p=p)
f_rho_et, e_rho_et = mms.evaluate('div(mass_flux * ht)', rho_et, variable='rho_et', rho_et=rho_et, rho=rho, rho_u=rho_u, mass_flux=mass_flux, u=u, vel=vel, e=e, p=p, rho_ht=rho_ht, ht=ht)
_, e_T = mms.evaluate('T', T, variable='T', rho=rho, rho_et=rho_et, rho_u=rho_u, u=u, vel=vel, e=e, T=T)
_, e_p = mms.evaluate('p', p, variable='p', rho=rho, rho_et=rho_et, rho_u=rho_u, u=u, vel=vel, e=e, p=p)

mms.print_hit(e_rho, 'exact_rho')
mms.print_hit(f_rho, 'forcing_rho')

mms.print_hit(e_rho_u, 'exact_rho_u')
mms.print_hit(f_rho_u, 'forcing_rho_u')

mms.print_hit(e_rho_et, 'exact_rho_et')
mms.print_hit(f_rho_et, 'forcing_rho_et')

mms.print_hit(e_T, 'exact_T')
Example #22
0
    def __init__(self, methodName='runTest'):
        super(TestGapConductance, self).__init__(methodName)

        exact_soln = 'x**4 + 2*y**4 +x*y**3'
        f, exact = mms.evaluate('-div(grad(T)) + T', exact_soln, variable='T')

        x, y = sympy.symbols('x y')

        u = eval(str(exact).replace('R.x', 'x').replace('R.y', 'y'))

        u_secondary = u.subs(x, 1)
        u_primary = u.subs(x, 2)
        lm = u_secondary - u_primary

        du_dx = sympy.diff(u, x)

        # flux = n * -grad_u = nx * -du_dx
        # n_secondary = 1
        # n_primary = -1
        flux_secondary = -du_dx.subs(x, 1)

        flux_primary = -1 * -du_dx.subs(x, 2)

        mms_secondary = flux_secondary - lm
        mms_primary = flux_primary + lm

        self.function_args = [
            "Functions/forcing_function/value=\'" + mms.fparser(f) + "\'",
            "Functions/exact_soln_primal/value=\'" + mms.fparser(exact) + "\'",
            "Functions/exact_soln_lambda/value=\'" + mms.fparser(lm) + "\'",
            "Functions/mms_secondary/value=\'" + mms.fparser(mms_secondary) +
            "\'",
            "Functions/mms_primary/value=\'" + mms.fparser(mms_primary) + "\'"
        ]

        self.gold_values = {
            'p2p2-2-to-2-u_same': 2.9822564691564524,
            'p2p2-2-to-2-lm_same': 3.001026070690089,
            'p2p2-3-to-2-u_coarse_primary': 2.9830362913692774,
            'p2p2-3-to-2-lm_coarse_primary': 2.9165033066603714,
            'p2p2-3-to-2-u_coarse_secondary': 2.974976328637989,
            'p2p2-3-to-2-lm_coarse_secondary': 3.210239428561721,
            'p2p2-4-to-2-u_coarse_primary': 2.982552524913371,
            'p2p2-4-to-2-lm_coarse_primary': 2.9082806315999687,
            'p2p2-4-to-2-u_coarse_secondary': 2.967163866045459,
            'p2p2-4-to-2-lm_coarse_secondary': 3.2244149963833273,
            'p2p2-5-to-2-u_coarse_primary': 2.9823936432051203,
            'p2p2-5-to-2-lm_coarse_primary': 2.9052727051947764,
            'p2p2-5-to-2-u_coarse_secondary': 2.964889659684415,
            'p2p2-5-to-2-lm_coarse_secondary': 3.2290095723998236,
            'p2p1-2-to-2-u_same': 2.9823879971978347,
            'p2p1-2-to-2-lm_same': 2.027908692116612,
            'p2p1-3-to-2-u_coarse_primary': 2.9830517599713926,
            'p2p1-3-to-2-lm_coarse_primary': 2.289722443118018,
            'p2p1-3-to-2-u_coarse_secondary': 2.9748053887963235,
            'p2p1-3-to-2-lm_coarse_secondary': 2.039540390360873,
            'p2p1-4-to-2-u_coarse_primary': 2.982541009917219,
            'p2p1-4-to-2-lm_coarse_primary': 2.4516029901427503,
            'p2p1-4-to-2-u_coarse_secondary': 2.9666727450503494,
            'p2p1-4-to-2-lm_coarse_secondary': 2.043610660107857,
            'p2p1-5-to-2-u_coarse_primary': 2.982377963288517,
            'p2p1-5-to-2-lm_coarse_primary': 2.75101171627186,
            'p2p1-5-to-2-u_coarse_secondary': 2.9643261771297698,
            'p2p1-5-to-2-lm_coarse_secondary': 2.0449872997477305,
            'p2p0-2-to-2-u_same': 2.865934548905254,
            'p2p0-2-to-2-lm_same': 0.9544384151198305,
            'p2p0-3-to-2-u_coarse_primary': 2.9513681749051264,
            'p2p0-3-to-2-lm_coarse_primary': 0.9871747739768003,
            'p2p0-3-to-2-u_coarse_secondary': 2.62873082898225,
            'p2p0-3-to-2-lm_coarse_secondary': 0.9551048423731033,
            'p2p0-4-to-2-u_coarse_primary': 2.9719537374138345,
            'p2p0-4-to-2-lm_coarse_primary': 1.0154487382629993,
            'p2p0-4-to-2-u_coarse_secondary': 2.5504738003975547,
            'p2p0-4-to-2-lm_coarse_secondary': 0.9542477401583049,
            'p2p0-5-to-2-u_coarse_primary': 2.9778820927330556,
            'p2p0-5-to-2-lm_coarse_primary': 1.0198046269451437,
            'p2p0-5-to-2-u_coarse_secondary': 2.5332102827019036,
            'p2p0-5-to-2-lm_coarse_secondary': 0.9543603794667151,
            'p1p1-2-to-2-u_same': 1.9859815251171462,
            'p1p1-2-to-2-lm_same': 2.011595941881354,
            'p1p1-3-to-2-u_coarse_primary': 1.9885251789927607,
            'p1p1-3-to-2-lm_coarse_primary': 2.0158955961283245,
            'p1p1-3-to-2-u_coarse_secondary': 1.9792698106931648,
            'p1p1-3-to-2-lm_coarse_secondary': 1.9981271512915104,
            'p1p1-4-to-2-u_coarse_primary': 1.9885475293380597,
            'p1p1-4-to-2-lm_coarse_primary': 1.9977186875839374,
            'p1p1-4-to-2-u_coarse_secondary': 1.9580169542840375,
            'p1p1-4-to-2-lm_coarse_secondary': 1.9403777939060056,
            'p1p1-5-to-2-u_coarse_primary': 1.988512993102887,
            'p1p1-5-to-2-lm_coarse_primary': 2.0006441170884512,
            'p1p1-5-to-2-u_coarse_secondary': 1.9388833409209203,
            'p1p1-5-to-2-lm_coarse_secondary': 1.8767785071182106,
            'p1p0-2-to-2-u_same': 1.9860344770137297,
            'p1p0-2-to-2-lm_same': 1.516294286226134,
            'p1p0-3-to-2-u_coarse_primary': 1.9883909312827506,
            'p1p0-3-to-2-lm_coarse_primary': 1.7057016469391288,
            'p1p0-3-to-2-u_coarse_secondary': 1.979352405490139,
            'p1p0-3-to-2-lm_coarse_secondary': 1.1510942533114046,
            'p1p0-4-to-2-u_coarse_primary': 1.9884810274602154,
            'p1p0-4-to-2-lm_coarse_primary': 1.8106476095984056,
            'p1p0-4-to-2-u_coarse_secondary': 1.95784294017922,
            'p1p0-4-to-2-lm_coarse_secondary': 1.0201644481503622,
            'p1p0-5-to-2-u_coarse_primary': 1.9884579467005514,
            'p1p0-5-to-2-lm_coarse_primary': 1.8694171519114244,
            'p1p0-5-to-2-u_coarse_secondary': 1.937763546002798,
            'p1p0-5-to-2-lm_coarse_secondary': 0.9892939793245561
        }

        self.tolerance = 1e-3
Example #23
0
#!/usr/bin/env python3

# MooseDocs:start:spatial
import mms
fs, ss = mms.evaluate(('rho * cp * diff(u,t) - div(k*grad(u)) - '
                      'shortwave*sin(0.5*x*pi)*exp(kappa*y)*sin(1/(hours*3600)*pi*t)'),
                      't*sin(pi*x)*sin(5*pi*y)',
                      scalars=['rho', 'cp', 'k', 'kappa', 'shortwave', 'hours'])
mms.print_hit(fs, 'mms_force')
mms.print_hit(ss, 'mms_exact')
# MooseDocs:end:spatial

# MooseDocs:start:temporal
import mms
fs, ss = mms.evaluate(('rho * cp * diff(u,t) - div(k*grad(u)) - '
                      'shortwave*sin(0.5*x*pi)*exp(kappa*y)*sin(1/(hours*3600)*pi*t)'),
                      'x*y*exp(-1/32400*t)',
                      scalars=['rho', 'cp', 'k', 'kappa', 'shortwave', 'hours'])
mms.print_hit(fs, 'mms_force')
mms.print_hit(ss, 'mms_exact')
# MooseDocs:end:temporal
Example #24
0
# 0.4 = gamma - 1
p = '0.4 * e * rho'
rho_ht = 'rho_et + p'
ht = 'rho_ht / rho'
gamma = 1.4
R = 8.3145
molar_mass = 29.0e-3
R_specific = R / molar_mass
cp = gamma * R_specific / (gamma - 1.)
cv = cp / gamma
T = 'e / ' + str(cv)
eps_p = 'eps * p'

f_rho, e_rho = mms.evaluate('div(mass_flux)',
                            rho,
                            variable='rho',
                            eps=eps,
                            rho_ud=rho_ud,
                            mass_flux=mass_flux)
f_rho_ud, e_rho_ud = mms.evaluate(
    'div(mass_flux * u) + rho*u + eps*grad(p).dot(e_i)',
    rho_ud,
    variable='rho_ud',
    eps=eps,
    rho=rho,
    rho_ud=rho_ud,
    mass_flux=mass_flux,
    ud=ud,
    u=u,
    rho_et=rho_et,
    vel=vel,
    e=e,
Example #25
0
#!/usr/bin/env python3

import mms
import sympy

rho = 'cos(x)'
rho_u = '2*sin(x)'
rho_et = '3*cos(x)'
p = 'rho'
vel = 'rho_u / rho * e_i'
rho_ht = 'rho_et + p'

f_rho, e_rho = mms.evaluate('div(vel*rho) - div(grad(rho))', rho, variable='rho', rho=rho, rho_u=rho_u, vel=vel)
f_rho_u, e_rho_u = mms.evaluate('div(vel*rho_u) - div(grad(rho_u)) + grad(p).dot(e_i)', rho_u, variable='rho_u', rho=rho, rho_u=rho_u, vel=vel, p=p)
f_rho_et, e_rho_et = mms.evaluate('div(vel*rho_ht) - div(grad(rho_et))', rho_et, variable='rho_et', rho_et=rho_et, rho=rho, rho_u=rho_u,  vel=vel, p=p, rho_ht=rho_ht)

mms.print_hit(e_rho, 'exact_rho')
mms.print_hit(f_rho, 'forcing_rho')

mms.print_hit(e_rho_u, 'exact_rho_u')
mms.print_hit(f_rho_u, 'forcing_rho_u')

mms.print_hit(e_rho_et, 'exact_rho_et')
mms.print_hit(f_rho_et, 'forcing_rho_et')
#!/usr/bin/env python3

import mms

f, e = mms.evaluate('div(vel*u) + u', 'sin(x)*cos(y)', variable='u',
                    vel='a*(e_i+e_k)', transformation='cylindrical',
                    coordinate_names=('x', 'phi', 'y'), scalars=['a'])

mms.print_hit(e, 'exact')
mms.print_hit(f, 'forcing', a='${a}')
Example #27
0
#!/usr/bin/env python3
#* This file is part of the MOOSE framework
#* https://www.mooseframework.org
#*
#* All rights reserved, see COPYRIGHT for full restrictions
#* https://github.com/idaholab/moose/blob/master/COPYRIGHT
#*
#* Licensed under LGPL 2.1, please see LICENSE for details
#* https://www.gnu.org/licenses/lgpl-2.1.html

import mms
fs, ss = mms.evaluate('-div(grad(u))', 'sin(a*pi*x)', scalars=['a'])
mms.print_fparser(fs)
mms.print_hit(fs, 'force')
mms.print_hit(ss, 'exact')
Example #28
0
#!/usr/bin/env python
import mms
fs,ss = mms.evaluate('-div(grad(u))', 'sin(2*pi*x)*sin(2*pi*y)')
mms.print_fparser(fs)

mms.print_hit(fs, 'force')
mms.print_hit(ss, 'exact')

ft,st = mms.evaluate('diff(u,t) - div(grad(u))', 't**3*x*y')
mms.print_fparser(ft)

mms.print_hit(ft, 'force')
mms.print_hit(st, 'exact')
Example #29
0
import mms
import sympy

u = 'cos(pi/2 * x)'
vel = u + '* e_i'
p = 'sin(x)'

# Select porosity model
porosity = '0.8'
porosity = '1 - 0.5 * 1 / (1 + exp(-30*(x-1)))'

# Requires smooth_porosity = true in FVKernels
f_u, e_u = mms.evaluate(
    'div(vel*rho*u/porosity) - div(mu*porosity*grad(u/porosity)) + porosity*grad(p).dot(e_i)',
    u,
    variable='u',
    vel=vel,
    p=p,
    porosity=porosity,
    scalars=['mu', 'rho'])
f_p, e_p = mms.evaluate('div(vel*rho)',
                        p,
                        variable='p',
                        vel=vel,
                        scalars=['rho'])

rho = sympy.Symbol('rho')

mms.print_hit(e_u, 'exact_u')
mms.print_hit(f_u, 'forcing_u', mu='${mu}', rho='${rho}')

mms.print_hit(e_p, 'exact_p')
# 0.4 = gamma - 1
p = '0.4 * e * rho'
rho_ht = 'rho_et + p'
ht = 'rho_ht / rho'
gamma = 1.4
R = 8.3145
molar_mass = 29.0e-3
R_specific = R / molar_mass
cp = gamma * R_specific / (gamma - 1.)
cv = cp / gamma
T = 'e / ' + str(cv)
eps_p = 'eps * p'

f_rho, e_rho = mms.evaluate('div(mass_flux)',
                            rho,
                            variable='rho',
                            rho_ud=rho_ud,
                            mass_flux=mass_flux,
                            scalars=['eps'])
f_rho_ud, e_rho_ud = mms.evaluate('div(mass_flux * u) + eps*grad(p).dot(e_i)',
                                  rho_ud,
                                  variable='rho_ud',
                                  rho=rho,
                                  rho_ud=rho_ud,
                                  mass_flux=mass_flux,
                                  ud=ud,
                                  u=u,
                                  rho_et=rho_et,
                                  vel=vel,
                                  e=e,
                                  p=p,
                                  scalars=['eps'])
#!/usr/bin/env python3

import mms

f, e = mms.evaluate('div(vel*u) - div(diff*grad(u)) + u', 'sin(x)*cos(y)', variable='u',
                    vel='a*(e_i + 2*e_j)', scalars=['a', 'diff'])

mms.print_hit(e, 'exact')
mms.print_hit(f, 'forcing', a='${a}', diff='${diff}')
Example #32
0
#!/usr/bin/env python3

import mms
f_rho, e_rho = mms.evaluate('div(u*rho) - div(grad(rho))',
                            '1.1*sin(1.1*x)',
                            variable='rho',
                            u='1.1*cos(1.1*x) * e_i')
f_vel, e_vel = mms.evaluate('div(u*vel*rho) - div(grad(vel))',
                            '1.1*cos(1.1*x)',
                            variable='vel',
                            u='1.1*cos(1.1*x) * e_i',
                            rho='1.1*sin(1.1*x)')

mms.print_hit(f_rho, 'forcing_rho')
mms.print_hit(e_rho, 'exact_rho')
mms.print_hit(f_vel, 'forcing_vel')
mms.print_hit(e_vel, 'exact_vel')
Example #33
0
vel = u + '* e_i + ' + v + ' * e_k'

# Prescribed value: outlet
# Zero gradient: left right bottom
p = 'cos(y * pi / 2) * cos(x * pi)'

# Zero value: left bottom right
# Zero gradient: top
temp = 'sin(pi * y / 2) * sin(x * pi)'

f_u, e_u = mms.evaluate(
    'div(vel*rho*u) - div(mu * grad(u)) + grad(p).dot(e_i)',
    u,
    variable='u',
    vel=vel,
    p=p,
    scalars=['mu', 'rho'],
    transformation='cylindrical',
    coordinate_names=('x', 'phi', 'y'))
f_v, e_v = mms.evaluate(
    'div(vel*rho*v) - div(mu * grad(v)) + grad(p).dot(e_k)',
    v,
    variable='v',
    vel=vel,
    p=p,
    scalars=['mu', 'rho'],
    transformation='cylindrical',
    coordinate_names=('x', 'phi', 'y'))
f_p, e_p = mms.evaluate('div(vel*rho)',
                        p,
Example #34
0
import mms
import sympy

u = 'cos(pi * x / 2) * sin(pi * y / 2)'
v = 'sin(pi * x / 4) * cos(pi * y / 2)'
vel = u + '* e_i + ' + v + ' * e_j'

p = 'cos(pi * x / 4) * sin(3 * pi * y / 2)'

porosity = '.5 + .1 * sin(pi * x / 4) * cos(pi * y / 4)'

f_u, e_u = mms.evaluate(
    'div(vel*rho*u/porosity) - div(mu*porosity*grad(u/porosity)) + porosity*grad(p).dot(e_i) + (darcy + forch)*rho*u/porosity',
    u,
    variable='u',
    vel=vel,
    p=p,
    porosity=porosity,
    scalars=['mu', 'rho', 'darcy', 'forch'])
f_v, e_v = mms.evaluate(
    'div(vel*rho*v/porosity) - div(mu*porosity*grad(v/porosity)) + porosity*grad(p).dot(e_j) + (darcy + forch)*rho*v/porosity',
    v,
    variable='v',
    vel=vel,
    p=p,
    porosity=porosity,
    scalars=['mu', 'rho', 'darcy', 'forch'])
f_p, e_p = mms.evaluate('div(vel*rho)',
                        p,
                        variable='p',
                        vel=vel,