Matlab Matlab... please try to answer as soon as
possible. please don't copy previous answers as it is wrong. please
help. happy to upvote and give very positive comments.
Matlab Matlab... please try to answer as soon as
possible. please don't copy previous answers as it is wrong. please
help. happy to upvote and give very positive comments.
Matlab Matlab... please try to answer as soon as
possible. please don't copy previous answers as it is wrong. please
help. happy to upvote and give very positive comments.
The Divergence Theorem states that for any closed surface within a vector field, the volume integral of the vector field's divergence over the enclosed region is equal to the surface integral of the vector field over that closed surface. In plain English, it says that the net flux out of a closed surface is related to the sum of all the sources/sinks within the enclosed volume. This can be stated mathematically as: JIC div(F) dv # F. ds S In the equation above, n represents the unit vector normal to the closed surface (pointing outwards from the surface by convention). In this assignment, you will consider a unit sphere (x² + y² + z² = 1) as your closed surface located within the 3-dimensional vector field, F = [xz²_xy yz] and show that the Divergence Theorem is valid. Question 1: Visualisation [10 marks] [CODING] Write a MATLAB script that generates a figure showing the unit sphere, its normal vectors, and the vector field F it is located within (all three of these should appear on the same graph). Assume the domain î € [−1, 1], y € [−1, 1], and z € [−1,1], and make sure that your figure is complete (title, axis labels, etc.). • Use the quiver 3 function to generate a plot of the vector field F (we recommend 20 equally-spaced points for each spatial dimension). • Use the sphere function to generate points that define the unit sphere (we recommend 30 × 30 faces) and the surfnorm function to generate its normal vectors. Question 2: Analytical Proof [20 marks] [CODING] Write a MATLAB script that uses the MATLAB Symbolic Toolbox to show that the Divergence Theorem is valid. Your code should use concepts and functions associated with the MATLAB Symbolic Toolbox to achieve the following: (a) Declare the following variables as symbolic: x, y, z, r, 0, ¢ (also declare all these variables to be real). (b) Define the vector field F in terms of x, y, and z. (c) LHS Volume Integral:
(i) Determine the Jacobian matrix, J and the Jacobian determinant, J for the Cartesian-spherical coordinate transformation, (x, y, z) → (r, 0, 0): x = r cos sin d y = r sin sin o z = r cos o (ii) Determine the divergence of F, div(F) in Cartesian coordinates. (iii) Use appropriate substitutions to convert div(F) into spherical coordinates. Do not use cart2sph. (iv) Determine the volume integral of div(F) using spherical coordinates. Remember that when performing integration in non-Cartesian coordinates, the integrand needs to be multiplied by the appropriate Jacobian determinant, |J|. (d) RHS Surface Integral: (i) The vector normal to a spherical surface, n is defined as follows (in Cartesian coordinates): n = [x y z]. (ii) Normalise n a unit vector, 7. (iii) Determine F.. (iv) Use appropriate substitutions to convert F. from Cartesian to spherical coordinates. Do not use cart2sph. (v) Define the integrand for the surface integral by multiplying your expression for F. with the appropriate Jacobian determinant |J| and substituting r = 1 into the resulting expression (as this is a surface integral corresponding to the surface of a unit sphere, i.e. r = 1). We highly recommend that you use the simplify function on this final integrand expression before proceeding with the integration. (vi) Determine the surface integral of F. using spherical coordinates. (e) Write a conditional statement that checks if the LHS Volume Integral in Part (c) is equal to the RHS Surface Integral in Part (d): • If they are equal, display the following sentence, replacing the text in the angled brackets with appropriate syntax: The 2 integrals are equal, with a value of <value to 4 d. p.>: Divergence Theorem shown.<new line> • If they are not, display the following sentence, replacing the text in the angled brackets with appropriate syntax: The volume integral is <value to 4 d.p.> while the surface integral is <value to 4 d. p.>. There is a mistake somewhere.<new line> If the second message is returned, it indicates that there is something that needs troubleshooting in your code.
Question 3: Numerical “Proof" [20 marks] [CODING] Write a MATLAB script that estimates the volume and surface integrals in the Divergence Theorem numerically. Without using any concepts or functions associated with the MATLAB Symbolic Toolbox, your code should achieve the following: (a) LHS Volume Integral: The volume integral can be numerically approximated as a discrete sum: [div (F) dV ≈ Σ (div(F)AV) V all points within V x (i) Set up a 3D grid corresponding to the domain à € [−1, 1], y € [−1, 1], and z € [−1, 1] (use 100 equally-spaced points for each spatial dimension).
(ii) Determine the components of the vector field, F at each point within this 3D grid. (iii) Determine the (numerical) divergence of F at each point within your 3D grid. (iv) Determine the volume of a volume element corresponding to your 3D grid, AV. (v) Use an appropriate loop to sum the values of (div(F)AV) for all points within the unit sphere. Remember that for a point to be within the unit sphere, its distance from the origin, r has to be < 1). You may want to “unwrap" the relevant matrices prior to entering your loop. (b) RHS Surface Integral: We can also numerically approximate the surface integral: ff. F . ñ ds ≈ Σ (F · î)(AS) all points on S (i) Use the sphere function to generate points that define the surface of a unit sphere (use 30 × 30 faces) and the surfnorm function to generate its normal vectors. (ii) Determine the components of the vector field, F at each point on the surface of your sphere. (iii) For simplicity, we assume that each face on the unit sphere in you generated has equal surface area. Use this assumption to determine the surface area of an area element, AS. The surface area of a sphere is 47². (iv) Use an appropriate loop to sum the values of (F. )(AS) for all points on the surface of the sphere. You may want to "unwrap" the relevant matrices prior to entering your loop. (c) Display the following result in the Command Window, replacing the text in the angled brackets with appropriate syntax: The volumetric sum of div (F) is <value to 4 d.p.>.<new line> The surface area sum of F dot ncap is <value to 4 d.p.>.<new line> You will observe some discrepancies between the analytical solutions calculated in Question 2 and the numerical solutions calculated in Question 3. This is to be expected due to the errors associated with numerical approximation.
Matlab Matlab... please try to answer as soon as possible. please don't copy previous answers as it is wrong. please hel
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Matlab Matlab... please try to answer as soon as possible. please don't copy previous answers as it is wrong. please hel
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!