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

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

Type Error running examples
by Christopher Jones

I am getting the following error while trying to run 'its2d_interactive.py'.
C:\Python36\Lib\site-packages\sfepy\linalg>python
C:\Python36\Lib\site-packages\sfepy\examples\linear_elasticity\its2D_interactive.py
Traceback (most recent call last):
File
"C:\Python36\Lib\site-packages\sfepy\examples\linear_elasticity\its2D_interactive.py",
line 51, in <module>
from examples.linear_elasticity.its2D_2 import stress_strain
ModuleNotFoundError: No module named 'examples'
I have been getting this error when ever I try to run examples.
I tried changing the forward slashes to back slashes with no effect. I
installed most of the dependencies from PIP, and installed a pre-built
binary from Gohlke's LFD python libs page.
I've tried running from the console as seen in the above error. I've also
tried running from IDLE, for python 3.6. ANd I get no error messages from
the IDLE console but also, I get no output file. I'm running IDLE with
elevated privelage and I created the output directory inside the sfepy
install directory, i.e.
C:\Python36\Lib\site-packages\sfepy\examples\results...
Ok, I see this error. I was not in the sfepy base directory. I changed this
and got output in the console with the following error:
C:\Python36\Lib\site-packages\sfepy>python
C:\Python36\Lib\site-packages\sfepy\examples\linear_elasticity\its2D_interactive.py
sfepy: using values:
sfepy: Young's modulus: 2000.0
sfepy: Poisson's ratio: 0.4
sfepy: vertical load: -1000.0
sfepy: uniform mesh refinement level: 0
sfepy: reading mesh [line2, tri3, quad4, tetra4, hexa8]
(C:\Python36\lib\site-packages\sfepy/meshes/2d/its2D.mesh)...
sfepy: ...done in 0.00 s
Traceback (most recent call last):
File
"C:\Python36\Lib\site-packages\sfepy\examples\linear_elasticity\its2D_interactive.py",
line 293, in <module>
main()
File
"C:\Python36\Lib\site-packages\sfepy\examples\linear_elasticity\its2D_interactive.py",
line 175, in main
domain = FEDomain('domain', mesh)
File "C:\Python36\lib\site-packages\sfepy\discrete\fem\domain.py", line
50, in __init__
gel.poly_space = PolySpace.any_from_args(key, gel, 1)
File "C:\Python36\lib\site-packages\sfepy\discrete\fem\poly_spaces.py",
line 272, in any_from_args
return table[key](name, geometry, order)
File "C:\Python36\lib\site-packages\sfepy\discrete\fem\poly_spaces.py",
line 444, in __init__
self.nodes, self.nts, node_coors = self._define_nodes()
File "C:\Python36\lib\site-packages\sfepy\discrete\fem\poly_spaces.py",
line 465, in _define_nodes
nodes = nm.zeros((n_nod, n_v), nm.int32)
TypeError: 'float' object cannot be interpreted as an integer
Any ideas?
Thanks,
Chris
2 years, 2 months

BC using dw_surface_flux not being met?
by David Jessop

Hi,
I need to set insulated boundaries on two edges of my problem, and set the
flux on a third. I've specified material properties (2D problem) as
ins = Material('ins', val=[[0.0, 0.0], [0.0, 0.0]])
flux = Material('flux', val=[[-1.0, 0.0], [0.0, -1.0]])
and then I write my BCs as
tSurfInsT = Term.new('dw_surface_flux(ins.val, u, v)', integral, Top, ins=
ins, u=u, v=v)
tSurfInsL = Term.new('dw_surface_flux(ins.val, u, v)', integral, Left, ins=
ins, u=u, v=v)
tSurfFluxR = Term.new('dw_surface_flux(flux.val, u, v)', integral, Right,
flux=flux, u=u, v=v)
As you might infer from the visualisation of the solution below, thes BCs
are not being met (slope of the contours should be flat on the LHS and not
flat on the right). Indeed, if I comment these out of the equation
definition, the solution remains unchanged. What is going on?
Thanks,
David
<https://lh3.googleusercontent.com/-cTRMmEvK4b0/WGy-o0MCHaI/AAAAAAAAA8s/F0...>
2 years, 3 months

Help in defining a contact problem for multiple bodies
by samyak jain

Hello everyone,
I am new to Sfepy and to Finite Element Analysis. I am currently trying to
solve a contact problem between two bodies to the find the displacement and
the stress.
The first body is a hemisphere (could be other shape-later on) and the
second body is any free-form shape.
The second body is fixed and there is a specified displacement boundary
condition on the first body.
That is all regarding the problem definition and the boundary conditions.
I have seen few examples in the gallery section sfepy website and I found
an example of Contact Sphere, Contact plane and an example with
displacement boundary condition.
But in all these examples, there is always one mesh and consequently one
domain where we can define our boundary regions and solve the PDE.
But in my case, I have two mesh as I cannot combine them. If I can combine
them as one mesh, I can solve the problem but I cannot do that.
So, how would I progress with this problem. I have two mesh, so I will have
two different domain and them use it to define regions. Now the problem
arises where should I define the field variable. What I understand that
there will be two different field variable based on two domain but I am not
sure how to use sfepy to solve such a problem.
Could someone please guide me by an example of such a case where contact
between multiple bodies is done with multiple mesh being used. I have tried
and I am unable to come up with a proper way to use sfepy with this problem.
Thanks a lot.
Samyak
2 years, 3 months

one problem in ''biot.py"
by Kid Guo

Hi,
I have a problem based on "../sfepy/examples/multi_physics/biot.py".
In the attached scripy 'block2.py', I have calculated the stress and strain
according to the displacement, at the 111 and 112 lines you can see it.
Now I want to output the K of every cell, I gave a value of k at the 64
line in this script, it is a 3*3 array.
I don't know which function or equation to use, so I was stucked at the 113
line.
if I change the K value, will where be some difference results?
Thank you advance
K.
2 years, 3 months

Surface normal
by Nikhil Vaidya

Hello,
I have a question regarding the surface normal vector when using the term:
dw_surface_flux
In my problem, I have an interface between two materials. For each
material, the weak form contains the above term. Now, I have defined the
interface as a facet region, and I pass this to the term in both equations.
I think that the normal vector for the surface in the respective materials
is not defined. How can I define this?
Best regards,
Nikhil
2 years, 3 months

Error in calculating cauchy stress. Wrong arguments shape
by samyak jain

Hi all. I keep getting this error with the latest version of sfepy when I
run the following lines. Could you guys please help.
strain = pb.evaluate('ev_cauchy_strain.{dim}.Omega(u)'.format(dim=dims), mode='el_avg')
The above line works fine.
stress = pb.evaluate('ev_cauchy_stress.3.Omega(m.D, u)', copy_materials=False, mode='el_avg')
but the stress line always shows the error below. m is defined before in the problem with 'D' value.
File "C:\Python27\lib\site-packages\sfepy\discrete\problem.py", line
1264, in evaluate
sfepy: allowed argument shapes for term "ev_cauchy_stress.3.Omega(m.D, u)":
sfepy: [{'material': 'S, S', 'parameter': 'D'}]
mode=mode, dw_mode=dw_mode, term_mode=term_mode)
File "C:\Python27\lib\site-packages\sfepy\discrete\evaluate.py", line
280, in eval_equations
term_mode=term_mode, asm_obj=asm_obj)
File "C:\Python27\lib\site-packages\sfepy\discrete\equations.py", line
621, in evaluate
term_mode=term_mode)
File "C:\Python27\lib\site-packages\sfepy\discrete\equations.py", line
817, in evaluate
ret_status=True)
File "C:\Python27\lib\site-packages\sfepy\terms\terms.py", line 1337, in
evaluate
self.check_shapes(*args)
File "C:\Python27\lib\site-packages\sfepy\terms\terms.py", line 1215, in
check_shapes
% term_str)
ValueError: wrong arguments shapes for "ev_cauchy_stress.3.Omega(m.D, u)"
term! (see above)
2 years, 3 months