HW05: More Functions and Objects#

Purposes of this assignment is to get more practice with the following:

  • Defining and calling functions

  • Using objects (class instance) and make a calculation using the objects attributes

Problem 1#

Define a function to calculate the heat adsorbed by the atmosphere given the suns radiation and the albedo of the earth. To get full credit please also specify defaults for the functions parameters. The function should have the following inputs:

  • solar radiation (W/m^2), default value of 2000 W/m^2

  • albedo (unitless), default value of 0.3

Some hints:

  • The heat adsorbed is the difference between the solar radiation and the reflected radiation.

  • The reflected radiation is the solar radiation times the albedo.

  • The function should return the heat adsorbed in units of W/m^2.

Some equations:

  • \(Q_{adsorbed} = Q_{solar} - Q_{reflected}\)

  • \(Q_{reflected} = Q_{solar} \times \alpha\)

where \(\alpha\) is the albedo. Calculate the heat adsorbed for an albedo of 0.3 and solar radiation of 2000 W/m^2.

Problem 2#

Create a plot that shows the heat adsorbed as a function of albedo for albedos ranging from 0 to 1. Use the function you defined in Problem 1 to calculate the heat adsorbed. Make sure to label your axes and title your plot. Also give a small description of what the plot is showing.

Problem 3#

In the last homework assignment, you made a class to calculate the properties of a gas. Specifically, the class had the critical parameters and you generated a function to determine the pressure from the Peng Robinson equation of state. In this problem, you will use that class to first create an instance (object) with the critical properties defined for CO2 and you’ll calculate the pressure of CO2 gas given the following properties by referencing the object’s attributes.

  • temperature = 298 K

  • volume = 1 L

  • number of moles = 1 mol

Problem 4#

Use the same class you used in Problem 3 to find the pressure of CO2 gas with various molar volume for a temperature of 2/3 times the critical temperature. Plot the pressure as a function of molar volume beginning at the critical molar volume and out to very large molar volumes (1e6 L/mol). Make sure to label your axes and title your plot. Also give a small description of what the plot is showing. Also plot the ideal gas law on the same plot. You can use the following equation for the ideal gas law: P = RT/V. Use the same temperature as you used for the Peng Robinson equation of state.