ECM3446代做、代写Python/C++编程
ECM3446: CA
This continuous assessment is for the ECM3446 version of the High Performance Computing
module. If you are an undergraduate student you should follow these in- structions. If you are a
student on an MSc programme please refer to the “ECMM461: Continuous assessment 1”
instructions instead.
1 The Atmospheric Boundary Layer
The part of the Earth’s atmosphere nearest the surface is known as the “Atmospheric Boundary
Layer”, and in this part of the atmosphere the wind speed increases with height. This causes
material emitted from a chimney to be advected at di↵erent horizontal speeds depending on its
height. Figure 1 shows material from a chimney being advected by the wind.
Figure 1: Material emitted from a chimney being advected by a horizontal wind
The wind in the Atmospheric Boundary Layer can be approximated as a horizontal velocity which
depends only on the height (z) and zero vertical velocity. The horizontal velocity as a function of height
vx(z) can be represented by a logarithmic profile
(1)
where u is a parameter called the “friction velocity”, z0 is a parameter called the “roughness
length”, and = 0.41 is a constant called Von K´arm´an’s constant.
2 The assignment
In this assignment you will calculate a numerical solution to the advection equation to simulate the
movement of a cloud of material in the atmospheric boundary layer. There are four parts to this assignment:
• Task 1: For the first part of this assignment you will parallelise a program which calculates a
numerical solution to the 2D advection equation. You have been provided with the program
1
-
-ECM3446: CA
and you will need to parallelise it using OpenMP. This part of the assignment is described
in Section 2.1.
• Task 2: For the second part of this assignment you will modify the program to change
the parameters of the test problem into a more realistic configuration. This is described in
Section 2.2.
• Task 3: For the third part of this assignment you will add a logarithmic velocity profile to
the program. This is described in Section 2.3.
• Task 4: For the fourth part of the assignment you will calculate the horizontal profile of the
advected material by calculating a vertical average. This is described in Section 2.4.
This assignment assesses the following Intended Learning Outcomes:
• Demonstrate skills in parallel processing algorithm design and the practical implementation
of such algorithms
• Demonstrate an awareness of numerical e↵ects and the influence of floating point number
representation in high-performance computing applications.
• Interpret an informal requirement specification
• Systematically analyse information and make appropriate design choices
2.1 Task 1: Parallelising the program
The advection equation for a two-dimensional scalar field u(x, y) is
(2)
where vx and vy are the velocities in the x and y direction, respectively. You have been
provided with a C program which calculates a numerical solution to the advection equation
for a two- dimensional scalar field u(x, y) using finite di↵erence approximations. The program
uses one-sided di↵erences to calculate the spatial derivatives
dy (4)
where ui,j is the value of the scalar field u(x, y) at grid point (i, j), dx is the spacing of grid points
in the x direction and dy is the spacing of grid points in the y direction. The solution starts
from specified initial conditions at time t = 0 and is updated from time t to time t + t using
forward-Euler time steps
t (5)
The program uses 1000 ⇥ 1000 grid points covering a unit square computational domain 0 
x  1.0 and 0  y  1.0. The initial conditions are a Gaussian given by the expression
(6)
The Gaussian is centred at x0 = 0.1, y0 = 0.1 and has a width x = y = 0.03. The boundary
conditions are u = 0 on all boundaries. The program calculates 1500 time steps, and the time step
size is calculated from the Courant condition with a CFL number of 0.9. The velocities in the x
and y directions are vx = 0.01 and vy = 0.01 respectively.
The first part of the assignment is to parallelise the program provided using OpenMP. There
are 10 loops or loop nests (a loop over j inside a loop over i) in the program and these have been
identified with a comment of the form
2ECM3446: CA
/* LOOP N */
where N is an integer between 1 and 10 inclusive. For each loop or loop nest you should decide
whether it can be correctly parallelised by adding an OpenMP directive:
• If the loop can be correctly parallelised then you should parallelise it by adding an OpenMP
directive, ensuring that all variables are correctly scoped. You do not need to scope variables
which have the const qualifier.
• If the loop cannot be parallelised then you should add a comment in the program to say that
the loop cannot be parallelised and explain why.
To build the serial program in ISCA use the command
gcc -o advection2D -std=c99 advection2D.c -lm
To build the program with OpenMP enabled in ISCA use the command
gcc -fopenmp -o advection2D -std=c99 advection2D.c -lm
A gnuplot script which plot the final values of u(x, y) has been provided.
The parallelised version of the program must produce exactly the same output as
the original program.
2.2 Task 2: Modifying the calculation
In this section you will modify the example program to change the test problem so that it more
closely resembles a cloud of material emitted from a chimney. This requires changing the size of
the computational domain, the initial conditions, the velocities and the number of time steps.
In the following instructions distances are measured in metres (m) and velocities in metres per
second (m/s).
• The test problem uses a computational domain which is a unit square (it covers the range
0  x  1.0 and 0  y  1.0). Change the computational domain so that it covers the range
0  x  30.0 m and 0  y  30.0 m
• For this calculation we require the Gaussian to be on the left hand side of the domain and
vertically centred. Change the centre of the Gaussian to x0 = 3.0 m, y0 = 15.0 m
• The cloud of material will have a larger vertical extent than horizontal extent. This will be
represented by a Gaussian which has di↵erent widths in the x and y directions. Change the
widths of the Gaussian specified in the initial conditions to x = 1.0 m and y = 5.0 m
• The material in the atmospheric boundary layer advects horizontally but not vertically.
Change the horizontal velocity to vx = 1.0 m/s and change the vertical velocity to vy = 0.
• Change the maximum number of time steps to 800 so that the material does not advect out
of the computational domain.
After you have made these changes re-compile and re-run the program. If necessary update
the OpenMP directives to ensure that the program produces identical results with and without
OpenMP.
Now plot the initial and final values of u(x, y). The initial values are in the file initial.dat
and the final values are in the file final.dat. You can use the example gnuplot script provided
but you will need to change the axis limits to match the new computational domain size. Plots of
the initial and final values of u(x, y) are shown in Figure 2 for comparison.
3ECM3446: CA
Figure 2: Initial (left) and final (right) values of u(x, y) from the calculation in Section 2.2
2.3 Task 3: Adding vertical shear
In this section you will modify the program so that the horizontal velocity varies with height
according to the logarithmic profile given in equation 1. The logarithmic profile should only be
used if z is greater than the roughness length z0. If z > z0 calculate the horizontal velocity using
equation 1, and if z  z0 set the horizontal velocity to zero. The parameters of the profile should
be set to u⇤ = 0.2 m/s, z0 = 1.0 m and  = 0.41.
In the program the variable y represents the height z in equation 1. The computational domain,
the initial conditions and the number of time steps should be kept at the values specified in the
previous section (Section 2.2).
Modify the horizontal velocity as described above and re-run the program. If necessary update
the OpenMP directives to ensure that the program produces identical results with and without
OpenMP.
Now plot the final values of u(x, y) (the initial values are the same as in the previous
section). Plots of the initial and final values of u(x, y) are shown in Figure 3.
Figure 3: Initial (left) and final (right) values of u(x, y) from the calculation in Section 2.3
2.4 Task 4: Calculating the vertically averaged distribution
In this last section you should calculate the vertically averaged distribution of u(x, y) at the end
of the calculation in Section 2.3. The vertical average should cover the whole vertical domain but
should not include the boundary values. The code you add to the program does not need to be
4ECM3446: CA
parallelised. Plot the vertically averaged values of u as a function of x using a line
graph.
3 Deliverables
The deliverables for this assignment are the source code for the program with your modifications,
and the four plots showing your results:
1. Source code for the final version of the program. The program should include the OpenMP
directives added in Section 2.1 with any changes required to ensure the modified program
continues to work correctly. The computational domain, the initial conditions, the velocities
and the number of time steps should be set to the values used in Section 2.3.
2. Four plots showing the output from running the program. The required plots are:
• A plot of the initial conditions u(x, y) from Section 2.2
• A plot of the final values of u(x, y) from Section 2.2
• A plot of the final values of u(x, y) from Section 2.3
• A plot showing the vertically averaged profile of u from Section 2.4
The plots may be generated using the gnuplot script provided, or alternative plotting software
of your choice provided the data values in the plot are clearly represented. Your plots should
be delivered as PNG or PDF files.
The deliverables should uploaded to ELE a single zip or tar file containing the
source code for the final version of the program, and the four plots. The deadline for
submission is 12 noon 20 February 2025.
4 Mark scheme
A total of 100 marks are available for this assignment:
1. Task 1: Parallelising the program (30 marks)
(a) For each of the 10 loops or loop nests identified in the program there are two marks to
be awarded according to the following criteria:
• The loop has been correctly identified as either one that can be parallelised or one
that cannot be parallelised (1 mark)
• If the loop can be parallelised then an appropriate OpenMP directive has been
added which unambiguously and correctly scopes all variables. Variables with the
const qualifier do not need to be scoped (1 mark)
OR
• If the loop cannot be parallelised then a comment has been added with a correct
explanation of why the loop cannot be parallelised (1 mark).
(b) An additional 10 marks are awarded if the parallelised program produces results which
exactly match the original serial program.
2. Task 2: Modifying the calculation (20 marks)
10 marks are awarded for correctly modifying the computational domain, the initial conditions
and the number of time steps, as specified in Section 2.2. 5 marks are awarded for the
plot of the initial conditions and 5 marks are awarded for the plot of the final results.
3. Task 3: Adding vertical shear (25 marks)
20 marks are awarded for correctly modifying the velocity profile as specified in Section 2.3.
5 marks are awarded for the plot of the final results.
5ECM3446: CA
4. Task 4: Calculating the vertically averaged distribution (25 marks)
20 marks are awarded for correctly modifying the program to calculate the vertically averaged
distribution of u as specified in Section 2.4. 5 marks are awarded for the plot of the final
results.
6

热门主题

课程名

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
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图