def plotAll2D(filename): dat = rc.readCheckpoint(filename) print("{0:s}: {1:s}".format(filename, rc.summary(*dat))) t = dat[0] x1 = dat[1] x2 = dat[2] prim = dat[3] pars = dat[5] X1, X2 = np.meshgrid(x1, x2, indexing='ij') fig, ax = plt.subplots(2,2,figsize=(12,9)) plot2DSingle(fig, ax[0,0], X1, X2, prim[:,:,0]) plot2DSingle(fig, ax[0,1], X1, X2, prim[:,:,1]) plot2DSingle(fig, ax[1,0], X1, X2, prim[:,:,2]) plot2DSingle(fig, ax[1,1], X1, X2, prim[:,:,3]) fig.suptitle("t = {0:.3f} ({1:s})".format(t, pars["GitHash"])) root = ".".join(filename.split("/")[-1].split(".")[:-1]) plotname = "{0:s}_{1:s}.png".format("plot2d", root) print(' Saving: {0:s}'.format(plotname)) fig.savefig(plotname) plt.close(fig)
def loadCheckpoint(self, filename): dat = rc.readCheckpoint(filename) r = dat[1] z = dat[3] piph = dat[11] if self._checkSame(r, z, piph): print("Looks like the same grid! Copying...") self._loadCheckpointIdentical(dat) else: print("Given checkpoint has different grid structure, can not load.")
def analyze(fname, p=1, plot=True, clip=True): t, x1, x2, prim, cons, pars = rc.readCheckpoint(fname) n1 = pars['Nx1'] n2 = pars['Nx2'] l1 = pars['X1max'] - pars['X1min'] l2 = pars['X2max'] - pars['X2min'] gam = pars['GammaLaw'] rho0 = pars['InitPar1'] P0 = pars['InitPar2'] a = pars['InitPar5'] rho = prim[:, :, 0] P = prim[:, :, 1] v1 = prim[:, :, 2] v2 = prim[:, :, 3] if clip: maxV = ((1.0+gam)*math.pow(1.0+a,0.5*(gam-1)) - 2) / (gam-1.0) \ * math.sqrt(gam*P0/rho0) ind1, ind2, ind1c, ind2c = clipInd(x1, x2, maxV * t, pars) rho = rho[ind1c][:, ind2c] P = P[ind1c][:, ind2c] v1 = v1[ind1c][:, ind2c] v2 = v2[ind1c][:, ind2c] x1 = x1[ind1] x2 = x2[ind2] rho_e, P_e, v1_e, v2_e, XX = isentrope(x1, x2, t, pars) if plot: fig, ax = plt.subplots(2, 2) ax[0, 0].plot(XX, rho_e, 'k+') ax[0, 0].plot(XX, rho, 'b+') ax[0, 1].plot(XX, P_e, 'k+') ax[0, 1].plot(XX, P, 'b+') ax[1, 0].plot(XX, v1_e, 'k+') ax[1, 0].plot(XX, v1, 'b+') ax[1, 1].plot(XX, v2_e, 'k+') ax[1, 1].plot(XX, v2, 'b+') else: fig = None dV = DV(x1, x2, pars) err_rho = math.pow((np.power(np.fabs(rho - rho_e), p) * dV).sum(), 1.0 / p) err_P = math.pow((np.power(np.fabs(P - P_e), p) * dV).sum(), 1.0 / p) err_v1 = math.pow((np.power(np.fabs(v1 - v1_e), p) * dV).sum(), 1.0 / p) err_v2 = math.pow((np.power(np.fabs(v2 - v2_e), p) * dV).sum(), 1.0 / p) return n1, n2, l1, l2, err_rho, err_P, err_v1, err_v2, fig
def plotAll2D(filename): dat = rc.readCheckpoint(filename) print("{0:s}: {1:s}".format(filename, rc.summary(*dat))) t = dat[0] x1 = dat[1] x2 = dat[2] prim = dat[3] pars = dat[5] geom = pars['Geometry'] if geom == 1 or geom == 3 or geom == 4 or geom == 5: X2, X1 = np.meshgrid(x1, x2, indexing='ij') sub_kw=dict(projection='polar') else: X1, X2 = np.meshgrid(x1, x2, indexing='ij') sub_kw=dict(projection='rectilinear') fig, ax = plt.subplots(2,2,figsize=(20,16), subplot_kw=sub_kw) plot2DSingle(fig, ax[0,0], X1, X2, prim[:,:,0]) plot2DSingle(fig, ax[0,1], X1, X2, prim[:,:,1]) plot2DSingle(fig, ax[1,0], X1, X2, prim[:,:,2]) plot2DSingle(fig, ax[1,1], X1, X2, prim[:,:,3]) fig.suptitle("t = {0:.3f} ({1:s})".format(t, pars["GitHash"])) root = ".".join(filename.split("/")[-1].split(".")[:-1]) plotname = "{0:s}_{1:s}.png".format("plot2d", root) print(' Saving: {0:s}'.format(plotname)) fig.savefig(plotname) plt.close(fig)