11.07.2015 Views

Modeling Tools for Environmental Engineers and Scientists

Modeling Tools for Environmental Engineers and Scientists

Modeling Tools for Environmental Engineers and Scientists

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

dependent variable, the dependent variable, <strong>and</strong> its range over which the ODEis to be solved. The procedure returns the solution in the <strong>for</strong>m of an interpolatingfunction in line Out[30].Finally, the Plot procedure is called in line In[31] to plot the resultsreturned by the NDSolve procedure. Unlike in Excel ® <strong>and</strong> Mathcad ® , whereone clicks a button to generate graphs, in Mathematica ® , the Plot procedurehas to be called, specifying all the objects associated with the plot. In theexample shown, the arguments indicate the function to be plotted, the rangeof the independent variable, <strong>and</strong> the titles <strong>for</strong> the two axes. Additional plotobject specifications can be optionally included with the call to further customizethe plot.7.5.4 LAKE PROBLEM MODELED IN MATLAB ®MATLAB ® , like Mathematica ® , can solve simple ODEs analytically, whenthe Symbolic Math Toolbox is available. This feature is illustrated first in thisexample, where a constant waste load of W is applied to a pristine lake, startingat time t = 0. The built-in procedure dsolve is called with the equation <strong>and</strong>the initial condition as the arguments. The algebraic solution is returned asthe result, as shown in Figure 7.7. This solution was obtained by entering thefirst line in the Comm<strong>and</strong> window directly. Comparing this result withEquation (7.4) (which was derived using traditional mathematical calculi), aswell as that returned by Mathematica ® , it can be seen that all can be reducedto the same <strong>for</strong>m.The MATLAB ® model of the unsteady state lake problem is presented inFigure 7.8. In this case, an exponential declining load of W = W 0 e –µ t isapplied to a pristine lake, starting at time t = 0. The objective is to plot theresponse of the lake <strong>for</strong> various values of µ. The governing ODE is first setup in an M-File named Lake.m, where a custom function, Lake, has beendefined as a two-dimensional matrix in line 1. The model parameters, W, Q,V, K, <strong>and</strong> µ are defined in this M-File to be global in line 2, so that they canbe interactively changed in the Comm<strong>and</strong> window without having to edit theM-File that contains the script. The governing ODE is entered in line 3.The model is run from the Comm<strong>and</strong> window, where the model parametersare first defined to be global. Numeric values <strong>for</strong> the parameters are thenFigure 7.7 Analytical solution <strong>for</strong> the lake problem in MATLAB ® .© 2002 by CRC Press LLC

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!