Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write a code in any other programming language that carries out the same function as the following code: import numpy as np import copy

Please write a code in any other programming language that carries out the same function as the following code:

image text in transcribed

image text in transcribed

import numpy as np import copy import math # Set max iteration and convergence tolerance maximum = 50 error = 0.000001 # Set Dimension and Delta lenY= 11 lenX= 5 delta = 1 # Boundary condition Ttop = 7 Tbottom= 4 Tleft = 0 Tright = 6 #Initial guess Tguess=0.5 # Set array size and set the interior value with Tguess T= np.emptyl(leny, lenx)) T.Fill(Tguess) # Electric field array mEfield = np.empty(19,3)) X = None Y = None # Set Boundary condition Tf(leny-1):, :] =Tbottom TC:1, :] = Ttop TC:, (lenX-1):1 = Tright T:,:1) = Tleft # initial array print("This is the Array with initial guess at Free nodes ") print(T) # Iteration (We assume that the iteration is convergence in maximum = 50) print(" Please wait for a moment") for iteration in range(0, maximum): Compare = copy.deepcopy(T) for i in range(1, len Y-1, delta): forj in rangel1, lenX-1, delta): Ti il = 0.25 (Compare[i+1] [i] + Compare[i-1] ] + Compare[i][i+1] + Compare[i][i-1]) #print(T[i,j]) #this shows the answer of each iteration if (abs(Tijl-Compare[ij]))

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What is Indian Polity and Governance ?

Answered: 1 week ago