Ejemplo n.º 1
0
def check_bloch_normalization(N, epsilon):
    Theta, Phi = inv.construct_grid(N)
    Angles = np.array([np.cos(Theta), Phi])
    Densities = inv.G_angles_q12(Angles, epsilon)
    Scaled_densities = Densities*np.sin(Theta)
    Total_prob = np.trapz(np.trapz(Scaled_densities, Phi), Theta[:,0])
    assert_greater(Total_prob, 0.95)
    assert_less_equal(Total_prob, 1)
                                     'given eigenbasis measurements ' +
                                     'in equivalence with Das-Arvind.')
    parser.add_argument('-e', '--epsilon', type=float, default=0.575,
                        help='Strength of the weak measurements')
    parser.add_argument('-N', type=int, default=256,
                        help='Resolution at which to calculate densities')
    parser.add_argument('-f', '--folder', type=str, default='../../data/',
                        help='Folder to write results to')
    args = parser.parse_args()

    data_file = h5py.File(args.folder + 'bloch_densities_e' +
                          str(args.epsilon) + '_N' + str(args.N) + '_' +
                          dt.utcnow().strftime('%Y%m%dT%H%M%SZ') + '.hdf5',
                          'w-')

    Theta, Phi = construct_grid(args.N)

    # Radial coordinates for a Lambert azimuthal equal-area projection
    R = 2*np.cos(pi/2 - Theta/2)

    X = np.sin(Theta) * np.cos(Phi)
    Y = np.sin(Theta) * np.sin(Phi)
    Z = np.cos(Theta)

    Angles = np.array([cos(Theta), Phi])

    Densities = G_angles_q12(Angles, args.epsilon)

    dataset = data_file.create_dataset('densities', data=Densities)
    dataset.attrs['epsilon'] = args.epsilon
    dataset.attrs['N'] = args.N