function DUROS_sensitivity_test()
% DUROS_SENSITIVITY_TEST  One line description goes here
%  
% Sensitivity test of DUROS for water level, wave height, grain size and
% profile fluctuation. The resulting figure is similar to figure 2 of Van
% de Graaff (1984).
%
%
%   See also 

%% Copyright notice
%   --------------------------------------------------------------------
%   Copyright (C) 2011 Delft University of Technology
%       Kees den Heijer
%
%       C.denHeijer@TUDelft.nl	
%
%       Faculty of Civil Engineering and Geosciences
%       P.O. Box 5048
%       2600 GA Delft
%       The Netherlands
%
%   This library is free software: you can redistribute it and/or
%   modify it under the terms of the GNU Lesser General Public
%   License as published by the Free Software Foundation, either
%   version 2.1 of the License, or (at your option) any later version.
%
%   This library is distributed in the hope that it will be useful,
%   but WITHOUT ANY WARRANTY; without even the implied warranty of
%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
%   Lesser General Public License for more details.
%
%   You should have received a copy of the GNU Lesser General Public
%   License along with this library. If not, see <http://www.gnu.org/licenses/>.
%   --------------------------------------------------------------------

% This tools is part of <a href="http://OpenEarth.Deltares.nl">OpenEarthTools</a>.
% OpenEarthTools is an online collaboration to share and manage data and 
% programming tools in an open source, version controlled environment.
% Sign up to recieve regular updates of this function, and to contribute 
% your own tools.

%% Version <http://svnbook.red-bean.com/en/1.5/svn.advanced.props.special.keywords.html>
% Created: 19 Aug 2011
% Created with Matlab version: 7.7.0.471 (R2008b)

% $Id$
% $Date$
% $Author$
% $Revision$
% $HeadURL$
% $Keywords: $

MTestCategory.WorkInProgress;

%%
reference = struct(...
    'xInitial', [-250 -24.375 5.625 55.725 230.625 1950]',...
    'zInitial', [15 15 3 0 -3 -14.4625]',...
    'WL_t', 5.25,...
    'Hsig_t', 7.95,...
    'D50', 225e-6,...
    'Tp_t', 12);

sensitivity = struct(...
    'WL_t', 4.5:.5:6,...
    'Hsig_t', 6.5:.5:9.5,...
    'D50', (175:25:300)*1e-6,...
    'ProfileFluct', -150:50:150);
Xref = findCrossings(reference.xInitial, reference.zInitial, reference.xInitial, repmat(5, size(reference.xInitial)));

vars2vary = fieldnames(sensitivity);
xlab = {'Water level [m]' 'Significant wave height [m]' 'Grain size [m]' 'Profile volume fluctuation m^3/m^1'};
for is = 1:length(vars2vary)
    varname = vars2vary{is};
    x = sensitivity.(varname);
    basicinput = reference;
    DuneErosionSettings('set', 'ProfileFluct', 0);
    for ic = 1:length(x)
        if strcmp(varname, 'ProfileFluct')
            DuneErosionSettings('set', 'ProfileFluct', x(ic));
        else
            basicinput.(varname) = x(ic);
        end
        inputcell = reshape([fieldnames(basicinput) struct2cell(basicinput)]', 1, 2*length(fieldnames(basicinput)));
        result = DUROS(inputcell{:});
        RD(is,ic) = Xref - result(1).VTVinfo.Xr;
    end
    
    %%
    subplot(2,2,is)
    plot(x, RD(is,1:length(x)), '-o')
    set(gca,...
        'XLim', [min(x) max(x)] + [-.1 .1]*(max(x) - min(x)),...
        'YLim', [40 75])
    xlabel(xlab{is})
    ylabel('Retreat distance [m]')
    title(char(is+96))
end