首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
辅导program编程、Matlab程序语言调试、Matlab编程讲解 辅导留学生 Statistics统计、回归、迭代|解析Haskell程序
项目预算:
开发周期:
发布时间:
要求地区:
Computing and Numerical Methods 2
Coursework
Academic Year 2020/2021
Deadline: 29th January 2021, 11pm GMT
Instructions
This coursework is divided into two parts. You are required to follow the instructions for each part detailed
below.
Part I:
This part consists of four exercises and involves programming in Matlab. You must answer each question
using the word template provided. Ensure that all figures are clear, labelled correctly and that you strictly
adhere to any word/space limits stated in the template. Do not alter the template in any way: textboxes
should not be changed and the written responses must be in “Calibri”, fontsize 12 (handwritten responses
are not accepted). Figures should be completely contained inside the textboxes. If the template calls only
for a plot, only a plot should be provided (anything else will not be marked).
Having completed the tutorial sheets, you will already have the core parts of the Matlab code required to
complete Part I. While marks will be awarded for each question, questions requring analysis carry a heavier
weight. Any discussions/analysis can be made solely based on the course material and observations made
regarding the questions within this coursework. Make sure that your answers to these parts are clear,
concise and to-the-point.
Part II:
This part requires you to write a program in C++. While the structure of the program is not prescribed,
marks will be awarded for well-structured code which is uses good programming practices and is clear to
read. You should ensure your program adheres to any requirements on the input and output format of
parameters and generated data.
The short report should be written in size 12 font. It should not exceed two A4 pages overall; any material
beyond the 2-page limit will not be marked. Make sure that your answers to these parts are clear, concise
and to-the-point. Plots should be legible and any text on figures should be no smaller than size 12 font.
Notation: Given a vector v, its derivative with respect to an independent variable t is denoted by v˙. Namely
dv
dt
= ˙v .
1
Figure 1: Diagram of the double pendulum. The diagram is not drawn to scale.
In this assignment you are going to numerically solve a system of ordinary differential equations which model the
motion of a simple double pendulum shown in Figure 1. The system consists of two weights of arbitrary mass, m1
and m2, connected by mass-less rigid rods of prescribed lengths, l1 and l2. As shown in Figure 1, the mass m1 is
considered as a point mass located at position (x1, y1) with a deflection angle θ1, whereas the second mass m2 is
located at position (x2, y2) with a deflection angle θ2. The energy of the system is given by
L = Linear Kinetic Energy + Potential Energy .
is the gravitational acceleration. Assuming conservation of energy, the system must satisfy
the Euler-Lagrange equation and can be described by the second-order differential equations (in the variables θ1
and θ2)
(m1 + m2)l1
¨θ1 + m2l2 cos(θ1 − θ2)
¨θ2 + m2l2 sin(θ1 − θ2)
˙θ
2
2 + (m1 + m2)g sin(θ1) = 0 ,
l2
¨θ2 + l1 cos(θ1 − θ2)
¨θ1 − l1 sin(θ1 − θ2)
˙θ
2
1 + g sin(θ2) = 0 .
(1)
The (x, y)-coordinates of each pendulum can readily be expressed in terms of the lengths l1 and l2, and the angles
θ1 and θ2 as follows
x1 = l1 sin(θ1),
y1 = −l1 cos(θ1),
x2 = l1 sin(θ1) + l2 sin(θ2),
y2 = −l1 cos(θ1) − l2 cos(θ2).
The initial position of the pendulum is such that θ1(0) = θ1,0 and θ2(0) = θ2,0 (the values of which will be specified
later) and the pendulum is initially at rest, i.e. ˙θ1(0) = ˙θ2(0) = 0.
2
m1 m2 l1 l2 θ1,0 θ2,0
1 1 0.01 1 0 π/4
Table 1: Parameters defining the pendulum considered in Q2).
m1 m2 l1 l2
1 1 1 1
Table 2: Parameters defining the pendulum considered in Q3)-Q4).
Part I - Numerical Methods
Q1) The two-dimensional, second order differential equation (1) can be expressed as a first order differential
equation of a larger dimension.
(a) Write the system of equations (1) in the form
M(θ1, θ2)
¨θ1
¨θ2
= g(θ1, θ2,
˙θ1,
˙θ2),
where the matrix M and vector g are smooth functions to be determined.
(b) Using the result of part (a) of Q1), express (1) as a system of first-order differential equations in terms of
a vector v of suitable dimension. Namely, express the second order differential equation (1) in the form
v˙ = f(v),
where f is a smooth function to be determined. [5%]
Q2) For this part of the problem, suppose that the various parameters characterising the pendulum are as speci-
fied in Table 1.
(a) For the initial conditions given in Table 1, solve the differential equation obtained in Q1)(b) using explicit
Euler with step size h = 0.1 for the interval t = [0, 10].
i. Plot the angles θ1 and θ2 obtained numerically as a function of time. Plot the two angles on different
axes (e.g. using two subplots).
ii. In a new figure, plot the position (x1, y1) for each time (such a plot is called a phase portrait) in red.
On the same figure, plot the position (x2, y2) for each time in blue.
iii. Inspecting the plots obtained in the preceding two sub-problems, do you believe the numerical
solution obtained represents well the behaviour of the double pendulum? Provide a brief explanation
for your answer. [15%]
Q3) For this part of the problem, suppose that the various parameters characterising the pendulum and are as
specified in Table 2.
(a) Let θ1,0 = π and θ2,0 =
π
2
. Solve the differential equation obtained in Q1)(b) using 4th order Runge-Kutta
with step size h = 0.001 for the interval t = [0, 10].
i. Plot the angles θ1 and θ2 obtained numerically as a function of time. Plot the two angles on different
axes (e.g. using two subplots).
ii. Plot x1, y1, x2 and y2 obtained numerically as a function of time. Plot each variable on different axes
(e.g. using four subplots).
iii. In a new figure, plot the position (x1, y1) for each time (such a plot is called a phase portrait) in red.
On the same figure, plot the position (x2, y2) for each time in blue.
(b) Let θ1,0 = π + 0.001 and θ2,0 =
π
2
. Solve the differential equation obtained in Q1)(b) using 4th order
Runge-Kutta with step size h = 0.001 for the interval t = [0, 10].
i. Plot the angles θ1 and θ2 obtained numerically as a function of time. Plot the two angles on different
axes (e.g. using two subplots).
3
ii. Plot x1, y1, x2 and y2 obtained numerically as a function of time. Plot each variable on different axes
(e.g. using four subplots).
iii. In a new figure, plot the position (x1, y1) for each time (such a plot is called a phase portrait) in red.
On the same figure, plot the position (x2, y2) for each time in blue.
(c) Compare the two numerical solutions obtained in Q3)(a) and Q3)(b). Comment on what you observe and
discuss briefly whether your observations are a consequence of the numerical solver used or whether
it is an artefact of the differential equation itself. [15%]
Q4) For this part of the problem, suppose that the various parameters characterising the pendulum are again as
specified in Table 2.
(a) Let θ1,0 = π and θ2,0 =
π
2
. Solve the differential equation obtained in Q1)(b) using explicit Euler with
step size h = 0.001 for the interval t = [0, 10].
i. Plot the angles θ1 and θ2 obtained numerically as a function of time. Plot the two angles on different
axes (e.g. using two subplots).
ii. Plot x1, y1, x2 and y2 obtained numerically as a function of time. Plot each variable on different axes
(e.g. using four subplots).
iii. In a new figure, plot the position (x1, y1) for each time (such a plot is called a phase portrait) in red.
On the same figure, plot the position (x2, y2) for each time in blue.
(b) Let θ1,0 = π and θ2,0 =
π
2
. Solve the differential equation obtained in Q1) using implicit Euler with step
size h = 0.001 for the interval t = [0, 10].
i. Plot the angles θ1 and θ2 obtained numerically as a function of time. Plot the two angles on different
axes (e.g. using two subplots).
ii. Plot x1, y1, x2 and y2 obtained numerically as a function of time. Plot each variable on different axes
(e.g. using four subplots).
iii. In a new figure, plot the position (x1, y1) for each time (such a plot is called a phase portrait) in red.
On the same figure, plot the position (x2, y2) for each time in blue.
(c) Compare the two numerical solutions obtained in Q4)(a) and Q4)(b). Comment briefly on what you
observe and discuss whether or not one numerical solution is better than the other. [15%]
Continues on next page ...
4
Part II: C++ Programming
Q5) Write a C++ code to numerically simulate the motion of the double-pendulum. Solve the system, given by
equation (1) from time 0 to time T. Your code should:
• read a file called parameters.txt, located in the current working directory, to supply the values of m1,
m2, l1, l2, θ1,0, θ2,0, ∆t, T. These values must be specified in the file in the order given above, with
values on a single line separated by spaces, for example:
1.5 2.0 1.0 1.0 1.571 2.356 0.01 10.0
• integrate the system using the 4th-order Runge-Kutta scheme.
• write the time t and (x, y)-coordinates of the masses at each time step to the file output.txt in the
current working directory;
• not require interaction with the user through the terminal during execution;
• not use third-party libraries or code beyond the standard C++ header files;
Marks will be awarded for the following:
• Code correctness;
• Code design (use of object-oriented paradigms, functions, suitable data structures);
• Code readability (layout, sensible choice of variable/function names, use of comments). [30%]
Q6) Write a short report as follows (max 2 pages).
(a) Validate your C++ code against your MATLAB implementation from Part I by generating 2D plots showing
the time evolution of the positions of the mass m2 for the following cases, given in terms of the vector
of parameters (m1, m2, l1, l2, θ1,0, θ2,0, ∆t, T) as:
i. 1.0 1.0 0.01 1.0 0.0 0.785 0.0001 1.0
ii. 1.0 1.0 1.0 1.0 0.785 0.785 0.001 10.0
iii. 1.0 2.0 0.5 2.0 1.571 2.356 0.001 10.0
(b) Consider the parameter set 1.5 2.0 1.0 1.0 1.571 2.356 0.01 10.0.
i. Compare and plot the behaviour of the pendulum under this parameter set against the same parameters
but with ∆t = 0.001.
ii. Identify the earliest time at which the difference between the positions of the second mass at these
different values of ∆t exceeds an error threshold of = 0.05.
iii. Determine if the solution obtained using ∆t = 0.001 is converged at the final time, based on the
threshold of = 0.01. Explain how you arrived at your answer.
(c) Discuss the potential advantages and disadvantages of solving this problem in C++, instead of an
interpreted language.
(d) Explain the benefits of using an object-oriented programming paradigm for this problem. [20%]
Submission
You should submit three files to Blackboard for this assignment. Make sure that these files have the format
and names as specified below.
1. Part1.pdf: Part I of this coursework must be submitted as a PDF (i.e. not as a word file).
2. Part2.pdf: The report component of Part II must be submitted a PDF (i.e. not as a word file).
3. Code.zip: The code component of Part II must be submitted as a ZIP archive. It should contain the
necessary C++ source code files only. For this, the xarchiver program, available from the Accessories
menu on the remote Linux environment can be used. Please unpack the archive file again
before submitting to check all the necessary files have been included and your code compiles.
End of assignment.
5
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做ceng0013 design of a pro...
2024-11-13
代做mech4880 refrigeration a...
2024-11-13
代做mcd1350: media studies a...
2024-11-13
代写fint b338f (autumn 2024)...
2024-11-13
代做engd3000 design of tunab...
2024-11-13
代做n1611 financial economet...
2024-11-13
代做econ 2331: economic and ...
2024-11-13
代做cs770/870 assignment 8代...
2024-11-13
代写amath 481/581 autumn qua...
2024-11-13
代做ccc8013 the process of s...
2024-11-13
代写csit040 – modern comput...
2024-11-13
代写econ 2070: introduc2on t...
2024-11-13
代写cct260, project 2 person...
2024-11-13
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!