Program Development Document

 

The procedure outlined in this document is intended to guide the design of a program using a top-to-bottom  approach.  Initially, one describes the nature of the program at the highest level, specifying only what task the program is to perform and noting the physical assumptions and data required to completely define the problem and the solution.  Next, one specifies the design choices used to execute the program’s tasks, making note of new data that are introduced.  These design choices should be as independent of each other as possible, and any possible interactions should be noted.

 

Until this point in the design process, most attention has been focused on data management.  Next, the program execution is designed starting first with an outline of the main program  in program development language, i.e. with plain-English descriptions of each operation instead of language-specific code.  Once the operations to be performed by the main program have been described, tasks that are to be performed by procedures (subroutines) are identified.  The same process used to write the main program is then repeated for these procedures (perhaps iteratively) until the structure of the entire program is complete.  At this point, the program development language provides comments to guide the actual coding of the program in the language of choice.  The format of this document is intended for non-object oriented programming, but the use of data structures, modules, and internal procedures is supported

.

Project Title :

 

first, a longer, more descriptive title

 

Calculation of the velocity profile of a Newtonian fluid driven by a pressure gradient between two parallel infinite plates, one of which is stationary and the other moving in a direction parallel to the pressure gradient at a set velocity.

 

 

next, a short title used to name the directory containing the project’s code

 

die_flow_1D

 

Author :

 

Kenneth J. Beers

MIT ChE

9/9/2001


Program Summary :

 

In this section, describe at the highest level the purpose of the program and the assumptions used at this level.  Avoid any discussion of details that are internal to the program.  Merely focus on what goes in and what comes out.

 

This program calculates the velocity of a Newtonian fluid that is driven by a specified pressure gradient between two infinite parallel plates that are separated by a distance B.  No-slip boundary conditions are employed with one plate being stationary and the other moving at a known velocity, velocity_up, parallel to the direction of the pressure gradient.

 


Program Input and Output Data Specification :

 

In this section, list the input and output variables of the program that are independent of the internal details of program execution.  Only the variables that are required to uniquely specify the problem or that characterize the output at the level of the Program Summary should be listed.  For each variable,  list the name to be used in the program, the intent (IN, OUT, or INOUT depending on whether it is a program input, an output, or both), the type (REAL, INT, STRING, or a user-defined type and the dimension), and finally a description of the variable’s meaning and use within the program.  List first the variables that define the dimensions of the other input and output variables.  Also, list the input variables first, the input/output variables next, and finally the output variables.  In a separate section, list the output variables whose exact form will not be known until further decisions regarding program implementation are made.  Denote with an asterisk a dependence of the dimension of an array on the details of the program implementation.  To organize the data in a modular fashion, enclose related variables within a DATAGROUP: group_name, ENDDATAGROUP wrapper.  If, during later design stages, additional variables are to be included in these DATAGROUPS, they are added to this list with the intent PROG denoting program-wide scope without being a program input or output variable.

 

 

Variable Name

Type   Intent

Description                                                                            

 

Program Input Variables :

 

B

REAL              IN

the distance between the two parallel plates

 

dp_dx

REAL              IN

the pressure gradient in the x-direction

 

velocity_up

REAL              IN

the velocity of the upper plate in the x-direction

 

viscosity

REAL              IN

the viscosity of the fluid

 

Known output variables :

 

 

Tentative output variables :

 

velocity_x

REAL(*)            OUT

the velocity profile of the fluid


Program Implementation Design Notes :

 

In this section, describe the major design choices for performing the task outlined in the Program Summary.  Try to make and express each design choice independently.  After each new design choice, examine the previous sections for possible interactions and interferences, and note any that occur.  In each design section, include a table of the new program variables introduced.  If the value of a variable must be input, specify the intent as PIN, the P prefix denoting that the format of this variable is dependent on the details of the program implementation.  If a new variable is neither input or output but has scope throughout the program, specify the intent as PROG.  If a variable is to be output but in a format that depends on the program implementation, the intent is POUT.  All “tentative output variables” from the previous section should now be declared in their form dictated by the program design.  Include only those variables absolutely needed to define the state of the system within the main program.  At this stage in the design, the organization of the program data is the primary concern.

 

 

Section 1. Discretization of differential equation with finite difference method :

 

To convert the 1-D differential equation to a set of algebraic equations, use the method of finite differences.  Since the second derivative is to be estimated, use the central finite difference method.  For simplicity, we will include the velocity at the grid points corresponding to the lower and upper plates as formal unknowns and the spacing between grid points will be uniform.

 

Variable Name

Type   Intent

Description                                                                            

 

num_pts

INT                              IN

the number of grid points

 

y_grid

REAL(num_pts)           OUT

a column vector of the y-values at each grid point

 

velocity_x

REAL(num_pts)           OUT

the velocity of the fluid in the x-direction at each grid point

 

h_grid

REAL                          OUT

the uniform distance between neighboring grid points

 


Program Outline in Program Development Language :

 

In this section, outline the operation of the program in program development language (PDL), i.e. in plain English that is organized similarly to code in a computer program.  Avoid any language-specific syntax.  One starts with the main program, listing all tasks to be performed and enclosing sets of operations to be performed by a procedure within a wrapper.  The input/output interfaces and purposes of each procedure are then written.  Then, the operations of the procedures are outlined in program development language, identifying further procedures that must be added.  This process is repeated, perhaps iteratively, until the structure of the entire program is complete.  The PDL outline developed in this section should satisfactorily comment the final code.

 

 

main program PDL :

 

First, outline the operation of the main program, without attempting to specify the nature of the procedures required to perform the tasks.  Then, identify the set of related tasks that are to be performed within a procedure rather than within the main program.  Enclose these tasks together within a PROCEDURE : proc_name, ENDPROCEDURE wrapper.

 

PROCEDURE: read_input

PDL> Read from user input the values of B, dp_dx, velocity_up, viscosity, and num_pts.

END PROCEDURE

 

PDL> Set the vector containing the grid point y values and the uniform spacing between adjacent grid points

 

PDL> Set the matrix that discretizes the differential equation and sets the boundary conditions.  Use the sparse matrix data format with an upper bound on the number of non-zero elements being three times the number of grid points.

 

PDL> Set the column vector for the right hand side of the linear problem that includes the source term for the interior points (proportional to the pressure gradient divided by the viscosity) and the known values of the velocity at each plate for the boundary condition equations.

 

PDL> Solve this set of linear algebraic equations for the column vector containing the velocities at each grid point.

 

PDL> Make a plot of the velocity as a function of y.

 


list of procedures :

 

This section first defines the interfaces to the routines used in the main program.  The input, input/output, and output variables to the procedure are listed.  To simplify the interface, one can use DATAGROUP: group_name, ALL to signify that all variables within the named DATAGROUP are used in the procedure interface.  If only certain variables in a DATAGROUP are to be used, change ALL to ONLY: and list the individual variables.  If all variables in a data group are to be used except for only a few, use ALL EXCEPT:.  In the PURPOSE: section, describe in plain English what the procedure does – this section will serve as the procedure header in the final code.  In the EXISTS: section, if the code for the procedure already exists from a previous project, make a note of where to find it.  In the CALLED BY: section, make a list of every procedure in the project that calls this procedure; initially, the main program will be the only listing.  In CALLS:, list the other procedures that the current procedure calls; this will generally not be known until the PDL: section, containing the outline of the procedure operation in project development language, has been written.  If the procedure is to be grouped with others in a module, enter the name in the MODULE: section.  Any internal routines to the procedure are to be added in the CONTAINS: section.  The format of each procedure’s outline is the following :

 

 

PROCEDURE: read_input

 

INPUT :

 

INPUT/OUTPUT :

 

OUTPUT :

 

B                      REAL

the distance between the two parallel plates

 

dp_dx              REAL

the pressure gradient in the x-direction

 

velocity_up            REAL

the velocity of the upper plate in the x-direction

 

viscosity            REAL

the viscosity of the fluid

 

num_pts            INT

the number of grid points

 

PURPOSE :

 

This procedure reads the input from the user that defines the die_flow_1D system.  The values are read from the keyboard, but since this is such a simple program written in a few lines, input assertion checks are not made.

 

EXISTS :

 

CALLED BY :

 

main

 

CALLS :

 

MODULE :

 

PDL :

 

PDL> Ask the user to input the value of B (with an explanation of the meaning) and read the input value from the keyboard.

 

PDL> Input in succession the values of dp_dx, velocity_up, viscosity, and num_pts

 

CONTAINS :