
Hey guys
First off let me congratulate you on an excellent FEM application. The more I get into it, the more I appreciate the volume of work that has gone into it :) I particularly like the way a problem is defined using python. I've never come across anything else that allows such a simple yet powerful definition. I understand that the app is still under development and that the documentation is lacking. My experience with FEM software has mostly been "blackboxed" using ABAQUS, etc. My lack of knowledge on the (weak) formulation of a problem is severely restricting my application of SfePy. For example, I have not been able to figure out how to output stresses and strains in the model using linear elastic analysis - the example provided only outputs displacements. Can someone please point me in the right direction.
Regards
Andre Smit

Hi Andre,
On 03/29/10 18:57, freevryheid wrote:
Hey guys
First off let me congratulate you on an excellent FEM application. The more I get into it, the more I appreciate the volume of work that has gone into it :) I particularly like the way a problem is defined using python. I've never come across anything else that allows such a simple yet powerful definition. I understand that the app is still under development and that the documentation is lacking. My experience with FEM software has mostly been "blackboxed" using ABAQUS, etc. My lack of knowledge on the (weak) formulation of a problem is severely restricting my application of SfePy. For example, I have not been able to figure out how to output stresses and strains in the model using linear elastic analysis - the example provided only outputs displacements. Can someone please point me in the right direction.
Regards
Andre Smit
Thanks for the positive feedback!
Basically, SfePy solves for the primary variables (= unknown variables in the variables keyword), other quantities can be then computed in the post-processing phase. An example how to do it is e.g. in examples/biot/biot_npbc.py.
Short summary:
in options, set the post_process_hook option to the name of your postprocessing function
options = { ... 'post_process_hook' : 'stress_strain', ... }
define the postprocessing function:
def stress_strain(out, pb, state, extend=False): """Strain and stress for given displacements.""" strain = pb.evaluate('de_cauchy_strain.ivol.Omega( u )', state) out['cauchy_strain'] = Struct(name='output_data', mode='cell', data=strain, dofs=None)
stress = pb.evaluate('de_cauchy_stress.ivol.Omega( solid.D, u )', state)
out['cauchy_stress'] = Struct(name='output_data',
mode='cell', data=stress,
dofs=None)
return out
here 'pb' is a ProblemDefinition instance, so you can do here anything...
Note however, that the de_cauchy_stress terms expects the stiffness given on the tensor form, so you may need some of the functions in [1], e.g. stiffness_tensor_lame() if you use the Lame's coefficients. Also do not forget to adjust the integral, domain, material and variable names in the pb.evaluate() calls.
cheers, r.
[1] http://docs.sfepy.org/doc-devel/src/sfepy/mechanics/matcoefs.html

I'm getting the following error on my input file:
grassy@lapdog:~/sfepy$ ./simple.py ~/pyfem/its2D.py sfepy: left over: ['_filename', '__builtins__', '__file__', '__name__', '__package__', 'youngpoisson_to_lame', 'filename', 'stress_strain', 'stiffness_tensor_youngpoisson', 'output_dir', 'get_pars', '__doc__'] Traceback (most recent call last): File "./simple.py", line 106, in <module> main() File "./simple.py", line 95, in main conf = ProblemConf.from_file( filename_in, required, other ) File "/home/grassy/sfepy/sfepy/base/conf.py", line 249, in from_file obj.setup( define_dict, funmod, filename, required, other ) File "/home/grassy/sfepy/sfepy/base/conf.py", line 287, in setup self.transform_input() File "/home/grassy/sfepy/sfepy/base/conf.py", line 372, in transform_input self.__dict__[key] = transform( self.__dict__[key] ) File "/home/grassy/sfepy/sfepy/base/conf.py", line 142, in transform_materials d2['material_'+conf['name']] = c2 KeyError: 'name'
The model is posted here: http://groups.google.com/group/sfepy-devel/web/its2D.vtk?hl=en
Can someone see the problem?
Here's its2D.py:
# 02.04.2010 # Diametrically point loaded disk.
from sfepy.mechanics.matcoefs import youngpoisson_to_lame, stiffness_tensor_youngpoisson
filename = 'its2D.vtk' output_dir = 'pyfem' filename_mesh = filename
def get_pars(young, poisson, dim, plane = 'strain', full = False): if full: return stiffness_tensor_youngpoisson(dim, young, poisson, plane) else: lam,mu=youngpoisson_to_lame(young, poisson, plane) return lam,mu
def stress_strain(out, pb, state, extend = False): ''' Strain and stress for given displacements. ''' from sfepy.base.base import Struct from sfepy.fem.evaluate import eval_term_op strain = eval_term_op(state, 'de_cauchy_strain.i1.Omega(u)', pb) out['cauchy_strain'] = Struct(name = 'output_data', mode = 'cell', data = strain, dofs = None) stress = eval_term_op(state, 'de_cauchy_stress.i1.Omega(solid.D, u)', pb) out['cauchy_stress'] = Struct(name = 'output_data', mode = 'cell', data = stress, dofs = None) return out
options = { 'output_dir' : output_dir, 'output_format' : 'vtk', 'post_process_hook' : 'stress_strain', }
regions = { 'Omega' : ('all', {}), 'Left' : ('nodes in (x < 0.001)', {}), 'Bottom' : ('nodes in (y < 0.001)', {}), 'Top' : ('node 2', {}), }
materials = { 'name' : 'solid', 'region' : 'Omega', 'values' : { 'lam' : get_pars(2000., 0.4, 2, 'stress')[0], 'mu' : get_pars(2000., 0.4, 2, 'stress')[1], 'D' : get_pars(2000., 0.4, 2, 'stress', full = True), 'density' : 0.2500, # in 1e4 kg/m3 }, 'flags' : {'special_constant' : True}, }
fields = { 'displacement': ((2,1), 'real', 'Omega', {'Omega' : '2_3_P1'}), }
integrals = { 'i1' : ('v', 'gauss_o3_d2'), }
variables = { 'u' : ('unknown field', 'displacement', 0), 'v' : ('test field' , 'displacement', 'u'), }
ebcs = { 'XSym' : ('Left', {'u.0' : 0.0}), 'YSym' : ('Bottom', {'u.1' : 0.0}), 'Load' : ('Top', {'u.0' : 0.0, 'u.1' : -0.5}), }
equations = { 'balance_of_forces' : """dw_lin_elastic_iso.i1.Omega(solid.lam, solid.mu, v, u ) = 0""", }
solvers = { 'ls' : ('ls.scipy_direct', {}), 'newton' : ('nls.newton', { 'i_max' : 1, 'eps_a' : 1e-6, 'problem' : 'nonlinear'}), }
fe = { 'chunk_size' : 10000 }
Andre

Hi Andre,
It looks like the problem is in your materials declaration. You have it correct for the long format syntax, however, you just need to change "materials" to "material_<N>" where <N> is a number. For example, see the corrected version of your script attached.
Alternatively, you can use the short syntax, which may be what you intended. For that case, see the Materials section of [1] and compare the difference between the long and short forms.
Best! Logan
[1] http://docs.sfepy.org/doc/users_guide.html#problem-description-file
On Sat, Apr 3, 2010 at 12:52 PM, freevryheid <freev...@gmail.com> wrote:
I'm getting the following error on my input file:
grassy@lapdog:~/sfepy$ ./simple.py ~/pyfem/its2D.py sfepy: left over: ['_filename', '__builtins__', '__file__', '__name__', '__package__', 'youngpoisson_to_lame', 'filename', 'stress_strain', 'stiffness_tensor_youngpoisson', 'output_dir', 'get_pars', '__doc__'] Traceback (most recent call last): File "./simple.py", line 106, in <module> main() File "./simple.py", line 95, in main conf = ProblemConf.from_file( filename_in, required, other ) File "/home/grassy/sfepy/sfepy/base/conf.py", line 249, in from_file obj.setup( define_dict, funmod, filename, required, other ) File "/home/grassy/sfepy/sfepy/base/conf.py", line 287, in setup self.transform_input() File "/home/grassy/sfepy/sfepy/base/conf.py", line 372, in transform_input self.__dict__[key] = transform( self.__dict__[key] ) File "/home/grassy/sfepy/sfepy/base/conf.py", line 142, in transform_materials d2['material_'+conf['name']] = c2 KeyError: 'name'
The model is posted here: http://groups.google.com/group/sfepy-devel/web/its2D.vtk?hl=en
Can someone see the problem?
Here's its2D.py:
# 02.04.2010 # Diametrically point loaded disk.
from sfepy.mechanics.matcoefs import youngpoisson_to_lame, stiffness_tensor_youngpoisson
filename = 'its2D.vtk' output_dir = 'pyfem' filename_mesh = filename
def get_pars(young, poisson, dim, plane = 'strain', full = False): if full: return stiffness_tensor_youngpoisson(dim, young, poisson, plane) else: lam,mu=youngpoisson_to_lame(young, poisson, plane) return lam,mu
def stress_strain(out, pb, state, extend = False): ''' Strain and stress for given displacements. ''' from sfepy.base.base import Struct from sfepy.fem.evaluate import eval_term_op strain = eval_term_op(state, 'de_cauchy_strain.i1.Omega(u)', pb) out['cauchy_strain'] = Struct(name = 'output_data', mode = 'cell', data = strain, dofs = None) stress = eval_term_op(state, 'de_cauchy_stress.i1.Omega(solid.D, u)', pb) out['cauchy_stress'] = Struct(name = 'output_data', mode = 'cell', data = stress, dofs = None) return out
options = { 'output_dir' : output_dir, 'output_format' : 'vtk', 'post_process_hook' : 'stress_strain', }
regions = { 'Omega' : ('all', {}), 'Left' : ('nodes in (x < 0.001)', {}), 'Bottom' : ('nodes in (y < 0.001)', {}), 'Top' : ('node 2', {}), }
materials = { 'name' : 'solid', 'region' : 'Omega', 'values' : { 'lam' : get_pars(2000., 0.4, 2, 'stress')[0], 'mu' : get_pars(2000., 0.4, 2, 'stress')[1], 'D' : get_pars(2000., 0.4, 2, 'stress', full = True), 'density' : 0.2500, # in 1e4 kg/m3 }, 'flags' : {'special_constant' : True}, }
fields = { 'displacement': ((2,1), 'real', 'Omega', {'Omega' : '2_3_P1'}), }
integrals = { 'i1' : ('v', 'gauss_o3_d2'), }
variables = { 'u' : ('unknown field', 'displacement', 0), 'v' : ('test field' , 'displacement', 'u'), }
ebcs = { 'XSym' : ('Left', {'u.0' : 0.0}), 'YSym' : ('Bottom', {'u.1' : 0.0}), 'Load' : ('Top', {'u.0' : 0.0, 'u.1' : -0.5}), }
equations = { 'balance_of_forces' : """dw_lin_elastic_iso.i1.Omega(solid.lam, solid.mu, v, u ) = 0""", }
solvers = { 'ls' : ('ls.scipy_direct', {}), 'newton' : ('nls.newton', { 'i_max' : 1, 'eps_a' : 1e-6, 'problem' : 'nonlinear'}), }
fe = { 'chunk_size' : 10000 }
Andre
-- You received this message because you are subscribed to the Google Groups "sfepy-devel" group. To post to this group, send email to sfepy...@googlegroups.com. To unsubscribe from this group, send email to sfepy-devel...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sfepy-devel?hl=en.
participants (3)
-
freevryheid
-
Logan Sorenson
-
Robert Cimrman