Esempio n. 1
0
def convergence_test():
    '''

    Used to obtain plots of L1 norm versus parameters (Number of elements
    or N_LGL).
    
    '''
    L1_norm_option_1 = np.zeros([15])
    N_lgl            = (np.arange(15) + 3).astype(float)
    L1_norm_option_3 = np.zeros([15])

    for i in range(0, 15):
        test_waveEqn.change_parameters(i + 3, 15, i + 3)
        u_diff = wave_equation.time_evolution()
        L1_norm_option_1[i] = L1_norm(u_diff)
        test_waveEqn.change_parameters(i + 3, 15, i + 4)
        u_diff = wave_equation.time_evolution()
        L1_norm_option_3[i] = L1_norm(u_diff)


    print(L1_norm_option_1, L1_norm_option_3)
    normalization = 0.00281 / (3 **(-3))
    plt.loglog(N_lgl, L1_norm_option_1, marker='o', label='option 1')
    plt.loglog(N_lgl, L1_norm_option_3, marker='o', label='option 3')
    plt.xlabel('No. of LGL points')
    plt.ylabel('L1 norm of error')
    plt.title('L1 norm after 1 full advection')
    plt.loglog(N_lgl, normalization * N_lgl **(-N_lgl), color='black',\
                          linestyle='--', label='$N_{LGL}^{-N_{LGL}}$')
    plt.legend(loc='best')

    plt.show()

    return
Esempio n. 2
0
    #B_00 = 0.2
    #B_01 = 0.5

    #E_z_init = E_00 * af.sin(2 * np.pi * params.element_LGL) \
            #+ E_01 * af.cos(2 * np.pi * params.element_LGL)

    #B_y_init = B_00 * af.sin(2 * np.pi * params.element_LGL) \
            #+ B_01 * af.cos(2 * np.pi * params.element_LGL)
    
    ## 2. Gaussian
    #E_0 = 1.
    #B_0 = 1.
    
    #sigma = 0.1
    
    #E_z_init = E_0 * np.e**(-(params.element_LGL)**2 / sigma**2)
    #B_y_init = B_0 * np.e**(-(params.element_LGL)**2 / sigma**2)
    
    
    ###############################################################
    ####################### SET u_init ############################
    ###############################################################
    #u_init = af.constant(0., d0 = params.N_LGL, d1 = params.N_Elements, d2 = 2)
    #u_init[:, :, 0] = E_z_init
    #u_init[:, :, 1] = B_y_init
    
    u_init = params.u_init
    
    u_diff = wave_equation.time_evolution(u_init)