Skip to content

Commit

Permalink
bug fix for dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
shankinsMechEng committed Nov 12, 2024
1 parent 4c396c7 commit 99f7b5f
Show file tree
Hide file tree
Showing 5 changed files with 1,878 additions and 472 deletions.
258 changes: 199 additions & 59 deletions python/FIERRO-GUI/fierro_gui/Bulk_Forming.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from PySide6.QtWidgets import (QTableWidgetItem, QMessageBox, QApplication, QFileDialog)
from PySide6.QtWidgets import (QTableWidgetItem, QMessageBox, QApplication, QFileDialog, QWidget, QHBoxLayout, QVBoxLayout, QLabel, QLineEdit, QTableWidget, QPushButton)
from PySide6.QtCore import (QCoreApplication, QProcess, Qt)
from PySide6.QtGui import (QColor, QBrush)
from PySide6.QtGui import (QColor, QBrush, QFont)
import numpy as np
import re
import os
Expand Down Expand Up @@ -49,44 +49,47 @@ def material_class_2():

# Define material properties using predefined values
def predefined_materials():
if "Custom" in self.INMaterialDefinition.currentText():
# Clear elastic parameters
self.INYoungsModulus_2.clear()
self.INPoissonsRatio_2.clear()
self.INEip_2.clear()
self.INNUip_2.clear()
self.INEop_2.clear()
self.INNUop_2.clear()
self.INGop_2.clear()
self.INEx_2.clear()
self.INEy_2.clear()
self.INEz_2.clear()
self.INNUxy_2.clear()
self.INNUxz_2.clear()
self.INNUyz_2.clear()
self.INGxy_2.clear()
self.INGxz_2.clear()
self.INGyz_2.clear()
for i in [0,1,2,3,4,5,6]:
for j in range(i,6):
if self.TAnisotropic_2.item(i,j):
self.TAnisotropic_2.item(i,j).setText('')
# Clear plastic parameters
self.INa.clear()
self.INb.clear()
self.INc.clear()
self.INSlipSystems.clear()
self.TSlipSystemParameters.setRowCount(0)
self.INnrsx.clear()
self.INgamd0x.clear()
self.INtau0xb.clear()
self.INtau0xf.clear()
self.INtau1x.clear()
self.INthet0.clear()
self.INthet1.clear()
self.INhselfx.clear()
self.INhlatex.clear()
elif "Single Crystal Copper" in self.INMaterialDefinition.currentText():
# Clear elastic parameters
self.INYoungsModulus_2.clear()
self.INPoissonsRatio_2.clear()
self.INEip_2.clear()
self.INNUip_2.clear()
self.INEop_2.clear()
self.INNUop_2.clear()
self.INGop_2.clear()
self.INEx_2.clear()
self.INEy_2.clear()
self.INEz_2.clear()
self.INNUxy_2.clear()
self.INNUxz_2.clear()
self.INNUyz_2.clear()
self.INGxy_2.clear()
self.INGxz_2.clear()
self.INGyz_2.clear()
for i in [0,1,2,3,4,5,6]:
for j in range(i,6):
if self.TAnisotropic_2.item(i,j):
self.TAnisotropic_2.item(i,j).setText('')
# Clear plastic parameters
self.INa.clear()
self.INb.clear()
self.INc.clear()
self.INSlipSystems.clear()
self.TSlipSystemParameters.setRowCount(0)
self.INnrsx.clear()
self.INgamd0x.clear()
self.INtau0xb.clear()
self.INtau0xf.clear()
self.INtau1x.clear()
self.INthet0.clear()
self.INthet1.clear()
self.INhselfx.clear()
self.INhlatex.clear()
if "Single Crystal Copper" in self.INMaterialDefinition.currentText():
if 'MPa' in self.INUnits.currentText():
m = 1
elif 'Pa' in self.INUnits.currentText():
m = 1000000
# Define elastic properties
for i in [0,1,2,3,4,5,6]:
for j in range(i,6):
Expand Down Expand Up @@ -120,6 +123,42 @@ def predefined_materials():
self.INthet1.setText('250.')
self.INhselfx.setText('1.0')
self.INhlatex.setText('1.0')
elif "Tantalum" in self.INMaterialDefinition.currentText():
# Define elastic properties
for i in [0,1,2,3,4,5,6]:
for j in range(i,6):
self.TAnisotropic_2.setItem(i,j,QTableWidgetItem('0.'))
self.INSolidGas_2.setCurrentIndex(0)
self.INMaterialType_2.setCurrentIndex(3)
self.TAnisotropic_2.setItem(0,0,QTableWidgetItem('266700.'))
self.TAnisotropic_2.setItem(1,1,QTableWidgetItem('266700.'))
self.TAnisotropic_2.setItem(2,2,QTableWidgetItem('266700.'))
self.TAnisotropic_2.setItem(0,1,QTableWidgetItem('160800.'))
self.TAnisotropic_2.setItem(0,2,QTableWidgetItem('160800.'))
self.TAnisotropic_2.setItem(1,2,QTableWidgetItem('160800.'))
self.TAnisotropic_2.setItem(3,3,QTableWidgetItem('82500.'))
self.TAnisotropic_2.setItem(4,4,QTableWidgetItem('82500.'))
self.TAnisotropic_2.setItem(5,5,QTableWidgetItem('82500.'))
# Define plastic properties
self.INa.setText('1.')
self.INb.setText('1.')
self.INc.setText('1.')
items = self.TSlipSystems.findItems('BCC', Qt.MatchExactly | Qt.MatchRecursive)
if items:
self.TSlipSystems.setCurrentItem(items[0])
self.BAddSlipSystem.click()
self.TSlipSystems.expandItem(items[0])
self.INSlipSystems.setCurrentRow(2)
self.BRemoveSlipSystem.click()
self.INnrsx.setText('14')
self.INgamd0x.setText('1.0')
self.INtau0xf.setText('115.')
self.INtau0xb.setText('115.')
self.INtau1x.setText('30.')
self.INthet0.setText('110.')
self.INthet1.setText('5.')
self.INhselfx.setText('1.0')
self.INhlatex.setText('1.2')
self.INMaterialDefinition.currentIndexChanged.connect(predefined_materials)

# Add material to the table
Expand Down Expand Up @@ -577,9 +616,11 @@ def slip_system_details():
selected_items = self.TSlipSystems.selectedItems()
selected_item = selected_items[0]
if selected_item.parent() is not None:
if '{111}<110>' in selected_item.text(0):
self.SlipSystemInfo.setCurrentIndex(1)
page = selected_item.text(0).split('.', 1)[0]
self.SlipSystemInfo.setCurrentIndex(int(page))
self.PlasticProperties.setCurrentIndex(2)
else:
warning_message("ERROR: Please select a specific slip system to view it's details.")
self.BSlipSystemDetails.clicked.connect(slip_system_details)

# Add slip system(s) to list
Expand All @@ -605,15 +646,13 @@ def add_slip_system():
# Add slip systems as a selection to the Voce parameters combobox and table
self.INSelectSlipSystem.clear()
self.INSelectSlipSystem.addItem('ALL')
self.TSlipSystemParameters.clearContents()
self.TSlipSystemParameters.setRowCount(0)
for i in range(self.INSlipSystems.count()):
item = self.INSlipSystems.item(i)
# Add the item's text to the QComboBox
self.INSelectSlipSystem.addItem(item.text())
# Add the item's text to the Table
self.TSlipSystemParameters.insertRow(i)
self.TSlipSystemParameters.setItem(i,0,QTableWidgetItem(item.text()))
row = self.TSlipSystemParameters.rowCount()
self.TSlipSystemParameters.insertRow(row)
self.TSlipSystemParameters.setItem(row,0,QTableWidgetItem(item.text()))

self.BAddSlipSystem.clicked.connect(add_slip_system)

Expand All @@ -638,6 +677,91 @@ def remove_slip_system():
self.TSlipSystemParameters.setItem(i,0,QTableWidgetItem(item.text()))
self.BRemoveSlipSystem.clicked.connect(remove_slip_system)

# Define custom slip system
def custom_slip_system():
# Index of new page
index = self.SlipSystemInfo.count()
# Layout
new_page = QWidget()
page_layout = QVBoxLayout()
page_layout.setContentsMargins(0, 0, 0, 0)
page_layout.setSpacing(5)
# Functionality
# Slip System Name
input_layout = QHBoxLayout()
label = QLabel("Slip System Name:")
input_layout.addWidget(label)
self.line_edit = QLineEdit()
input_layout.addWidget(self.line_edit)
page_layout.addLayout(input_layout)
# Add or remove colums from table
arbuttons = QHBoxLayout()
self.BAddRow = QPushButton("Add Row")
arbuttons.addWidget(self.BAddRow)
self.BRemoverow = QPushButton("Remove Row")
arbuttons.addWidget(self.BRemoverow)
page_layout.addLayout(arbuttons)
# Functions to add or remove rows from table
def add_row():
current_row_count = self.table.rowCount()
self.table.insertRow(current_row_count)
self.BAddRow.clicked.connect(add_row)
def remove_row():
current_row = self.table.currentRow() # Get the index of the selected row
if current_row >= 0: # Check if a row is selected
self.table.removeRow(current_row) # Remove the selected row
self.BRemoverow.clicked.connect(remove_row)
# Table
setattr(self, f"T{index}", QTableWidget())
self.table = getattr(self, f"T{index}")
self.table.setRowCount(12)
self.table.setColumnCount(2)
self.table.setHorizontalHeaderLabels(["(Slip Plane)", "<Slip Direction>"])
self.table.horizontalHeader().setDefaultSectionSize(167)
font = QFont()
font.setPointSize(13)
self.table.horizontalHeader().setFont(font)
page_layout.addWidget(self.table)
# Add custom slip system
self.BSubmit = QPushButton("Add Custom Slip System")
page_layout.addWidget(self.BSubmit)
# Function to add the slip system to table
def add_custom_system():
# Check that everything is completely filled out
if not self.line_edit.text().strip():
warning_message("ERROR: Please assign a name to custom slip system.")
warning_flag = 0
for row in range(self.table.rowCount()):
for col in range(self.table.columnCount()):
item = self.table.item(row,col)
if item is None or not item.text().strip():
warning_flag = 1
if warning_flag == 1:
warning_message("ERROR: Ensure custom slip system is completely filled out, and delete any unused rows.")
# If there are no errors, add custom slip system to the table
else:
# count the number of slip systems already defined in the table
num_children = 0
for i in range(self.TSlipSystems.topLevelItemCount()):
top_level_item = self.TSlipSystems.topLevelItem(i)
num_children += top_level_item.childCount()
# Find the custom heading and add the new system to it
custom_label = self.TSlipSystems.findItems("CUSTOM", Qt.MatchExactly, 0)
# custom_item = next((item for item in matching_items if item.parent() is None), None)
# if custom_item:
# # Add a subitem to the found "custom" item
# new_subitem = QTreeWidgetItem(custom_item, [subitem_name])
# custom_item.addChild(new_subitem)
# self.BSubmit.clicked.connect(add_custom_system)

# Setup New Page
new_page.setLayout(page_layout)
self.SlipSystemInfo.addWidget(new_page)
# Display
self.PlasticProperties.setCurrentIndex(2)
self.SlipSystemInfo.setCurrentIndex(index)
self.BCustomSlipSystem.clicked.connect(custom_slip_system)

# Add Voce parameters to table based on assigned slip systems
self.updating = False
def voce_parameters():
Expand Down Expand Up @@ -686,17 +810,17 @@ def voce_parameters_i():
slip_system = self.INSelectSlipSystem.currentText()
rows = self.TSlipSystemParameters.rowCount()
for i in range(rows):
if "ALL" in slip_system:
self.INnrsx.clear()
self.INgamd0x.clear()
self.INtau0xf.clear()
self.INtau0xb.clear()
self.INtau1x.clear()
self.INthet0.clear()
self.INthet1.clear()
self.INhselfx.clear()
self.INhlatex.clear()
elif slip_system in self.TSlipSystemParameters.item(i, 0).text():
# if "ALL" in slip_system:
# self.INnrsx.clear()
# self.INgamd0x.clear()
# self.INtau0xf.clear()
# self.INtau0xb.clear()
# self.INtau1x.clear()
# self.INthet0.clear()
# self.INthet1.clear()
# self.INhselfx.clear()
# self.INhlatex.clear()
if slip_system in self.TSlipSystemParameters.item(i, 0).text():
self.INnrsx.setText(self.TSlipSystemParameters.item(i, 1).text() if self.TSlipSystemParameters.item(i, 1) is not None else "")
self.INgamd0x.setText(self.TSlipSystemParameters.item(i, 2).text() if self.TSlipSystemParameters.item(i, 2) is not None else "")
self.INtau0xf.setText(self.TSlipSystemParameters.item(i, 3).text() if self.TSlipSystemParameters.item(i, 3) is not None else "")
Expand Down Expand Up @@ -780,7 +904,7 @@ def boundary_conditions():
self.TVgrad.clearContents()
self.TVgradi.clearContents()
self.TCstress.clearContents()
elif "Test" in self.INbulkBC.currentText():
elif "Example" in self.INbulkBC.currentText():
# Clear tables
self.TVgrad.clearContents()
self.TVgradi.clearContents()
Expand All @@ -798,6 +922,22 @@ def boundary_conditions():
self.TVgradi.setItem(1,1,QTableWidgetItem("-0.35"))
self.TCstress.setItem(0,0,QTableWidgetItem("0."))
self.TCstress.setItem(1,1,QTableWidgetItem("0."))
elif "ECAP" in self.INbulkBC.currentText():
# Clear tables
self.TVgrad.clearContents()
self.TVgradi.clearContents()
self.TCstress.clearContents()

# Assign values
self.TVgrad.setItem(0,0,QTableWidgetItem("0."))
self.TVgrad.setItem(0,1,QTableWidgetItem("-1.0"))
self.TVgrad.setItem(0,2,QTableWidgetItem("0."))
self.TVgrad.setItem(1,0,QTableWidgetItem("0."))
self.TVgrad.setItem(1,1,QTableWidgetItem("0."))
self.TVgrad.setItem(1,2,QTableWidgetItem("0."))
self.TVgrad.setItem(2,0,QTableWidgetItem("0."))
self.TVgrad.setItem(2,1,QTableWidgetItem("0."))
self.TVgrad.setItem(2,2,QTableWidgetItem("0."))
self.INbulkBC.currentIndexChanged.connect(boundary_conditions)

# Run Bulk Formation
Expand Down
17 changes: 10 additions & 7 deletions python/FIERRO-GUI/fierro_gui/Bulk_Forming_WInput.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,25 @@ def Bulk_Forming_WInput(self):
plastic_parameters.write(nmodes)
modei = ' 1'
for i in range(num_systems-1):
modei = modei + ' {i+2}'
modei = modei + f' {i+2}'
modei = modei + ' mode(i) (label of the modes to be used)\n'
plastic_parameters.write(modei)
slip_system_names = system_names.split(',')
nsmx_max = 0
for i in range(num_systems):
slip_system_name = slip_system_names[i].split('.', 1)[1].strip()
dict = slip_system_names[i].split('.', 1)[0]
dict = slip_system_names[i].split('.', 1)[0].strip()
dvar = f'T{dict}'
slip_table = getattr(self, dvar)
nsmx = slip_table.rowCount()
if nsmx > nsmx_max:
nsmx_max = nsmx
slip_parameters = f' {slip_system_name} SLIP\n' \
f' {i+1} {nsmx} {self.TMaterials_2.item(0,27).text()} {self.TMaterials_2.item(0,28).text()} 0.0 0 modex,nsmx,nrsx,gamd0x,twshx,isectwx\n' \
f' {self.TMaterials_2.item(0,29).text()} {self.TMaterials_2.item(0,30).text()} {self.TMaterials_2.item(0,31).text()} {self.TMaterials_2.item(0,32).text()} {self.TMaterials_2.item(0,33).text()} tau0xf,tau0xb,tau1x,thet0,thet1\n' \
f' {self.TMaterials_2.item(0,34).text()}'
f' {i+1} {nsmx} {self.TMaterials_2.item(0,27).text().split(",")[i]} {self.TMaterials_2.item(0,28).text().split(",")[i]} 0.0 0 modex,nsmx,nrsx,gamd0x,twshx,isectwx\n' \
f' {self.TMaterials_2.item(0,29).text().split(",")[i]} {self.TMaterials_2.item(0,30).text().split(",")[i]} {self.TMaterials_2.item(0,31).text().split(",")[i]} {self.TMaterials_2.item(0,32).text().split(",")[i]} {self.TMaterials_2.item(0,33).text().split(",")[i]} tau0xf,tau0xb,tau1x,thet0,thet1\n' \
f' {self.TMaterials_2.item(0,34).text().split(",")[i]}'
for ii in range(num_systems):
slip_parameters = slip_parameters + f' {self.TMaterials_2.item(0,35).text()}'
slip_parameters = slip_parameters + f' {self.TMaterials_2.item(0,35).text().split(",")[i]}'
slip_parameters = slip_parameters + ' hselfx,hlatex\n'
plastic_parameters.write(slip_parameters)
for j in range(nsmx):
Expand Down Expand Up @@ -78,7 +81,7 @@ def Bulk_Forming_WInput(self):

# Bulk Forming input parameters file
bulk_forming_input = open(self.BULK_FORMING_INPUT,"w")
modes = '1 1 1 12 NPHMX, NMODMX, NTWMMX, NSYSMX\n'
modes = f'1 1 1 {nsmx_max} NPHMX, NMODMX, NTWMMX, NSYSMX\n'
bulk_forming_input.write(modes)
Nx = int(self.TParts.item(0,7).text())
Ny = int(self.TParts.item(0,8).text())
Expand Down
Loading

0 comments on commit 99f7b5f

Please sign in to comment.