Exemplo n.º 1
0
print("Mean Error: " + str(np.mean(err)))

# Plot the analytical solution in polar coordinates
X = xTest[0] * np.cos(xTest[1])
Y = xTest[0] * np.sin(xTest[1])

# Create plots
if usePlotly:
    from tfc.utils.PlotlyMakePlot import MakePlot

    p = MakePlot(r'x', r'y', zlabs=r'u(x,y)')
    p.Surface(x=X.reshape((nTest, nTest)),
              y=Y.reshape((nTest, nTest)),
              z=real(*xTest).reshape((nTest, nTest)),
              showscale=False)
    p.view(azimuth=45, elevation=45)
    p.fig['layout']['scene']['aspectmode'] = 'cube'
    p.show()

    p1 = MakePlot('x', 'y', zlabs='error')
    p1.Surface(x=xTest[0].reshape((nTest, nTest)),
               y=xTest[1].reshape((nTest, nTest)),
               z=err.reshape((nTest, nTest)),
               showscale=False)
    p1.show()

else:
    from matplotlib import cm
    from tfc.utils import MakePlot

    xlabs = [[r'$x$', r'$x$'], ['', r'$x$']]
Exemplo n.º 2
0
err = np.abs(u(xi, *xTest) - real(*xTest))
print("Time: " + str(time))
print("Max Error: " + str(np.max(err)))
print("Mean Error: " + str(np.mean(err)))

# Plot the analytical solution
if usePlotly:
    from matplotlib import cm
    from tfc.utils.PlotlyMakePlot import MakePlot

    p = MakePlot(r'x', r'y', zlabs=r'u(x,y)')
    p.Surface(x=xTest[0].reshape((nTest, nTest)),
              y=xTest[1].reshape((nTest, nTest)),
              z=real(*xTest).reshape((nTest, nTest)),
              showscale=False)
    p.view(azimuth=-135, elevation=20)
    p.fig['layout']['scene']['aspectmode'] = 'cube'
    p.show()

else:
    from tfc.utils import MakePlot

    p = MakePlot(r'$x$', r'$y$', zlabs=r'$u(x,y)$')
    p.ax[0].plot_surface(xTest[0].reshape((nTest, nTest)),
                         xTest[1].reshape((nTest, nTest)),
                         real(*xTest).reshape((nTest, nTest)),
                         cmap=cm.gist_rainbow)

    p.ax[0].tick_params(axis='z', which='major', pad=10)
    p.ax[0].xaxis.labelpad = 20
    p.ax[0].yaxis.labelpad = 20