Project01.pdf

Queens College, CUNY Physics Department

Physics 661 – Computational Methods in Physics Spring 2019 – Dr. David Goldberg

Page 1/2

PROJECT 1 Due: Monday, 4/29/19, before 4PM

3D Surfaces Surface Area

Write a script that computes the surface area of a function 𝑓𝑓(𝑥𝑥, 𝑦𝑦) over a rectangular boundary on the 𝑥𝑥𝑦𝑦- plane. Do this by segmenting the square grid into triangles, then sum the area of the triangular surface.

Normal Vector Write a script that calculate and plot the normal vectors on the surface. The vector should be computed for each triangular surface.

Gauss’s Law • Suppose a point charge is placed at the origin of an 𝑥𝑥, 𝑦𝑦, 𝑧𝑧 coordinate system, write a script that

computes the electric flux through a cube centered at the origin. Note that you need not compute the flux through all the surfaces of the cube if you take advantage of the symmetry. Furthermore, there is sufficient symmetry that you only need to compute a quarter of one side of the cube.

• Suppose the charge is no longer at the origin, however, the charge is still inside the cube. Calculate the flux through the cube. Note that the symmetry is now broken, therefore, you’ll need to compute the flux through each side separately.

Random Walk 1D Walk

• For a 1D random walk consisting of 𝑁𝑁 steps of ±1, compute the average displacement, ⟨Δ𝑥𝑥⟩, and average displacement squared, ⟨Δ𝑥𝑥2⟩, for an average over √𝑁𝑁 trials. 𝑁𝑁 should be large but increase 𝑁𝑁 systematically so you don’t overload your computer by making it too large. Plot points of the computed ⟨Δ𝑥𝑥⟩ 𝑣𝑣𝑣𝑣. 𝑁𝑁 and ⟨Δ𝑥𝑥2⟩ 𝑣𝑣𝑣𝑣. 𝑁𝑁 along with a theory curve.

• Repeat the previous problem for uniformly distributed steps on the interval [−1,1]. • Repeat once again for normally distributed steps (use MATLAB’s randn function).

Physics 661 Spring 2019

Dr. David Goldberg

[email protected]

Page 2/2

Multidimensional Random Walk

2D Uniform Random Walk • Consider a uniform 2D random walk where the step size is fixed to one unit. Write a script that simulates

the random walk by: o Cartesian Coordinates: Choose Δ𝑥𝑥 and Δ𝑦𝑦 ∈ [−1,1] then normalizing the step size. Plot the

trajectory of five different trials on the same graph for 100 steps each. o Polar Coordinates: Choose 𝜃𝜃 ∈ [0,2𝜋𝜋] with a fixed unit radius. Plot the trajectory of five different

trials on the same graph for 100 steps each. • Plot points of the computed ⟨Δ𝑟𝑟⟩ 𝑣𝑣𝑣𝑣. 𝑁𝑁 and ⟨Δ𝑟𝑟2⟩ 𝑣𝑣𝑣𝑣. 𝑁𝑁 along with a theory curve for both Cartesian and

Polar methods on the same graph.

2D Random Walk with Normally Distributed Step Size • Repeat the above procedure for step (Δ𝑟𝑟𝑖𝑖) is normally distributed with random direction. Consider what

would be the appropriate normalization to get the expected statistics, i.e., ⟨Δ𝑟𝑟2⟩ = 𝑁𝑁⟨Δ𝑟𝑟𝑖𝑖 2⟩

Brownian Motion 1D Uniform • Consider a 1D random walk where a particle has a displacement of Δ𝑥𝑥𝑖𝑖 in time interval of Δ𝑡𝑡. After 𝑁𝑁

steps, the time elapsed is 𝑇𝑇 = 𝑁𝑁Δ𝑡𝑡, and the average variance of the displacement would be ⟨Δ𝑥𝑥2⟩ =

𝑁𝑁⟨Δ𝑥𝑥𝑖𝑖 2⟩. If one would look at the displacement after time 1

2 Δ𝑡𝑡, after time 𝑇𝑇, there would be a total

number of 2𝑁𝑁 steps. In order to keep the same variance, i.e., ⟨Δ𝑥𝑥2⟩ = 𝑁𝑁⟨Δ𝑥𝑥𝑖𝑖 2⟩, the step size would need

to be adjusted to 1 √2 𝛥𝛥𝑥𝑥𝑖𝑖.

⟨Δ𝑥𝑥2⟩ = (2𝑁𝑁) ⟨� 1 √2

Δ𝑥𝑥𝑖𝑖� 2 ⟩ = 𝑁𝑁⟨Δ𝑥𝑥𝑖𝑖

2⟩

• Create a 1D random walk where Δ𝑥𝑥 = ±1 for time Δ𝑡𝑡, and simulate the displacement after total time

𝑇𝑇 = 𝑁𝑁Δ𝑡𝑡. However, introduce an integer parameter 𝑘𝑘 which reduces the time for each step to 1 𝑘𝑘 Δ𝑡𝑡. The

total number of steps is 𝑘𝑘𝑁𝑁. • Plot ⟨Δ𝑥𝑥2⟩ 𝑣𝑣𝑣𝑣. 𝑁𝑁 for different values of 𝑘𝑘. Is it still linear?

1D Normal • Repeat the above for Δ𝑥𝑥𝑖𝑖 being a random normally distributed step.

3D Brownian Motion • Repeat the above (1D Uniform and Normal) for in three-dimensional space.

  • 3D Surfaces
    • Surface Area
    • Normal Vector
    • Gauss’s Law
  • Random Walk
    • 1D Walk
    • Multidimensional Random Walk
      • 2D Uniform Random Walk
      • 2D Random Walk with Normally Distributed Step Size
  • Brownian Motion
    • 1D Uniform
    • 1D Normal
    • 3D Brownian Motion