![](https://secure.gravatar.com/avatar/27f6b03a726ccff3f7a5007b1df6bf8c.jpg?s=120&d=mm&r=g)
Hi Torsten!
Look at the SfePy Primer [1], specifically the post-processing section. In short, you need to define a function ('post_process_hook' option in input file) that computes derived quantities from the computed variables (e.g. strain or stress from displacements).
Let us know how it goes.
Cheers, r.
[1] http://docs.sfepy.org/doc-devel/primer.html
----- Reply message ----- From: "Torsten Bronger" <torsten...@gmail.com> To: <sfepy...@googlegroups.com> Subject: Getting tension for each finite element Date: Tue, Dec 20, 2011 22:22
Hallöchen!
I used linear_elasticity.py as a starting point for simulating stress in thin silicon layers. My manual meshing worked, and the displacements seem to be calculated properly. However, how do I get the stress in each element? I need it for determining where the layer will break.
The original node positions of the mesh are totally relaxated (no tension anywhere).
Tschö, Torsten.
-- Torsten Bronger Jabber ID: torsten...@jabber.rwth-aachen.de or http://bronger-jmp.appspot.com
-- 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.
![](https://secure.gravatar.com/avatar/7aaa97c584bdc77a84645c8d31e2205b.jpg?s=120&d=mm&r=g)
Hallöchen!
Robert Cimrman writes:
Look at the SfePy Primer [1], specifically the post-processing section. In short, you need to define a function ('post_process_hook' option in input file) that computes derived quantities from the computed variables (e.g. strain or stress from displacements).
Thanks for the hint!
I added the second line of
m = Material("m", lam=1.0, mu=1.0)
m.D = stiffness_tensor_youngpoisson(2, young, poisson)
but I don't know how to add the post processing hook to
pb = ProblemDefinition("elasticity", equations=eqs, nls=nls, ls=ls)
In SfePy's sources, I find post_process_hook only in SimpleApp. However, linear_elasticity.py doesn't use it. Do I have to switch to SimpleApp?
Tschö, Torsten.
-- Torsten Bronger Jabber ID: torsten...@jabber.rwth-aachen.de or http://bronger-jmp.appspot.com
![](https://secure.gravatar.com/avatar/7aaa97c584bdc77a84645c8d31e2205b.jpg?s=120&d=mm&r=g)
Hallöchen!
Torsten Bronger writes:
[...]
I added the second line of
m = Material("m", lam=1.0, mu=1.0) m.D = stiffness_tensor_youngpoisson(2, young, poisson)
This must be:
m = Material("m", lam=1.0, mu=1.0,
D=stiffness_tensor_youngpoisson(2, young, poisson))
but I don't know how to add the post processing hook to
pb = ProblemDefinition("elasticity", equations=eqs, nls=nls, ls=ls)
It works with
pb.save_state("linear_elasticity.vtk", vec,
post_process_hook=stress_strain)
Tschö, Torsten.
-- Torsten Bronger Jabber ID: torsten...@jabber.rwth-aachen.de or http://bronger-jmp.appspot.com
![](https://secure.gravatar.com/avatar/27f6b03a726ccff3f7a5007b1df6bf8c.jpg?s=120&d=mm&r=g)
On 12/21/11 19:11, Torsten Bronger wrote:
Hallöchen!
Torsten Bronger writes:
[...]
I added the second line of
m = Material("m", lam=1.0, mu=1.0) m.D = stiffness_tensor_youngpoisson(2, young, poisson)
This must be:
m = Material("m", lam=1.0, mu=1.0, D=stiffness_tensor_youngpoisson(2, young, poisson))
Even the way above should work, right?
but I don't know how to add the post processing hook to
pb = ProblemDefinition("elasticity", equations=eqs, nls=nls, ls=ls)
It works with
pb.save_state("linear_elasticity.vtk", vec, post_process_hook=stress_strain)
Yes, exactly!
r.
![](https://secure.gravatar.com/avatar/7aaa97c584bdc77a84645c8d31e2205b.jpg?s=120&d=mm&r=g)
Hallöchen!
Robert Cimrman writes:
On 12/21/11 19:11, Torsten Bronger wrote:
Torsten Bronger writes:
[...]
I added the second line of
m = Material("m", lam=1.0, mu=1.0) m.D = stiffness_tensor_youngpoisson(2, young, poisson)
This must be:
m = Material("m", lam=1.0, mu=1.0, D=stiffness_tensor_youngpoisson(2, young, poisson))
Even the way above should work, right?
No, it doesn't work here.
Traceback (most recent call last): File "asi_breaker.py", line 141, in <module> main() File "asi_breaker.py", line 134, in main pb.save_state("linear_elasticity.vtk", vec, post_process_hook=stress_strain) File "/home/bronger/sfepy/sfepy/fem/problemDef.py", line 661, in save_state out = post_process_hook( out, self, state, extend = extend ) File "asi_breaker.py", line 74, in stress_strain stress = ev(b"de_cauchy_stress.2.Omega(silicon.D, u)", mode="el_avg") File "/home/bronger/sfepy/sfepy/fem/problemDef.py", line 1160, in evaluate mode=mode, dw_mode=dw_mode, term_mode=term_mode) File "/home/bronger/sfepy/sfepy/fem/evaluate.py", line 280, in eval_equations asm_obj=asm_obj) File "/home/bronger/sfepy/sfepy/fem/equations.py", line 505, in evaluate asm_obj=asm_obj) File "/home/bronger/sfepy/sfepy/fem/equations.py", line 716, in evaluate ret_status=True) File "/home/bronger/sfepy/sfepy/terms/terms.py", line 1418, in evaluate args = self.get_args(**kwargs) File "/home/bronger/sfepy/sfepy/terms/terms.py", line 957, in get_args ig, par_name) File "/home/bronger/sfepy/sfepy/fem/materials.py", line 354, in get_data return self._get_data( key, ig, name ) File "/home/bronger/sfepy/sfepy/fem/materials.py", line 380, in _get_data return datas[ig][name] KeyError: 'D'
Tschö, Torsten.
-- Torsten Bronger Jabber ID: torsten...@jabber.rwth-aachen.de or http://bronger-jmp.appspot.com
![](https://secure.gravatar.com/avatar/27f6b03a726ccff3f7a5007b1df6bf8c.jpg?s=120&d=mm&r=g)
On Thu, 22 Dec 2011, Torsten Bronger wrote:
Hall�chen!
Robert Cimrman writes:
On 12/21/11 19:11, Torsten Bronger wrote:
Torsten Bronger writes:
[...]
I added the second line of
m = Material("m", lam=1.0, mu=1.0) m.D = stiffness_tensor_youngpoisson(2, young, poisson)
This must be:
m = Material("m", lam=1.0, mu=1.0, D=stiffness_tensor_youngpoisson(2, young, poisson))
Even the way above should work, right?
No, it doesn't work here.
Traceback (most recent call last): File "asi_breaker.py", line 141, in <module> main() File "asi_breaker.py", line 134, in main pb.save_state("linear_elasticity.vtk", vec, post_process_hook=stress_strain) File "/home/bronger/sfepy/sfepy/fem/problemDef.py", line 661, in save_state out = post_process_hook( out, self, state, extend = extend ) File "asi_breaker.py", line 74, in stress_strain stress = ev(b"de_cauchy_stress.2.Omega(silicon.D, u)", mode="el_avg") File "/home/bronger/sfepy/sfepy/fem/problemDef.py", line 1160, in evaluate mode=mode, dw_mode=dw_mode, term_mode=term_mode) File "/home/bronger/sfepy/sfepy/fem/evaluate.py", line 280, in eval_equations asm_obj=asm_obj) File "/home/bronger/sfepy/sfepy/fem/equations.py", line 505, in evaluate asm_obj=asm_obj) File "/home/bronger/sfepy/sfepy/fem/equations.py", line 716, in evaluate ret_status=True) File "/home/bronger/sfepy/sfepy/terms/terms.py", line 1418, in evaluate args = self.get_args(**kwargs) File "/home/bronger/sfepy/sfepy/terms/terms.py", line 957, in get_args ig, par_name) File "/home/bronger/sfepy/sfepy/fem/materials.py", line 354, in get_data return self._get_data( key, ig, name ) File "/home/bronger/sfepy/sfepy/fem/materials.py", line 380, in _get_data return datas[ig][name] KeyError: 'D'
Yes, sorry, I was wrong. The data attributes have to be passed all when creating the instance (the second way above).
Cheers, r.
![](https://secure.gravatar.com/avatar/27f6b03a726ccff3f7a5007b1df6bf8c.jpg?s=120&d=mm&r=g)
On 12/21/11 15:50, Torsten Bronger wrote:
Hallöchen!
Robert Cimrman writes:
Look at the SfePy Primer [1], specifically the post-processing section. In short, you need to define a function ('post_process_hook' option in input file) that computes derived quantities from the computed variables (e.g. strain or stress from displacements).
Thanks for the hint!
I added the second line of
m = Material("m", lam=1.0, mu=1.0) m.D = stiffness_tensor_youngpoisson(2, young, poisson)
but I don't know how to add the post processing hook to
pb = ProblemDefinition("elasticity", equations=eqs, nls=nls, ls=ls)
In SfePy's sources, I find post_process_hook only in SimpleApp. However, linear_elasticity.py doesn't use it. Do I have to switch to SimpleApp?
post_process_hook is a keyword argument to ProblemDefinition.save_state()
otherwise - at the level if an input file, you can specify it in 'options' keyword.
r.
![](https://secure.gravatar.com/avatar/7aaa97c584bdc77a84645c8d31e2205b.jpg?s=120&d=mm&r=g)
Hallöchen!
Robert Cimrman writes:
Look at the SfePy Primer [1], specifically the post-processing section. In short, you need to define a function ('post_process_hook' option in input file) that computes derived quantities from the computed variables (e.g. strain or stress from displacements).
Let us know how it goes.
If I say
stress = pb.evaluate("de_cauchy_stress.2.Omega(silicon.D, u)", mode="el_avg")
print(repr(stress))
I get something like
array([[[[ 298.62126426],
[ 228.57003414],
[ 19.25326414]]],
[[[ 342.02403106],
[ 353.74870016],
[ -21.73842943]]],
What do the three values in each group mean?
Tschö, Torsten.
-- Torsten Bronger Jabber ID: torsten...@jabber.rwth-aachen.de or http://bronger-jmp.appspot.com
![](https://secure.gravatar.com/avatar/27f6b03a726ccff3f7a5007b1df6bf8c.jpg?s=120&d=mm&r=g)
Hello Torsten!
On 01/03/12 15:44, Torsten Bronger wrote:
Hallöchen!
Robert Cimrman writes:
Look at the SfePy Primer [1], specifically the post-processing section. In short, you need to define a function ('post_process_hook' option in input file) that computes derived quantities from the computed variables (e.g. strain or stress from displacements).
Let us know how it goes.
If I say
stress = pb.evaluate("de_cauchy_stress.2.Omega(silicon.D, u)", mode="el_avg") print(repr(stress))
I get something like
array([[[[ 298.62126426], [ 228.57003414], [ 19.25326414]]], [[[ 342.02403106], [ 353.74870016], [ -21.73842943]]],
What do the three values in each group mean?
The shape is, in general, (n_elements, n_quadrature_points, n_row, n_col). In "el_avg" mode, you get an average of all quadrature points values per element, so the shape in your case is (n_elements, 1, n_row, n_col). So each group, as you say, is the value of the stress tensor in the corresponding element. It has n_row = 3, n_col = 1, as it is symmetric 2x2 and we store only the items 11, 22, 12 (in this order).
Is this clear enough?
r.
![](https://secure.gravatar.com/avatar/7aaa97c584bdc77a84645c8d31e2205b.jpg?s=120&d=mm&r=g)
Hallöchen!
Robert Cimrman writes:
[...]
The shape is, in general, (n_elements, n_quadrature_points, n_row, n_col). In "el_avg" mode, you get an average of all quadrature points values per element, so the shape in your case is (n_elements, 1, n_row, n_col). So each group, as you say, is the value of the stress tensor in the corresponding element. It has n_row = 3, n_col = 1, as it is symmetric 2x2 and we store only the items 11, 22, 12 (in this order).
Is this clear enough?
Absolutely, thank you. It enabled me to calculate the "equivalent tensile stress" (see http://en.wikipedia.org/wiki/Von_Mises_yield_criterion) for each element according to sqrt(a11**2 - a11 * a22 + a22**2 + 3*a12**2).
If this exceeds a certain threshold, the element is deleted. This way, I plan to let a crack extend through the material.
Tschö, Torsten.
-- Torsten Bronger Jabber ID: torsten...@jabber.rwth-aachen.de or http://bronger-jmp.appspot.com
![](https://secure.gravatar.com/avatar/27f6b03a726ccff3f7a5007b1df6bf8c.jpg?s=120&d=mm&r=g)
On 01/06/12 13:23, Torsten Bronger wrote:
Hallöchen!
Robert Cimrman writes:
[...]
The shape is, in general, (n_elements, n_quadrature_points, n_row, n_col). In "el_avg" mode, you get an average of all quadrature points values per element, so the shape in your case is (n_elements, 1, n_row, n_col). So each group, as you say, is the value of the stress tensor in the corresponding element. It has n_row = 3, n_col = 1, as it is symmetric 2x2 and we store only the items 11, 22, 12 (in this order).
Is this clear enough?
Absolutely, thank you. It enabled me to calculate the "equivalent tensile stress" (see http://en.wikipedia.org/wiki/Von_Mises_yield_criterion) for each element according to sqrt(a11**2 - a11 * a22 + a22**2 + 3*a12**2).
Check also [1], especially get_von_mises_stress() function.
If this exceeds a certain threshold, the element is deleted. This way, I plan to let a crack extend through the material.
Good, let us know how it goes.
Cheers, r.
[1] http://docs.sfepy.org/doc-devel/src/sfepy/mechanics/tensors.html
participants (2)
-
Robert Cimrman
-
Torsten Bronger