Sie sind auf Seite 1von 2

MATLAB ASSIGNMENT # 1

1. Plot the circle x2+y2 = 5 in MATLAB


2. Make a panel of figure with four subplots. In one of these, plot x2+y2=25; in the second, plot y = 5x+3;
in the third, plot y = x2; in the fourth plot any function that you come up with where y cant be explicitly
written in terms of x. Plot these functions for x values between [-5 5].
3. Write your own function subroutine for finding the numerical derivative of any scalar function that
you define. The function subroutine should be callable as follows: derivative =
myfunction(arg1,arg2,arg3,arg3). In the first function that you write, arg1 should take the function
whose derivative you want to find as an inline expression, arg2 is the point at which you want to
calculate the derivative, arg3 should be the step size that you want to use and arg4 should indicate if the
derivative scheme is forward, backward or central difference. In the second function that you write, arg1
should be the name of the subroutine function that evaluates and returns the value of the scalar
function of your choice.
4. Write a MATLAB program to determine the specific volume of a pure component at a given pressure
and temperature using the Peng Robinson cubic equation of state model. Also determine the saturated
liquid and saturated vapour volume of the component at the specified temperature. Structure your
code as follows
(a) A subroutine reader that reads the basic properties for the specified component (critical
pressure, temperature, volume, accentric factor, dipole moment, constants for the specific heat
capacity correlation of the ideal gas state, type of correlation for computing saturated vapour
pressure and corresponding constants for the saturated vapour pressure vs temperature
correlation). All these constants are available for more than 700 compounds in the reference
Properties of Liquids and Gases by Reid, Prausnitz, Sherwood, Poling. Store all this data in a
common block.
(b) Subroutine for calculating the constants a and b of the PR equation of state given by
=




   + 2 
 =

0.07780


0.45724 
=
[1 +  1 . ]

 = 0.37464 + 1.54226 0.26992
where Pc, Tc are the critical pressure and temperature, w is the acentric factor and Tr is the reduced
temperature = T/Tc.

(c) Subroutine for computing the constants of the cubic equation in Z, the compressibility factor =
PV/RT given a, b of the PR equation of state
(d) A subroutine for computing the saturated pressure at the given temperature using the
appropriate correlation
(e) A main program that reads the values of temperature and pressure and solves the cubic
equation (in Z) to get the roots for the compressibility factor and hence compute the specific
volume. The main program should also determine the state and print out the state, and specific
volume, saturated liquid and saturated vapour volume (along with units)
Note: Be careful of the units. Make sure the units for R are consistent with the units of Pc, Tc, P and T.
Use your program to print out the specific volume of any compound you choose for a range of pressures
and a range of temperatures for each pressure.

Das könnte Ihnen auch gefallen