check attacked files
Microsoft Word - Lab11.docx ENGR 102 - Lab 11 This weeks activities are to be done with others. You can work with friends and classmates outside of class and will work with classmates during recitation. PLEASE BE SURE TO INCLUDE THE NAMES OF THOSE YOU WORKED WITH IN THE HEADER FILE. Deliverables: There are two pdf files for this team assignment. Please submit the following files to eCampus: • Lab11a_Act1.pdf • Lab11a_Act2.pdf This week’s lab and individual assignments are meant to familiarize you with two of the most commonly used engineering packages in Python: numpy and matplotlib. It will also begin to give you more experience in making function calls and using a module. To do this, as a team you will work some of the basic tutorial/intro material for each one, and ensure that each member of the team knows how it works. numpy is a package for performing scientific computing. In particular, it offers functions and types that will allow you to create vectors and matrices, and perform linear algebra operations more easily. The website for numpy is: http://www.numpy.org/ matplotlib is a library for creating plots, graphs, and charts. It supports a wide range of plots and graphs, and is often used for visualizing data. The website for matplotlib is: https://matplotlib.org/ Activity #1: Functions The key idea is to write functions that can be used to analyze the amount of material remaining after drilling a hole through a metal block. In creating your function, you should create a program that will essentially “test” the functions. For example, you might include several function calls and the results, or create a program where a user can enter values and see the results. Imagine that you have a block of material in which a hole has been drilled: a. Write a function that will take in (arguments/parameters) the dimensions of the metal block, length, width, and height. The function should also take in a numpy array of radii of 32 linearly spaced values between 0 and the maximum value of (width or length). The radii is for a hole that is to be bored through the metal block. Assume the hole has been drilled along the height direction. The function should return two arrays: 1) the diameter of the hole; and, 2) the volume of material remaining. b. Write a function that will take in two arrays corresponding to diameter of a cylinder (from the function above) and the volume of material remaining as well as a string corresponding to the units used for the dimension of the hole (i.e. cm, m, in. etc.) The function should produce a figure with a plot with two curves. The first curve, shown as a blue solid line, should plot the volume of material remaining (ordinate) versus the diameter of the bore (abcissa). A second curve should also be plotted that corresponds to the volume of the bore (ordinate) versus the diameter of the bore (abcissa). The second curve should be a red dashed line. Your plot should include major gridlines for both axes, a legend, axes labels that include units, and a title. The scale of your abcissa should be from zero to the maximum value rounded up to the next whole number. Example: 4.3 would round to 5, 123 would round to 130. c. Create a third function that will take in two arguments. The first is a single float that corresponds to the volume of metal remaining and the second is a value for density. The function should return the mass of material remaining. https://www.engineersedge.com/materials/densities_of_metals_and_elements_table_13976.h tm Name your program Lab11a_Act1.py. This activity will be manually graded. Activity #2: Linear equations This activity will focus on using numpy arrays and plotting. You are working on developing a new insecticide. A mixture of 12 liters of chemical A, 16 liters of chemical B, and 26 liters of chemical C is required to kill a destructive crop insect. Product X contains 1, 2, and 2 parts, respectively, of these chemicals (A, B, and C). Product Y contains only chemical C. Product Z contains only chemicals A and B in equal amounts. How much of each type of commercial spray is needed to get the desired mixture? a. Setup the three linear equations. The unknowns will be X, Y, and Z corresponding to the three products available to mix and each equation will correspond to the chemicals A, B, and C. The three equations should have the unknowns on the left hand side of the equal sign and the constants on the right hand side. b. Create a coefficient matrix from your three equations along with a solution vector. Use the numpy function to solve this linear equation as described in the lecture notes. Print the solution for X, Y, and Z. Be sure to use a descriptive statement including units. c. Create numpy arrays for X, Y, Z each consisting of 101 points between 0 and 20 each (the units will be liters). Plot the three lines in 3D space. The following link may help. https://matplotlib.org/examples/mplot3d/lines3d_demo.html Include a red circle at the X, Y, Z point determined in part b. Print out any interesting observation. Name your program Lab11a_Act2.py. This activity will be manually graded.