Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from matflow.param_classes.orientations import Orientations
import numpy as np

from cipher_parse import (
CIPHERInput,
MaterialDefinition,
Expand All @@ -21,7 +24,12 @@ def generate_phase_field_input_from_random_voronoi_orientations(
interface_binning,
combine_phases,
):
quats = orientations["quaternions"]
try:
quats = orientations["quaternions"]
except TypeError:
# Convert to old matflow format
orientations = _convert_orientations_to_old_matflow_format(orientations)
quats = orientations["quaternions"]

# initialise `MaterialDefinition`, `InterfaceDefinition` and
# `PhaseTypeDefinition` objects:
Expand Down Expand Up @@ -63,3 +71,40 @@ def generate_phase_field_input_from_random_voronoi_orientations(
phase_field_input = inp.to_JSON(keep_arrays=True)

return {"phase_field_input": phase_field_input}


# This code is copied from dream3D/generate_volume_element_statistics.py
def _convert_orientations_to_old_matflow_format(orientations: Orientations):
# see `LatticeDirection` enum:
align_lookup = {
"A": "a",
"B": "b",
"C": "c",
"A_STAR": "a*",
"B_STAR": "b*",
"C_STAR": "c*",
}
unit_cell_alignment = {
"x": align_lookup[orientations.unit_cell_alignment.x.name],
"y": align_lookup[orientations.unit_cell_alignment.y.name],
"z": align_lookup[orientations.unit_cell_alignment.z.name],
}
type_lookup = {
"QUATERNION": "quat",
"EULER": "euler",
}
type_ = type_lookup[orientations.representation.type.name]
oris = {
"type": type_,
"unit_cell_alignment": unit_cell_alignment,
}

if type_ == "quat":
quat_order = orientations.representation.quat_order.name.lower().replace("_", "-")
oris["quaternions"] = np.array(orientations.data)
oris["quat_component_ordering"] = quat_order
elif type_ == "euler":
oris["euler_angles"] = np.array(orientations.data)
oris["euler_degrees"] = orientations.representation.euler_is_degrees

return oris
1 change: 1 addition & 0 deletions matflow/data/template_components/task_schemas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2228,6 +2228,7 @@
- parameter: solution_parameters
- parameter: orientation_gradient
- parameter: random_seed
default_value: null
- parameter: is_periodic
- parameter: interface_binning
default_value: null
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: grain_growth_from_voronoi_with_texture_binned

tasks:
- schema: sample_texture_random_mtex
inputs:
specimen_symmetry: cubic
num_orientations: 1000
crystal_symmetry: cubic
execution_mode: script
- schema: generate_phase_field_input_from_random_voronoi_with_orientations
inputs:
is_periodic: false
num_phases: 200
grid_size: [256, 256]
size: [256, 256]
materials:
- name: sub-grain-matrix
properties:
chemicalenergy: none
molarvolume: 1e-5
temperature0: 500.0
interfaces:
- materials: [sub-grain-matrix, sub-grain-matrix]
properties:
width: 4.0
energy:
e0: 1.0e+8
mobility:
m0: 10.0e-11
components: [ti]
outputs: [phaseid, matid, interfaceid, 0_phi]
solution_parameters:
abstol: 0.0001
amrinterval: 25
initblocksize: [1, 1]
initcoarsen: 8
initrefine: 8
interpolation: cubic
maxnrefine: 8
minnrefine: 0
outfile: out
outputfreq: 100
petscoptions: -ts_adapt_monitor -ts_rk_type 2a
random_seed: 1579993586
reltol: 0.0001
time: 10_000
interface_binning: # specify one or both of energy_range/mobility_range:
base_interface_name: sub-grain-matrix-sub-grain-matrix
theta_max: 35
bin_width: 1
energy_range: [0.1e+8, 1.0e+8]
# mobility_range: [1.0e-11, 10.0e-11]
# n: 1 # mobility parameter
# B: 5 # mobility parameter

- schema: simulate_grain_growth
inputs:
VTU_files_time_interval: 1_000
derive_outputs:
- name: num_voxels_per_phase
save_outputs:
- name: phaseid
time_interval: 1_000
- name: matid
number: 4
- name: interfaceid
number: 4
- name: 0_phi
number: 4
- name: num_voxels_per_phase
time_interval: 1_000
delete_VTUs: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: grain_growth_from_voronoi_with_texture_gradient

tasks:
- schema: generate_phase_field_input_from_random_voronoi_with_orientations_gradient
inputs:
is_periodic: false
num_phases: 200
grid_size: [256, 256]
size: [256, 256]
materials:
- name: sub-grain-matrix
properties:
chemicalenergy: none
molarvolume: 1e-5
temperature0: 500.0
interfaces:
- materials: [sub-grain-matrix, sub-grain-matrix]
properties:
width: 4.0
energy:
e0: 1.0e+8
mobility:
m0: 10.0e-11
components: [ti]
outputs: [phaseid, matid, interfaceid, 0_phi]
solution_parameters:
abstol: 0.0001
amrinterval: 25
initblocksize: [1, 1]
initcoarsen: 8
initrefine: 8
interpolation: cubic
maxnrefine: 8
minnrefine: 0
outfile: out
outputfreq: 100
petscoptions: -ts_adapt_monitor -ts_rk_type 2a
random_seed: 1579993586
reltol: 0.0001
time: 10_000
orientation_gradient:
max_misorientation_deg: 20
add_highly_misoriented_grain: true
interface_binning: # specify one or both of energy_range/mobility_range:
base_interface_name: sub-grain-matrix-sub-grain-matrix
theta_max: 35
bin_width: 1
energy_range: [0.1e+8, 1.0e+8]
# mobility_range: [1.0e-11, 10.0e-11]
# n: 1 # mobility parameter
# B: 5 # mobility parameter

- schema: simulate_grain_growth
inputs:
VTU_files_time_interval: 1_000
derive_outputs:
- name: num_voxels_per_phase
save_outputs:
- name: phaseid
time_interval: 1_000
- name: matid
number: 4
- name: interfaceid
number: 4
- name: 0_phi
number: 4
- name: num_voxels_per_phase
time_interval: 1_000
delete_VTUs: true
Loading