Skip to content

Commit

Permalink
added convergence error warnings for evpfft solver
Browse files Browse the repository at this point in the history
  • Loading branch information
shankinsMechEng committed Dec 24, 2024
1 parent 7e82640 commit 50682c3
Show file tree
Hide file tree
Showing 4 changed files with 451 additions and 219 deletions.
32 changes: 32 additions & 0 deletions python/FIERRO-GUI/fierro_gui/Bulk_Forming.py
Original file line number Diff line number Diff line change
Expand Up @@ -1134,8 +1134,13 @@ def boundary_conditions():

# Run Bulk Formation
self.run = 0
self.ConvergenceError = False
self.min_iterations_old = 0
def run_bulk_forming():
self.run = 1
# Restart progress bar
self.RunOutputProgress.setValue(0)

# Create location to save files
self.job_name = "simulation_files"
self.working_directory = os.path.join(self.bulk_forming_dir, f'{self.job_name}')
Expand Down Expand Up @@ -1194,18 +1199,41 @@ def run_bulk_forming():
self.warning_message("ERROR: evpfft executable")
return
self.progress_re = re.compile(" Current Time STEP = (\\d+)")
# Count how many iterations were taken towards the solution
self.iterations_re = re.compile(r" ITER = (\d+)")

# Save job directory
self.INBFJobDir.setText(f'{self.working_directory}')

# Wait for program to finish before checking for errors
self.p.waitForStarted()
while self.p != None:
QApplication.processEvents()

# Provide warnings for convergence
if self.ConvergenceError == True:
self.ConvergenceError = False
self.min_iterations_old = 0
warning_message("WARNING: It is recomended that you increase your maximum number of iterations. Solution convergence was NOT achieved.")
self.BRunBulkForming.clicked.connect(run_bulk_forming)

def convergence_check(output):
iterations = self.iterations_re.findall(output)
if iterations:
return int(iterations[-1])
def simple_percent_parser(output):
m = self.progress_re.search(output)
if m:
pc_complete = m.group(1)
return int(pc_complete)
def process_finished(num):
handle_stdout()
handle_stderr()
self.RunOutputProgress.setValue(100)
# If the iterations reached the maximum number, write out an error
if self.min_iterations_old >= int(self.INBFmaxiter.text()):
self.ConvergenceError = True
self.min_iterations_old = 0
self.p.close()
self.p = None
def handle_stdout():
Expand All @@ -1214,6 +1242,10 @@ def handle_stdout():
progress = simple_percent_parser(stdout)
if progress:
self.RunOutputProgress.setValue((progress/int(self.INBFloadsteps.text()))*100)
# check for convergence
self.min_iterations = convergence_check(stdout)
if self.min_iterations is not None and self.min_iterations > self.min_iterations_old:
self.min_iterations_old = self.min_iterations
self.RunOutputWindow.appendPlainText(stdout)
def handle_stderr():
data = self.p.readAllStandardError()
Expand Down
165 changes: 126 additions & 39 deletions python/FIERRO-GUI/fierro_gui/FIERRO_GUI.ui
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1355</width>
<height>1208</height>
<width>1326</width>
<height>1002</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down Expand Up @@ -274,6 +274,12 @@
</item>
<item>
<widget class="QFrame" name="frame_27">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
Expand Down Expand Up @@ -305,7 +311,7 @@
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
Expand Down Expand Up @@ -3707,7 +3713,7 @@ li.checked::marker { content: &quot;\2612&quot;; }
<bool>false</bool>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<property name="iconSize">
<size>
Expand Down Expand Up @@ -5467,7 +5473,7 @@ li.checked::marker { content: &quot;\2612&quot;; }
<bool>true</bool>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="Elastic_2">
<attribute name="icon">
Expand Down Expand Up @@ -6455,7 +6461,7 @@ li.checked::marker { content: &quot;\2612&quot;; }
</font>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<property name="iconSize">
<size>
Expand Down Expand Up @@ -10017,7 +10023,7 @@ li.checked::marker { content: &quot;\2612&quot;; }
<item row="1" column="0">
<widget class="QRadioButton" name="INHomogenizationSettingC">
<property name="text">
<string>Custom (WARNING: not reccomended)</string>
<string>Custom </string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -10647,7 +10653,7 @@ li.checked::marker { content: &quot;\2612&quot;; }
</property>
<widget class="QWidget" name="page_31"/>
<widget class="QWidget" name="page_32">
<layout class="QFormLayout" name="formLayout_9">
<layout class="QVBoxLayout" name="verticalLayout_72">
<property name="leftMargin">
<number>0</number>
</property>
Expand All @@ -10660,33 +10666,127 @@ li.checked::marker { content: &quot;\2612&quot;; }
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="1">
<widget class="QSpinBox" name="INmpiRanks">
<property name="readOnly">
<bool>false</bool>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::UpDownArrows</enum>
</property>
<property name="minimum">
<number>1</number>
<item>
<widget class="QFrame" name="frame_65">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="maximum">
<number>1</number>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QFormLayout" name="formLayout_9">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_58">
<property name="text">
<string>MPI Ranks:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="INmpiRanks">
<property name="readOnly">
<bool>false</bool>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::UpDownArrows</enum>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>1</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_58">
<item>
<widget class="QLabel" name="label_65">
<property name="text">
<string>MPI Ranks:</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; color:#797979;&quot;&gt;Warning: mpi could be slower than serial for small models due to initialization and overhead.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label_64">
<property name="font">
<font>
<bold>true</bold>
<underline>true</underline>
</font>
</property>
<property name="text">
<string>Convergence Tuning</string>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QFrame" name="frame_64">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QFormLayout" name="formLayout_19">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item row="0" column="0">
<widget class="QRadioButton" name="INHAutomatic">
<property name="toolTip">
<string>Automatically adjust model parameters if solution convergence is not met.</string>
</property>
<property name="text">
<string>Automatic</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="INHManual">
<property name="toolTip">
<string>Outputs a convergence warning. Requires manual parameter adjustment and manual re-run.</string>
</property>
<property name="text">
<string>Manual</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QPushButton" name="BRunEVPFFT2">
<property name="text">
Expand Down Expand Up @@ -11595,7 +11695,7 @@ li.checked::marker { content: &quot;\2612&quot;; }
</property>
<widget class="QStackedWidget" name="OutputWindows">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
Expand Down Expand Up @@ -11839,19 +11939,6 @@ li.checked::marker { content: &quot;\2612&quot;; }
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_21">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QStatusBar" name="statusbar"/>
Expand All @@ -11860,8 +11947,8 @@ li.checked::marker { content: &quot;\2612&quot;; }
<rect>
<x>0</x>
<y>0</y>
<width>1355</width>
<height>37</height>
<width>1326</width>
<height>24</height>
</rect>
</property>
<widget class="QMenu" name="menuHelp">
Expand Down
Loading

0 comments on commit 50682c3

Please sign in to comment.