Skip to content

Commit

Permalink
FEM: Add frequency analysis to FEM wb
Browse files Browse the repository at this point in the history
Signed-off-by: Przemo Firszt <przemo@firszt.eu>
  • Loading branch information
PrzemoF authored and wwmayer committed Sep 9, 2015
1 parent 7bf1bcd commit b516e35
Show file tree
Hide file tree
Showing 7 changed files with 711 additions and 82 deletions.
34 changes: 31 additions & 3 deletions src/Mod/Fem/FemTools.py
Expand Up @@ -33,13 +33,17 @@ def __init__(self, analysis=None):
QtCore.QRunnable.__init__(self)
QtCore.QObject.__init__(self)

self.known_analysis_types = ["static", "frequency"]

if analysis:
self.analysis = analysis
else:
import FemGui
self.analysis = FemGui.getActiveAnalysis()
if self.analysis:
self.update_objects()
self.set_analysis_type()
self.set_eigenmode_parameters()
self.base_name = ""
self.results_present = False
self.setup_working_dir()
Expand Down Expand Up @@ -119,14 +123,17 @@ def check_prerequisites(self):
message = ""
if not self.analysis:
message += "No active Analysis\n"
if self.analysis_type not in self.known_analysis_types:
message += "Unknown analysis type: {}\n".format(self.analysis_type)
if not self.mesh:
message += "No mesh object in the Analysis\n"
if not self.material:
message += "No material object in the Analysis\n"
if not self.fixed_constraints:
message += "No fixed-constraint nodes defined in the Analysis\n"
if not (self.force_constraints or self.pressure_constraints):
message += "No force-constraint or pressure-constraint defined in the Analysis\n"
if self.analysis_type == "static":
if not (self.force_constraints or self.pressure_constraints):
message += "No force-constraint or pressure-constraint defined in the Analysis\n"
return message

def write_inp_file(self):
Expand All @@ -136,7 +143,8 @@ def write_inp_file(self):
try:
inp_writer = iw.inp_writer(self.analysis, self.mesh, self.material,
self.fixed_constraints, self.force_constraints,
self.pressure_constraints, self.working_dir)
self.pressure_constraints, self.analysis_type,
self.eigenmode_parameters, self.working_dir)
self.base_name = inp_writer.write_calculix_input_file()
except:
print "Unexpected error when writing CalculiX input file:", sys.exc_info()[0]
Expand Down Expand Up @@ -165,6 +173,26 @@ def start_ccx(self):
return p.returncode
return -1

## sets eigenmode parameters for CalculiX frequency analysis
# @param self The python object self
# @param number number of eigenmodes that wll be calculated, default 10
# @param limit_low lower value of requested eigenfrequency range, default 0.0
# @param limit_high higher value of requested eigenfrequency range, default 1000000.0
def set_eigenmode_parameters(self, number=10, limit_low=0.0, limit_high=1000000.0):
self.eigenmode_parameters = (number, limit_low, limit_high)

def set_base_name(self, base_name=None):
if base_name is None:
self.base_name = ""
else:
self.base_name = base_name

def set_analysis_type(self, analysis_type=None):
if analysis_type is None:
self.analysis_type = "static"
else:
self.analysis_type = analysis_type

def setup_working_dir(self, working_dir=None):
if working_dir is None:
self.fem_prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem")
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Fem/Gui/Resources/Fem.qrc
Expand Up @@ -17,6 +17,7 @@
<file>icons/fem-new-analysis.svg</file>
<file>icons/fem-purge-results.svg</file>
<file>icons/fem-quick-analysis.svg</file>
<file>icons/fem-frequency-analysis.svg</file>
<file>icons/fem-result.svg</file>
<file>icons/preferences-fem.svg</file>
<file>translations/Fem_af.qm</file>
Expand Down

0 comments on commit b516e35

Please sign in to comment.