function [modelout] = bucketModel_student(rainfall,pet)
% assign model parameters
bsize             = 200;         % in cm/month
recharge_quotient = 0.10;        % a fraction
K                 = 1/12;        % /month 
vegfrac           = 1;           % determined by nature of vegetation

% initialize states
nummonths       = length(rainfall);
soil            = zeros(nummonths,1);
aet             = zeros(nummonths,1);
runoff          = zeros(nummonths,1);
gwstore         = zeros(nummonths,1);
baseflow        = zeros(nummonths,1);

%run the model
for month = 1:nummonths
    % update soil state baesd on this month's rainfall
    % remove the rainfall going into groundwater
    tempsoil     = soil(month)+rainfall(month)*(1-recharge_quotient);
    
    %if soil state exceeds the maximum height of soil store, generate
    %runoff
    runoff(month) = max(0,tempsoil-bsize);
    
    %update soil state after generating runoff
    tempsoil      = min(bsize,tempsoil);
    
    %evaporate 
    aet(month)    = tempsoil/bsize*pet(month)*vegfrac;
    aet(month)    = min(tempsoil,aet(month));
    %update soil store
    tempsoil      = max(0,tempsoil-aet(month));
    
    %update groundwater storage
    gwstore(month)= gwstore(month)+rainfall(month)*recharge_quotient;
    
    %release baseflow
    baseflow(month)= gwstore(month)*K;
    
    %update groundwater storage
    gwstore(month) = gwstore(month)-baseflow(month);
    
    %update total flow
    totalflow(month) = runoff(month)+baseflow(month);
    
    %update future values
    soil(month+1)    = tempsoil;
    gwstore(month+1) = gwstore(month);
end

modelout.soil     = soil;
modelout.runoff   = runoff;
modelout.gwstore  = gwstore;
modelout.baseflow = baseflow;
modelout.aet      = aet;
modelout.totalflow= totalflow;