checkInputSolver

PURPOSE ^

check fields in input data that must exist.

SYNOPSIS ^

function pbeDefinition = checkInputSolver(pbeDefinition)

DESCRIPTION ^

 check fields in input data that must exist.

 THIS IS NO USER FUNCTION.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function pbeDefinition = checkInputSolver(pbeDefinition)
0002 % check fields in input data that must exist.
0003 %
0004 % THIS IS NO USER FUNCTION.
0005 
0006 % The elk-library: convex geometry applied to crystallization modeling.
0007 %   Copyright (C) 2012 Alexander Reinhold
0008 %
0009 % This program is free software: you can redistribute it and/or modify it
0010 %   under the terms of the GNU General Public License as published by the
0011 %   Free Software Foundation, either version 3 of the License, or (at your
0012 %   option) any later version.
0013 %
0014 % This program is distributed in the hope that it will be useful, but
0015 %   WITHOUT ANY WARRANTY; without even the implied warranty of
0016 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0017 %   General Public License for more details.
0018 %
0019 % You should have received a copy of the GNU General Public License along
0020 %   with this program.  If not, see <http://www.gnu.org/licenses/>.
0021 
0022 %% options
0023 if ~isfield(pbeDefinition, 'option')
0024     pbeDefinition.option = struct();
0025 end
0026 
0027 
0028 %% time span
0029 if ~isfield(pbeDefinition,'timeSpan')
0030     error('elk:pbeSolver:wrongInput', ...
0031         'pbeDefinition must contain a field ''timeSpan''');
0032 end
0033 
0034 %% dec
0035 if ~isfield(pbeDefinition,'dec') && (...
0036         isfield(pbeDefinition, 'seeding') || ...
0037         isfield(pbeDefinition, 'nucleationRate'))
0038     error('elk:pbeSolver:wrongInput', ...
0039         'pbeDefinition must contain a field ''dec'' if seeding or nucleation is used');
0040 elseif ~isfield(pbeDefinition,'dec')
0041     % use some simple dummy decomposition
0042     pbeDefinition.dec = obtainCrystalDec('generic_potash_alum', 0);
0043 end
0044 
0045 if ~isfield(pbeDefinition, 'nDecCoordinate')
0046     pbeDefinition.nDecCoordinate = pbeDefinition.dec.nC;
0047 end
0048 if ~isfield(pbeDefinition, 'nExtraCoordinate')
0049     pbeDefinition.nExtraCoordinate = 0;
0050 end
0051 if ~isfield(pbeDefinition, 'extraZeroBound')
0052     pbeDefinition.extraZeroBound = [];
0053 elseif size(pbeDefinition.extraZeroBound, 2) ~= pbeDefinition.nExtraCoordinate
0054     error('elk:pbeSolver:inputError', ['Please correct the number of columns '...
0055         ' for the extra condition matrix, it must match the number of ' ...
0056         ' extra property coordinates']);
0057 end
0058 
0059 
0060 %% growth rate
0061 if ~isfield(pbeDefinition,'growthRate')
0062     pbeDefinition.growthRate = @(H, P, x, y, t)(H-H);
0063     pbeDefinition.growthGrad = @(H, P, x, y, t)([]);
0064 else
0065     if ~isfield(pbeDefinition,'growthGrad')
0066         pbeDefinition.growthGrad = @(H, P, x, y, t)([]);
0067     end
0068 end
0069 
0070 %% nucleation
0071 if ~isfield(pbeDefinition, 'nucleationRate')
0072     pbeDefinition.nucleationRate = @(x, y, t)(-1);
0073     pbeDefinition.nucleationSize = zeros([...
0074             pbeDefinition.nDecCoordinate + ...
0075             pbeDefinition.nExtraCoordinate, 1]);
0076 else
0077     %! Dev: Nucleation cannot be fully supported yet. It was more or less
0078     %    implemented with a relatively rudimentary scheme analogue to the
0079     %    moving pivot technique (Kumar, 1997) or Borchert (Thesis, 2012).
0080     %    This deterministic scheme is currently incompatiple with the
0081     %    computation of integral properties, but only in a minor extend.
0082     %    The error estimates would be wrong in that case.
0083     % This might be resolved by using some probabilistic approach for
0084     %   introducing pivots and fixing the calculation of integral
0085     %   properties appropriately. Alternatively, a more rigorous error
0086     %   estimate might be introduced, given by Briesen 2009 (Escape).
0087     warning('elk:pbeSolver:wrongInput', ['Handling of nucleation ' ...
0088         'is not yet fully supported. Calculation of integral properties ' ...
0089         'will yield wrong error estimated. See more in code comments.']);
0090     %/
0091     if ~isfield(pbeDefinition, 'nucleationSize')
0092         pbeDefinition.nucleationSize = zeros([...
0093             pbeDefinition.nDecCoordinate + ...
0094             pbeDefinition.nExtraCoordinate, 1]);
0095     end
0096 end
0097 
0098 %% bulk
0099 if (~isfield(pbeDefinition, 'bulkRate') && ...
0100      isfield(pbeDefinition, 'bulkInitial')...
0101      ) || (...
0102      isfield(pbeDefinition, 'bulkRate') && ...
0103     ~isfield(pbeDefinition, 'bulkInitial')...
0104     )
0105     error('elk:pbeSolver:wrongInput', ...
0106         'pbeDefinition must contain both fields ''bulkRate'' and ''bulkInitial''');
0107 elseif ~isfield(pbeDefinition, 'bulkRate') && ...
0108        ~isfield(pbeDefinition, 'bulkInitial')
0109     % apply a dummy bulk rate to keep solver alive in case of nucleation or
0110     %   delayed seeding
0111     pbeDefinition.bulkInitial = 0;
0112     pbeDefinition.bulkRate = @(x, y, t)(1);
0113 end
0114 
0115 %% pivot property
0116 if ~isfield(pbeDefinition, 'pivotProperty')
0117     pbeDefinition.pivotProperty = @(H, up)(H);
0118 elseif ischar(pbeDefinition.pivotProperty) || ...
0119        iscell(pbeDefinition.pivotProperty)
0120    
0121    pbeDefinition.pivotProperty = @(H, up)(computeMeasureDec(...
0122        pbeDefinition.dec, 'hC', {up, H}, ...
0123        pbeDefinition.pivotProperty, [], 0, 1));
0124 end
0125 
0126 %% bulk property
0127 if ~isfield(pbeDefinition, 'bulkProperty')
0128     pbeDefinition.bulkProperty = @(P, N, x, t)([]);
0129 end
0130 
0131 %% seeding
0132 if ~isfield(pbeDefinition, 'seeding')
0133     pbeDefinition.seeding = struct('');
0134 end

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