Frequency analysis

About the development of the FEM module/workbench.

Moderator: bernd

HoWil
Veteran
Posts: 1279
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: Frequency analysis

Post by HoWil »

...
To get the eigenfrequency values in GUI we have to write .dat file reader first. It's not hard, but it takes time (I can help if someone is willing to code it)
Hi PrzemoF,
I tried to write a small function/definiton to read in the eigenfrequency values stored in the .dat file.
Maybe it is usefull but do not expect to much I am no computer scientist.

BR Howil

Code: Select all

# -*- coding: utf-8 -*-

import numpy as np

def dat_ef_reader(foldername, filename, freecad_fem_mesh_fn, skh=7, nr_ef=10):
    #==============================================================================
    # Data readin
    #==============================================================================
    f = open(foldername+filename) # opening the input file
    
    # skipping the header
    for n in np.arange(skh):
        text2 = f.readline()
    
    # output list
    ef_data = []
    
    # reading the eigenfrequencies
    for n in np.arange(nr_ef):
        ef_data.append(np.fromstring(f.readline(), dtype=float, sep=' '))
    
    f.close() # closing the input file

    return ef_data



#==============================================================================
# Setting default parameter
#==============================================================================

# foldername of .dat file has to be adopted for windows !!!!!!!
foldername = '/tmp/'

# filename of Freecad FEM mesh name
freecad_fem_mesh_fn = 'Pad_Mesh'

filename = freecad_fem_mesh_fn+'.dat'

# setting skip_header and skip_footer
skh = 7
# number of eigenfrequencies to readin
nr_ef = 10



ef_data = dat_ef_reader(foldername, filename, freecad_fem_mesh_fn, skh, nr_ef)

#==============================================================================
# Testing the found data
#==============================================================================
ef_counter = 3
print(" Eigenfrequency nr "+str(ef_counter)+" : "+str(ef_data[ef_counter][3])+" Hz (CYCLES/TIME)")

User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: Frequency analysis

Post by PrzemoF »

Hi Howil,
Thanks for the code! I'm sure we could make it work, but we'll need something that can be easily extended to parse different parts of the .dat file.
I started using ccxFrdReader as the base [1]. It's not fully usable yet, but it can produce this:

Code: Select all

import ccxDatReader
ccxDatReader.import_dat('/tmp/aaaaa/Beam_Mesh.dat')
Results [{'eigenmode': 1, 'frequency': 162.7162}, {'eigenmode': 2, 'frequency': 808.0947}, {'eigenmode': 3, 'frequency': 1025.64}, {'eigenmode': 4, 'frequency': 2898.789}, {'eigenmode': 5, 'frequency': 3501.777}, {'eigenmode': 6, 'frequency': 4899.052}, {'eigenmode': 7, 'frequency': 5758.346}, {'eigenmode': 8, 'frequency': 9689.247}, {'eigenmode': 9, 'frequency': 10587.33}, {'eigenmode': 10, 'frequency': 12578.87}]
I'm going to add 2 new fields to result objects called 'Mode' and 'Frequency' and store the values extracted for the .dat file there.

[1] https://github.com/PrzemoF/FreeCAD/tree/dat_reader
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Frequency analysis

Post by bernd »

Serchu wrote:Hi, I have problems also with the name of the generated Calculix files, ... We normally run several load cases for the same part, so having the Calculix files correctly named is very good for archiving...
If you would like to have the CalculiX file named the way you would like to have it you could make a new DocumentObject with your favorite name and copy the FEMMesh to the new Document object by python.

Code: Select all

old_label = "Face_Mesh"  # the name displayed in FreeCAD Tree View
new_name = "My_Fancy_FEM_Mesh"

newobj = App.ActiveDocument.addObject("Fem::FemMeshObject",new_name)
newobj.FemMesh = App.ActiveDocument.getObjectsByLabel(old_label)[0].FemMesh
Test:

Code: Select all

App.ActiveDocument.getObject("My_Fancy_FEM_Mesh").FemMesh
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Frequency analysis

Post by bernd »

Or even easier, select your FEMMesh which has not the Name you would like to have and copy the following code in python console:

Code: Select all

new_name = "My_Fancy_FEM_Mesh"
newobj = App.ActiveDocument.addObject("Fem::FemMeshObject",new_name)
newobj.FemMesh = Gui.Selection.getSelection()[0].FemMesh
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Frequency analysis

Post by bernd »

PrzemoF wrote:...
I'm going to add 2 new fields to result objects called 'Mode' and 'Frequency' and store the values extracted for the .dat file there.
[1] https://github.com/PrzemoF/FreeCAD/tree/dat_reader
Started to improve the dat file reader since I will need it for shellthickness and beamsection node displacements. https://github.com/berndhahnebach/FreeC ... tReader.py

import ccxDatReader
ccxDatReader.import_dat('/home/hugo/Desktop/CalculiX--Results/Mesh.dat')
Post Reply