%
%   FISHSTORY.M  Find fish population versus time for "Fish Story" Example
%
%   This problem is described in some detail in the Class Notes for Differential
%   Equations.  The basic idea was derived from Prob. 2 pg. 76 of Edwards and Penny
%   (Prentice Hall Inc., 1996).  It addresses the NUMERICAL solution of a paricular 
%   Population Model that approximates the fish population in a man-made pond.  
%
%   The population balance equation for this problem is
%       dP/dt = k*sqrt(P)   
%   where k is a constant that needs to be determined based on data for the 
%   particular problem.  We will solve the problem for a range of k's.
%
%   Calls FISHSTORY_EQNS.M to evaluate desired function P' = f(t,P).
%
%   File prepared by J. R. White, UMass-Lowell (last update Jan. 2003)
%
      
%
%   getting started
      clear all;   close all;   nfig = 0;
      global kk
%
%   define integration variables and initial condition
      to = 0;   tf = 30;   Po = 100;     % time in months and P in numbers of fish
%
%   let's define 4 values of k to investigate (since we don't know this value)
      k = [.50 1.00 1.50 2.00];   % growth rate constant (units of sqrt(fish)/month)
      cols = ['r- ';'g: ';'b-.';'m--'];
%
%   evaluate P(t) for each value of k
%   (Note:  A single experimental value of the fish population at a specific time 
%   point should be sufficient to determine the unknown growth coefficient, k, in the
%   mathematical model.  However, since we are solving this problem numerically, our
%   approach is to search for the value of k that gives a solution curve that passes
%   directly through the known experimental value.  If this occurs, then we have 
%   "guessed" the correct value of k, and we have the correct population profile vs
%   time.  In this problem, we pick four (4) values of k and plot the resultant 
%   solution to the given IVP, as well as the known experimental point.  From here,
%   we can easily pick an appropriate value for k.  As seen in the resultant plots,
%   k = 1.0 gives essentially the exact solution.)
      Nk = length(k);
      for n = 1:Nk
        kk = k(n);  [t,P] = ode23('fishstory_eqns',[to tf],Po);
        plot(t,P,cols(n,:),'LineWidth',2),hold on
        gtext(['k = ',num2str(kk,'%2.1f')])
      end
      plot(6,169,'kx','LineWidth',2),grid    % mark the known experimental point
      gtext('expt')
      hold off
      title('Fish Population Versus Time for the "Fish Story" Example')
      xlabel('Time (months)'),ylabel('Number of Fish')
%
%   end of problem
