Calculate total force from cauchy stress
by Patricia Garcia Cañadilla

Dear Robert,
I have a 2D body of hyperelastic material which contracts and I would like
to compute the total force developed by the body from the cauchy stress. I
am trying to follow some of your indications I found in this group, but I
still couldn't make it works. Could you please help me to fix the problem?
I am getting the following error:
key = (region.name, integral.order, integration)
AttributeError: 'dict' object has no attribute 'name'
I am trying to do the following, inside stress_strain post-processing
function:
def stress_strain(out, problem, state, extend = False ):
from sfepy.base.base import Struct
from sfepy.mechanics.tensors import StressTransform
from sfepy.mechanics.tensors import transform_data
from sfepy.discrete.common.mappings import get_normals
ev = problem.evaluate
field = problem.fields['displacement']
region = problem.domain.regions['Gamma']
integral = problem.integrals['i2']
n = get_normals(field,integral,regions)
stress = ev('dw_tl_fib_a.1.Omega(f1.fmax, f1.eps_opt, f1.s, f1.fdir,
f1.act, v, u )',mode='qp', term_mode= 'stress');
F = ev('ev_def_grad.1.Omega(u)',mode='el_avg');
transform = StressTransform(F)
Cstress = transform.get_cauchy_from_2pk(stress)
T = Cstress*n;
Force = ev('ev_surface_integrate.2.Gamma(T)')
And here it is part of the problem configuration file.
fields = {
'displacement': ('real', 'vector', 'Omega', 1),
}
materials = {
'solid' : (None, 'get_elastic_pars'),
'load' : (None, 'linear_tension'),
'f1' : 'get_pars_fibres1',
}
variables = {
'u': ('unknown field', 'displacement', 0),
'v': ('test field', 'displacement', 'u'),
}
regions = {
'Omega' : 'all',
'Fix1' : ('vertices in x < %.10f' % (fix_point + eps2), 'facet'),
'Fix2' : ('vertices in x > %.10f' % (fix_point - eps2), 'facet'),
'Fix' : ('r.Fix1 *v r.Fix2', 'facet'),
'Gamma' : ('vertices of surface','edge'),
}
ebcs = {
'fixb' : ('Fix', {'u.all' : 0.0}),
}
integrals = {
'i1' : ('v', 1),
'i2' : ('s', 2),
}
3 months, 1 week

Re: Torque
by Robert Cimrman

In examples/large_deformation/hyperelastic.py a rotation by displacements is applied. By using a similar function the vectors defining the force couples could be defined for dw_surface_ltr (IMHO). Does it make sense?
r.
----- Reply message -----
From: "Andre Smit" <freev...(a)gmail.com>
To: <sfepy...(a)googlegroups.com>
Subject: Torque
Date: Sat, Dec 18, 2010 05:10
What is the best way to apply a torque load to a model?
--
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...(a)googlegroups.com.
To unsubscribe from this group, send email to sfepy-devel...(a)googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sfepy-devel?hl=en.
1 year, 1 month

Do I generate mesh in the wrong way?
by Ronghai Wu

Hi Robert,
I am using sfepy for static linear elasticity problem in 2D. The mesh size
is 200*200 (mesh file is attached) and equations are as following:
def D_function(self, ts, coors, mode, term=None, **kwargs):
if mode != 'qp': return
_, weights = term.integral.get_qp('2_4')
self.n_qp = weights.shape[0]
self.val_D = np.repeat(self.stiffness_tensor, self.n_qp, axis=0)
return {'function' : self.val_D}
def prestress_function(self,ts, coors, mode, term=None, **kwargs):
if mode != 'qp': return
_, weights = term.integral.get_qp('2_4')
self.n_qp = weights.shape[0]
self.val_pre = np.repeat(self.prestress_value, self.n_qp, axis=0)
return {'function' : self.val_pre}
self.m = Material('m', function=self.D_function)
self.prestress_value = np.copy(self.stress_0)
(self.prestress_value).shape = (-1, 3, 1)
self.prestress = Material('prestress', function=self.prestress_function)
integral = Integral('i', order=2)
self.t1 = Term.new('dw_lin_elastic(m.function, v, u )', integral, self.omega, m=self.m, v=self.v, u=self.u)
self.t2 = Term.new('dw_lin_prestress(prestress.function, v )',integral, self.omega, prestress=self.prestress, v=self.v)
self.t3 = Term.new('dw_surface_ltr(traction_lef.val, v)', integral, self.lef, traction_lef=self.traction_lef, v=self.v)
self.t4 = Term.new('dw_surface_ltr(traction_rig.val, v)', integral, self.rig, traction_rig=self.traction_rig, v=self.v)
self.t5 = Term.new('dw_surface_ltr(traction_top.val, v)', integral, self.top, traction_top=self.traction_top, v=self.v)
self.t6 = Term.new('dw_surface_ltr(traction_bot.val, v)', integral, self.bot, traction_bot=self.traction_bot, v=self.v)
self.fem_eq = Equation('balance', self.t1 - self.t2 - self.t3 - self.t4 - self.t5 - self.t6)
self.eqs = Equations([self.fem_eq])
self.ls = ScipyDirect({})
self.nls_status = IndexedStruct()
self.nls = Newton({'i_max' : 1,'eps_a' : 1e-8,'problem' : 'nonlinear'}, lin_solver=self.ls, status=self.nls_status)
self.pb = Problem('elasticity', equations=self.eqs, nls=self.nls, ls=self.ls)
self.pb.time_update(ebcs=Conditions([fix_u_lef_corn]))
self.pb.update_materials()
self.vec = self.pb.solve()
When I run the simulation, the information below are printed. I have
several questions about it. I tried to find answers from source codes but
failed. Could you please give me some help, thanks.
(1) I do understand why "matrix shape: (79999, 79999)" and "matrix
structural nonzeros: 1439965". what exactly this "matrix" is? what is its
relation with mesh size (200*200)?
(2) I do not understand why "updating materials..." did twice.
(3) "solve: 6.18 [s]". I guess it should not take such a long time for a
mesh size (200*200) problem. Is it because I generate mesh file in the
wrong way or because of other reasons?
(4) In which source code file the following information are printed?
sfepy: updating variables...
sfepy: ...done
sfepy: setting up dof connectivities...
sfepy: ...done in 0.00 s
sfepy: matrix shape: (79999, 79999)
sfepy: assembling matrix graph...
sfepy: ...done in 0.05 s
sfepy: matrix structural nonzeros: 1439965 (2.25e-04% fill)
sfepy: updating materials...
sfepy: m
sfepy: traction_bot
sfepy: traction_rig
sfepy: prestress
sfepy: traction_top
sfepy: traction_lef
sfepy: ...done in 0.05 s
sfepy: updating materials...
sfepy: m
sfepy: traction_bot
sfepy: traction_rig
sfepy: prestress
sfepy: traction_top
sfepy: traction_lef
sfepy: ...done in 0.05 s
sfepy: nls: iter: 0, residual: 4.741758e+01 (rel: 1.000000e+00)
sfepy: rezidual: 0.04 [s]
sfepy: solve: 6.18 [s]
sfepy: matrix: 0.10 [s]
sfepy: nls: iter: 1, residual: 5.936719e-14 (rel: 1.252008e-15)
sfepy: equation "tmp":
sfepy: ev_cauchy_strain.2.Omega(u)
sfepy: updating materials...
sfepy: ...done in 0.00 s
Regards
Ronghai
2 years, 7 months

ValueError: variable kind is 2 or 3 words! (test_field)
by Nikhil Vaidya

When I run a simulation i get the following error:
Traceback (most recent call last):
File "C:\sfepy\simple.py", line 170, in <module>
main()
File "C:\sfepy\simple.py", line 163, in main
app = PDESolverApp(conf, options, output_prefix)
File "C:\sfepy\sfepy\applications\pde_solver_app.py", line 137, in
__init__
self.problem = Problem.from_conf(conf, init_equations=is_eqs, **kwargs)
File "C:\sfepy\sfepy\discrete\problem.py", line 120, in from_conf
obj.set_equations(conf.equations, user={'ts' : obj.ts})
File "C:\sfepy\sfepy\discrete\problem.py", line 411, in set_equations
variables = Variables.from_conf(self.conf_variables, self.fields)
File "C:\sfepy\sfepy\discrete\variables.py", line 156, in from_conf
var = Variable.from_conf(key, val, fields)
File "C:\sfepy\sfepy\discrete\variables.py", line 809, in from_conf
raise ValueError('variable kind is 2 or 3 words! (%s)' % conf.kind)
ValueError: variable kind is 2 or 3 words! (test_field)
The above error message is displayed after the region definition process.
Can you tell me what is causing this issue?
Best regards,
Nikhil
2 years, 7 months

probe.py
by Jan Heczko

Hi,
I tried to test the usage of probe.py as a script according to the example
[1], i.e. I called
./simple.py examples/linear_elasticity/its2D_4.py
which creates its2D.h5 and then
./probe.py examples/linear_elasticity/its2D_4.py its2D.h5
which results in:
probe: left over: ['refine_mesh', 'verbose', '__builtins__',
'absolute_import', '__file__', '__name__', 'stiffness_from_youngpoisson',
'data_dir', '_filename', 'refinement_level', 'young', '__package__',
'stress_strain', 'range', 'probe_hook', 'output_dir', 'poisson', 'gen_lines'
, '__doc__']
probe: results in: its2D.h5
probe: loaded: [u'cauchy_stress', u'cauchy_strain', u'u']
probe: from step: 0
probe: reading mesh [line2, tri3, quad4, tetra4, hexa8] (/media/sf_sfepy/
meshes/2d/its2D.mesh)...
probe: ...done in 0.00 s
probe: creating regions...
probe: Top
probe: Bottom
probe: Omega
probe: Left
probe: ...done in 0.01 s
probe: 0 line [[ 0. 0.], [ 75. 0.]]
Traceback (most recent call last):
File "./probe.py", line 272, in <module>
main()
File "./probe.py", line 269, in main
generate_probes(filename_input, filename_results, options)
File "./probe.py", line 139, in generate_probes
out = probe_hook(data, probe, labels[ip], problem)
File "/media/sf_sfepy/examples/linear_elasticity/its2D_4.py", line 92, in
probe_hook
results['u'] = get_it('u', 'u')
File "/media/sf_sfepy/examples/linear_elasticity/its2D_4.py", line 87, in
get_it
pars, vals = probe(var)
File "/media/sf_sfepy/sfepy/discrete/probes.py", line 239, in __call__
return self.probe(variable, **kwargs)
File "/media/sf_sfepy/sfepy/discrete/probes.py", line 287, in probe
refine_flag = self.refine_points(variable, points, cells)
File "/media/sf_sfepy/sfepy/discrete/probes.py", line 322, in
refine_points
ed = variable.get_element_diameters(cells, 0)
File "/media/sf_sfepy/sfepy/discrete/variables.py", line 1830, in
get_element_diameters
diameters = domain.get_element_diameters(cells, vg, mode, square=square)
File "/media/sf_sfepy/sfepy/discrete/fem/domain.py", line 173, in
get_element_diameters
vg.get_element_diameters(diameters, gel.edges,
AttributeError: 'tuple' object has no attribute 'get_element_diameters'
Am I using it the right way? Is my sfepy installation broken in some way?
I tried the same using an older version of sfepy, which gave a different
error.
[1]
http://sfepy.org/doc-devel/examples/linear_elasticity/its2D_4.html?highli...
Regards
Jan
2 years, 7 months

Error while reading mesh
by Nikhil Vaidya

I am running a Navier stokes simulation. I observed the following output
after I ran my file:
simple.py RF_testcase\Vein_flow_setup.py
sfepy: left over: ['__builtins__', '__file__', 'absolute_import',
'__doc__', '__name__', '__package__', 'verbose',
'verify_incompressibility', '_filename']
sfepy: reading mesh [line2, tri3, quad4, tetra4, hexa8]
(C:\sfepy\RF_testcase\sfepy_test_full_geom_m.mesh)...
Traceback (most recent call last):
File "C:\sfepy\simple.py", line 170, in <module>
main()
File "C:\sfepy\simple.py", line 163, in main
app = PDESolverApp(conf, options, output_prefix)
File "C:\sfepy\sfepy\applications\pde_solver_app.py", line 137, in
__init__
self.problem = Problem.from_conf(conf, init_equations=is_eqs, **kwargs)
File "C:\sfepy\sfepy\discrete\problem.py", line 88, in from_conf
mesh = Mesh.from_file(conf.filename_mesh, prefix_dir=conf_dir)
File "C:\sfepy\sfepy\discrete\fem\mesh.py", line 225, in from_file
mesh = io.read(mesh, omit_facets=omit_facets)
File "C:\sfepy\sfepy\discrete\fem\meshio.py", line 330, in read
_read_cells(3, 4)
File "C:\sfepy\sfepy\discrete\fem\meshio.py", line 305, in _read_cells
data = read_array(fd, num, size + 1 * has_id, nm.int32)
File "C:\sfepy\sfepy\base\ioutils.py", line 215, in read_array
raise ValueError('(%d, %d) array reading failed!' % (n_row, n_col))
ValueError: (1376353, 5) array reading failed!
I created the mesh in NETGEN and had to remove surface elements by hand.
Can you tell me what is going wrong?
Best regards,
Nikhil
2 years, 7 months

About Mesh
by Nikhil Vaidya

Hello!
I am trying to solve a problem using sfepy. It is a multiphysics problem
with weakly coupled convection and conduction. There are three regions in
my domain which need to be separately defined. I went through the user
guide and saw the format for defining regions in the domain. The regions in
my geometry are not simple enough to be described by mathematical
conditions. I usually use Starccm+ for my multiphysics simulations. There I
define the regions using the GUI. One region in my domain is a real blood
vessel observed in a CT scan. Can anyone tell me how I should define my
regions in this case?
I have seen in the user guide, that regions can be defined using "groups"
of cells and vertices. I would like to know how these groups are defined.
Best regards,
Nikhil
2 years, 8 months

memory corruption error
by Nicolas DELAN

Hi,
I try to launch several times sfepy using a loop but at the second
iteration i have this error:
glibc detected *** python: malloc(): memory corruption: 0x0000000002e2d810
***
Is there any solution ?
2 years, 8 months

Error in mult_physics/thermal_electric.py example
by Nikhil Vaidya

Hi I ran the thermal_electric example in the multiphysics folder using
simple.py. I got the following error messages during execution:
sfepy: ====== time 0.000000e+00 (step 1 of 11) =====
sfepy: initial residual evaluation failed, giving up...
Traceback (most recent call last):
File "C:\sfepy\simple.py", line 170, in <module>
main()
File "C:\sfepy\simple.py", line 167, in main
app()
File "C:\sfepy\sfepy\applications\application.py", line 29, in call_basic
return self.call(**kwargs)
File "C:\sfepy\sfepy\applications\pde_solver_app.py", line 220, in call
post_process_hook=self.post_process_hook):
File "C:\sfepy\sfepy\solvers\ts_solvers.py", line 337, in __call__
state = self.solve_step(ts, state0, nls_status=nls_status)
File "C:\sfepy\sfepy\solvers\ts_solvers.py", line 374, in solve_step
nls_status=nls_status)
File "C:\sfepy\sfepy\solvers\ts_solvers.py", line 185, in
make_implicit_step
vec_r = ev.eval_residual(state(), is_full=True)
File "C:\sfepy\sfepy\discrete\evaluate.py", line 54, in eval_residual
vec_r = self.problem.equations.eval_residuals(vec)
File "C:\sfepy\sfepy\discrete\equations.py", line 679, in eval_residuals
self.evaluate(mode='weak', dw_mode='vector', asm_obj=out)
File "C:\sfepy\sfepy\discrete\equations.py", line 615, in evaluate
term_mode=term_mode, asm_obj=asm_obj)
File "C:\sfepy\sfepy\discrete\equations.py", line 832, in evaluate
ret_status=True)
File "C:\sfepy\sfepy\terms\terms.py", line 1368, in evaluate
fargs = self.call_get_fargs(_args, kwargs)
File "C:\sfepy\sfepy\terms\terms.py", line 1233, in call_get_fargs
fargs = self.get_fargs(*args, **kwargs)
File "C:\sfepy\sfepy\terms\terms_electric.py", line 27, in get_fargs
grad = self.get(parameter, 'grad')
File "C:\sfepy\sfepy\terms\terms.py", line 1082, in get
is_trace=self.arg_traces[name], bf=bf)
File "C:\sfepy\sfepy\discrete\variables.py", line 1634, in evaluate
vec = self(step=step, derivative=time_derivative, dt=dt)
File "C:\sfepy\sfepy\discrete\variables.py", line 1152, in __call__
% (self.name, step))
ValueError: data of variable are not set! (phi_known, step 0)
Do you know what is causing this error?
Also, could anyone provide a sample output for all the sfepy examples? That
would be of great help.
- Nikhil
2 years, 8 months