0001 function cdef = editCrystalDefinition(cdef)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058 if ~exist('cdef', 'var')
0059 cdef = struct();
0060 end
0061
0062 if ischar(cdef)
0063 cdef = obtainCrystal(cdef);
0064 elseif ~isstruct(cdef)
0065 error('elk:crystal:wrongInput', ['Input must be a crystal definition ' ...
0066 'structure or a string to be called with obtainCrystal']);
0067 end
0068
0069
0070
0071 P = executeExternBorchertFunction('pointgroup');
0072 P = reshape(struct2cell(P), [9,32]);
0073
0074
0075
0076
0077
0078 for i = 1:size(P, 2)
0079 P{5, i} = abbreviateCrystalSystem(P{5, i});
0080 P{6, i} = num2str(P{6, i});
0081 end
0082
0083
0084 control = -1;
0085
0086 while control ~= 0
0087
0088 clc
0089 disp(' /----------------------------------\');
0090 disp('| Interactive Crystal Definition |');
0091 disp(' \----------------------------------/');
0092 disp(' ');
0093 disp(' During this setup, you will specify crystal symmetry, lattice ');
0094 disp(' parameters and Miller indices of faces. From these informations');
0095 disp(' the facet normals in cartesian space are calculated.');
0096 disp(' ');
0097 disp('Main Menu');
0098 list = {};
0099
0100 if isfield(cdef, 'sym') && isfield(cdef.sym, 'defined')
0101 list{1} = 'Delete Crystal Symmetry';
0102 elseif isfield(cdef, 'sym') && (isfield(cdef.sym, 'system') || isfield(cdef.sym, 'LC'))
0103 list{1} = 'Extend Crystal Symmetry Information';
0104 else
0105 list{1} = 'Define Crystal Symmetry';
0106 end
0107
0108 if isfield(cdef, 'lat')
0109 list{2} = 'Delete Lattice Parameters';
0110 else
0111 list{2} = 'Define Lattice Parameters';
0112 end
0113 clist = [1 2];
0114
0115 if isfield(cdef, 'sym') && isfield(cdef.sym, 'defined')
0116 list{end+1} = 'Edit Miller Indices';
0117 clist(end+1) = 3;
0118 end
0119
0120 list{end+1} = 'Display Current Informations';
0121 clist(end+1) = 4;
0122
0123 if isfield(cdef, 'sym') && isfield(cdef.sym, 'defined') && isfield(cdef, 'lat')
0124 list{end+1} = 'Show Image of Crystal';
0125 clist(end+1) = 5;
0126 end
0127
0128 list{end+1} = 'Save to database and exit';
0129 clist(end+1) = 6;
0130
0131
0132 control = selectFromList(list, 'Exit');
0133 if control ~= 0
0134 control = clist(control);
0135 end
0136
0137 switch control
0138
0139 case 1
0140 if isfield(cdef, 'sym') && isfield(cdef.sym, 'defined')
0141
0142 cdef = rmfield(cdef, 'sym');
0143
0144 if isfield(cdef, 'lat');
0145 cdef = rmfield(cdef, 'lat');
0146 end
0147
0148 if isfield(cdef, 'millerDefined');
0149 cdef = rmfield(cdef, 'millerDefined');
0150 end
0151 disp('..crystal definition deleted');
0152 elseif isfield(cdef, 'sym') && isfield(cdef.sym, 'system')
0153
0154
0155 disp(' ');
0156 disp('Please choose a notation');
0157 list = {'Schonflies Notation', 'Hermann-Mauguin Notation',...
0158 'Trivialname (German)', 'Number'};
0159 sel = selectFromList(list, 'Back');
0160
0161 if sel == 0,control = -1;continue;end;
0162
0163
0164 list = [1, 2, 7, 6];
0165 sel = list(sel);
0166
0167 sublistindices = [];
0168 for i = 1:size(P, 2)
0169 if strcmp(P(5, i), cdef.sym.system)
0170 sublistindices(end+1) = i;
0171 end
0172 end
0173
0174 disp(' ');
0175 disp('Please specify the symmetry group');
0176 list = P(sel, sublistindices);
0177 sel = selectFromList(list, 'Back')
0178
0179 if sel == 0,control = -1;continue;end;
0180
0181 cdef.sym.defined = sublistindices(sel);
0182 else
0183
0184 disp(' ');
0185 disp('Please choose a notation');
0186 list = {'Schonflies Notation', 'Hermann-Mauguin Notation',...
0187 'Trivialname (German)', 'Number', ...
0188 'Crystal Family'};
0189 sel = selectFromList(list, 'Back');
0190
0191 if sel == 0,control = -1;continue;end;
0192
0193 list = [1, 2, 7, 6, 5];
0194 sel = list(sel);
0195 list = P(sel,:);
0196
0197 if sel == 4 || sel == 5
0198 list = unique(list);
0199 end
0200
0201 disp(' ');
0202 disp('Please specify the symmetry group');
0203 selt = selectFromList(list, 'Back');
0204
0205 if selt == 0,control = -1;continue;end;
0206
0207 if sel == 1 || sel == 2 || sel == 7 || sel == 6
0208 cdef.sym.defined = selt;
0209 cdef.sym.system = P{5, selt};
0210 elseif sel == 5
0211 cdef.sym.system = list{selt};
0212 end
0213 end
0214
0215 case 2
0216 if isfield(cdef, 'lat')
0217
0218 cdef = rmfield(cdef, 'lat');
0219 disp('..lattice parameters deleted');
0220 else
0221
0222 [latspec cdef] = printLatticeSummary(cdef);
0223 disp(' ');
0224 disp('Please specify missing lattice parameters (lengths in aengstroem, angles in degree)');
0225 cdef.lat.unit_length = 'angstrom';
0226 cdef.lat.unit_angle = 'degree';
0227 cdef.lat.a = input(' a = ');
0228 if ~strcmp(latspec{2}, 'a')
0229 cdef.lat.b = input(' b = ');
0230 else
0231 cdef.lat.b = cdef.lat.a;
0232 end
0233 if ~strcmp(latspec{3}, 'a')
0234 cdef.lat.c = input(' c = ');
0235 else
0236 cdef.lat.c = cdef.lat.a;
0237 end
0238 if ~isfield(cdef.lat, 'alpha')
0239 cdef.lat.alpha = input(' alpha = ');
0240 end
0241 if ~isfield(cdef.lat, 'beta')
0242 cdef.lat.beta = input(' beta = ');
0243 end
0244 if ~isfield(cdef.lat, 'gamma')
0245 cdef.lat.gamma = input(' gamma = ');
0246 end
0247 end
0248
0249 case 3
0250 cdef = editMiller(cdef, P);
0251
0252
0253 case 4
0254 disp(' ');
0255 printSymmetrySummary(cdef, P);
0256
0257 disp(' ');
0258 printLatticeSummary(cdef);
0259
0260 disp(' ');
0261 printMillerSummary(cdef, P);
0262 pause
0263
0264
0265 case 5
0266 try
0267 figure
0268 cdef_tmp = extendCdef(cdef);
0269 viewCrystal(cdef_tmp);
0270 catch thisError
0271 warning(thisError.message)
0272 warning('Could not display crystal shape');
0273 end
0274 pause
0275 case 6
0276
0277 disp(' ')
0278 fileName = input('File name (e.g. my_crystal): ', 's');
0279
0280 disp(' ')
0281 disp('Proceed with file operation?');
0282 list = {['Save as elk' filesep 'crystal' ...
0283 filesep 'database' filesep fileName '.m']};
0284 sel = selectFromList(list, 'Do not safe file.');
0285 if sel==1
0286 writeCdefToDatabase(fileName, cdef);
0287 control = 0;
0288 end
0289 otherwise
0290 if control ~= 0
0291 disp('Choice was invalid');
0292 end
0293 end
0294 end
0295
0296
0297 if nargout == 1;
0298 try
0299 cdef = extendCdef(cdef);
0300 end
0301 else
0302 clear cdef
0303 end
0304
0305
0306 end
0307
0308
0309