This course is currently part of a trial of the Open Course Ware (OCW) program at MIT (http://web.mit.edu/ocw/). The goal of this project is to make available to the general public lecture material from MIT courses. The in-house development site of the OCW homepage for 10.34 may be found at https://ocw-int.mit.edu/10/10.34/f02/index.html. As the semester progresses, lecture notes from 10.34 will be posted as pdf files under the section titles listed below.
Program Development Document Example: die_flow_1D_program_development.htm
When writing a program from scratch, it is best to organize first the logical flow of data in the program before you begin to write code. To help this planning process, I have attached an example of a Program Development Document, a tool that you can use to help organize the job or writing a computer program. The basic idea is to plan out the structure of the program in terms that are comfortable and familiar to you before you start worrying about how to convert these ideas into computer code. Once you develop a program development document, all you have to do is paste the lines as comments into a file, and add after each comment the code that performs the tasks that you have outlined. Experience teaches that this is a more efficient and quicker way to write programs that work than simply to sit and the keyboard and start typing blindly. Of course, programming style is highly individual, so you will not be required to write these program development documents, and you are free adapt this approach to your own way of solving problems.
MATLAB Program: approx_Jacobian_FD.m. This routine uses a simple finite difference approach to approximate the Jaobian matrix. An option exists to compute the Jacobian as a sparse matrix of known structure, but no effort is made to employ graph theory to reduce the number of finite difference operations.
MATLAB PROGRAM: Newton_2D_test1b_v2.m. This program compares the performance of the full-step and reduced-step Newton's methods, where in the latter method a weak line search is implemented to improve robustness. To run this program, you must also save the m-files Newton_2D_test1b_calc_f.m and Newton_2D_test1b_calc_Jac.m, that calculate the vector of function values and the Jacobian for this problem. In addition, the program calls the function reduced_Newton.m that implements the reduced-step Newton's method algorithm.
MATLAB PROGRAM: reduced_Newton.m. This program implements a reduced-step Newton's method algorithm to solve a set of nonlinear algebraic equations. The method is rather robust, but may still "hang up" when the search direction becomes nearly orthogonal to the direction of steepest descent. A possible modification to correct this failure would be to implement a Levenberg-Marquardt type of modification of the Jacobian, adding a small positive scalar times the identify matrix to the Jacobian to push the method toward the direction of steepest descent when the weak line search results in very small step sizes.
MATLAB PROGRAM : SS_CSTR_2_rxn_scan_Q.m. This program simulates a CSTR at steady state with the two reactions A + B --> C and B + C --> D. The concentrations of each species are plotted as functions of the volumetric flow rate. The program uses the MATLAB nonlinear solver fsolve(), part of the optimization toolkit.
MATLAB PROGRAM: test_Gershorgin.m. This program takes an input matrix, compute the bounds on the eigenvalues based on Gershorgin's theorem, and then computes the eigenvalues. A graph is made showing how the eigenvalues fit within the bounds.
MATLAB PROGRAM: QR_eig.m. This program demonstrates the iterative QR approach to calculating the eigenvalues of a matrix. This routine is meant to demonstrate the method only, use the command eig() and eigs() for actual computations.
MATLAB PROGRAM: get_poly_roots.m. This program demonstrates how eigenvalue calculations can be used to compute all of the roots of a polynomial.
MATLAB PROGRAM: analyze_SVD.m. This program analyzes the existence and uniqueness properties of a system of linear algebraic equations using singular value decomposiiton.
MATLAB PROGRAM: test_data_CVD.m. This program demonstrates the use of SVD to perform linear least squares data analysis.
MATLAB program: quantum_1D.m. This MATLAB program uses a basis function exapansion to solve for the quantum states of a particle trapped in a 1-D infinite well with an arbitrary external potential energy function. The program uses a basis set exapansion is sine function s to convert the eigenvalue differential equation into a matrix eigenvalue problem. The program file also includes various subroutines for specific examples of external potential energy functions. Type "harmonic_V_ext" to compute the energy levels of a harmonic spring.
MATLAB Program: plot_Greens_fcn_1D.m. This program plots the Green's function for the 1-D second derivative with zero-value Dirichlet boundary conditions. The forms obtained from both eigenfunction expansion and the "physical" approach from shell balances are compared.
MATLAB Program: plot_2D_duct_flow.m. This program plots the analytical solution, expressed as an eigenfunction expansion, of the steady-state velocity profile for laminar, pressure-driven flow down a rectangular duct.
MATLAB Program: plot_Bessel_function.m. This program plots a few leading-order Bessel functions of the first and second kinds.
MATLAB Program: fit_Bessel.m. This program fits a truncated expansion in Bessel functions to a function f(r), demonstrating the use of the orthogonality relations for Bessel functions.
MATLAB Program: Poiseuille_startup.m. This program uses expansion in Bessel functions to compute analytically the time-varying velocity profile of laminar flow in a circular tube upon imposition of an axial pressure gradient.
MATLAB Program: test_integration.m. This program demonstrates various methods within MATLAB to compute definite integrals numerically.
MATLAB Program: get_Fourier_series.m. This program computes the Fourier coefficients (using sine and cosine basis functions) of an input function measured at various (not necessarily discrete) times.
MATLAB Program: get_Fourier_transform.m. This program computes uses FFT to compute and plot the Fourier transform and power spectrum of a discretely-sampled signal. Optionally, a low-pass digital filter can be applied to the data prior to computing the Fourier transform.
MATLAB Program: results_get_Fourier_transform.m. This script file invokes get_Fourier_transform.m to demonstrate its use.
MATLAB Program: compute_convolution.m. This MATLAB program uses convolution to compute the time-varying output of a system to a given input signal, where the time-domain response function of the system is known. This program automatically performs zero-padding prior to computing Fourier transforms to avoid wraparound problems.
MATLAB Program: damped_spring_response.m. This program demonstrates the response-function behavior of a damped spring.
MATLAB Program: get_response_example.m. This script demonstrates the use of Fourier analysis to estimate the response function of a damped spring from input and output data.
MATLAB Program: get_response.m. This program uses deconvolution to estimate the response function of a system from input and output data.
MATLAB Program: correct_signal_example.m. This program uses deconvolution to correct a measured signal to remove the bias in the detector.
MATLAB Program: correlation_example.m. This program uses Fourier analysis to compute the correlation of two functions.
MATLAB Program: example_fft2.m This program demonstrates the computation and interpretation of 2-D Fourier transforms.
MATLAB Program: example_2D_scatter.m. This program demonstrates, in 2D, how scattering information can be used to probe spatial structure.
MATLAB Program: polymer_flow_1D_v3.m. This program computes the velocity profile of a polymeric shear-thinning fluid in steady, pressure-driven, laminar flow between two parallel, semi-infinite flat-plates. A shear thinning generalized Newton fluid constitutive model is used. Finite differences are used to convert the boundary value problem to a set of nonlinear algebraic equations. These are then solved using the MATLAB fsolve() routine. The user enters the simulation parameters through an input file, an example of which is polymer_flow_1D_input1.m.