


load data from executed population balance Syntax: [result pbeDefinition] = loadResultPbe(caseName) The case from the data folder is loaded (result) and returned including its original definition (pbeDefinition). See also: executeCasePbe, solvePbe


0001 function [result pbeDefinition] = loadPbeResult(caseName) 0002 % load data from executed population balance 0003 % 0004 % Syntax: [result pbeDefinition] = loadResultPbe(caseName) 0005 % 0006 % The case from the data folder is loaded (result) and returned including 0007 % its original definition (pbeDefinition). 0008 % 0009 % See also: executeCasePbe, solvePbe 0010 0011 % The elk-library: convex geometry applied to crystallization modeling. 0012 % Copyright (C) 2012 Alexander Reinhold 0013 % 0014 % This program is free software: you can redistribute it and/or modify it 0015 % under the terms of the GNU General Public License as published by the 0016 % Free Software Foundation, either version 3 of the License, or (at your 0017 % option) any later version. 0018 % 0019 % This program is distributed in the hope that it will be useful, but 0020 % WITHOUT ANY WARRANTY; without even the implied warranty of 0021 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0022 % General Public License for more details. 0023 % 0024 % You should have received a copy of the GNU General Public License along 0025 % with this program. If not, see <http://www.gnu.org/licenses/>. 0026 0027 %% input handling 0028 if ~exist('caseName', 'var') 0029 caseName = []; 0030 end 0031 % thats my path: 0032 myPath = fileparts(which(mfilename)); 0033 % starting path 0034 currentPath = cd; 0035 0036 %% database handling 0037 if nargout == 0 0038 obtainData(caseName, 'database', [myPath filesep 'data'], 'type', 'mat'); 0039 else 0040 result = obtainData(caseName, ... 0041 'database', [myPath filesep 'data'], 'type', 'mat'); 0042 % if isfield(result, 'result') 0043 pbeDefStored = result.pbeDefinition; 0044 pbeDefinitionString = result.pbeDefinitionString; 0045 result = result.result; 0046 pbeDefStored = convertStringToFunctionPbe(pbeDefStored); 0047 % else 0048 % pbeDefStored = result; 0049 % end 0050 0051 % write generating file 0052 cd([myPath filesep 'database']) 0053 fileHandle = fopen('tmpPbeDefinition.m', 'w'); 0054 fprintf(fileHandle, '%s', pbeDefinitionString); 0055 fclose(fileHandle); 0056 % ensure it is in scope for matlab 0057 rehash 0058 % and call it 0059 pbeDefinition = tmpPbeDefinition; 0060 % remove it again 0061 % delete('tmpPbeDefinition.m') 0062 cd(currentPath) 0063 % Result: all anonymuous functions in tmpPbeDefinition can be called 0064 % again. 0065 0066 % ensure extra fields in pbeDef from solver are present 0067 pbeDefinition = mergeStruct(pbeDefinition, pbeDefStored); 0068 0069 % ensure option struct is complete 0070 pbeDefinition.optionStruct = mergeStruct(pbeDefStored.optionStruct, ... 0071 pbeDefinition.optionStruct); 0072 0073 0074 end