:param U: :param t: :return: """ plt.figure(fign) plt.plot() plt.pcolor(x, t, U, cmap='RdBu') plt.colorbar() plt.title(title) plt.xlabel('x (mm)') plt.ylabel(r'time ($\mu$s)') #plt.show() if __name__ == "__main__": solver = WRKR(f, s, N=N, x0=0.0, xf=L, t0=0.0, tf=tf, dim=5) U_0 = init_cond(printout=True, x=solver.x) print(f'solver.x.shape = {solver.x.shape}') print(f'U_0.shape = {U_0.shape}') # Solve Urk3, solrk3 = solver.rk3(U_0) # self.U_0_sol #Ue, sole = solver.euler(U_0) # self.U_0_sol U = solrk3 plot_u_t(solver.x, solver.t, U[:, 0, :], title=r'Density $\rho$ (g/mm$^3$)', fign=1) plot_u_t(solver.x,
tf = 0.07 tf = 0.05 tf = 0.14 #tf = 0.0165 #1tf = 0.2 #tf = 0.06 #tf = 1 #tf = 0.3 #tf = 0.75 solver = WRKR( f, s, N=N, #x0=-2.0, x0=-0.4, #xf=2.0, xf=0.4, t0=0.0, #tf=0.014, tf=tf, #dt=0.002, #dt=.02, dim=3) # IC's U_0 = IC(solver.xc) #print(f'U_0 = {U_0}') #print(f'U_0[0] = {U_0[0]}') #print(f'U_0[1] = {U_0[1]}') #print(f'U_0[2] = {U_0[2]}') Urk3, solrk3 = solver.rk3(U_0) # self.U_0_sol # Ue, sole = solver.euler(U_0) # self.U_0_sol
:param U: :return: """ C = np.ones_like(U) S = np.zeros_like(U) return S, C if __name__ == "__main__": # Domain N = 120 # Number of discrete spatial elements solver = WRKR( f, s, N=120, x0=-0.4, xf=0.4, t0=0.0, #tf=2.0, tf=0.005, ) # Initial conditions U_0 = ic(solver.x) U_0 = np.append(U_0, U_0[-solver.gc:]) U_0 = np.append(U_0[0:solver.gc], U_0) U_0 = np.atleast_2d(U_0) # Solve Urk3, solrk3 = solver.rk3(U_0) # self.U_0_sol Ue, sole = solver.euler(U_0) # self.U_0_sol if 1:
def s(U, F, pp): """ Compute s, given U :param U: :return: """ C = np.ones_like(U) S = np.zeros_like(U) return S, C if __name__ == "__main__": N = 81 solver = WRKR(f, s, N=N, x0=0.0, xf=2.0, t0=0.0, tf=0.5, dt=.02) # IC's U_0 = np.zeros(N) # U_0 = np.zeros([2, N]) U_0[int(.5 / solver.dx):int(1 / solver.dx + 1)] = 2 #sol = solver.rk3(U_0) # self.U_0_sol U_0 = np.atleast_2d(U_0) # Add ghost cells U_0 = np.hstack((U_0, U_0[:, -solver.gc:])) U_0 = np.hstack((U_0[:, -solver.gc:], U_0)) # Solve Urk3, solrk3 = solver.rk3(U_0) # self.U_0_sol Ue, sole = solver.euler(U_0) # self.U_0_sol #print(f'sol = {sol}') #fsol = self.U_0_sol
plt.title(title) plt.xlabel('x (mm)') plt.ylabel(r'time ($\mu$s)') #plt.axis('scaled') #plt.set_size_inches(18.5, 10.5) #plt.show() if __name__ == "__main__": solver = WRKR( f, s, N=N, x0=0.0, xf=L, t0=0.0, #tf=tf, #dt=0.5*tf, tf=tf, #dt=0.5*tf, flux_bc=BC_flux, bc=BC, dim=5, #k=k k=50) gc = solver.gc # Compute e_0 #e_0 = e_0_guess #e_0 = e(p_0, v_0, lambd_0, phi_0) #U_0 = init_cond(e_0, printout=True, x=solver.x) U_0 = init_cond(x=solver.x, gc=solver.gc) # Solve
# tf = 1.2 #tf = 0.01 #tf = 0.2 #tf = 0. #tf = 1.0 # tf = 0.4 #tf = 2.0 #tf = 0.6 # tf = 0.06 solver = WRKR( f, s, flux_bc=BC_flux, bc=BC, N=N, x0=0.0, xf=2.0, t0=0.0, tf=tf, dim=3, #dt= 0.001 k=3 #k=500 ) # IC's #U_0 = np.zeros(N) #U_0 = np.zeros([2, N]) #U_0[:, int(.5 / solver.dx): int(1 / solver.dx + 1)] = 2 #sol = solver.rk3(U_0) # self.U_0_sol #U_0 = np.atleast_2d(U_0) # Add ghost cells #U_0 = np.hstack((U_0, U_0[:, -solver.gc:])) #U_0 = np.hstack((U_0[:, -solver.gc:], U_0))