Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion matflow/data/scripts/cluster_orientations.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ def cluster_orientations(
volume_element = validate_volume_element(volume_element)

quaternions = volume_element["orientations"]["quaternions"]
# Convert quaternion representation to DAMASK format
quaternions[:, 1:] *= -1

material_index = volume_element["element_material_idx"]
material_index_2d = material_index[:, :, 0]
material_index_3d = np.stack(
Expand Down Expand Up @@ -60,14 +63,16 @@ def cluster_orientations(
return_full=True,
)

# Convert quaternions back to MTEX notation
orientations_shuffled_vol[:, 1:] *= -1
# Replace quaternions in volume element
volume_element["orientations"]["quaternions"] = np.array(
[list(x) for x in orientations_shuffled_vol]
)

plt.hist(misorientation)
plt.hist(misorientation_init, color="r", alpha=0.5)
plt.legend(["Initial", "shuffled"], fontsize=5)
plt.legend(["Shuffled", "Initial"], fontsize=5)
plt.xlabel("Misorientation")
plt.ylabel("Number of grains")
plt.savefig("misorientation.png")
Expand Down