It is necessary to solve the problem of thermal conductivity on the segment
The solution used an explicit scheme
N = 10> # maximum number of steps in xK = 10 # maximum number of steps in tl = l = 1 # value of x on the right borderh = l /N # grid# grid pitch along xT= 1 # maximum time value t on the right bordert = T/K # grid step by time# setting the grid x_i = np.arange(0, N, h) # values in nodes of xt_j = np.arange(0, K, t) # value in nodes by tr_j=ass=""># value in nodes by tr_j= len(t_j) # number of nodes by tr_i = len(x_i) # number of nodes by xw_h_t = np.zeros([r_i, r_j]) # final grid size x_i*t_j# set the value of the function included in the initial equationx =nx = 0defdef f(x): retu np.sin(x)# boundary conditions# boundary coditionsux_0 = 1 # boundary condition at the left end at x=0ut_0 = np.cos(x_i) # boundary condition at t=0# find the values at zero layer at t=0 ut_0 = np.cos(x_i)w_h_t[0] = np.cos(x_i)# find the values of w_h_t on the first and subsequent layersconst = t / (h**2) forfor j ins="">in range(1, len(x_i)-1): 1): for i in range(len(w_h_t[j])-1): w_h_t[j+1, i] = w_h_t[j, i] + const * (w_h_t[j,i] - 2*w_h_t[j,i] + w_h_t[j, i-1]) + t*f(x_i[j]) w_h_t[j+1, 0] = 1 w_h_t[j+1, len(w_h_t[i])-1] = w_h_t[j+1, len(w_h_t[i])-2] + h * t_j[j+1]plot_ = np.arange(0,len(w_h_t)-1,1)foran>,1)for y inpan> plot_: plt.plot(x_i, w_h_t[y]) As a result, I got this graph of the dependence of X on the calculated value of the function at the nodes of the grid
I don't understand how wrong my decision is. I had problems finding a private solution, wolfram gave u(x) = 1.54x+1+sinx, which doesn't seem right to me, but I couldn't solve it myself. There were no similar examples in Filippov's textbook, and I didn't find anything detailed enough on the Web to figure out the solution. Can you tell me where I can find how to solve such an equation analytically and how wrong is my solution? What is the error? And how is it generally checked for the correctness of solving such problems, except for comparison with an analytical solution?
In general, I figured it out. I decided to add an edited solution to my question, perhaps it will be useful to someone. The numerical solution has not been found correctly, but it is found by the Fourier method (separation of variables). Final schedule:
Working code:
N = 10> # maximum number of steps in xK = 500 # maximum number of steps in tl = l = 1 # value of x on the right borderh = l /N # grid# grid pitch along xT= 1 # maximum time value t on the right bordert = T/K # grid time step# set the grid x_i = np.range(0, 1, h) # values in nodes of xt_j = np.arange(0, 1, t) # value in nodes by tr_j =ss=""># value in nodes by tr_j = len(t_j) # number of nodes by tr_i = len(x_i) # number of nodes by xw_h_t = np.zeros([r_j, r_i]) # final grid size x_i*t_j# set the value of the function included in the initial equationx =nx = 0defdef f(x): retu np.sin(x)# boundary conditions# boundary coditionsux_0 = 1 # boundary condition at the left end at x=0ut_0 = np.cos(x_i) # boundary condition at t=0# find the values at zero layer at t=0 ut_0 = np.cos(x_i)w_h_t[0] = np.cos(x_i)# find the values of w_h_t on the first and subsequent layersconst = t / (h**2) forfor j ins="">in range(len(w_h_t) - 1): 1): for i in range(len(w_h_t[j]) - 1): w_h_t[j + 1, i] = w_h_t[j, i] + const* (w_h_t[j, i+1] - 2/span> * w_h_t[j, i] + w_h_t[j, i - 1]) + t*f(x_i[i]) w_h_t[j + 1, 0] = 1 w_h_t[j + 1, len(w_h_t[i])-1] = w_h_t[j + 1, len(w_h_t[i])-1] + h
question@mail.ru
·