Skip to content

Instantly share code, notes, and snippets.

View jhiscocks's full-sized avatar

jhiscocks

View GitHub Profile
@jhiscocks
jhiscocks / UnitCellOverlay
Last active June 22, 2025 14:55
Overlay HCP or cubic unit cells on EBSD Map #mtexScript
%% Draw HCP or cubic unit cells overlaid on EBSD Map rotated by Euler angles
%rev 1.
%file assumes the following; -you select the crystal unit cell to draw
%-that the default for HCP is z//c axis, x//to [1,0,-1,0],
%that the default for cubic is faces aligned with axes
%no promises at all, but a pole figure plotting utility included to check your annotations (based on mtex and not my work)
%IF YOUR DATA HAS MORE THAN ONE PHASE you'll need to edit the plot(ebsd...line)
%Rev1; fixed problem with cases where maps plotted with z into plane.
@jhiscocks
jhiscocks / PFandIPFbySchmid.txt
Last active June 22, 2025 14:56
PF and IPF of Schmid factor (for Mg) #mtexScript
%% Creates pole figure and inverse pole figure maps of schmid factor
% Rev 0-Created Jan 21, 2017 by J. Hiscocks
%rev 1 fixed IPF point generation issue
%rev 2 added more graph outputs to IPF and titles etc.
%note that IPF section is the second half, and variables are not shared.
%on a pole figure(PF), we can plot the Schmid factor(SF) of a specific
%orientation that has forces applied in a variety of orientations. For a
@jhiscocks
jhiscocks / stiffness3D
Last active February 23, 2018 20:07
Plot directional Young's modulus and it's inverse in 3D #mtexScript
%% Plot directional Young's modulus and it's inverse in 3D for HCP
%this script takes values of the stiffness tensor and creates a 3d plot of
%the values of S, or 1/S which equals the directional Young's modulus. It
%is currently set up for HCP, and two sets of values are provided.
%note that the surface plot method used here has trouble with 'undercut' shapes.
%since it works fine for my purposes I do not intend to alter it further,
%and have plotted by splitting into two surfaces and using hold on. This
%does not work well for the Zn figures which are dumbbell shaped.
@jhiscocks
jhiscocks / SchmidPoleFigR1.m
Last active June 22, 2025 14:56
This script plots the orientation of a selected parent data point along with the possible twin variants and their schmid factors #mtexScript
%% Schmid pole figure
%this script plots the orientation of a selected parent data point along
%with the possible twin variants and their schmid factors
%the function Schmid must be installed
%input; ebsd data must be available
%output; pole figure plots
cs=ebsd('Magnesium').CS;
% get the parent orientation
figure; plot(ebsd('Magnesium'), ebsd('Magnesium').orientations)
@jhiscocks
jhiscocks / MapSeg.m
Last active February 17, 2017 18:07
A script to segment ebsd data into a grid or strips #mtexScript
%% MapSeg a script to segment ebsd data into a grid or strips
% code input; EBSD data in a variable named ebsd.
%both segx and segy must be positive integers
%code output ebsd variables named ebsd_1 through the total number of sections.
%note to run code repeatedly with the same number of segments, manually
%define segx and segy and comment out the prompts.
prompt = 'how many sections in x? ';
segx = input(prompt);
prompt = 'how many sections in y? ';
@jhiscocks
jhiscocks / SchmidR2.m
Last active February 14, 2017 19:56
For magnesium EBSD data, compute Schmid factors and plot #mtexScript
%% Function to calculate the schmid factors for all magnesium slip/twin systems
%code input; EBSD data (ebsd variable), and a vector3d defining the applied
%tensile force (default is in x).
%output a 6 column array containing from left to right the SF of basal
%slip, the SF of prismatic slip, the SF of pyramidal slip, the SF of
%extension twinning, the lowest SF of the four available types and
%the index (column) of the lowest SF of the four systems. Information for plotting is at
%bottom.
@jhiscocks
jhiscocks / Parent_Twin_InteractR18.m
Created February 13, 2017 02:26
Identifies twinning within an EBSD map using the MTEX package with user input #mtexScript
%% CRYSTALLOGRAPHIC VARIABLE LIST
%This code analyses EBSD data and outputs information for all
%mergedGrains and grains. This version of the code assumes the largest
%grain composing the merged grain is the parent, BUT CHECKS MANUALLY WITH
%THE USER FOR CONFIRMATION. For automatic acceptance of the largest
% parent see Parent_Twin_Area instead.
%Customization options include material, twinning type,
%and direction of applied force (r)
%input; EBSD data (ebsd variable).
@jhiscocks
jhiscocks / Parent_Twin_AreaR8.m
Last active July 28, 2020 01:04
Automatically calculate twin areas, percentages and grain sizes from EBSD data using MTEX #mtexScript
%% CRYSTALLOGRAPHIC VARIABLE LIST
%This code analyses EBSD data and outputs information for all
%mergedGrains and grains. This version of the code assumes the largest
%grain composing the merged grain is the parent. For manual selection of
%the parent see Parent_Twin_Interact instead.
%Customization options include material, twinning type,
%and direction of applied force (r)
%input; EBSD data (ebsd variable).