[Solved] Compile multiple results in one

About the development of the FEM module/workbench.

Moderator: bernd

Post Reply
User avatar
flachyjoe
Veteran
Posts: 1869
Joined: Sat Mar 31, 2012 12:00 pm
Location: Limoges, France

[Solved] Compile multiple results in one

Post by flachyjoe »

Hi,
I'm trying to visualize the optimum point on a structure where a vibrator can excites the largest number of eigen modes.
So I run CalculiX with

Code: Select all

*STEP
*FREQUENCY
100,20.0,20000.0
and obtain 93 result objects in FreeCAD (7 eigen frequencies are below 20Hz).
Then I sum the per node absolute displacement vectors throw the results and extract the z components with

Code: Select all

vect=[]
for obj in FreeCAD.ActiveDocument.Objects :
	if (obj.TypeId == "Fem::FemResultObjectPython") :
		if len(vect)>0 :
			i=0
			for v in obj.DisplacementVectors :
				vect[i] += abs(v)
				i+=1
		else :
			vect = obj.DisplacementVectors

z=[v.z for v in vect]
How can I visualize this field in FreeCAD ? ie How can I create a mesh colored by these datas ?
Last edited by flachyjoe on Tue May 22, 2018 12:43 pm, edited 1 time in total.
- Flachy Joe -
Image
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Compile multiple results in one

Post by bernd »

duplicate one of your result objeccts and override the displacement vektor. Or create a new result object. It needs the dicplacment vector, the node nombers and the result mesh object set. Than just use your new result object in FreeCAD gui or export it to paraview.
User avatar
flachyjoe
Veteran
Posts: 1869
Joined: Sat Mar 31, 2012 12:00 pm
Location: Limoges, France

[Solved] Compile multiple results in one

Post by flachyjoe »

Hallo bernd,
thank for the answer.

Code: Select all

freq=[]
disp=[]
vect=[]

import FemGui
analys=FemGui.getActiveAnalysis()

#sum of displacements
for obj in analys.Group :
	if (obj.TypeId == "Fem::FemResultObjectPython") :
		if obj.EigenmodeFrequency>0 :
			freq.append (obj.EigenmodeFrequency)
			dist=max(obj.DisplacementLengths)- min(obj.DisplacementLengths)  
			disp.append(dist)
			if len(vect)>0 :
				i=0
				for v in obj.DisplacementVectors :
					vect[i] += abs(v)
					i+=1
			else :
				vect =map(lambda v:abs(v), obj.DisplacementVectors)

#Format results
import math
rvect=[]
for v in vect :
	v *= 0.5 #<<<< Change to adapt color range
	rvect.append(FreeCAD.Vector(math.log(v.x),math.log(v.y),math.log(v.z)))
#normalize displacement
disp=map(lambda s : s/max(disp), disp)

#Create result object
import ObjectsFem
result=ObjectsFem.makeResultMechanical(App.ActiveDocument,'global_result')
result.Mesh = obj.Mesh
result.NodeNumbers=obj.NodeNumbers
result.DisplacementVectors= rvect

analys.addObject(result)

#Plot displacement per frequency
import Plot
Plot.plot(freq, disp)
Plot.axes().set_xscale('log')
Plot.axes().set_xbound(20,20000)
- Flachy Joe -
Image
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: [Solved] Compile multiple results in one

Post by bernd »

:) How about a pretty cloured screen of your project? This is what FEM is about :mrgreen: !
User avatar
flachyjoe
Veteran
Posts: 1869
Joined: Sat Mar 31, 2012 12:00 pm
Location: Limoges, France

Re: [Solved] Compile multiple results in one

Post by flachyjoe »

You're right ! :)
A 800x400x18mm wood plate with 3 sides frame.
mesh.png
mesh.png (298.4 KiB) Viewed 692 times
plot.png
plot.png (54.93 KiB) Viewed 692 times
Orange spots are not visible enough so I'll filter the data.
I also have to check the mesh size sensibility of the result.
- Flachy Joe -
Image
Post Reply