Skip to content

Commit

Permalink
Added Create Orientation button with a popup messagebox.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronakshoghi committed May 21, 2024
1 parent 010ac87 commit 1f70db2
Showing 1 changed file with 34 additions and 17 deletions.
51 changes: 34 additions & 17 deletions examples/RVE_generation/RVE_generation_GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,27 +171,44 @@ def create_rve_and_plot():
display_plot(fig, plot_type="stats")


def compare_statistics():
"""Create plot of initial statistics together with final microstructure
descriptors for particles and voxels"""
# def compare_statistics():
# """Create plot of initial statistics together with final microstructure
# descriptors for particles and voxels"""
# global ms, ms_stats
# if ms_stats is None or ms is None or ms.mesh is None:
# print("No microstructure. Create RVE first.")
# return
# gs_param = [ms_stats['Equivalent diameter']['sig'],
# ms_stats['Equivalent diameter']['loc'],
# ms_stats['Equivalent diameter']['scale']]
# ar_param = [ms_stats['Aspect ratio']['sig'],
# ms_stats['Aspect ratio']['loc'],
# ms_stats['Aspect ratio']['scale']]
# flist = ms.plot_stats(silent=True, gs_param=[gs_param], ar_param=[ar_param], enhanced_plot=True)
# for fig in flist:
# display_plot(fig, plot_type="stats")

def create_orientation_first_tab():
"""A function to create the orientation """
global ms, ms_stats
popup = self_closing_message("The process has been started, please wait...", duration=2000)
texture = texture_var1.get()
matname = matname_var1.get()
if ms_stats is None or ms is None or ms.mesh is None:
print("No microstructure. Create RVE first.")
return
gs_param = [ms_stats['Equivalent diameter']['sig'],
ms_stats['Equivalent diameter']['loc'],
ms_stats['Equivalent diameter']['scale']]
ar_param = [ms_stats['Aspect ratio']['sig'],
ms_stats['Aspect ratio']['loc'],
ms_stats['Aspect ratio']['scale']]
flist = ms.plot_stats(silent=True, gs_param=[gs_param], ar_param=[ar_param], enhanced_plot=True)
for fig in flist:
display_plot(fig, plot_type="stats")
popup = self_closing_message("Please generate the RVE first...", duration=2000)
if knpy.MTEX_AVAIL:
start_time = time.time()
# Based on the notebook should the ang be different based on the selected texture?
# After finishing can we have a popup message to ask if files should be exported?
ms.generate_orientations(texture, ang=[0, 45, 0], omega=7.5)
ms.write_voxels(file=f'{matname}_voxels.json', script_name='generate_rve.ipynb', mesh=False, system=False)
end_time = time.time()
duration = end_time - start_time
self_closing_message(f"Process completed in {duration:.2f} seconds, the Voxel file has been saved. ", duration=2000)


""" Functions for RVEs with cuboid grains """


def run_simulation(texture, matname, ngr, nv_gr, size, nphases, periodic):
"""Create and plot microstructure object with cuboid grains
return figure axes
Expand Down Expand Up @@ -501,8 +518,8 @@ def close():
command=create_and_plot_stats)
button_statistics.grid(row=0, column=0, padx=10)

button_compare_statistics = ttk.Button(button_frame1, text="Compare Statistics", style='TButton',
command=compare_statistics)
button_compare_statistics = ttk.Button(button_frame1, text="Create Orientations", style='TButton',
command=create_orientation_first_tab)
button_compare_statistics.grid(row=0, column=2, padx=10)
button_exit1 = ttk.Button(button_frame1, text="Exit", style='TButton', command=close)
button_exit1.grid(row=0, column=3, padx=10)
Expand Down

0 comments on commit 1f70db2

Please sign in to comment.