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.
Returns convective part of material derivative of expr. e.g.:
>>> print Conv(c, v) == Grad(c) * v
True
Returns divergence of expr.
>>> divv = Div(v)
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)
e.g.:
>>> M = UnitM
>>> print M
[1, 0]
[0, 1]
Returns vector of shape 2x1 with components a, b.
e.g.:
>>> bc = (v - Vector(1.0, 0.0))
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
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
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)
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)
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
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