代写 C algorithm math matlab statistic MAEV 511 Numerical Methods

MAEV 511 Numerical Methods
Midterm Exam
Vorticity field, Newton’s method, and zero-crossing techniques
Date distributed: May 1, 2019
Date due: June 1, 2018 at 5:00 p.m.
Compile your work as a single pdf file to the instructor’s email account. MATLAB codes as .m files also need to send to the instructor. Please submit the files before the due date shown above.
1. Bubble sort, insertion sort and MATLAB built-in function sort
Sort an array of 1000 numbers, ranging from 0.1 to 1000, generated by the MATLAB built-in function rand ((1000 – 0.1).*rand(1000,1) + 0.1), and sort them in the descending order by writing codes for the bubble and insertion sorting algorithms, and the MATLAB built-in function sort.
2. Wave train analysis
Visual observation of the sea surface and measurements indicate that the sea surface is composed of waves of varying heights and periods moving in different directions. It can be defined as a combination of many wave components. These individual components were generated by the wind in different regions of the ocean and have propagated to the point of observation. If a recorder were to measure waves at a fixed location on the ocean, a non-repeating wave profile would be seen and the wave surface record would be rather irregular and random. Different approaches and methods have been developed during the years for describing and analyzing natural sea states. Wave-by-wave (wave train) analysis is one of the two mostly used methods (the other one is the spectral method). In this method, undulations in the time-history of the surface at a point are identified as individual waves; the height and period of each wave will be measured. Once this is done, statistical characteristics of the record can be estimated, and the statistics of the record are compiled.
In the time-domain analysis of irregular or random seas, wave height and period, wavelength, wave crest, and trough have to be carefully defined for the analysis to be performed. The adopted engineering procedure is the zero-crossing technique, where a wave is defined when the surface elevation crosses the zero-line or the mean water level (MWL) upward (zero-upcrossing) or downward
1

(zero-downcrossing), and continues until the next crossing point. The entire wave record is then decomposed into numerous individual wave events, where each wave height and period are then noted for every zero-upcrossing or zero-downcrossing, depending on the method selected. It is customary to define wave height as the vertical distance between the highest and lowest points, while wave period is defined as the horizontal distance between two successive zero-crossing points. All local maxima and minima not crossing the zero-line have to be discarded. Using these definitions of wave parameters for an irregular sea state, it is seen that, unlike the regular (monochromatic) sinusoidal waves, the periods and heights of irregular waves are not constant with time, changing from wave to wave.
Wave statistics is to produce some statistical estimates from the analyzed time-series data to describe an irregular sea state in a simple parametric form. For parameterization, there are many parameters used to define statistics of irregular sea states. Two of the most important parameters necessary for adequately quantifying a given sea state are characteristic height H and characteristic period T. Characteristic wave height H for an irregular sea state may be defined in several ways. These include the mean height H̄ which is the mean of all the measured wave heights in the entire record analyzed, the maximum wave height Hmax which is the largest wave height in the record, the root- mean-square height Hrms which is the root-mean-square of all the measured wave heights, and the mean height of the highest 1/n of all waves H1/n where n = 10, 11, 12, 13,…, 99, 100 are common values. From one wave record measured at a point, wave heights are ordered from the largest to the smallest and each one is assigned a number from 1 to n. H1/10 is the mean height of the highest one-tenth waves, while the significant wave height H1/3 or Hs is the average of the first (highest) n/3 waves. The characteristic period T could be the mean zero-crossing period Tz obtained from the total length of wave record length Tr by
Tz = Tr/Nz (1)
where Nz is the number of zero-upcrossings (or zero-downcrossings) in the wave record.
The attached file (WaveData.dat) is the water elevation recordings at water depth h = 0.2 m. The data sampling rate is 4 Hz (which means the elevation was recording every 0.25 s). Please write a
MATLAB program to include the following steps for the irregular wave data.
1. Find the mean water level (MWL) as the average of the water elevation measurements.
2. Each elevation measurement needs to subtract the MWL value to have a zero average.
2

3. Write a MATLAB program with zero-downcrossing algorithm to find the zero-crossing points. The zero-crossing points need to linearly interpolate from the time stamps of the data. The time interval between two successive zero-crossing points denote the wave period Ti of each individual wave. The difference between the maximum and minimum water elevation within each individual wave denotes the wave height Hi.
4. Sort all the wave heights Hi’s from the largest to the smallest and each one is assigned a number from 1. Calculate all the characteristic wave heights, including H̄, Hmax, Hrms, H1/10 and H1/3 (Hs), and characteristic wave period Tz.
3. Solving dispersion relation (Newton-Raphson method)
The speed at which a wave form propagates is termed the phase velocity or wave celerity C. Since the distance traveled by a wave during one wave period T is equal to one wavelength L, the wave celerity C then can be related to the wave period and length by
C=L (2) T
An expression relating wave celerity C to wavelength L and water depth d is given by
C= gLtanh2πd (3)
2π L 
and termed the linear dispersion relation since it indicates that waves with different periods travel at different speeds; At same water depth, the longer period waves travel faster than those waves with shorter period. Eq. (3) can be rewritten as
C = gT tanh2πd = g tanh(kd) (4) 2π Lω

where k = 2π/L and ω = 2π/T are the wave number and wave angular frequency, respectively. Eq. (4) can be further rewritten to obtain wavelength L under known water depth d and wave period T
L=gT2 tanh2πd (5) 2π L
Solving Eq. (5) analytically involves some difficulty since the unknown L appears on both sides of the equation. Instead, Newton-Raphson method can be used to solve the equation numerically, with a good initial guess for the wavelength L by Eckart (1952)
3


L=gT2 tanh4π2 d (6) 2π T2g
A wave with a period T = 10 seconds is propagated shoreward over a uniformly sloping shelf from a depth d = 200 m to a depth d = 3 m. Write a MATLAB program to solve the linear dispersion equation, and calculate the wave lengths L and wave celerity C at these two depths. Plot the variation of L and C against d from 200 to 3 m.
4. Solving simultaneous equations by LU factorization and inverse matrix
Find the solution of the following linear system by computing the LU factorization, and compare the result with the solution obtained directly by using the MATLAB built-in function inv.
3×1 −2×2 +4×3 +6×4 +5×5 =60
5×1 +3×2 −4×3 +9×4 +x5 =40
4×1 −8×2 +x3 +6×4 +2×5 =25 (7) 3×1 −x2 +5×3 −3×4 +4×5 =24
2×1 −4×2 +5×3 +8×4 +x5 =46
5. Velocity and vorticity fields
Vorticity is a vector field that is twice the angular velocity of a fluid particle. A concentration of codirectional or nearly codirectional vorticity is called a vortex. Fluid motion leading to circular or nearly circular streamlines is called vortex motion. Mathematically, it is defined as the curl of the velocity field,
ω=∇×V (8) and is hence a measure of local rotation of the fluid. This definition makes it a vector quantity. In two
dimensions (x, y), the only non-zero component of the vorticity
ωz = ∂v/∂x − ∂u/∂y (9)
where u and v are the velocity components in the x and y directions, respectively. The vorticity can be directly obtained by numerical differentiation of the velocity field. To obtain a reliable estimate it is important that the velocity measurement data are accurate, do not contain spurious data, and that the spatial resolution is adequate to perform a differentiation of the data. For velocity data that are obtained at discrete locations the vorticity ωz can be estimated by means of the circulation, i.e.,
4


4∆x∆y
ωz =lim1∫V dl ⋅ (10) A→0 A C
where C is the contour that encloses an area A. The discrete representation of Eq. (9) is: ωz (i, j) ≅ 1 [
∆y⋅v(i+1,j)+ 1∆y[v(i+1,j−1)+v(i+1,j+1)] 21
−∆x ⋅u(i, j + 1) − 2 ∆x[u(i − 1, j + 1) + u(i + 1, j + 1)]
−∆y⋅v(i−1,j)− 1∆y[v(i−1,j−1)+v(i−1,j+1)] 21
+∆x⋅u(i,j−1)+ 2∆x[u(i−1,j−1)+u(i+1,j−1)] ]
(11)
The attached file (Velocity.dat) is a velocity field from PIV measurements. Please use MATLAB to plot the velocity field, and write a program to calculate and plot the vorticity field of the corresponding velocity field.
5