


extend crystal definition according to symmetry
Syntax: cdef = extendCdef(cdef)
This function creates additional symmetry information (Herman-Mauguin
symbol, Schonflies symbol, Laue class, crystal system), the complete
list of Miller indices according to symmetry, the group mapping matrix
and the matrix of facet normals in Cartesian space. The output
structure has the fields:
cdef.sym.Schonflies - Schonflies symbol (symmetry)
cdef.sym.HermanMaugin - Herman-Mauguin symbol (symmetry)
cdef.sym.LaueClass - Laue class (symmetry, not unique)
cdef.sym.system - crystal system (symmetry, not unique)
cdef.millerComplete - the complete list of Miller indices
cdef.groupMappingMatrix - the group mapping matrix (hC -> h)
cdef.A - matrix of facet normals
cdef.mapMillerToReal - mapping matrix from Miller coordinates (row
vector) to real coordinates
cdef.mapRealToMiller - mapping matrix from real coordinates (row
vector) to Miller coordinates
The input crystal definition must contain the fields:
cdef.millerDefined - the face groups of the crystal
cdef.sym.defined - a name of the crystal definition (Schoenflies, Laue,
International)
cdef.lat.a, cdef.lat.b, cdef.lat.c - the length of the crystallographic
axes
cdef.lat.alpha, cdef.lat.beta, cdef.lat.gamma - the angles of the
lattice coordinate system
This function is an interface to functions provided by Christian Borchert
under the GNU GPL. See subfolder borchert-05-2010 for details.
See also: obtainCrystal, viewCrystal, editCrystal

0001 function cdef = extendCdef(cdef, varargin) 0002 % extend crystal definition according to symmetry 0003 % 0004 % Syntax: cdef = extendCdef(cdef) 0005 % 0006 % This function creates additional symmetry information (Herman-Mauguin 0007 % symbol, Schonflies symbol, Laue class, crystal system), the complete 0008 % list of Miller indices according to symmetry, the group mapping matrix 0009 % and the matrix of facet normals in Cartesian space. The output 0010 % structure has the fields: 0011 % cdef.sym.Schonflies - Schonflies symbol (symmetry) 0012 % cdef.sym.HermanMaugin - Herman-Mauguin symbol (symmetry) 0013 % cdef.sym.LaueClass - Laue class (symmetry, not unique) 0014 % cdef.sym.system - crystal system (symmetry, not unique) 0015 % cdef.millerComplete - the complete list of Miller indices 0016 % cdef.groupMappingMatrix - the group mapping matrix (hC -> h) 0017 % cdef.A - matrix of facet normals 0018 % cdef.mapMillerToReal - mapping matrix from Miller coordinates (row 0019 % vector) to real coordinates 0020 % cdef.mapRealToMiller - mapping matrix from real coordinates (row 0021 % vector) to Miller coordinates 0022 % 0023 % The input crystal definition must contain the fields: 0024 % cdef.millerDefined - the face groups of the crystal 0025 % cdef.sym.defined - a name of the crystal definition (Schoenflies, Laue, 0026 % International) 0027 % cdef.lat.a, cdef.lat.b, cdef.lat.c - the length of the crystallographic 0028 % axes 0029 % cdef.lat.alpha, cdef.lat.beta, cdef.lat.gamma - the angles of the 0030 % lattice coordinate system 0031 % 0032 % This function is an interface to functions provided by Christian Borchert 0033 % under the GNU GPL. See subfolder borchert-05-2010 for details. 0034 % 0035 % See also: obtainCrystal, viewCrystal, editCrystal 0036 0037 % The elk-library: convex geometry applied to crystallization modeling. 0038 % Copyright (C) 2012 Alexander Reinhold 0039 % 0040 % This program is free software: you can redistribute it and/or modify it 0041 % under the terms of the GNU General Public License as published by the 0042 % Free Software Foundation, either version 3 of the License, or (at your 0043 % option) any later version. 0044 % 0045 % This program is distributed in the hope that it will be useful, but 0046 % WITHOUT ANY WARRANTY; without even the implied warranty of 0047 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0048 % General Public License for more details. 0049 % 0050 % You should have received a copy of the GNU General Public License along 0051 % with this program. If not, see <http://www.gnu.org/licenses/>. 0052 0053 %% Parameters 0054 borchertDir = 'borchert-05-2010'; 0055 0056 %% Handle options 0057 [normalize, checkDoubleFacet] = mapOption(varargin, ... 0058 'normalize', 1, ... 0059 'check double', 1); 0060 0061 %% Input handling 0062 %! ToDo: Standard should be degree, no crystallographer reads radian 0063 if strcmp(cdef.lat.unit_angle, 'degree') 0064 cdef.lat.unit_angle = 'radian'; 0065 cdef.lat.alpha = cdef.lat.alpha / 180 * pi; 0066 cdef.lat.beta = cdef.lat.beta / 180 * pi; 0067 cdef.lat.gamma = cdef.lat.gamma / 180 * pi; 0068 end 0069 if ~strcmp(cdef.lat.unit_angle, 'radian') 0070 error(['angles in cdef.lat must be given in radian or degree (cdef.lat.unit_angle = ' cdef.lat.unit_angle]); 0071 end 0072 0073 %% Add external path 0074 % where am I 0075 myPath = which('extendCdef'); 0076 tmp = find(myPath == filesep, 1, 'last'); 0077 myPath = myPath(1:tmp); 0078 % where is geometry 0079 borchertPath = [myPath borchertDir]; 0080 eval(['addpath ' borchertPath]); 0081 0082 %% Symmetry information 0083 pg = pointgroup; 0084 cdef.sym.Schoenflies = pg(cdef.sym.defined).SF; 0085 cdef.sym.HermanMauguin = pg(cdef.sym.defined).HM; 0086 cdef.sym.Laue = pg(cdef.sym.defined).LC; 0087 cdef.sym.system = abbreviateCrystalSystem(pg(cdef.sym.defined).CF); 0088 %cdef.sym.name = pg(cdef.sym.defined).TN; % implemented in german 0089 0090 %% Obtain complete set of Miller indices 0091 [cdef.millerComplete, ~, facetTypeVector] = ... 0092 form2face(cdef.millerDefined, pg(cdef.sym.defined).HM); 0093 0094 %% Obtain matrix of facet normals 0095 [transformationMatrix, ~] = transmatrix(cdef.lat.a,cdef.lat.b,cdef.lat.c,... 0096 cdef.lat.alpha,cdef.lat.beta,cdef.lat.gamma); 0097 transformationMatrixInverted = inv(transformationMatrix); 0098 for iFacet = 1:size(cdef.millerComplete, 1) 0099 cdef.A(iFacet,:) = cdef.millerComplete(iFacet, :) * transformationMatrixInverted; 0100 end 0101 % safe transformation matrix 0102 cdef.mapMillerToReal = transformationMatrixInverted'; 0103 cdef.mapRealToMiller = transformationMatrix'; 0104 0105 %% Generate grouping matrix 0106 cdef.groupMappingMatrix = zeros([size(cdef.A, 1) max(facetTypeVector)]); 0107 for iFacet = 1:length(facetTypeVector) 0108 cdef.groupMappingMatrix(iFacet, facetTypeVector(iFacet)) = 1; 0109 end 0110 0111 %% Remove required paths 0112 eval(['rmpath ' borchertPath]); 0113 0114 %% Normalize facet normals 0115 if normalize 0116 for i = 1:size(cdef.A, 1) 0117 cdef.A(i,:) = cdef.A(i,:) / norm(cdef.A(i,:)); 0118 end 0119 end 0120 0121 %% Check four double facets 0122 if checkDoubleFacet 0123 uniqueMillerMatrix = unique(cdef.millerComplete, 'rows'); 0124 if size(uniqueMillerMatrix, 1) ~= size(cdef.millerComplete, 1) 0125 error('Created Miller indices are not unique') 0126 end 0127 end