I need help coding and understanding this assignement. I understand it is really late so I am willing to negotiate the price. Thank you in advance!
I need help coding and understnading this assignment with matlab
Department of Mechanical Engineering ME 2173: Numerical Methods Laboratory Project 2 – Summer 2022 1 Name: ___________________________________________ abc123: ________________ Directions Use the Publish button/command in MATLAB to generate PDF file s of your script s. Submit your MATLAB file s (.m) and the published PDFs to Blackboard. Note that the .m files should run when opened on any computer. Background for part 1 and 2: You are an engineer with NASA on a team tasked with developing a habitat suitable for human life on Mars. Within your team, you specialize in thermodynamics and will be utilizing a non -ideal gas law to better understand the Martian environment. Based on your advanced knowledge of thermodynamics, you have selected a three -parameter equation of state, presented below in Equation 1, where , , and are physically informed constants, is pressure in kPa, is the specific gas constant in kJ/kg *K, is temperature in K, and is the specific volume in m 3/kg. Recall: density = 1/. = − − (+ ) Equation 1 While the values for , , , and will be given or solved for, the values of the constants depend on a constant , which can be obtained as the sum of the numeric values of your abc123. For example, if your ID is abc123, = 1+ 2+ 3. Table 1 shows the values of the parameters depending on the value of . Be sure to use the correct values in your problem setup to avoid losing points. K Value a b ≤ 10 0.775 0.19 2 0.00085 7 10 < ≤ 15 0.785 0.189 0.000861 > 15 0.795 0.18 6 0.000859 Table 1. Thermodynamic constants for different K values. The structural engineers on your team are utilizing finite element analysis (FEA) to determine if the habitat they designed will be stable on the surface of Mars. To do this, they need to know what the density, , of the atmosphere is where the habitat wi ll be located. Based on information obtained by the Curiosity Rover, you know that the pressure = 620 Pa and the temperature = 205 K. Additionally, you know that the specific gas constant of the Martian atmosphere is = 0.192 kJ/kg -K 2 Part 1: Determine a suitable root finding method (100 pts) In this section , you will need to determine the best suited method to find the root of the equation, (i.e., determine so that ()≈ 0) using the thermodynamic constants in Table 1 as well as Equation 1 . Submissions for this part include: i. Using an “if” statement, determine the values of , , and based on your value of (10 pts). ii. Choose any one bracketing method and any one open method from the list below and use “for” loop s to set t hem up (60 pts) . a. Bracketing methods: i. Bisection method ii. False position method b. Open method: i. Newton Raphson method ii. Modified Newton Raphson method iii. Secant method iii. Make a comparison between results obtained with both methods ( 30 pts). a. Provide a comparison of accuracy between the 2 methods using the error on the last iteration. b. Provide a comparison of computational efficiency between 2 methods using the Tic Toc method. c. Discuss which of the methods is the better option for root finding based on the comparisons. Part 2 : Automate the process using a f unction (100 pts) Now that you have determined the best root finding method, it is time for the next task! In this case, you will still work with Equation 1 but now both density and temperature , are going to vary. You will use your knowledge of functions to create MATLAB functions using the expression below: (,,,)= − − (+ )− Equation 2 Submissions for this part include: i. Use the script from Part 1 and convert it into a function file that (60 pts): a. Takes , , P, and R as inputs. b. Determines for which , (,,,)≈ 0 using your choice of root finding methods from Part 1 . Recall: = 1/ 3 c. Gives as an output. ii. In a separate .m file, use a “for” loop such that each iteration is a different value and call the function file to determine for each iteration. Create a matrix to store the values of and in after each iteration (20 pts). iii. Run the .m file with = 100 :1:300 K (10 pts). iv. Plot vs. , including axis labels , a title , grid lines, as well as a linewidth of 2 (10 pts). Part 3: Systems of linear equations (100 pts) Consider the following system of linear equations presented below in Equation 3 : 10 − + 2= 6 −+ 11 − + 3 = 25 2− + 10 − = −11 3− + 8 = 15 Equation 3 Submission s for this part include: i. Solve the system on linear equations using the Gauss -Seidel method in MATLAB. Consider a random initial guess (with values between 0 and 1) and perform iterations until the approximate percent error is less then 0.0 1 percent for all the unknowns in the sys tem of linear equations (60 pts). HINT: a “while” loop will be helpful for this exercise. ii. Confirm your answer is correct by solving the system of linear equations using a direct method such as Gauss elimination, Cramer’s rule, or the inverse of the coefficient matrix. You should use MATLAB for this problem (40 pts). Part 4: Nonlinear r egression (100 pts) The data presented below in Table 2 follows the nonlinear relationship presented below in Equation 4. = Equation 4 0.1 0.2 0.4 0.6 0.9 1.3 1.5 1.7 1.8 0.73 1.27 1.41 1.26 0.85 0.53 0.36 0.28 0.17 Table 2: and data for nonlinear regression analysis Use MATLAB to determine the values of constants and that minimize the sum of the squares of errors between the predictions of the nonlinear functional relationship and the data. 4 Submissions for this part include: i. Linearize the data (20 pts) ii. Plot the linearized data and fit a linear equation to the linea rized data. Be sure to include axis labels , a legend and title in your plot (30 pts). iii. Use the linear regression coefficients to calculate the values of and . Display your answer using fprintf (30 pts). iv. Plot the raw (nonlinearized) data against Equa tion 4 and comment on the goodness of the fit . As before, your plot should include axis labels, a legend and title (20 pts). Part 5: Interpolation (100 pts) The volumetric flow rate of water in a long pipe is related to pressure using the Hagen -Poiseuille equation ( = ()). However, this relationship is relatively inaccurate, and you decide to collect experimental data for interpolation instead. This data is presen ted below in Table 3 and MATLAB should be used for all parts of this exercise . Pressure [kPa] Flow Rate [mL/s] 15 15.4 25 39.6 35 53.3 45 58.4 65 66.1 80 73.2 Table 3: Experimental flow rate and pressure data Submissions for this part include: i. Using a second -order interpolation polynomial and the method of linear equations, determine the flow rate of the water when the pressure = 50 kPa (60 pts). ii. Plot the raw data, the interpolation polynomial, and the estimated flow rate at = 50 kPa in a single figure . This figure should include axis labels, a legend, and title (40 pts).