u = lambda x, t: u_(x, t, x_0, c_0, xA, xB) x_i, x_f = 0, 2000 t_i, t_f = 0, 40 Nx = 201 Nt = 201 x = np.linspace(x_i, x_f, Nx) t = np.linspace(t_i, t_f, Nt) X, T = np.meshgrid(x, t) #%% Ritter HR = h(X, T) UR = u(X, T) #%% Initial condition plot1D(x, HR[-1]) #%% Evolution plot2D(x, t, HR) #%% 3D plot3D(X, T, HR) #%% Initial condition plot1D(x, UR[0]) #%% Evolution plot2D(x, t, UR) #%% 3D plot3D(X, T, UR)
u = lambda x, t: u_(x, t, x_0, c_0, xA, xB) x_i, x_f = 0, 2000 t_i, t_f = 0, 40 Nx = 201 Nt = 201 x = np.linspace(x_i, x_f, Nx) t = np.linspace(t_i, t_f, Nt) X, T = np.meshgrid(x, t) #%% Dressler HD = h(X, T) UD = u(X, T) #%% Initial condition plot1D(x, HD[0]) #%% Evolution plot2D(x, t, HD) #%% 3D plot3D(X, T, HD) #%% Initial condition plot1D(x, UD[0]) #%% Evolution plot2D(x, t, UD) #%% 3D plot3D(X, T, UD)
u = lambda x, t: u_(x, t, x_0, c_0, c_m, xA, xB, xC) x_i, x_f = 0, 2000 t_i, t_f = 0, 40 Nx = 201 Nt = 201 x = np.linspace(x_i, x_f, Nx) t = np.linspace(t_i, t_f, Nt) X, T = np.meshgrid(x, t) #%% Ritter HS = h(X, T) US = u(X, T) #%% Initial condition plot1D(x, HS[0]) #%% End plot1D(x, HS[-1]) #%% Evolution plot2D(x, t, HS) #%% 3D plot3D(X, T, HS) #%% Initial condition plot1D(x, US[-1]) #%% Evolution plot2D(x, t, US)
import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from plot import plot1D # Read file t, x, y, z, v_x, v_y, v_z = np.loadtxt("../output/output.txt", unpack=True) ############################################################## # t, x, v plot (1D) : select desired components to plot ############################################################## # Plot t, x, v_x (plot1d function in plot1D.py) plot1D(t, x, v_x) ############################################################## # 3D Trajectory Plot: comes after user closes previous 2 windows ############################################################## # Plot 3D trajectory fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.plot(x, y, z) ### Set axes limits here: #ax.set_xlim3d(0, 2) #ax.set_ylim3d(-1, 1) #ax.set_zlim3d(0, 10) ax.set_xlabel('x') ax.set_ylabel('y') ax.set_zlabel('z')
def OnPlot1D(self, event): if (not self.IsXmlRead): wx.MessageBox("No xml file loaded!", "Warning!", wx.OK | wx.ICON_EXCLAMATION, self) return if (not self.IsChargeRead): wx.MessageBox("No charge file loaded!", "Warning!", wx.OK | wx.ICON_EXCLAMATION, self) return try: # Create the Plot1D Dialog and get the x0,e1,nx values dlg = Plot1DDialog() result = dlg.ShowModal() dlg.Destroy() if result == wx.ID_OK: selection = int(dlg.radiobox.GetSelection()) x0 = np.array([float(dlg.x0_0.GetValue()), float(dlg.x0_1.GetValue()), float(dlg.x0_2.GetValue())]) e1 = np.array([float(dlg.e1_0.GetValue()), float(dlg.e1_1.GetValue()),float(dlg.e1_2.GetValue())]) nx = int(dlg.nx.GetValue()) # Compute the G vectors if needed self.SetStatusText("Generating the g vectors...") try: self.G except: self.G, discard = compute_Gs(self.b,self.charge.shape,self.ecutrho,self.alat) if (selection==0): try: toplot = self.charge except: wx.MessageBox("No charge file loaded!", "Warning!", wx.OK | wx.ICON_EXCLAMATION, self) return elif (selection==1): try: toplot = self.v_bare except: wx.MessageBox("No Vbare calculated!", "Warning!", wx.OK | wx.ICON_EXCLAMATION, self) return elif (selection==2): try: toplot = self.v_bare + self.v_h except: wx.MessageBox("No Vbare+VH calculated!", "Warning!", wx.OK | wx.ICON_EXCLAMATION, self) return elif (selection==3): try: toplot = self.v_bare + self.v_h + self.v_xc except: wx.MessageBox("No Vbare+VH calculated!", "Warning!", wx.OK | wx.ICON_EXCLAMATION, self) return self.SetStatusText("Plotting...") self.plot1D = plot1D(toplot,self.G,self.a,x0,e1,nx,selection) self.plot1D.show() self.SetStatusText("Plotting... done!") except: wx.MessageBox("Something wrong while plotting the charge...", "", wx.OK | wx.ICON_EXCLAMATION, self) self.SetStatusText("")
Ny=Ny, Nt=Nt, xf=xf, yf=yf, tf=tf, bc=bc, h0=lambda x, y: h0(x, y, .1, .1), u0=u0, v0=v0, ) #%% QUESTION 2.1 ### tr, Xr, Yr, Hr, Ur, Vr = exp.solveVF('rk4') #%% Plot exp 1 plot1D(tr, Hr[:, Ny // 2, Nx // 2]) #%% n = 250 # for n in range(len(tr)): # if n % 100 == 0: # print(n) plot2D(Xr, Yr, Hr[n]) #%% plot3D(Xr, Yr, Hr[n]) #%% quiver(Xr, Yr, Ur[125], Vr[125]) #%% QUESTION 2.2 - Coriolis effect %%
pars = get_plot_input_parameters() print (pars) # get some needed values from the xml output ecutwfc, ecutrho, ibrav, alat, a, b, functional, atomic_positions, atomic_species,\ nat, ntyp = get_from_xml(pars.prefix+".xml",settings.schema) celldms = calcola_celldm(alat,a[0],a[1],a[2],ibrav) charge = read_postqe_output_file(pars.filein) if (pars.iplot==1): # Read the charge and write it in filpl x0 = [pars.x0_1,pars.x0_2,pars.x0_3] e1 = [pars.e1_1,pars.e1_2,pars.e1_3] nx = pars.nx G = compute_G(b,charge.shape,ecutrho,alat) fig = plot1D(charge,G,a,x0,e1,nx) fig.show() elif (pars.iplot==2): x0 = [pars.x0_1,pars.x0_2,pars.x0_3] e1 = [pars.e1_1,pars.e1_2,pars.e1_3] nx = pars.nx e2 = [pars.e2_1,pars.e2_2,pars.e2_3] ny = pars.ny G = compute_G(b,charge.shape,ecutrho,alat) fig = plot2D(charge,G,a,x0,e1,e2,nx,ny) fig.show() else: print ("Not implemented yet.") end_time = time.time()
tf=tf, bc=bc, h0=lambda x, y: h0(x, y, .1, .1), #h0 = h0g, u0=u0, v0=v0, ) #%% QUESTION 2.1 - Experiments changing H value ### #%% Exp 1 exp.H = .1 t1, X1, Y1, H1, U1, V1 = exp.solvePDE() #%% Plot exp 1 plot1D(t1, H1[:, Ny // 2, Nx // 2]) #%% Exp 2 exp.H = .5 t2, X2, Y2, H2, U2, V2 = exp.solvePDE() #%% Plot exp 2 plot1D(t2, H2[:, Ny // 2, Nx // 2]) #%% Exp 3 exp.H = 1 t3, X3, Y3, H3, U3, V3 = exp.solvePDE() #%% Plot exp 3 plot1D(t3, H3[:, Ny // 2, Nx // 2])