from matplotlib.pyplot import * from matplotlib.ticker import * from matplotlib import rc from PostProc.Data import Data from PostProc.Field import XField, YField if __name__ == '__main__': style = ('k--', 'k-.', 'co', 'mo', 'yo') label = ('CSF', 'SSF') fig1 = figure(1) pic1 = fig1.add_subplot(111) n = 0 for arg in argv[1:]: d = Data(arg) lx = d.XCV / float(d.NX) x = np.linspace(lx * 0.5, lx * 0.5 + lx * float(d.NX - 1), d.NX) y = 0.5 rx = XField(x, y, d) x = np.array(rx.x) p = np.array(rx.p) pic1.plot(x, p - p[0], style[n], label=label[n], linewidth=2) n += 1 xp = np.linspace(0, 1, 1000) pp = []
def show_figure(args, type_of_output, title): # rc('text' , usetex = True) # rc('text.latex', unicode = True) style = ('ro', 'g^', 'cd', 'ms', 'yH') label = ('WCSPH', 'ISPH') d = [] r = [] time = "" t = 0.0 fig = figure(1) pic2 = fig.add_subplot(212) pic1 = fig.add_subplot(211) for n in range(len(args) - 1): d = Data(args[n + 1]) lx = d.XCV / float(d.NX) ly = d.YCV / float(d.NY) x = 0.5 y = linspace(ly * 0.5, ly * 0.5 + ly * float(d.NY - 1), d.NY) r = YField(x, y, d) du = [] if n == 0: t = d.t y_a = linspace(0.0, 1.0, 150) u_a = couette(y_a, t, d.nu[0], 1.0, d.V_N, 500) for i in range(len(r.y)): du.append( abs(r.u[i] - couette(r.y[i], t, d.nu[0], 1.0, d.V_N, 500))) if n == 0: pic1.plot(y_a, u_a, linewidth=2) pic1.plot(r.y, r.u, style[n]) pic2.plot(r.y, du, style[n]) pic1.set_title(r"$t=%0.5f, u_0=%0.4f, \nu=%0.1f, \varrho=1.0$" % (t, d.V_N, d.nu[0]), size='x-large') #pic2.set_ylim(0.0, 0.0000004) #pic1.set_ylim(0.0, 0.0001) pic1.set_ylabel(r"$u_x$", size='xx-large') pic2.set_ylabel(r"$|u_x-u_x^{ex}|$", size='xx-large') pic2.set_xlabel(r"$y/L$", size='xx-large') setp(pic1.get_xticklabels(), visible=False) setp(pic1.get_xticklabels(), fontsize='large') setp(pic2.get_xticklabels(), fontsize='large') setp(pic1.get_yticklabels(), fontsize='large') setp(pic2.get_yticklabels(), fontsize='large') pic1.ticklabel_format(style='sci', scilimits=(0, 0), axis='y') pic2.ticklabel_format(style='sci', scilimits=(0, 0), axis='y') if type_of_output == 1: filename = str('%03d' % title) + '.png' fig.savefig(filename, dpi=80) fig.clf() else: show()
1.5279187999999999, 1.5532994, 1.5583756, 1.5736041000000001, 1.5837562999999999, 1.5939087000000001, 1.5989846999999999, 1.6040608999999999, 1.5989846999999999, 1.5939087000000001, 1.5837562999999999, 1.5736041000000001, 1.5532994, 1.5431471999999999, 1.5126903, 1.4873097, 1.4568528000000001, 1.4111674999999999, 1.3756344, 1.3451777, 1.3045685, 1.2639594000000001, 1.2436548000000001, 1.2233502999999999, 1.2131978999999999, 1.2030456, 1.1928934, 1.1827411999999999, 1.1827411999999999, 1.1675127000000001, 1.1675127000000001, 1.1573604, 1.1522843, 1.1370559, 1.1370559, 1.1218273999999999, 1.1218273999999999, 1.1116751, 1.1015229, 1.1015229, 1.0964468000000001, 1.0812181999999999, 1.0659898999999999, 1.0507614999999999, 1.0253806999999999, 1.0203046, 1.0203046 ] if __name__ == '__main__': d = Data(argv[1]) r = Field(d) extent = (0, d.XCV, 0, d.YCV) figure(figsize=(5.0 * d.XCV, 3.8 * d.YCV)) if (argv[-1] == '1'): plot(t1x, t1y, 'k-', linewidth=2) if (argv[-1] == '3'): plot(t3x, t3y, 'k-', linewidth=2) if (argv[-1] == '5'): plot(t5x, t5y, 'k-', linewidth=2) #imshow(r.d, cmap=cm.OrRd, origin='lower', extent=extent) #imshow(r.d, cmap=cm.autumn, origin='lower', extent=extent) #imshow(r.d, cmap=cm.spring, origin='lower', extent=extent) imshow(r.d, cmap=cm.summer, origin='lower', extent=extent) #imshow(r.d, cmap=cm.winter, origin='lower', extent=extent) #imshow(r[3], cmap=cm.spectral, origin='lower', extent=extent)
def show_figure(args, type_of_output, title): # rc('text' , usetex = True) # rc('text.latex', unicode = True) style = ('ro', 'go', 'co', 'mo', 'yo') label = ('WCSPH', 'ISPH') d = [] r = [] u0 = [] time = "" t = 0.0 fig = figure(1) pic1 = fig.add_subplot(211) pic2 = fig.add_subplot(212) for n in range(len(args) - 1): d = Data(args[n + 1]) lx = d.XCV / float(d.NX) ly = d.YCV / float(d.NY) x = 0.5 y = linspace(ly * 0.5, ly * 0.5 + ly * float(d.NY - 1), d.NY) r = YField(x, y, d) du = [] if n == 0: t = d.t y_a = linspace(0.0, 1.0, 150) u_a = poiseuille(y_a, t, d.nu[0], 1.0, d.G_X, 100) for i in range(len(r.y)): du.append( abs(r.u[i] - poiseuille(r.y[i], t, d.nu[0], 1.0, d.G_X, 100))) if n == 0: pic1.plot(y_a, u_a, linewidth=2, label="exact") pic1.plot(r.y, r.u, style[n], label=label[n]) pic2.plot(r.y, du, style[n]) pic1.set_title(r"$t = %f$" % (t), size='x-large') #pic2.set_ylim(0, 0.005) #pic1.set_ylim(0.0, 0.14) pic1.set_ylabel(r"$u_x$", size='xx-large') pic2.set_ylabel(r"$|u_x-u^{ex}_x|$", size='xx-large') pic2.set_xlabel(r"$y/L$", size='xx-large') pic1.legend(ncol=1, fancybox=True) #, loc=8) setp(pic1.get_xticklabels(), visible=False) setp(pic1.get_xticklabels(), fontsize='large') setp(pic2.get_xticklabels(), fontsize='large') setp(pic1.get_yticklabels(), fontsize='large') setp(pic2.get_yticklabels(), fontsize='large') if type_of_output == 1: filename = str('%03d' % title) + '.png' fig.savefig(filename, dpi=80) fig.clf() else: show()