Question: def initialize_1(u, h): ''' Initialize an array to account for BCs and geometry for problem 1. Args: u: 2D numpy array corresponding to values sampled

 def initialize_1(u, h): ''' Initialize an array to account for BCs

def initialize_1(u, h):

'''

Initialize an array to account for BCs and geometry for problem 1.

Args:

u: 2D numpy array corresponding to values sampled on a regular 2D grid

h: float grid-spacing

Returns:

2D numpy array corresponding to the input with boundary values on the boundary/exterior or the triangular domain.

'''

pass

def update(u):

'''

Update values within the triangular domain based on the 5-point averaging stencil

Args:

u: 2D numpy array of input values (with appropriate boundary conditions outside the triangular domain)

Returns:

2D numpy array of with values updated within the triangular domain

'''

pass

def iter_solve(u, tol, max_iters):

'''

Solve the Laplace equation by iterating with 5-point averaging stencil (by calling update() )

Args:

u: 2D numpy array to update

tol: float maximal allowable change in an updated value

max_iters: int limit on number of update iterations

Return:

2D numpy array with final solution

number of iterations to achieve specified tolerance

'''

pass

1) In class, we will see that that analytic and Fourier Transform techniques are applicable for "nice" geometries whose boundaries lie on constant coordinate curves. For this problem, you will show that finite difference methods can be applied to more general geometries. (This problem is constructed so regularly sample grid points lie on the boundary. For boundaries that do not align nicely with a regular grid, only a slightly more complicated formulation is required.) In particular, solve Laplace's equation uxx+uyy=0 to determine the steady-state temperature distribution u(x,y) in a flat triangular plate with insulated faces (to ensure no heat flow in the z-direction) and vertices at [[0,0],[0,1],[1,0]]. The boundary conditions are as follows: - On the edge along the y-axis, u(0,y)=y. - On the edge along the x-axis, u(x,0)=x2. - On the hypotenuse (lying on y=1x),u(x,1x)=1. Choose an initial guess of the temperature distribution (e.g. u0 ), then interatively update (using the 5point stencil scheme on a uniform grid with spacing 0.05 ) until the maximum change caused by an update is less than 1e2. Implement this solution scheme by filling in code for the functions initialize_1, update and iter_solve. initialize_1 should do what its name implies by imposing the boundary conditions on an input grid. update should do a single update step of the values at the grid points internal to the triangle. iter_solve should create an array to represent the relevant grid, repeatedly call update until the termination condition is met, and return the array of computed values (for plotting etc.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!