Skip to content

Commit 5691d44

Browse files
authored
Merge pull request #100 from kkiesling/material_info
Material info on right click
2 parents 2f2e21b + 9434c65 commit 5691d44

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

openmc_plotter/main_window.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,3 +1228,26 @@ def exportTallyData(self):
12281228
# show export tool dialog
12291229
self.showExportDialog()
12301230

1231+
def viewMaterialProps(self, id):
1232+
"""display material properties in message box"""
1233+
mat = openmc.lib.materials[id]
1234+
if mat.name:
1235+
msg_str = f"Material {id} ({mat.name}) Properties\n\n"
1236+
else:
1237+
msg_str = f"Material {id} Properties\n\n"
1238+
1239+
# get density and temperature
1240+
dens_g = mat.get_density(units='g/cm3')
1241+
dens_a = mat.get_density(units='atom/b-cm')
1242+
msg_str += f"Density: {dens_g:.3f} g/cm3 ({dens_a:.3e} atom/b-cm)\n"
1243+
msg_str += f"Temperature: {mat.temperature} K\n\n"
1244+
1245+
# get nuclides and their densities
1246+
msg_str += "Nuclide densities [atom/b-cm]:\n"
1247+
for nuc, dens in zip(mat.nuclides, mat.densities):
1248+
msg_str += f'{nuc}: {dens:5.3e}\n'
1249+
1250+
msg_box = QMessageBox(self)
1251+
msg_box.setText(msg_str)
1252+
msg_box.setModal(False)
1253+
msg_box.show()

openmc_plotter/plotgui.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,14 @@ def contextMenuEvent(self, event):
354354

355355
# Domain ID
356356
if domain[id].name:
357-
domainID = self.menu.addAction("{} {}: \"{}\"".format(domain_kind, id, domain[id].name))
357+
domainID = self.menu.addAction("{} {} Info: \"{}\"".format(domain_kind, id, domain[id].name))
358358
else:
359-
domainID = self.menu.addAction("{} {}".format(domain_kind, id))
359+
domainID = self.menu.addAction("{} {} Info".format(domain_kind, id))
360+
361+
# add connector to a new window of info here for material props
362+
if domain_kind == 'Material':
363+
mat_prop_connector = partial(self.main_window.viewMaterialProps, id)
364+
domainID.triggered.connect(mat_prop_connector)
360365

361366
self.menu.addSeparator()
362367

0 commit comments

Comments
 (0)