EGR 103/Fall 2020/Lab 5

From PrattWiki
Revision as of 03:12, 18 September 2020 by DukeEgr93 (talk | contribs) (5.6 Connect)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Errors / Additions

None yet!

5.1 Introduction

The main purpose of this lab will be to look at debugging and using Chapra Figure 4.2. You will also be introduced to the Connect system.

5.2 Resources

See main EGR 103 page for links to these

5.3 Getting Started

Beginning of Lab

5.4 Debugging Introduction

We will go through debugging in lab using the Python:Debugging page.

5.5 APT

The second APT assignment is active.

5.6 Connect

The first Connect assignment is active. You will be submitting the information required in the Connect system and also uploading your programs to a drop box on Sakai. When you are ready for the latter part, go to the Drop Box section of Sakai and create a folder called "Connect 1" for your files. You will include the code that answers 2.013, the code that answers all parts of 2.021, and the code that answers all parts of 3.001. Note:

  • Anywhere it asks you to use MATLAB, use Python.
  • Anywhere it says create/store a vector, interpret that to mean an array.

Specific hints / clarifications:

  • 2.013: Fill in the blank with the value max(U) or U.max() gives you.
  • 2.021a: Calculate an estimate for each data point; later we will be able to calculate a single estimate based on a data set.
  • 2.021b: This will pick out particular values from the coefficients calculated in the previous part.
  • 2.021c: A "stacked plot" means using two subplots, one above the other. See the Python:Plotting page for details on getting multiple subplots in one figure window. Use solid blue squares connected by a cyan dotted line for the top graph and solid red circles connected by a dashed yellow line for the bottom graph. Save the plot as a PNG file and upload that to Connect.
    • Note - I failed to recognize that the masses aren't given in order, so the connecting lines are going to zig zig across the figures. We'll accept that for this problem. But if you want to make it pretty, you can ask numpy to figure out the index values for m in order and use that for the plot. That is to say, assuming you have $$m$$ and $$A$$:
      midx = m.argsort() # produces an array of the indices of the elements of m if they were in order
      ax.plot(m[midx], A[midx], ...) # where ... is the format stuff you need
      
  • 3.001a: You can either use an if tree or a logical mask for the calculations, but you will need an if tree before you do the calculation to report if the d value is too large. To report an error, just print the word "Overtop" to the screen and have your program return -1 instead of a valid volume.
  • 3.001b: Put test code under an if __name__ == "__main__": statement to print out the values and then select the correct options from the dropdown boxes.

5.7 Individual Lab Assignment

5.7.1

For this one, you will be making changes to an extended version of the Chapra 4.2 code in order to use accumulation to estimate values of cosine. It is very similar to using an accumulation to estimate values of the exponential.

5.7.2

For this one, you will be making changes to either the original or extended version of Chapra 4.2 in order to use a mapping to estimate roots of a function. It is very similar to using the Newton method mapping to estimate values of a square root. Note - though the mapping for the lab assignment comes from a method called Newton-Raphson, its origin is different from the Newton method discussed in class for finding a square root.

Class Document Protection