obtainCrystalDec

PURPOSE ^

obtain decomposition of a crystal definition from database

SYNOPSIS ^

function dec = obtainCrystalDec(crystalName, genericCode, flagEnforce,verbose)

DESCRIPTION ^

 obtain decomposition of a crystal definition from database

 Syntax: dec = obtainCrystalDec(name, code)

 This function essentially does:
   >> cdef = obtainCrystal(crystalName, genericCode);
   >> dec = obtainDec(cdef.A, 'mapping', cdef.groupMappingMatrix);
 However, the result is stored in the data folder so that a decomposition
   is calculated only once and loaded from disk for subsequent calls.

 Use obtainCrystalDec(name, code, enforce, verbose) with enforce=1 to 
   recalculate the requested decomposition or to change the verbosity
   level for calling obtainDec.

 For more details on name and code, see obtainCrystal.

 See also: obtainCrystal, obtainDec

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function dec = obtainCrystalDec(crystalName, genericCode, flagEnforce, ...
0002     verbose)
0003 % obtain decomposition of a crystal definition from database
0004 %
0005 % Syntax: dec = obtainCrystalDec(name, code)
0006 %
0007 % This function essentially does:
0008 %   >> cdef = obtainCrystal(crystalName, genericCode);
0009 %   >> dec = obtainDec(cdef.A, 'mapping', cdef.groupMappingMatrix);
0010 % However, the result is stored in the data folder so that a decomposition
0011 %   is calculated only once and loaded from disk for subsequent calls.
0012 %
0013 % Use obtainCrystalDec(name, code, enforce, verbose) with enforce=1 to
0014 %   recalculate the requested decomposition or to change the verbosity
0015 %   level for calling obtainDec.
0016 %
0017 % For more details on name and code, see obtainCrystal.
0018 %
0019 % See also: obtainCrystal, obtainDec
0020 
0021 % The elk-library: convex geometry applied to crystallization modeling.
0022 %   Copyright (C) 2013 Alexander Reinhold
0023 %
0024 % This program is free software: you can redistribute it and/or modify it
0025 %   under the terms of the GNU General Public License as published by the
0026 %   Free Software Foundation, either version 3 of the License, or (at your
0027 %   option) any later version.
0028 %
0029 % This program is distributed in the hope that it will be useful, but
0030 %   WITHOUT ANY WARRANTY; without even the implied warranty of
0031 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0032 %   General Public License for more details.
0033 %
0034 % You should have received a copy of the GNU General Public License along
0035 %   with this program.  If not, see <http://www.gnu.org/licenses/>.
0036 
0037 %% input handling
0038 if ~exist('crystalName', 'var')
0039     crystalName = '';
0040 end
0041 if ~exist('genericCode', 'var')
0042     genericCode = [];
0043 end
0044 if ~exist('flagEnforce', 'var')
0045     flagEnforce = false;
0046 end
0047 if ~exist('verbose', 'var')
0048     verbose = 2;
0049 end
0050 
0051 %% load crystal
0052 % load crystal
0053 cdef = obtainCrystal(crystalName, genericCode);
0054 % init and empty is not supported for obtainCrystal, but still has proper
0055 %   behavior. Hence, we return warning and return
0056 if isempty(crystalName) || strcmpi(crystalName, 'init')
0057     warning('elk:decomposition:crystalName', ['Initialization of crystal ' ...
0058         'database performed even though this function is not supported']);
0059     return
0060 end
0061 % adjust file name
0062 if isempty(cdef.genericCode)
0063     fileName = [crystalName '.mat'];
0064 else
0065     fileName = [crystalName '_' num2str(cdef.genericCode) '.mat'];
0066 end
0067 
0068 %% try to load data
0069 if ~flagEnforce
0070     try
0071         dec = obtainData(fileName(1:end-4), ...
0072             'database', ['.' filesep 'data-crystal'], 'type', 'mat');
0073         % return, if this succeeds
0074         return
0075     catch
0076         % have to calculate decomposition
0077         flagEnforce = true;
0078     end
0079 end
0080 if flagEnforce
0081     dec = obtainDec(cdef.A, 'mapping', cdef.groupMappingMatrix, ...
0082         'verbose', verbose, 'allowFixPosition', 1);
0083 end
0084 
0085 %% store cdef
0086 dec.cdef = cdef;
0087 
0088 %% save data
0089 save([fileparts(which('obtainCrystalDec')) filesep 'data-crystal' filesep fileName], ...
0090     'dec')
0091 dump = obtainData('init', 'database', ['.' filesep 'data-crystal'], 'type', 'mat');

Generated on Sat 18-Jul-2015 16:45:31 by m2html © 2005