Question: You should write a Python program that timesteps through and prints the solutions at each timestep, according to the following parameters: # Domain parameters L

 You should write a Python program that timesteps through and prints

the solutions at each timestep, according to the following parameters: # Domain

You should write a Python program that timesteps through and prints the solutions at each timestep, according to the following parameters: # Domain parameters L = 1.0 # Length of domain NPOINTS = 5 # Number of points for discretisation DT = 0.1 # delta_t timestep size TN = 10.0 # t_n last time h = float(L/(NPOINTS-1)) # Physical parameters k = 1.0 # Conductivity c = 2.0 # Heat capacity rho = 5.0 # Density r = (k*DT)/(c*rho*h*h) # Assume all points start off with this value at time t=0 initial_value = 0.0 # Boundary conditions left_bc = 0.0 right_bc = 100.0 Formatting the output neatly for a variable number of points can be just a little tricky, so Im helping you out with that part (there may be a more concise way than Ive shown): # Create a format string for variable number of points fmtstr = "{:4.1f}" for idx in range(NPOINTS): fmtstr += " {:7.2f}" # Put the timestep plus point values in a single list the_list = [t] + list(u_new) # Print the timestep and values according to formatting above print(fmtstr.format(*the_list)) I recommend the following approach to solve these problems ? Fill your coefficient matrix for the given problem specifications. Since this is a linear problem, you only need to do this once. ? Compute the inverse or the LU factorization of the coefficient matrix. Again, you only need to do this once for a given set of physical conditions. ? Iterate through the timestepping with new RHS vectors at each step, and convince yourself that your results are believable. Then, as before, you should derive two experiments where you know what the physical answer would be, run the experiment, and verify that you are getting the expected result. Again, this is meant as a sanity check in a world where we need something simple to help convince us that our model is behaving as expected. Then, you should try two more experiments in which you vary physical parameters, like , , etc. Determine how you think these changes should affect your model run, then verify that you see that.

Letting cph the ith equation is t+At So, the system of equations looks like -(2r r t+At r 2r 1) t+At Letting cph the ith equation is t+At So, the system of equations looks like -(2r r t+At r 2r 1) t+At

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!