ui

Module:

This is the only module you need to know if you don’t want to use the ui. This module specifies functions necessary to formulate problems.

ui.Conv(expr, v)

Returns convective part of material derivative of expr. e.g.:

>>> print Conv(c, v) == Grad(c) * v
 True
ui.DDot(A, B)
Returns double-dot product of A and B, which is defined as trace of A*B.
ui.Div(expr)

Returns divergence of expr.

>>> divv = Div(v)
ui.Dot(v, w)

Returns inner product of v and w.

>>> v = def_variable(['vx', 'vy'], ['QC2', 'QC2'])
>>> v_norm = sqrt(Dot(v, v))
>>> print v_norm
 (vx(x, y, t)**2 + vy(x, y, t)**2)*(1/2)
ui.Dt(expr)
Returns derivative of expr with respect to t.
ui.Dx(expr)
Returns derivative of expr with respect to x.
ui.Dy(expr)
Returns derivative of expr with respect to y.
ui.Grad(expr)
Returns gradient of expr. expr can be only a scalar of a vector.
ui.Norm(A)
Returns Eulclidean norm of A, i.e. square root of sum of squares of components.
ui.UnitM

e.g.:

>>> M = UnitM
>>> print M
 [1, 0]
 [0, 1]
ui.Vector(a, b)

Returns vector of shape 2x1 with components a, b.

e.g.:

>>> bc = (v - Vector(1.0, 0.0))
ui.def_equation(_var, parts, no_dt=False)

This function allows defining a new equation. e.g.:

>>> def_equation(v, {
    'Omega': Dot(Grad(u), Grad(v)) - 2*sin(x)*sin(y)*v,
    '-1': {'type': 'Dirichlet', 'form': (u - 0.0) * v}
    })

defines Poisson equation with test function v. Or for example

>>> def_equation(_p, {
    'Omega': forward(Div(v))
    }, no_dt=True)

defines incompressibility equation with velocity v and test function _p.

no_dt option drops dt multiplicant in the case of time-dependent problem

ui.def_function(*args)

Creates a new definition in eq.c

e.g.

>>> L = def_function([['vx_x', 'vx_y'], ['vy_x', 'vy_y']], Grad(v)) #returns a complete function

or

>>> dn = def_function(['dnx', 'dny']) # as a dummy function
ui.def_parameter(label, name)

Define a new parameter. Value of this parameters must be specified in the coresponding settings file in material_params. name specifies name of item in the settings file. label specifies name of the parameter in C. label and name might differ. e.g.:

>>> mu = def_parameter('mu', 'viscosity')

while there must be an item viscosity in the material_params dictionary in the settings file. e.g.:

>>> NS_bench_settings.material_params['viscosity']
 10**(-3)
ui.def_stress_tensor(names, form)

Define the stress tensor. This is needed only if you want to export forces during postprocessing.

e.g.:

>>> T = def_stress_tensor([['Txx', 'Txy'], ['Tyx', 'Tyy']], -p*UnitM + 2*mu*D)
ui.def_test_function(var, prefix='_')

Define a test function coupled to given variable var. Name of the new test function is prefix + name of the variable. Default prefix is ‘_’. e.g.:

>>> phi_vx = def_test_function(vx, 'phi')
>>> print phi_vx 
 phi_vx
>>> #but
>>> phi_vx = def_test_function(vx)
>>> print phi_vx
 _vx
ui.def_variable(names, el_types, **kwargs)

Return a new variable. Actually, it is a trial function and Bender will try to calculate it. Name of the variable is specified by names, type of finite elements Bender should use is specified by el_types. Elements you can use are:

QD1 ... bilinear discontinuous elements

QD2 ... biquadratic discontinuous elements

QC1 ... bilinear continuous elements

QC2 ... biquadratic continuous elements

>>> p = def_variable('pr', 'QD1')#defines variable for computing pressure on bilinear discontinuous elements
>>> print p
 pr

You can also define both tensor and scalar variables with this function. It you want to define a symmetric tensor, use the symmetric=True option.

>>> v = def_variable(['vx', 'vy'], ['QC2', 'QC2'])#defines a vector variable
>>> M = def_variable([['Mxx', 'Mxy'], ['Myx', 'Myy']], [['QD1', 'QD1'], ['QD1', 'QD1']], symmetric=True)#defines a symmetric tensor variable

Previous topic

Welcome to The Bender’s UI’s documentation!

Next topic

pool

This Page