Reference no: EM132775343
MAE 3403 Computer Methods in Analysis and Design - Oklahoma State University
Description:
We are analyzing data read from a thermocouple that measures the temperature in a chemical reactor (i.e., a round bottom flask or beaker) that is being heated to cause an endothermic (i.e., absorbs heat) reaction. The reaction rate varies with temperature and, due to environmental conditions beyond our control, the temperature of the reactor varies somewhat over time.
The functions described below are intended to a.) determine if a value lies between a minimum and maximum, b.) remove "outlier" temperatures from sets of data collected during individual experiments, c.) calculate the sample mean and standard deviation of temperature for each experiment, and d.) calculate the maximum, minimum and average reaction rate predicted for each experiment.
To Do:
You should write four different functions in addition to a function named main(), which you can simply copy from the HW1-Stem.py on Canvas. All of your code should be in a single Python file named HW1- SP21.py . You will test your functions using the particular numerical values given in the main() function.
When we grade your assignment, we will run your program with those given numerical values, looking for correct answers. Then we will change the numerical values (including changing the SIZES of the arrays) and look for correct answers for those modified values as well. We will only use numerical values and array sizes that make sense. We will not be testing your program to see how it handles bad data.
In this assignment, you must use: variables, loops, if statements, your own function definitions and function calls. Y ou must include reasonable comments in your code. For now, you may not use any of the powerful functions available in python modules, with one exception: you may import functions from the math module.
a) Write a function defined as: def ClampInclusive(val, minval, maxval): val: is a floating point number
minval, maxval: are the minimum and maximum values the val can have.
return TF: where TF is a boolean (True or False) indication of val is between minval and
maxval (inclusive)
b) Write a function defined as: def RemoveOutliers(vals, mean, stdev):
vals: a list of lists (i.e., 2-D-matrix) containing temperatures read from a thermocouple. Each list is the result of an experiment and may contain outlier data.
mean: the average temperature read by the thermocouple over time
stdev: the standard deviation of data read by the thermocouple
return trimmed: where trimmed is a list of lists (i.e., 2-D matrix) where each row contains the temperature data considered valid by being within 2*stdev of the mean.
c) Write a function defined as: def SampleEstimators(vals): vals: an array (list) containing temperature readings.
return stats: stats is a list containing the sample mean and standard deviation of the
temperature readings
d) Write a function defined as: def ReactionRate(T, P, EA NStDev=2):
T: is a list containing the average and standard deviation of the temperature for a reaction in oC.
P: is a reaction rate coefficient in mol/min-1.
EA: is the activation energy for the reaction in kJ/mol
NStDev: is the number of standard deviations from the mean for which we want to calculate the maximum and minimum reaction rates according to the formula:
Rate = P.e(-EA/R.T) where R = 8.3145 J/mol⋅K
return RateRange: where RateRange is a list of the minimum, maximum and average reaction rates we can expect from the given distribution of temperature.
Use HW1-stem.py as a starting point to test the four functions defined above. When you upload your program, it must include defined main function and call to main(). An additional requirement of this homework is that you understand EVERY LINE of this main program. If you don't understand something, Google it or ASK Dr. Smay or the TA.
Attachment:- PYTH_HW.rar