function pbeDefinition = snyderCuboidGrowth
clear all
%% Basic information
pbeDefinition.info = ['seeded dissolution of cuboids with new facets ' ...
    'evolving on edges (stepped faces) and vertices (kinked)'];

% obtain decomposition
dec = obtainSynderCuboidDec;
pbeDefinition.source = dec.cdef.source;
pbeDefinition.dec = dec;

%% initial condition
rng(1)
% normal distribution of particle size (mean diameter) with mean:
% hCube = [1 2 3]'*5*1e-6;
% hC = mapToValidityCone([hCube; 100*ones(4,1)*max(hCube)], dec, 1e-12);
hC = ones(7,1)*1e-5;
% and some coefficient of variation of 20% (3x20% = 60%)
% disD = obtainDistributionDiscrete('normal', ...
%     'nSample', 100, ...
%     'mean', 1, ...
%     'cov', 0.2^2);
% mean(disD.positionMatrix, 2)
% std(disD.positionMatrix, [], 2)
% if any(disD.positionMatrix(:) < 1e-6)
%     error('random particles are too small')
% end
% finally we assign the seeds:
% pbeDefinition.seeding.positionMatrix = hC * disD.positionMatrix;
% pbeDefinition.seeding.numberVector = 1 + disD.positionMatrix * 0;
pbeDefinition.seeding.positionMatrix = hC;
pbeDefinition.seeding.numberVector = 1;


%% growth
% the relative growth rates are already specified in the crystal definition
%   where two versions are available.
% pbeDefinition.growthRateOriginal = @(H, P, y, t)(...
%     1./dec.cdef.relativeGrowthCaseTwo*1e-8*...
%     ones(1, size(H,2))...
%     );
pbeDefinition.growthRateOriginal = @(H, P, y, t)(...
    dec.cdef.relativeGrowthCaseTwo*2/10*1e-9*...
    ones(1, size(H,2))...
    );
pbeDefinition.growthRate = @(H, P, y, t)(...
    pbeDefinition.growthRateOriginal(H, P, y, t));

%% pivot properties
% we need the unified partitions in P for growth rate projections
pbeDefinition.pivotProperty = @(H, up)(up);

%% time span for solution
pbeDefinition.timeSpan = 0:60:(1*60*60); %s
% pbeDefinition.timeSpan = 0:60:(0.5*60*60); %s

% options
pbeDefinition.optionStruct.distanceLimit = 1e-7; %m
pbeDefinition.optionStruct.relTol = 1e-6;
pbeDefinition.optionStruct.absTolNumber = 1e-30;
pbeDefinition.optionStruct.absTolPosition = 1e-30;
pbeDefinition.optionStruct.updateLimit = 2;
pbeDefinition.optionStruct.updateTime = 1;

% pbeDefinition.optionStruct.odeSolver = @ode113; % 113, 45