Пример #1
0
    # incident polarization of the light, [1,0,0] means light is polarized in x, [0,1,0] mean light is polarized in y
    if args.pol == 'p':
        E0_vec = np.array([1, 0, 0], dtype=complex)
    elif args.pol == 's':
        E0_vec = np.array([0, 1, 0], dtype=complex)
    # inciddent k vector [0,0,1] means light is travelling in +z axis
    k_vec = np.array(
        [np.sin(AOI) * np.cos(phi),
         np.sin(AOI) * np.sin(phi),
         np.cos(AOI)])
    # Dielectric function of surrounding medium
    eps_surround = args.N_m**2
    # Create lattice object
    Lat = Lattice(args.nx, args.ny, args.lc, args.a, args.b, args.c)
    N, pos, r_eff = getattr(Lat, args.Lat)()  # Call a class method by a string
    Lat.Grid_Viz()  # Visualize the grid

    # Create empy containers
    A = np.zeros([3 * N, 3 * N],
                 dtype='complex')  # A matrix of 3N x 3N filled with zeros
    p = np.zeros(
        3 * N, dtype='complex'
    )  # A vector that stores polarization Px, Py, Pz of the each particles, we will use this for initial guess for solver
    E0 = np.tile(
        E0_vec, N
    )  # A vector that has the Ex, Ey, Ez for each particles, we make this by tiling the E0_vec vector
    E_inc = np.zeros(
        3 * N, dtype='complex'
    )  # A vector storing the Incident Electric field , Einc_x, Einc_y, Einc_z for each particle

    n_wave = wave.size