예제 #1
0
def non_physical_behavior(I, a, T, dt, theta):
    """
    Given lists/arrays a and dt, and numbers I, dt, and theta,
    make a two-dimensional contour line B=0.5, where B=1>0.5
    means oscillatory (unstable) solution, and B=0<0.5 means
    monotone solution of u'=-au.
    """
    a = np.asarray(a); dt = np.asarray(dt)  # must be arrays
    B = np.zeros((len(a), len(dt)))         # results
    for i in range(len(a)):
        for j in range(len(dt)):
            u, t = solver(I, a[i], T, dt[j], theta)
            # Does u have the right monotone decay properties?
            correct_qualitative_behavior = True
            for n in range(1, len(u)):
                if u[n] > u[n-1]:  # Not decaying?
                    correct_qualitative_behavior = False
                    break  # Jump out of loop
            B[i,j] = float(correct_qualitative_behavior)
    a_, dt_ = st.ndgrid(a, dt)  # make mesh of a and dt values
    st.contour(a_, dt_, B, 1)
    st.grid('on')
    st.title('theta=%g' % theta)
    st.xlabel('a'); st.ylabel('dt')
    st.savefig('osc_region_theta_%s.png' % theta)
    st.savefig('osc_region_theta_%s.pdf' % theta)
예제 #2
0
def test_easyviz():
    from scitools.std import linspace, ndgrid, plot, contour, peaks, \
         quiver, surfc, backend, get_backend
    n = 21
    x = linspace(-3, 3, n)
    xx, yy = ndgrid(x, x, sparse=False)

    # a basic plot
    plot(x, x**2, 'bx:')
    wait()

    if backend in ['gnuplot', 'vtk', 'matlab', 'dx', 'visit', 'veusz']:
        # a contour plot
        contour(peaks(n), title="contour plot")
        wait()

        # a vector plot
        uu = yy
        vv = xx
        quiver(xx, yy, uu, vv)
        wait()

        # a surface plot with contours
        zz = peaks(xx, yy)
        surfc(xx, yy, zz, colorbar=True)
        wait()

    if backend == 'grace':
        g = get_backend()
        g('exit')
예제 #3
0
def non_physical_behavior(I, a, T, dt, theta):
    """
    Given lists/arrays a and dt, and numbers I, dt, and theta,
    make a two-dimensional contour line B=0.5, where B=1>0.5
    means oscillatory (unstable) solution, and B=0<0.5 means
    monotone solution of u'=-au.
    """
    a = np.asarray(a)
    dt = np.asarray(dt)  # must be arrays
    B = np.zeros((len(a), len(dt)))  # results
    for i in range(len(a)):
        for j in range(len(dt)):
            u, t = solver(I, a[i], T, dt[j], theta)
            # Does u have the right monotone decay properties?
            correct_qualitative_behavior = True
            for n in range(1, len(u)):
                if u[n] > u[n - 1]:  # Not decaying?
                    correct_qualitative_behavior = False
                    break  # Jump out of loop
            B[i, j] = float(correct_qualitative_behavior)
    a_, dt_ = st.ndgrid(a, dt)  # make mesh of a and dt values
    st.contour(a_, dt_, B, 1)
    st.grid('on')
    st.title('theta=%g' % theta)
    st.xlabel('a')
    st.ylabel('dt')
    st.savefig('osc_region_theta_%s.png' % theta)
    st.savefig('osc_region_theta_%s.eps' % theta)
예제 #4
0
def test_easyviz():
    from scitools.std import linspace, ndgrid, plot, contour, peaks, \
         quiver, surfc, backend, get_backend
    n = 21
    x = linspace(-3, 3, n)
    xx, yy = ndgrid(x, x, sparse=False)

    # a basic plot
    plot(x, x**2, 'bx:')
    wait()

    if backend in ['gnuplot', 'vtk', 'matlab', 'dx', 'visit', 'veusz']:
        # a contour plot
        contour(peaks(n), title="contour plot")
        wait()

        # a vector plot
        uu = yy
        vv = xx
        quiver(xx, yy, uu, vv)
        wait()

        # a surface plot with contours
        zz = peaks(xx, yy)
        surfc(xx, yy, zz, colorbar=True)
        wait()

    if backend == 'grace':
        g = get_backend()
        g('exit')