CSCI 2202 Computer Modelling for Scientists Lab A 

$30.00

Download Details:

  • Name: LabA-htn1bt.zip
  • Type: zip
  • Size: 99.98 KB

Category:

Description

5/5 - (1 vote)

• Reading Data Files:
• Fitting Regression Lines to data
(1) Write a function readDatFile(inFile) to read in the coffee cooling data.
The function should take a filename as a parameter (input by the user) and
should return the numpy arrays x, y containing the data.
(2) Using Regression to Determine Model Parameters:
(a) The file coffeeCooling.txt alongside, holds the time, Temp data for
coffee cooling. Create a program that reads the data from the file and
using matplotlib.pyplot To scatter-plot the data. Use the pyplot functions xlabel( ), ylabel( ) to label the axes approriately.
(b) A model of coffee cooling in a room at T0 = 22oC is:
∆T = Tn+1−Tn = −k(Tn−T0). Use the function scipy.stats.linregress(x,y)
(usage: slope, intercept, r value, p value, std err = stats.linregress(x,y)),
to make a fit of the coffee data given above. Make a plot of the regression
line fit, superposed on a scatter plot of ∆Tn v/s Tn − T0.
(3) Fitting a Power Law Function Small nanoparticles of soot suspended in
water start to aggregate when salt is added. The average radius r of the
aggregates is predicted to grow as a power law in time t according to the
equation r = r0t
n
. (The data is in the file sootAggregation.txt. The
columns are: time (mins), Avg. Radius (nm), Uncertainty in Radius (nm)).
Taking the logarithm of this equation gives ln r = n ln t+ ln r0. Thus the data
should fall on a straight line if ln r is plotted vs ln t. Fit a regression line to
the data using ln r = n ln t + ln r0 and find values for n and r0.