Skip to content

Commit

Permalink
fully functioning bulk forming pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
shankinsMechEng committed Nov 8, 2024
1 parent 0ea65a9 commit 4c396c7
Show file tree
Hide file tree
Showing 4 changed files with 1,772 additions and 1,322 deletions.
178 changes: 129 additions & 49 deletions python/FIERRO-GUI/fierro_gui/Bulk_Forming.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,81 @@ def material_class_2():
self.MaterialTypeTool_2.setCurrentIndex(4)
self.INMaterialType_2.currentIndexChanged.connect(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():
# 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('168400.'))
self.TAnisotropic_2.setItem(1,1,QTableWidgetItem('168400.'))
self.TAnisotropic_2.setItem(2,2,QTableWidgetItem('168400.'))
self.TAnisotropic_2.setItem(0,1,QTableWidgetItem('121400.'))
self.TAnisotropic_2.setItem(0,2,QTableWidgetItem('121400.'))
self.TAnisotropic_2.setItem(1,2,QTableWidgetItem('121400.'))
self.TAnisotropic_2.setItem(3,3,QTableWidgetItem('75400.'))
self.TAnisotropic_2.setItem(4,4,QTableWidgetItem('75400.'))
self.TAnisotropic_2.setItem(5,5,QTableWidgetItem('75400.'))
# Define plastic properties
self.INa.setText('1.')
self.INb.setText('1.')
self.INc.setText('1.')
items = self.TSlipSystems.findItems('FCC', Qt.MatchExactly | Qt.MatchRecursive)
if items:
self.TSlipSystems.setCurrentItem(items[0])
self.BAddSlipSystem.click()
self.TSlipSystems.expandItem(items[0])
self.INnrsx.setText('10')
self.INgamd0x.setText('1.0')
self.INtau0xf.setText('9.0')
self.INtau0xb.setText('9.0')
self.INtau1x.setText('5.')
self.INthet0.setText('400.')
self.INthet1.setText('250.')
self.INhselfx.setText('1.0')
self.INhlatex.setText('1.0')
self.INMaterialDefinition.currentIndexChanged.connect(predefined_materials)

# Add material to the table
def add_material_2():
# Elastic properties checks
Expand Down Expand Up @@ -264,70 +339,65 @@ def add_material_2():
self.INGxy_2.clear()
self.INGxz_2.clear()
self.INGyz_2.clear()


# Fill out material definition table
row = self.TMaterials_2.rowCount()
self.TMaterials_2.insertRow(row)
self.TMaterials_2.setItem(row, 0, QTableWidgetItem(
self.INMaterialName_2.text())
)
if str(self.INMaterialType_2.currentText()) == 'Anisotropic':
# Fill out material definition table
row = self.TMaterials_2.rowCount()
self.TMaterials_2.insertRow(row)
self.TMaterials_2.setItem(row, 0, QTableWidgetItem(
self.INMaterialName_2.text().strip())
)
self.TMaterials_2.setItem(row, 1, QTableWidgetItem(
str(self.INMaterialType_2.currentText()))
)
k = 2
for i in [0,1,2,3,4,5,6]:
for i in range(7):
for j in range(i,6):
self.TMaterials_2.setItem(
row, k, QTableWidgetItem(self.TAnisotropic_2.item(i,j).text())
)
self.TAnisotropic_2.item(i,j).setText('')
k += 1
self.INMaterialName_2.clear()

# Fill out material definition table
row = self.TMaterials_2.rowCount()
self.TMaterials_2.insertRow(row)
self.TMaterials_2.setItem(row, 0, QTableWidgetItem(
self.INMaterialName_2.text().strip())
)
if str(self.INMaterialType_2.currentText()) == 'Transversely Isotropic':
self.TMaterials_2.setItem(row, 1, QTableWidgetItem(
str(self.INMaterialType_2.currentText() + ' ' + self.INIsotropicPlane_2.currentText()))
)
else:
self.TMaterials_2.setItem(row, 1, QTableWidgetItem(
str(self.INMaterialType_2.currentText()))
if str(self.INMaterialType_2.currentText()) == 'Transversely Isotropic':
self.TMaterials_2.setItem(row, 1, QTableWidgetItem(
str(self.INMaterialType_2.currentText() + ' ' + self.INIsotropicPlane_2.currentText()))
)
else:
self.TMaterials_2.setItem(row, 1, QTableWidgetItem(
str(self.INMaterialType_2.currentText()))
)
self.TMaterials_2.setItem(
row, 2, QTableWidgetItem(str(C11))
)
self.TMaterials_2.setItem(
row, 2, QTableWidgetItem(str(C11))
)
self.TMaterials_2.setItem(
row, 3, QTableWidgetItem(str(C12))
)
self.TMaterials_2.setItem(
row, 4, QTableWidgetItem(str(C13))
)
self.TMaterials_2.setItem(
row, 8, QTableWidgetItem(str(C22))
)
self.TMaterials_2.setItem(
row, 9, QTableWidgetItem(str(C23))
)
self.TMaterials_2.setItem(
row, 13, QTableWidgetItem(str(C33))
)
self.TMaterials_2.setItem(
row, 17, QTableWidgetItem(str(C44))
)
self.TMaterials_2.setItem(
row, 20, QTableWidgetItem(str(C55))
)
self.TMaterials_2.setItem(
row, 22, QTableWidgetItem(str(C66))
)
for i in [5,6,7,10,11,12,14,15,16,18,19,21]:
self.TMaterials_2.setItem(row, i, QTableWidgetItem('0'))
self.TMaterials_2.setItem(
row, 3, QTableWidgetItem(str(C12))
)
self.TMaterials_2.setItem(
row, 4, QTableWidgetItem(str(C13))
)
self.TMaterials_2.setItem(
row, 8, QTableWidgetItem(str(C22))
)
self.TMaterials_2.setItem(
row, 9, QTableWidgetItem(str(C23))
)
self.TMaterials_2.setItem(
row, 13, QTableWidgetItem(str(C33))
)
self.TMaterials_2.setItem(
row, 17, QTableWidgetItem(str(C44))
)
self.TMaterials_2.setItem(
row, 20, QTableWidgetItem(str(C55))
)
self.TMaterials_2.setItem(
row, 22, QTableWidgetItem(str(C66))
)
for i in [5,6,7,10,11,12,14,15,16,18,19,21]:
self.TMaterials_2.setItem(row, i, QTableWidgetItem('0'))

# Add plastic parameters
self.TMaterials_2.setItem(row,23,QTableWidgetItem(self.INa.text()))
Expand Down Expand Up @@ -501,6 +571,16 @@ def delete_material_2():
# )
# k += 1
# self.BRegenElasticConstants_2.clicked.connect(regenerate_elastic_constants_2)

# View details about a slip system
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)
self.PlasticProperties.setCurrentIndex(2)
self.BSlipSystemDetails.clicked.connect(slip_system_details)

# Add slip system(s) to list
def add_slip_system():
Expand Down
76 changes: 44 additions & 32 deletions python/FIERRO-GUI/fierro_gui/Bulk_Forming_WInput.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,49 @@ def Bulk_Forming_WInput(self):

# Plastic Input File
plastic_parameters = open(self.BULK_FORMING_PLASTIC_PARAMETERS,"w")
if "None" in self.TMaterials_2.item(0,23).text():
plasticity_input = 'SLIP SYSTEMS FOR CUBIC CRYSTAL\n' \
'CUBIC icryst\n' \
' 1. 1. 1. crystal axis (cdim(i))\n' \
' 0 nmodesx (total # of modes listed in the file)\n' \
' 0 nmodes (# of modes to be used in the calculation)'
modes = ''
elif "FCC" in self.TMaterials_2.item(0,23).text():
plasticity_input = 'SLIP SYSTEMS FOR CUBIC CRYSTAL\n' \
'CUBIC icryst\n' \
' 1. 1. 1. crystal axis (cdim(i))\n' \
' 1 nmodesx (total # of modes listed in the file)\n' \
' 1 nmodes (# of modes to be used in the calculation)\n' \
' 1 mode(i) (label of the modes to be used)\n'\
' <110>(111) SLIP\n' \
' 1 12 10 1.0 0.0 0 modex,nsmx,nrsx,gamd0x,twshx,isectwx\n' \
' 9.0 9.0 5. 400. 250. tau0xf,tau0xb,tau1x,thet0,thet1\n' \
' 1.0 1.0 hselfx,hlatex\n' \
' 1 1 -1 0 1 1 SLIP (n-b)\n' \
' 1 1 -1 1 0 1\n' \
' 1 1 -1 1 -1 0\n' \
' 1 -1 -1 0 1 -1\n' \
' 1 -1 -1 1 0 1\n' \
' 1 -1 -1 1 1 0\n' \
' 1 -1 1 0 1 1\n' \
' 1 -1 1 1 0 -1\n' \
' 1 -1 1 1 1 0\n' \
' 1 1 1 0 1 -1\n' \
' 1 1 1 1 0 -1\n' \
' 1 1 1 1 -1 0'
modes = '1 1 1 12 NPHMX, NMODMX, NTWMMX, NSYSMX\n'
plastic_parameters.write(plasticity_input)
header = 'SLIP SYSTEMS FOR CUBIC CRYSTAL\n' \
'CUBIC icryst\n'
plastic_parameters.write(header)
crystal_axis = f' {self.TMaterials_2.item(0,23).text()} {self.TMaterials_2.item(0,24).text()} {self.TMaterials_2.item(0,25).text()} crystal axis (cdim(i))\n'
plastic_parameters.write(crystal_axis)
system_names = self.TMaterials_2.item(0,26).text()
num_systems = system_names.count(',') + 1
nmodes = f' {num_systems} nmodesx (total # of modes listed in the file)\n' \
f' {num_systems} nmodes (# of modes to be used in the calculation)\n'
plastic_parameters.write(nmodes)
modei = ' 1'
for i in range(num_systems-1):
modei = modei + ' {i+2}'
modei = modei + ' mode(i) (label of the modes to be used)\n'
plastic_parameters.write(modei)
slip_system_names = system_names.split(',')
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]
dvar = f'T{dict}'
slip_table = getattr(self, dvar)
nsmx = slip_table.rowCount()
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()}'
for ii in range(num_systems):
slip_parameters = slip_parameters + f' {self.TMaterials_2.item(0,35).text()}'
slip_parameters = slip_parameters + ' hselfx,hlatex\n'
plastic_parameters.write(slip_parameters)
for j in range(nsmx):
slip_plane = slip_table.item(j,0).text().split(',')
slip_system = ' '
for k in range(len(slip_plane)):
slip_system = slip_system + f'{slip_plane[k]} '
slip_direction = slip_table.item(j,1).text().split(',')
for k in range(len(slip_direction)):
slip_system = slip_system + f' {slip_direction[k]}'
if j == 0:
slip_system = slip_system + ' SLIP (n-b)\n'
else:
slip_system = slip_system + '\n'
plastic_parameters.write(slip_system)
plastic_parameters.close()

# Elastic Input File
Expand Down Expand Up @@ -67,6 +78,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'
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 4c396c7

Please sign in to comment.