Ejemplo n.º 1
0
def calculate_bands(param):
    print("Checkpoint 1 reached")
    ctx = sirius.Simulation_context(json.dumps(param))
    ctx.set_gamma_point(False)
    ctx.initialize()

    print("Checkpoint 2 reached")
    dft = sirius.DFT_ground_state(ctx)
    dft.initial_state()

    print("Checkpoint 3 reached")
    result = dft.find(1e-6, 1e-6, 100, False)  #enter the tolerances directly.
    #print("result_dict=", result)
    dft.print_magnetic_moment()

    if param["parameters"]["electronic_structure_method"] == "pseudopotential":
        ctx.set_iterative_solver_tolerance(1e-12)

    print("Checkpoint 4 reached")
    potential = dft.potential()  #sirius.Potential(ctx)
    H = dft.hamiltonian()  #sirius.Hamiltonian(ctx, potential)

    density = dft.density()

    print("Checkpoint 5 reached")
    #print("Total Energy = ", dft.total_energy())

    print("Checkpoint 6 reached")
    t = 0

    band = dft.band()

    print("Checkpoint 7 reached")

    print("Checkpoint 8 reached")
    k_point_list = param["kpoints_path"]
    rec_vec = param["kpoints_rel"]

    k_points, x_ticks, x_axis = get_kpoint_path(k_point_list, rec_vec, ctx)
    ks = sirius.K_point_set(ctx, k_points)  # create and initalize k-set

    if param["parameters"]["electronic_structure_method"] == "pseudopotential":
        band.initialize_subspace(ks, H)

    print("Checkpoint 9 reached")
    # after creating new k-point set along the symmetry lines
    band = dft.band()
    H = dft.hamiltonian()
    print("Checkpoint 10 reached")

    band.solve(ks, H, True)

    print("Calculation finished.")

    return ctx, ks, x_ticks, x_axis
Ejemplo n.º 2
0
        "GAMMA": [0.0, 0.0, 0.0],
        "W_2": [0.75, 0.25, 0.5]
    },
    "kpoints_path": ["GAMMA", "K", "L"]
}

print("Checkpoint 1 reached")

ctx = sirius.Simulation_context(json.dumps(parameters1))
ctx.initialize()
print("Checkpoint 2 reached")

ctx.parameters_input()  #not needed acutally, just for debugging.
print("Checkpoint 3 reached")

dft = sirius.DFT_ground_state(ctx)
dft.initial_state()
result = dft.find(ctx.parameters_input().potential_tol_,
                  ctx.parameters_input().energy_tol_,
                  ctx.parameters_input().num_dft_iter_, True)
dft.print_magnetic_moment()

#s = sirius.Stress(ctx, dft.k_point_set(), dft.density(), dft.potential())
print("Checkpoint 4 reached")
#s.calc_stress_total()
print("Checkpoint 5 reached")
#s.print_info()
print("Checkpoint 6 reached")

#f = sirius.Force(ctx, dft.density(), dft.potential(), dft.hamiltonian(), dft.k_point_set())
print("Checkpoint 7 reached")
Ejemplo n.º 3
0
def calculate_bands(param):
    ctx = sirius.Simulation_context(json.dumps(param))
    ctx.set_gamma_point(False)
    ctx.initialize()

    dft = sirius.DFT_ground_state(ctx)
    dft.initial_state()

    result = dft.find(ctx.parameters_input().potential_tol_,
                      ctx.parameters_input().energy_tol_,
                      ctx.parameters_input().num_dft_iter_, True)
    dft.print_magnetic_moment()

    if param["parameters"]["electronic_structure_method"] == "pseudopotential":
        ctx.set_iterative_solver_tolerance(1e-12)

    potential = sirius.Potential(ctx)
    potential.allocate()

    H = sirius.Hamiltonian(ctx, potential)

    density = sirius.Density(ctx)
    density.allocate()

    ks = sirius.K_point_set(ctx)
    print("Total Energy = ", dft.total_energy())

    x_axis = []
    x_ticks = []

    index = param["kpoints_path"]

    vertex = []

    for i in enumerate(index):
        v = param["kpoints_rel"][i[1]]
        print(i[1])
        vertex.append((i[1], v))

    x_axis.append(0)
    x_ticks.append((0, vertex[0][0]))
    print("vertex[0][1] =", vertex[0][1])
    print("type(vertex[0][1]) = ", type(vertex[0][1]))
    print("len(vertex)=", len(vertex))
    ks.add_kpoint(vertex[0][1], 1.0)

    t = 0
    print(vertex)
    for i in range(len(vertex) - 1):
        v0 = sirius.vector3d_double(vertex[i][1])
        v1 = sirius.vector3d_double(vertex[i + 1][1])
        dv = v1 - v0
        dv_cart = ctx.unit_cell().reciprocal_lattice_vectors() * dv
        np = max(10, int(30 * dv_cart.length()))
        for j in range(1, np + 1):
            v = sirius.vector3d_double(v0 + dv * (float(j) / np))
            ks.add_kpoint(v, 1.0)
            t += dv_cart.length() / np
            x_axis.append(t)
        x_ticks.append((t, vertex[i + 1][0]))

    counts = []
    ks.initialize()

    density.load()
    potential.generate(density)

    band = sirius.Band(ctx)
    if param["parameters"]["electronic_structure_method"] == "pseudopotential":
        band.initialize_subspace(ks, H)

    band.solve(ks, H, True)
    #print("Fermi-Energy = ", ks.energy_fermi())
    #ks.sync_band_energies()
    print("Calculation finished.")
    return ctx, ks, x_ticks, x_axis
Ejemplo n.º 4
0
def calculate_bands(param):
    ctx = sirius.Simulation_context(json.dumps(param))
    ctx.set_gamma_point(False)
    ctx.initialize()

    dft = sirius.DFT_ground_state(ctx)
    dft.initial_state()

    result = dft.find(ctx.parameters_input().potential_tol_,
                      ctx.parameters_input().energy_tol_,
                      ctx.parameters_input().num_dft_iter_, True)
    dft.print_magnetic_moment()

    if param["parameters"]["electronic_structure_method"] == "pseudopotential":
        ctx.set_iterative_solver_tolerance(1e-12)

    potential = sirius.Potential(ctx)
    potential.allocate()

    H = sirius.Hamiltonian(ctx, potential)

    density = sirius.Density(ctx)
    density.allocate()

    ks = sirius.K_point_set(ctx)
    print("Total Energy = ", dft.total_energy())

    x_axis = []
    x_ticks = []

    index = param["kpoints_path"]

    vertex = []

    for i in enumerate(index):
        v = param["kpoints_rel"][i[1]]
        print(i[1])
        vertex.append((i[1], v))

    x_axis.append(0)
    x_ticks.append((0, vertex[0][0]))
    print("vertex[0][1] =", vertex[0][1])
    print("type(vertex[0][1]) = ", type(vertex[0][1]))
    print("len(vertex)=", len(vertex))
    ks.add_kpoint(vertex[0][1], 1.0)

    t = 0
    print(vertex)
    for i in range(len(vertex) - 1):
        v0 = sirius.vector3d_double(vertex[i][1])
        v1 = sirius.vector3d_double(vertex[i + 1][1])
        dv = v1 - v0
        dv_cart = ctx.unit_cell().reciprocal_lattice_vectors() * dv
        np = max(10, int(30 * dv_cart.length()))
        for j in range(1, np + 1):
            v = sirius.vector3d_double(v0 + dv * (float(j) / np))
            ks.add_kpoint(v, 1.0)
            t += dv_cart.length() / np
            x_axis.append(t)
        x_ticks.append((t, vertex[i + 1][0]))

    counts = []
    ks.initialize()

    density.load()
    potential.generate(density)

    band = sirius.Band(ctx)
    if param["parameters"]["electronic_structure_method"] == "pseudopotential":
        band.initialize_subspace(ks, H)

    band.solve(ks, H, True)
    #print("Fermi-Energy = ", ks.energy_fermi())
    #ks.sync_band_energies()

    dict = {}
    dict["header"] = {}
    dict["header"]["x_axis"] = x_axis
    dict["header"]["x_ticks"] = []
    dict["header"]["num_bands"] = ctx.num_bands()
    dict["header"]["num_mag_dims"] = ctx.num_mag_dims()

    for e in enumerate(x_ticks):
        j = {}
        j["x"] = e[1][0]
        j["label"] = e[1][1]
        dict["header"]["x_ticks"].append(j)

    dict["bands"] = []

    for ik in range(ks.num_kpoints()):
        bnd_k = {}
        bnd_k["kpoint"] = [0.0, 0.0, 0.0]
        for x in range(3):
            bnd_k["kpoint"][x] = ks(ik).vk()(x)
            if ik == 32:
                print(bnd_k["kpoint"][x])
        bnd_e = []

        for ispn in range(ctx.num_spin_dims()):
            for j in range(ctx.num_bands()):
                bnd_e.append(ks(ik).band_energy(j, ispn) - 0.3)

        bnd_k["values"] = bnd_e
        dict["bands"].append(bnd_k)
    return dict