[SOLVED] 代写 C Scheme html math matlab database Status: Individual Weighting: 10

30 $

File Name: 代写_C_Scheme_html_math_matlab_database_Status:_Individual_Weighting:_10.zip
File Size: 697.08 KB

SKU: 9888726034 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


Status: Individual Weighting: 10
MCD 4140: Computing for Engineers
Assignment Trimester 3, 2019
Due by: 10am on Monday Week 10 January 6, 2020 Late penalty: Deduct 10 per day
INSTRUCTIONS
This assignment should be completed INDIVIDUALLY. Plagiarism will result in a mark of zero. Plagiarism includes letting others copy your work and using code without citing the source. If a part of your code is written in collaboration with classmates, say so in your comments and clearly state the contributions of each person.
NOTE: Your MATLAB code will be checked for plagiarismDONT RISK LOSING ALL 10 MARKS BY COPYING SOMEONE ELSES CODE OR BY ALLOWING SOMEONE ELSE TO COPY YOURS.
Download the assignment template files from Moodle and update the mfiles named Q1a.m, Q1b.m, etc… with your assignment code. DO NOT rename the mfiles in the template or modify runall.m. Check your solutions to Q1 and Q2 by running runall.m and ensuring all questions are answered as required. Do not use close all, clear all, clc in any individual mfiles.
SUBMITTING YOUR ASSIGNMENT
Submit your assignment online using Moodle. Your ZIP file not .rar or any other format must include the following attachments:
a. Solution mfiles for assignment tasks e.g. runall, Q1a.m, Q1b.m, etc.
b. Any additional function files required by your mfiles e.g. heun.m, falseposition.m, etc.
c. All data files needed to run the code including the input data provided to you e.g. data1.txt,
data2.csv, etc.
d. A completed cover sheet
Your assignment will be marked in your usual computer lab session during Week 11. YOU MUST ATTEND TO HAVE IT MARKED. IF YOU DO NOT ATTEND, YOUR ASSIGNMENT MARK WILL BE ZERO. YOUR ZIP FILE WILL BE DOWNLOADED FROM MOODLE DURING WEEK 10 AND ONLY THESE FILES WILL BE MARKED. We will extract unzip your ZIP file and mark you based on the output of runall.m on a Windowsbased system. It is your responsibility to ensure that everything needed to run your solution is included in your ZIP file. It is also your responsibility to ensure that everything runs seamlessly on a Windowsbased system especially if you have used MATLAB on a Mac OS or Linux system. Windows OS computers are available in the computer labs on campus for testing. The assignment will not be downloaded to your individual laptops for marking.
MCD4140 Assignment Page 1 of 11

MARKING SCHEME
This assignment is worth 10 1 Mark1 of the unit mark. Your assignment will be graded using the following criteria:
1 runall.m produces results automatically additional user interaction only if asked explicitly
2 Your code produces correct results printed values, plots, etc… and is well written.
3 Coding interview performance
CODING INTERVIEW RUBRIC
As part of the marking process, your demonstrator will spend a few minutes interviewing you to gauge your understanding of the assignment code. The purpose of this is to ensure that you have contributed to the assignment and understand the code.
You will be assigned a score based on your interview and your code mark will be penalized if you are unable to explain your submission.
Category
Description
Penalty
No understanding
The student has not prepared, cannot answer even the most basic questions and likely has not even seen the code before.
100
Trivial understanding
The student may have seen the code before and can answer something partially relevant or correct to a question but they clearly cant engage in a serious discussion of the code
30
Selective understanding
The student gives answers that are partially correct or can answer questions about one area correctly but another not at all. The student has not prepared sufficiently
20
Good understanding
The student is reasonably well prepared and can consistently provide answers that are mostly correct, possibly with some prompting. The student may lack confidence or speed in answering.
10
Complete understanding
The student has clearly prepared and understands the code. They can answer questions correctly and concisely with little to no prompting.
0
MCD4140 Assignment Page 2 of 11

ASSIGNMENT HELP
1 You may use the function files that you have written in the labs.
2 You may ask questions in the Discussion Board on Moodle.
3 The mfile templates contain prewritten comments and sections only as a guide. You do not need to follow
its structure. You may delete the comments.
4 Hints may also be provided during workshops.
5 Bold text has been used to emphasize important aspects of each task. This does not mean that you should
ignore all other text.
6 The questions have been split into subquestions. It is important to understand how each subquestion
contributes to the whole, but each subquestion is effectively a standalone task that does part of the
problem. Each can be tackled individually.
7 It is recommended that you break down each subquestion into smaller parts too and figure out what needs
to be done stepbystep. Then you can begin to put things together again to complete the whole.
8 Solve the question, of part thereof, by hand before attempting to code the solution.
MCD4140 Assignment Page 3 of 11

QUESTION 1 4 MARKS
Background
The ideal gas law describes the behaviour of an ideal gas using relationships between pressurePa, molar volumem3mol and temperatureK. It is defined by
where 8.314 Jmol.K is the ideal gas constant.
Nonidealistic behaviour of a gas can be described by the Peng Robinson equations of state, which are defined as:

whereis the compressibility factor that characterises the nonideality of the gas at different operating
conditions, and ,andare the same as those in the ideal gas law. Hereis solved in the equation1 23 0
with

The coefficientsandaccount for gas mixtures mixtures with more than 1 gas component through the coefficientsandsubscriptdenotes mixed gas, which are defined as

1

whereis the mol fraction of componentin the gas mixture whileis the binary interaction parameter between gas pairand .
Finally, the coefficientsandare given by

0.4572410.374641.542260.269921
0.07780
whererepresents the critical temperature,is the critical pressure andis the acentric factor of individual gasses.
MCD4140 Assignment Page 4 of 11

Data from a database has been downloaded in the three files below.
1. prgas.txt contains
the gas names
the critical pressure Pc bar
the critical temperature Tc Cthe acentric factor Ac
2. binaryinteractionparameter.txt containsthe binary interaction parameter kij
3. gasmixtures.xls contains
the gas mixture comprised of 3 components
the initial temperature Ti K and final temperature Tf Kthe initial pressure Pi Pa and final pressure Pf Pa
The composition of each component totals to 1
Q1a
In the Q1a.m file, import the files and create variables for the gas name, critical pressure, critical temperature, acentric factor and the binary interaction parameter.
Use fprintf to print the gas mixture options to the command window. An example output is shown below.
Gas mixture 1: CH4 CO2 N2
Gas mixture 2: CO2 O2 H2

Gas mixture 5: C2H6 C3H8 nC4H10
Note: The textdata field in the imported structures are cells1 and need to be referenced using curly braces .
Prompt the user for a valid option number. i.e. the option choice should be an integer from 1 to the number of mixtures available. Continue to prompt the user for an option if the input is invalid.
Store the gas mixture data and gas mixture components in variables to be used in Q1b.
Note: You may be provided with a text file that has more than 5 mixture options during marking. However, each mixture will always contain only 3 components.
You should have no figure windows by the end of this task.
1 Cells are similar to matrices except it may contain both numerical data and strings inside a single cell.
Source: https:au.mathworks.comhelpmatlabmatlabprogaccessdatainacellarray.html
MCD4140 Assignment Page 5 of 11
the elements of a cell array. Enclose indices in smooth parentheses, , to refer to sets of cellsfor example, to define a subset of the
There are two ways to refer to
array. Enclose indices in curly braces, , to refer to the text, numbers, or other data within individual cells.

Q1b
In the Q1b.m file, extract the critical pressure in Pa, critical temperature in K and acentric factor for each gas component in the chosen gas mixture. Use fprintf to print this information for each gas component. An example is shown below.
Component 1 CH4: PcX.XXeXX Pa, TcXXX.XX K, AcX.XXXX
Component 2 Ar: PcX.XXeXX Pa, TcXXX.XX K, AcX.XXXX
Component 3 CO2: PcX.XXeXX Pa, TcXXX.XX K, AcX.XXXX
You should still have no figure windows by the end of this task.
Q1c
In the Q1c.m file, create vectors for temperature and pressure each comprising of 100 equally spaced values starting from the respective initial and final values for the chosen gas mixture. For each combination of temperature and pressure, calculate the molar volume in cm3mol using the ideal gas law.
In figure12, produce a surface plot of the molar volume cm3mol, axis against pressure Pa, axis and temperature K, axis using the surf function.
You should have one figure window by the end of this task.
Q1d
In the Q1d.m file, solve for the compressibility factorfor each combination of temperature and pressure using the bisection method with a precision of . Note thatis a nondimensional number between 0 and 1.
In figure22, produce a surface plot of the compressibility factor axis against pressure Pa, axis and temperature K, axis using the surf function.
Hint: For each temperature and pressure combination andwill contain 3 values each one for each gas component, andandwill contain a single value each. You only need to iterate through pressure values onceandhave been calculated for the current temperature. Solve this by hand before attempting to code it in MATLAB.
You should have two figure windows by the end of this task.
2 Note that figureH makes H the current figure, forces it to become visible, and raises it above all other figures on the screen. If Figure H does not exist, and H is an integer, a new figure is created with handle H.
MCD4140 Assignment Page 6 of 11
To increase visibility and readability, set the Edgecolor
argument to none in the surf function. Additionally, set the colormap to cool using the colormap function.
To increase visibility and readability, set the Edgecolor
argument to none in the surf function. Additionally, set the colormap to parula using the colormap
function.

Q1e
In the Q1e.m file, calculate the molar volume in cm3mol using the Peng Robinson gas law for each combination of temperature and pressure.
In figure32, produce a surface plot of the molar volume cm3mol, axis against pressure Pa, axis and temperature K, axis using the surf function.
Determine the maximum percentage error between the molar volume based on the ideal gas law and the Peng Robinson gas law. The percentage error is defined as
100
Use fprintf to print a statement containing the maximum percentage error and the corresponding temperature and pressure values.
You should have three figure windows by the end of this task.
To increase visibility and readability, set the Edgecolor
argument to none in the surf function. Additionally, set the colormap to summer using the colormap
function.
MCD4140 Assignment Page 7 of 11

QUESTION 2 2.5 MARKS The temperature profile on a plate with dimensions 1,8 and 7,10 is illustrated in the figure
below. The temperature profile on the plate is described by:
,sin cos
whererepresents the temperature.
The average temperature of the plate can be calculated as:
1
whererepresents the total surface area of the plate.
Q2a
In the compsimp13vector.m file, complete the function file for the Composite Simpsons 13 rule which integrates the vector inputs.
Q2b
In the Q2b.m file, create a 3by1 subplot plot in figure42. In each subplot, plot the temperature of the plate alongfrombetween 1 to 8 inclusive as a red line of thickness 2, using 100 equally spaced points. Additionally, fit the ,data using polynomials see below using a blue line. Turn the grid on and include the polynomial degree in the title of each subplot.
Top subplot: polynomial degree 3
Middle subplot: polynomial degree 5
Bottom subplot: polynomial degree 7
You should have four figure windows by the end of this task.
,dd
MCD4140 Assignment
Page 8 of 11

Q2c
In the Q2c.m file, calculate the average temperature of the plate using the compsimp13 function written in Q2a with the minimum number of points required in each directionand . Continue to increase the number of points until the approximated volume achieves an accuracy of 8 decimal places DP matching the temperature value obtained using MATLABs integral2 function.
Use fprintf to print the number of points, the approximated average temperature, MATLABs average temperature value, and the error, but only when the approximated average temperature has improved by at least a decimal place. The error is taken to be the absolute difference between the approximated average temperature and the MATLABs integral2 value. An example of this is shown below, with the decimal places bolded and underlined for clarity you do not need to bold and underline the values in your MATLAB answers.
pts tempapprox tempMATLAB error DP X X.XXXXXXXXX X.XXXXXXXXX 0.0XXXXXXXX 1 X X.XXXXXXXXX X.XXXXXXXXX 0.00XXXXXXX 2 X X.XXXXXXXXX X.XXXXXXXXX 0.000XXXXXX 3 X X.XXXXXXXXX X.XXXXXXXXX 0.0000XXXXX 4
Hint: Start by evaluating the inner integral along thedimension for each value of . The resulting values can then be integrated along thedimension.
Hint: Look at the result of log10error to help determine the number of zeros in the error i.e. DP.
You should still have four figure windows by the end of this task.
MCD4140 Assignment Page 9 of 11

QUESTION 3 3.5 MARKS Background
A freeswinging pendulum with damping is modelled using the following equation
d d
d d sin0
whererepresents angle of the pendulum radians measured from the vertical axis,is time s,is the damping coefficient kgs,is mass kg,is the gravitational acceleration ms2 andis the link length m.
The 2ndorder ODE can be solved as a set of 1storder ODEs, as shown below. Here,is a dummy variable. d
d sin d
The two 1storder ODEs above are coupled and must be solved simultaneously. i.e. the solutions are dependent on each other and therefore cannot be solved individually. The first iteration will solve forandusing initial conditionsand . The second iteration will solve forandusingand , and so forth. You are strongly encouraged to complete a few iterations by hand to fully understand the process.
Q3a
In the midpoint2.m file, complete the function file to perform the midpoint method to solve two 1storder ODE equations simultaneously.
You should still have four figure windows by the end of this task.
Q3b
In the Q3b.m file, consider initial conditions 090 and 00. Theparametersare:1kgs,1kg,9.81ms2,and0.5m.
Solve for the angle of the pendulumand the angular velocityusing the midpoint2 function written in

d
Q2a with a time step of 0.001s from 0 to 10s.
In figure52, plot the following in 2by1 subplot arrangement.
Top paneldeg againsts
Bottom paneldegs againsts

You should have five figure windows by the end of this task.
MCD4140 Assignment
Page 10 of 11

Q3c
In the Q3c.m file, use the midpoint2 function to solve the angle of the pendulum with , , , , ,kgs using a time step of 0.001s. Use the same initial conditions and parameters as in Q3b, unless otherwise specified in this question.
In figure62, produce a plot ofdeg againsts for each value ofas solid lines. Use the RGB values defined in the colourmap variable as provided in the mfile to colour solutions from the smallestto the largesttop row to the bottom row.
Is this the behaviour that you would expect with varyingvalues? Use fprintf to print a statement to justify your answer.
Note: the legend syntax provided in the mfile will produce the appropriate legend for the plot ifis a row vector.
You should have six figure windows by the end of this task.
Q3d
Experiments have measuredto be less than 1 at 10s using the initial conditions and parameters specified in Q3b. Hence, the solution of the 2ndorder differential equation is considered accurate ifis less than 1 at 10s.
In the Q3d.m file, solve forusing the midpoint2 function starting with a time step of 0.025s and plotdeg againsts in figure72. Use the same initial conditions and parameters as in Q3b, unless otherwise specified in this question. If the solution is accurate as per the experiments then double the time step, solve forand plot the result on the same figure. Continue to do this until an inaccurate solution as per the experiments is obtained. Your figure should also include a plot of the inaccurate solution.
Use fprintf to print out the time step when the solution first becomes inaccurate based on the experiments.
Note: the legend syntax provided in the mfile will produce the appropriate legend for the plot if h is a row vector.
You should have seven figure windows by the end of this task.
Poor Programming Practices 2 Marks Includes, but is not limited to, poor coding style, hardcoding, not using loops where appropriate, insufficient comments unlabelled figures, etc.
MCD4140 Assignment Page 11 of 11

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] 代写 C Scheme html math matlab database Status: Individual Weighting: 10
30 $