engn2219 comp6719
play

ENGN2219/COMP6719 Computer Architecture & Simulation Ramesh - PowerPoint PPT Presentation

ENGN2219/COMP6719 Computer Architecture & Simulation Ramesh Sankaranarayana Semester 1, 2020 1 Course Revision 2 Final exam Final exam details and practice exams are up on the course website 3 Examinable material The examinable


  1. ENGN2219/COMP6719 Computer Architecture & Simulation Ramesh Sankaranarayana Semester 1, 2020 1

  2. Course Revision 2

  3. Final exam Final exam details and practice exams are up on the course website 3

  4. Examinable material The examinable material comprises the contents of the lectures and labs. This includes the lectures on statistics for simulation. The lectures in Week 11 on communication and architectures are not examinable. There will be a mix of theoretical and lab based questions, on a rough 50-50 split. There will be 5-6 main questions in the exam. A sample exam paper will be provided. Look at the sample paper, the mid-semester exam and the labs/labtests for a guide on questions of a practical nature. Roughly 60% of the questions will be on Architecture and 40% on Simulation. 4

  5. Exam environment The exam environment will be similar to the one that you had for the mid- semester exam - so gitlab based, open book. There will be no use of Proctorio. The gitlab environment is itself being upgraded, to minimize the risk of a repeat of the forking/pushing issues that took place during the midsem. This will be stress tested before the actual exam. 5

  6. In addition, we are going to provide you with exams ahead of time, but encrypted. The encryption key will only be provided at the scheduled start of the exam. This will ensure that all of you have forked and cloned the repo well ahead of the scheduled exam time. As for pushing, the upgrades to the environment will minimize any latency issues. In any case, what is important is that you commit your exams to your local repo by the scheduled time. It does not matter if the actual push to your gitlab fork gets delayed a bit. However, it is really important that you commit and push regularly. Do so after you complete each question (or major subquestion), or every 30 mins. 6

  7. Revision Part 1 - Simulation 7

  8. Content Questions will cover the content covered in the following topics: Week 7: Simulation Introduction Week 8: Simulation methods, Monte Carlo, Discrete Event Week 9: Dynamics Systems, System Dynamics, Verification and Validation Week 10: Statistics for Simulation 8

  9. Programming Programming questions will cover the following topics: Simple Monte Carlo, Discrete Event. eg, coin toss Visualisation of plots Simple dynamical systems. eg, random walk Interpolation/Extrapolation Numerical Integration/Differentiation Use of odeint You will not be asked to do statistics related programming. 9

  10. Sample questions - Theory 1. What are the objectives of simulation? 2. Differentiate between the Eulerian and Lagrangian approaches to modeling space. Give an example for each. 3. What are the main features of Discrete-Event simulation? 4. What is a dynamical system? How are such systems represented? 5. What is system dynamics? How are systems represented in this context? 6. What are the four components of Boyd’s OODA loop? What happens if your competitor is quicker in going around the loop than you? 10

  11. 7. Differentiate between verification and validation. What are some of the difficulties of verification and validation? 8. Briefly describe the three common measures of central tendency. 9. What are the five values included in a five number summary? What is a common approach taken to represent this summary? 10. Suppose you have paired bivariate data about temperature and electricity use. You want to find out if there is any significant relationship between the two, and if so, use it to assist you in making predictions. Would you use correlation or regression ? Briefly explain. 11

  12. Sample questions - Problems 12

  13. Coin toss How would you use the Monte Carlo approach to calculate the probability of an unbiased coin landing on its head? Use repeated iterations Use a random number between 0 and 1 to imitate a coin toss. If the number is, say, , it is heads, else tails. <= 0.5 Average the total number of heads over the number of iterations 13

  14. cointoss.py import random # Function takes in the probability of heads as a number betwee # 0 and 1, and the number of tosses. Returns the average of the # number of heads over the number of tosses. def cointoss(headsprob, numtosses): heads = 0 for toss in range(numtosses): currentoss = random.random() if (currentoss <= headsprob): heads += 1 return(heads/numtosses) 14

  15. cointoss.py (contd) # Print this value for say, 1000 tosses print (cointoss(0.5, 1000)) 15

  16. Boiling temperature of water The boiling temperature of water at various altitudes is given below: T B h 0 600 1500 2300 3000 6100 7900 h ( m ) 100 98.8 95.1 92.2 90 81.2 75.6 ( ∘ T C ) Use linear interpolation to calculate the boiling temperature at 5000m. Draw a plot of the points. Now, do the same using cubic spline interpolation. What if you needed to find the temperature at 8500m? 16

  17. water.py import numpy as np from scipy.interpolate import interp1d import matplotlib.pyplot as plt height = [0,600,1500,2300,3000,6100,7900]; temp = [100,98.8,95.1,92.2,90,81.2,75.6]; flinear = interp1d(height,temp) fcubic = interp1d(height,temp,kind='cubic') heightnew = np.linspace(0,7900,num=100) plt.plot(height,temp,'o',heightnew, flinear(heightnew), '-', he plt.legend(['data', 'linear', 'cubic-spline'], loc='best') plt.title('Linear and Cubic Spline Interpolation') plt.show() 17

  18. water.py 18

  19. Sunflower growth The growth data of a sunflower plant is given below: 1 3 5 7 9 11 13 Week 22 51 127 202 227 248 252 Height ( cm ) Use regression to curve-fit the data with a second-order polynomial. Use the polynomial to estimate the height in week 6. Draw a plot of the data and the fitted curve. Now do the same using a third-order polynomial and a tenth-order polynomial. In each case, calculate the error using the sum of squares approach. 19

  20. sunflower.py import numpy as np from scipy.interpolate import interp1d import matplotlib.pyplot as plt from pylab import * week = [1,3,5,7,9,11,13]; height = [22,51,127,202,227,248,252]; z2 = np.polyfit(week,height,2) # second order polynomial f2 = poly1d(z2) heightfit2 = f2(week) sse2 = round(((height - heightfit2)**2).sum(),2) z3 = np.polyfit(week,height,3) # third order polynomial f3 = poly1d(z3) 20

  21. sunflower.py (contd.) heightfit3 = f3(week) sse3 = round(((height - heightfit3)**2).sum(),2) z10 = np.polyfit(week,height,10) # tenth order polynomial f10 = poly1d(z10) heightfit10 = f10(week) sse10 = round(((height - heightfit10)**2).sum(),2) plt.plot(week,height,'o',week, heightfit2,'-',week,heightfit3,' plt.legend(['data', 'second', 'third', 'tenth'], loc='best') plt.title('Sunflower Growth') plt.text(1,1,f'SSE2 = {sse2}') plt.text(5,1,f'SSE3 = {sse3}') plt.text(9,1,f'SSE10 = {sse10}') plt.show() 21

  22. sunflower.py 22

  23. Numerical Differentiation Let be a vector with values ranging from to . Let be a function x − 2 π 2 π y defined as follows: x 2 y = 50 ∗ sin ( x ) + 3 ∗ tan ( x ) − 5 ∗ − x − 30 Find the derivative of the above function using forward differentiation. Plot the function and against x, on the same graph with blue and red colors, y ′ y respectively. Give the graph an appropriate title and labels. 23

  24. numerical-differentiation.py import numpy as np from scipy.interpolate import interp1d import matplotlib.pyplot as plt from pylab import * x = linspace(-2*np.pi,2*np.pi,180); y = 50*np.sin(x) + 3*np.cos(x) - 5*x**2 - x - 30; deriv_y = np.diff(y)/np.diff(x); 24

  25. numerical-differentiation.py (contd.) xd = x[0:-1]; # forward difference x values plt.plot(x,y,'b',xd,deriv_y,'r') plt.title('Polynomial-Trig Function') plt.ylabel("y and y'"); plt.xlabel('x') plt.legend(['y',"y'"],loc='best') plt.show(); 25

  26. numerical-differentiation.py 26

  27. Potential energy The variation of gravitational acceleration with altitude is given by: g y R 2 g = ( R + y ) 2 g 0 where = 6371 km is the radius of the earth and = 9.81 is the m/s 2 R g 0 gravitational acceleration at sea level. The change in the gravitational potential energy, , of an object with mass kg that is raised from the Δ U m earth to a height km is given by: h h Δ U = mgdy ∫ 0 27

  28. Determine the change in the potential energy of a satellite with a mass of 500kg that is raised from the surface of the earth to a height of 800 km. Hint : Use the function. quad 28

  29. potentialEnergyIntegration.py import numpy as np from scipy import integrate import matplotlib.pyplot as plt from pylab import * def gravity(altitude): # Gravitational acceleration function # altitude in km; gravity in ms^-2 # Earth's radius (km) R = 6371; # Mean gravitational acceleration @ ground-level g0 = 9.81; return((R**2)*g0)/((R+altitude)**2); 29

  30. potentialEnergyIntegration.py (contd.) # given parameters # mass (kg) of satellite m = 500; # height (km) from Earth's surface h = 800; gpevariation = integrate.quad(gravity,0,h); gpeChange = m*gpevariation[0]; #print(m,h); #print(gpeChange); print("The difference in gravitational potential energy of the 30

  31. Velocity of a falling object The velocity of an object that falls freely due to the earth’s gravity can be v modeled by the equation: dv v 2 m = − mg + k dt where is the mass of the object, = 9.81 , and is a constant. m/s 2 m g k Solve the equation for for the case = 5 kg, = 0.05 kg/m, s v m k 0 ≤ t ≤ 15 and (0) = 0 m/s. Make a plot of as a function of time. v v 31

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend