diff --git a/README.md b/README.md index c226ff86..33a2370b 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ This is a list tracking which workflows/tasks we have reimplemented/tested in th | ⇒ method: [add_buffer_zones/damask](https://github.com/LightForm-group/UoM-CSF-matflow/blob/569fa7bdc7006d04bd6ed2d4e4b6a114df23492e/task_schemas.yml#L760) | ✅ | [modify_VE/add_buffer_zones](https://docs.matflow.io/stable/reference/template_components/task_schemas.html#modify-ve-add-buffer-zones) | | ⇒ method: [new_orientations/damask](https://github.com/LightForm-group/UoM-CSF-matflow/blob/569fa7bdc7006d04bd6ed2d4e4b6a114df23492e/task_schemas.yml#L770) | ❌ | Unimplemented | | ⇒ method: [geometry](https://github.com/LightForm-group/UoM-CSF-matflow/blob/569fa7bdc7006d04bd6ed2d4e4b6a114df23492e/task_schemas.yml#L775) | ❌ | Unimplemented | -| ⇒ method: [spread_orientations/damask](https://github.com/LightForm-group/UoM-CSF-matflow/blob/569fa7bdc7006d04bd6ed2d4e4b6a114df23492e/task_schemas.yml#L780) | ❌ | Unimplemented | +| ⇒ method: [spread_orientations/damask](https://github.com/LightForm-group/UoM-CSF-matflow/blob/569fa7bdc7006d04bd6ed2d4e4b6a114df23492e/task_schemas.yml#L780) | ✅ | [modify_VE/spread_orientations](https://docs.matflow.io/stable/reference/template_components/task_schemas.html#modify-ve-spread-orientations) | | ⇒ method: [grid_size/damask](https://github.com/LightForm-group/UoM-CSF-matflow/blob/569fa7bdc7006d04bd6ed2d4e4b6a114df23492e/task_schemas.yml#L786) | ✅ | [modify_VE/grid_size](https://docs.matflow.io/stable/reference/template_components/task_schemas.html#modify-ve-grid-size) | | **generate_load_case** | | | | ⇒ method: [mixed/formable](https://github.com/LightForm-group/UoM-CSF-matflow/blob/569fa7bdc7006d04bd6ed2d4e4b6a114df23492e/task_schemas.yml#L912) | ✅ | [define_load_case](https://docs.matflow.io/stable/reference/template_components/task_schemas.html#define-load-case) / [LoadCase](https://docs.matflow.io/stable/reference/template_components/parameters.html#load-case) | diff --git a/matflow/data/scripts/damask/modify_VE_spread_orientations.py b/matflow/data/scripts/damask/modify_VE_spread_orientations.py new file mode 100644 index 00000000..aeec7d0c --- /dev/null +++ b/matflow/data/scripts/damask/modify_VE_spread_orientations.py @@ -0,0 +1,25 @@ +from damask_parse.utils import spread_orientations + + +def modify_VE_spread_orientations(volume_element, phases, stddev_degrees): + # need to convert Zarr arrays to numpy arrays first: + VE = volume_element + ori_copy = VE["orientations"] + ori_copy["quaternions"] = ori_copy["quaternions"][:] + VE_copy = { + "size": VE["size"], + "grid_size": VE["grid_size"][:], + "orientations": ori_copy, + "element_material_idx": VE["element_material_idx"][:], + "constituent_material_idx": VE["constituent_material_idx"][:], + "constituent_material_fraction": VE["constituent_material_fraction"][:], + "constituent_phase_label": VE["constituent_phase_label"][:], + "constituent_orientation_idx": VE["constituent_orientation_idx"][:], + "material_homog": VE["material_homog"][:], + } + VE = spread_orientations( + volume_element=VE_copy, phase_names=phases, sigmas=stddev_degrees + ) + VE["grid_size"] = tuple(int(i) for i in VE["grid_size"]) + VE["size"] = tuple(float(i) for i in VE["size"]) + return {"volume_element": VE} diff --git a/matflow/data/template_components/task_schemas.yaml b/matflow/data/template_components/task_schemas.yaml index 0c4e1b99..0e3526e8 100644 --- a/matflow/data/template_components/task_schemas.yaml +++ b/matflow/data/template_components/task_schemas.yaml @@ -1067,3 +1067,21 @@ script_data_in: direct script_data_out: direct script_exe: python_script + +- objective: modify_VE + method: spread_orientations + inputs: + - parameter: volume_element + - parameter: phases + - parameter: stddev_degrees + outputs: + - parameter: volume_element + actions: + - environments: + - scope: + type: any + environment: damask_parse_env + script: <> + script_data_in: direct + script_data_out: direct + script_exe: python_script diff --git a/matflow/data/workflows/spread_orientations.yaml b/matflow/data/workflows/spread_orientations.yaml new file mode 100644 index 00000000..9a74dbc2 --- /dev/null +++ b/matflow/data/workflows/spread_orientations.yaml @@ -0,0 +1,31 @@ +doc: + - > + Demonstration of modifying a volume element by applying a perturbation to its orientations. + +tasks: + - schema: generate_volume_element_from_voronoi + inputs: + homog_label: SX + VE_grid_size: [8, 8, 8] + microstructure_seeds::from_random: + num_seeds: 4 + box_size: [1, 1, 1] + phase_label: Al + orientations: + data: + - [1, 0, 0, 0] + - [1, 0, 0, 0] + - [1, 0, 0, 0] + - [1, 0, 0, 0] + unit_cell_alignment: + x: a + y: b + z: c + representation: + type: quaternion + quat_order: scalar_vector + + - schema: modify_VE_spread_orientations # underscore to separate the levels of the task schema objective/method + inputs: + phases: [Al] + stddev_degrees: [0.01]