obtainTimeEvolution

PURPOSE ^

generate time evolution from arbitrary function handle

SYNOPSIS ^

function [outX outY] = obtainTimeEvolution(resultStruct, functionHandle,varargin)

DESCRIPTION ^

 generate time evolution from arbitrary function handle

 The function handle is supposed to generate a scalar from a structure 
   that contains the variables of the solver in a time-dependent state. 
   These variables are: H, N, up, P, x, y, time

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [outX outY] = obtainTimeEvolution(resultStruct, functionHandle, ...
0002     varargin)
0003 % generate time evolution from arbitrary function handle
0004 %
0005 % The function handle is supposed to generate a scalar from a structure
0006 %   that contains the variables of the solver in a time-dependent state.
0007 %   These variables are: H, N, up, P, x, y, time
0008 
0009 % The elk-library: convex geometry applied to crystallization modeling.
0010 %   Copyright (C) 2013 Alexander Reinhold
0011 %
0012 % This program is free software: you can redistribute it and/or modify it
0013 %   under the terms of the GNU General Public License as published by the
0014 %   Free Software Foundation, either version 3 of the License, or (at your
0015 %   option) any later version.
0016 %
0017 % This program is distributed in the hope that it will be useful, but
0018 %   WITHOUT ANY WARRANTY; without even the implied warranty of
0019 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0020 %   General Public License for more details.
0021 %
0022 % You should have received a copy of the GNU General Public License along
0023 %   with this program.  If not, see <http://www.gnu.org/licenses/>.
0024 
0025 % we can assume that result struct is NOT empty so that we can evaluate the
0026 %   first entry and determine the dimension.
0027 outX = resultStruct.time;
0028 outY = evaluateHandle(functionHandle, resultStruct, 1, varargin{:});
0029 
0030 % stretch output to foll size
0031 nTime = length(resultStruct);
0032 outX(nTime) = 0;
0033 outY(1, nTime) = 0;
0034 
0035 for iTime = 2:nTime  
0036     outX(iTime) = resultStruct(iTime).time;
0037     outY(:, iTime) = evaluateHandle(functionHandle, resultStruct, iTime, ...
0038         varargin{:});
0039 end
0040 
0041 end
0042 
0043 function outY = evaluateHandle(functionHandle, resultStruct, iTime, varargin)
0044     info.i = iTime;
0045     info.H =  resultStruct(iTime).hcMatrix;
0046     info.N =  resultStruct(iTime).numberVector;
0047     info.up = resultStruct(iTime).upVector;
0048     info.P =  resultStruct(iTime).pivotPropertyMatrix;
0049     
0050     info.x =  resultStruct(iTime).bulkStateVector;
0051     info.y =  resultStruct(iTime).bulkPropertyVector;
0052     info.time = resultStruct(iTime).time;
0053     
0054     info.nPivot = size(info.H, 2);
0055     info.nDim = size(info.H, 1);
0056     if length(resultStruct(iTime).dissolvedPivotVector) >= 1
0057         info.nZero = resultStruct(iTime).dissolvedPivotVector(1);
0058     else
0059         info.nZero = 0;
0060     end
0061     info.nSample = info.nPivot + info.nZero;
0062     
0063     % some extra information that can be precomputed to save time in
0064     %   functionHandle(info) if these values are required multiple times.
0065     info.extra = struct([]);
0066     for iArgin = 1:length(varargin)
0067         info.extra(iArgin).data = feval(varargin{iArgin}, info);
0068     end
0069     outY = functionHandle(info);
0070 end

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