예제 #1
0
파일: test_md.py 프로젝트: chemlab/chemlab
def test_ewald():
    particles1 = [[0.0, 0, 0], [0.5, 0.5, 0.5]]
    types1 = ["Li", "Cl"]
    box = [1.0, 1.0, 1.0]
    
    li = Molecule([Atom('Li', [0, 0, 0], name='Li+')])
    cl = Molecule([Atom('Cl', [0, 0, 0], name='Cl-')])

    cell_par = 2.0
    rocksalt = crystal([[0.0, 0.0, 0.0], [0.5, 0.5, 0.5]], # Fractional Positions
            [li, cl], # Molecules
            225, # Space Group
            cellpar = [cell_par, cell_par, cell_par, 90, 90, 90], # unit cell parameters
            repetitions = [1, 1, 1]) # unit cell repetitions in each direction
    
    particles1 = rocksalt.r_array
    types1 = rocksalt.type_array.astype("S2")
    box = np.diagonal(rocksalt.box_vectors)
    
    # for k_max in (2, 3, 4, 5, 6):
    rcut = cell_par * 4
    ewald = Ewald({"Li": 1, "Cl": -1}, rcut=rcut, alpha=(3.6/0.9)**0.5, kmax=10)
    result = ewald.real(particles1, types1, particles1, types1, box)

    print("Real", result)
    result = ewald.reciprocal(particles1, types1, particles1, types1, box)
    print("Reciprocal", result)
    print("Whole", ewald.interaction(particles1, types1, particles1, types1, box) / 2)

    print("Madelung", madelung(rmin(rocksalt), ROCKSALT_M)/2)
예제 #2
0
파일: test_md.py 프로젝트: yccai/chemlab
def test_ewald_wurtzite():
    particles1 = [[0.0, 0, 0], [0.5, 0.5, 0.5]]
    types1 = ["Li", "Cl"]
    box = [1.0, 1.0, 1.0]

    li = Molecule([Atom('Li', [0, 0, 0], name='Li+')])
    cl = Molecule([Atom('Cl', [0, 0, 0], name='Cl-')])

    cell_param = 0.45
    wurtz = crystal(
        [[2 / 3., 1 / 3., 0.0], [2 / 3., 1 / 3., 3 / 8.]
         ],  # Fractional Positions
        [li, cl],  # Molecules
        186,  # Space Group
        cellpar=[
            cell_param * 1., cell_param * 1., cell_param * 2. * (2 / 3.)**0.5,
            90, 90, 120
        ],  # unit cell parameters
        repetitions=[1, 1, 1])  # unit cell repetitions in each direction

    # Volume is the same
    a, b, c = wurtz.box_vectors
    #
    # print("Volume 1", np.dot(a, np.cross(b, c)))
    # print("Volume 2", np.prod(np.diagonal(wurtz.box_vectors)))

    # straight_box = np.diag(np.diagonal(wurtz.box_vectors))
    # wurtz.box_vectors = straight_box
    # wurtz.r_array = minimum_image(wurtz.r_array + cell_param/2, np.diagonal(wurtz.box_vectors))

    particles1 = wurtz.r_array
    types1 = wurtz.type_array.astype("S2")
    # box = np.diagonal(wurtz.box_vectors)
    box = wurtz.box_vectors

    # for k_max in (2, 3, 4, 5, 6):
    rcut = cell_param * 4
    ewald = Ewald({
        "Li": 1,
        "Cl": -1
    },
                  rcut=rcut,
                  alpha=(3.6 / 0.9)**0.5,
                  kmax=10)
    result = ewald.real(particles1, types1, particles1, types1, box)

    # print("Real", result)
    # result = ewald.reciprocal(particles1, types1, particles1, types1, box)
    # print("Reciprocal", result)
    # print("Dipole", ewald.dipole_correction(particles1, types1, box) / 4)
    print("Whole",
          ewald.interaction(particles1, types1, particles1, types1, box) / 2)
    print("Madelung", madelung(rmin(wurtz), WURTZ_M) / 2)
예제 #3
0
파일: test_md.py 프로젝트: chemlab/chemlab
def test_ewald_wurtzite():
    particles1 = [[0.0, 0, 0], [0.5, 0.5, 0.5]]
    types1 = ["Li", "Cl"]
    box = [1.0, 1.0, 1.0]
    
    li = Molecule([Atom('Li', [0, 0, 0], name='Li+')])
    cl = Molecule([Atom('Cl', [0, 0, 0], name='Cl-')])

    cell_param = 0.45
    wurtz = crystal([[2/3., 1/3., 0.0], [2/3., 1/3., 3/8.]], # Fractional Positions
                [li,  cl], # Molecules
                186, # Space Group
                cellpar = [cell_param * 1., cell_param * 1., cell_param * 2. * (2/3.)**0.5, 90, 90, 120], # unit cell parameters
                repetitions = [1, 1, 1]) # unit cell repetitions in each direction
    
    # Volume is the same
    a, b, c = wurtz.box_vectors
    # 
    # print("Volume 1", np.dot(a, np.cross(b, c)))
    # print("Volume 2", np.prod(np.diagonal(wurtz.box_vectors)))

    # straight_box = np.diag(np.diagonal(wurtz.box_vectors))
    # wurtz.box_vectors = straight_box
    # wurtz.r_array = minimum_image(wurtz.r_array + cell_param/2, np.diagonal(wurtz.box_vectors))

    particles1 = wurtz.r_array
    types1 = wurtz.type_array.astype("S2")
    # box = np.diagonal(wurtz.box_vectors)
    box = wurtz.box_vectors
    
    # for k_max in (2, 3, 4, 5, 6):
    rcut = cell_param * 4
    ewald = Ewald({"Li": 1, "Cl": -1}, rcut=rcut, alpha=(3.6/0.9)**0.5, kmax=10)
    result = ewald.real(particles1, types1, particles1, types1, box)
    
    
    # print("Real", result)
    # result = ewald.reciprocal(particles1, types1, particles1, types1, box)
    # print("Reciprocal", result)
    # print("Dipole", ewald.dipole_correction(particles1, types1, box) / 4)
    print("Whole", ewald.interaction(particles1, types1, particles1, types1, box) / 2)
    print("Madelung", madelung(rmin(wurtz), WURTZ_M)/2)
예제 #4
0
파일: test_md.py 프로젝트: yccai/chemlab
def test_ewald():
    particles1 = [[0.0, 0, 0], [0.5, 0.5, 0.5]]
    types1 = ["Li", "Cl"]
    box = [1.0, 1.0, 1.0]

    li = Molecule([Atom('Li', [0, 0, 0], name='Li+')])
    cl = Molecule([Atom('Cl', [0, 0, 0], name='Cl-')])

    cell_par = 2.0
    rocksalt = crystal(
        [[0.0, 0.0, 0.0], [0.5, 0.5, 0.5]],  # Fractional Positions
        [li, cl],  # Molecules
        225,  # Space Group
        cellpar=[cell_par, cell_par, cell_par, 90, 90,
                 90],  # unit cell parameters
        repetitions=[1, 1, 1])  # unit cell repetitions in each direction

    particles1 = rocksalt.r_array
    types1 = rocksalt.type_array.astype("S2")
    box = np.diagonal(rocksalt.box_vectors)

    # for k_max in (2, 3, 4, 5, 6):
    rcut = cell_par * 4
    ewald = Ewald({
        "Li": 1,
        "Cl": -1
    },
                  rcut=rcut,
                  alpha=(3.6 / 0.9)**0.5,
                  kmax=10)
    result = ewald.real(particles1, types1, particles1, types1, box)

    print("Real", result)
    result = ewald.reciprocal(particles1, types1, particles1, types1, box)
    print("Reciprocal", result)
    print("Whole",
          ewald.interaction(particles1, types1, particles1, types1, box) / 2)

    print("Madelung", madelung(rmin(rocksalt), ROCKSALT_M) / 2)