Hi,
I'm trying to modify an existing example, complicating it bit by bit. I started from sinbc.py which is essentially the Laplace equation with Dirichlet boundary conditions specified by functions. I know how to add a constant source term:
material_1 = { 'name' : 'coef', 'region' : 'Omega', 'values' : {'val' : 1.0}, }
material_2 = { 'name' : 'source_term', 'region' : 'Omega', 'mode' : 'here', 'values' : {'val' : 1.0}, }
integral_1 = { 'name' : 'i1', 'kind' : 'v', 'quadrature' : 'gauss_o2_d2', # The elements are 2_3_P1 }
equations = { 'Temperature' : """dw_laplace.i1.Omega( coef.val, w, u ) = dw_volume_lvf.i1.Omega( source_term.val, w )""" }
That works fine. But how do I add a nonlinear source term specified by a function? I tried the following:
material_2 = { 'name' : 'source_term', 'region' : 'Omega', 'mode' : 'function', 'function' : 'source_term_func', }
def source_term_func(ts, coor, mode=None, region=None, ig=None, extra_arg=None): r = -25 * nm.sin(3*coor[:,0]) * nm.cos(4*coor[:,1]) r.shape = (r.shape[0], 1, 1) out = {} out['val'] = r return out
functions = { 'ebc_sin' : (ebc_sin,), 'ebc_sin2' : (ebc_sin2,), 'source_term_func' : (source_term_func,), }
But all I'm getting is an overflow error:
sfepy: left over: ['__builtins__', 'ebc_sin', '__file__', '__name__', 'ebc_sin2', 'source_term_func', 'data_dir', 'nm', '_filename', '__package__', 'amplitude', '__doc__'] sfepy: reading mesh (/Users/dpo/local/src/sfepy/meshes/2d/ square_unit_tri.mesh)... sfepy: ...done in 0.00 s sfepy: setting up domain edges... sfepy: ...done in 0.00 s sfepy: creating regions... sfepy: Omega sfepy: Gamma_Top sfepy: Gamma_Bottom sfepy: ...done in 0.01 s sfepy: equation "Temperature": sfepy: dw_laplace.i1.Omega( coef.val, w, u ) = dw_volume_lvf.i1.Omega( source_term.val, w ) sfepy: setting up dof connectivities... sfepy: ...done in 0.00 s sfepy: describing geometries... sfepy: ...done in 0.00 s sfepy: using solvers: nls: newton ls: ls sfepy: matrix shape: (112, 112) sfepy: assembling matrix graph... sfepy: ...done in 0.00 s sfepy: matrix structural nonzeros: 702 (5.60e-02% fill) sfepy: updating materials... sfepy: coef sfepy: source_term sfepy: ...done in 0.00 s sfepy: updating variables... sfepy: ...done Warning: overflow encountered in multiply sfepy: nls: iter: 0, residual: inf (rel: nan) sfepy: rezidual: 0.00 [s] sfepy: solve: 0.00 [s] sfepy: matrix: 0.00 [s] Warning: overflow encountered in multiply sfepy: linear system not solved! (err = inf) Warning: overflow encountered in multiply sfepy: linesearch: iter 1, (inf < inf) (new ls: 1.000000e-01) Warning: overflow encountered in multiply sfepy: linesearch: iter 1, (inf < inf) (new ls: 1.000000e-02) Warning: overflow encountered in multiply sfepy: linesearch: iter 1, (inf < inf) (new ls: 1.000000e-03) Warning: overflow encountered in multiply sfepy: linesearch: iter 1, (inf < inf) (new ls: 1.000000e-04) Warning: overflow encountered in multiply sfepy: linesearch: iter 1, (inf < inf) (new ls: 1.000000e-05) Warning: overflow encountered in multiply sfepy: linesearch: iter 1, (inf < inf) (new ls: 1.000000e-06) Warning: overflow encountered in multiply sfepy: linesearch: iter 1, (inf < inf) (new ls: 1.000000e-07) sfepy: linesearch failed, continuing anyway sfepy: nls: iter: 1, residual: inf (rel: nan)
I'm obviously doing something wrong...
Thanks! Dominique
participants (2)
-
Dominique
-
Robert Cimrman