Exemplo n.º 1
0
def dos_map(args, newsystem, bfrange, enrange, cmap=None):
    if args.nmax is not None and args.angle is not None:
        if cmap is None:
            cmap = DEFAULT_CMAP
        if args.allden is not None and args.nos is not None:
            den_slices = make_slices(args.allden, args.nos)
        elif args.loadden is not None:
            den_slices = read_den_from_csv(args.loadden)
        else:
            sys.stderr.write(
                'The arguments -nmax and -angle and -allden and -nos are needed\n'
            )
        ax = make_canvas()
        # data storage
        y_databdl = []
        y_tot = []
        for den_slice in tqdm(den_slices):
            newsystem.set_all_density(den_slice)
            tot_den = newsystem.tot_density()
            y_tot.append(tot_den)
            # disable the band with zero density or below
            idx_disabled = []
            # if any band has a density <=0 then disable it
            for idx, den in enumerate(den_slice):
                if den <= 0:
                    newsystem.get_band(idx).disable()
                    idx_disabled.append(idx)
            # calculate the chemical potential for the new system
            mus = [
                newsystem.mu(enrange, B, args.nmax, args.angle, [
                    SIGMA_COND if band.get('is_cond') else SIGMA_VAL
                    for band in newsystem.get_band('a')
                ], args.parity) for B in bfrange
            ]
            # calculate the dos for each band at each chemical potential along the B field axis
            to_append = [
                sum([(1 if band.get('is_cond') else -1) * band.cal_dos(
                    mu_at_B, B, args.nmax, args.angle, SIGMA_COND
                    if band.get('is_cond') else SIGMA_VAL, args.parity)
                     for band in newsystem.get_band('a')])
                for B, mu_at_B in zip(bfrange, mus)
            ]
            y_databdl.append(to_append)
            newsystem.databdl_write_csv(args.fnm, bfrange, to_append, 'dosm')
            # enable the disabled band again for next loop
            if idx_disabled:
                for idx in idx_disabled:
                    newsystem.get_band(idx).enable()
        make_2d_dos_map(bfrange, y_tot, y_databdl, cmap, ax=ax)
        system_stamp_csv(args)
        super_save(args.fnm, args.dir)
    else:
        sys.stderr.write('The arguments -nmax and -angle are needed\n')
Exemplo n.º 2
0
def dos_at_mu(args, newsystem, bfrange, enrange, colors=None):
    if args.nmax is not None and args.angle is not None:
        if colors is None:
            colors = make_n_colors(len(newsystem.get_band('a')), DEFAULT_CMAP,
                                   DEFAULT_CMAP_VMIN, DEFAULT_CMAP_VMAX)
        y_databdl = newsystem.ydata_gen(args.nmax, args.angle, bfrange,
                                        enrange, 'dos', SIGMA_COND, SIGMA_VAL,
                                        args.parity)
        make_1d_dos_B_plot(bfrange, y_databdl, colors)
        newsystem.databdl_write_csv(args.fnm, bfrange, y_databdl, 'dos')
        system_stamp_csv(args)
        super_save(args.fnm, args.dir)
    else:
        sys.stderr.write('The arguments -nmax and -angle are needed\n')
Exemplo n.º 3
0
def denplot(args, newsystem, bfrange, enrange, colors=None):
    if args.nmax is not None and args.angle is not None:

        # bundle data from each Landau level originating from each band
        y_databdl = newsystem.ydata_gen(args.nmax, args.angle, bfrange,
                                        enrange, 'denplot', SIGMA_COND,
                                        SIGMA_VAL, args.parity)
        if colors is None:
            colors = make_n_colors(len(newsystem.get_band('a')), DEFAULT_CMAP,
                                   DEFAULT_CMAP_VMIN, DEFAULT_CMAP_VMAX)
        tot_den = newsystem.tot_density()
        make_1d_den_B_plots(bfrange, y_databdl, colors, tot_den)
        newsystem.databdl_write_csv(args.fnm, bfrange, y_databdl, 'denplot')
        system_stamp_csv(args)
        super_save(args.fnm, args.dir)
    else:
        sys.stderr.write('The arguments -nmax and -angle are needed\n')
Exemplo n.º 4
0
def enplot(args, newsystem, bfrange, enrange, colors=None):
    if args.nmax is not None and args.angle is not None:
        y_databdl = newsystem.ydata_gen(args.nmax, args.angle, bfrange,
                                        enrange, 'enplot', SIGMA_COND,
                                        SIGMA_VAL, args.parity)
        if colors is None:
            colors = make_n_colors(len(newsystem.get_band('a')), DEFAULT_CMAP,
                                   DEFAULT_CMAP_VMIN, DEFAULT_CMAP_VMAX)
        mu_pos = [
            newsystem.mu(enrange, B, args.nmax, args.angle, [
                SIGMA_COND if band.get('is_cond') else SIGMA_VAL
                for band in newsystem.get_band('a')
            ], args.parity) for B in bfrange
        ]
        ax = make_1d_E_B_plots(bfrange, y_databdl, colors, mu_pos)
        newsystem.databdl_write_csv(args.fnm, bfrange, y_databdl, 'enplot')
        super_save(args.fnm, args.dir)
        system_stamp_csv(args)
    else:
        sys.stderr.write("The arguments -nmax and -angle are needed\n")
Exemplo n.º 5
0
def draw(args, newsystem):
    draw_band(newsystem)
    super_save(args.fnm + '_bandsketch', os.path.join(DEFAULT_PATH, args.fnm))
Exemplo n.º 6
0
def simu(args, newsystem, bfrange, enrange, colors=None):
    if args.nmax is not None and args.angle is not None:
        if args.allden is not None and args.nos is not None:
            den_slices = make_slices(args.allden, args.nos)
        elif args.loadden is not None:
            den_slices = read_den_from_csv(args.loadden)
        else:
            sys.stderr.write(
                'The arguments -nmax and -angle and -allden and -nos are needed\n'
            )
        tot_den_list = [sum(den_slice) for den_slice in den_slices]
        tot_den_int = np.mean([
            abs(tot_den_list[i] - tot_den_list[i + 1])
            for i in range(len(tot_den_list) - 1)
        ])
        ax = make_canvas()
        if colors is None:
            colors = make_n_colors(len(newsystem.get_band('a')), DEFAULT_CMAP,
                                   DEFAULT_CMAP_VMIN, DEFAULT_CMAP_VMAX)
        for den_slice in tqdm(den_slices):
            # colors_p = color will only generate a new pointer to the same list
            colors_p = [color for color in colors]
            newsystem.set_all_density(den_slice)
            tot_den = newsystem.tot_density()
            IDOS = [
                newsystem.dos_gen(enrange, B, args.nmax, args.angle, [
                    SIGMA_COND if band.get('is_cond') else SIGMA_VAL
                    for band in newsystem.get_band('a')
                ], args.parity) for B in bfrange
            ]
            # disable the band with zero density
            idx_disabled = []
            # if any band has a density <=0 then disable it
            for idx, den in enumerate(den_slice):
                if den <= 0:
                    newsystem.get_band(idx).disable()
                    idx_disabled.append(idx)
                    colors_p[idx] = None
            colors_p = [color for color in colors_p if color is not None]
            y_databdl = [[[
                np.interp(x=x, xp=enrange, fp=IDOS[index])
                for index, x in enumerate(
                    band.cal_energy(bfrange, args.nmax, args.angle)
                    [f'#{N}'].tolist())
            ] for N in range(args.nmax)] for band in newsystem.get_band('a')]
            plotrange = [
                tot_den - 0.5 * tot_den_int, tot_den + 0.5 * tot_den_int
            ]
            ax = make_1d_den_B_plots(bfrange,
                                     y_databdl,
                                     colors_p,
                                     ax=ax,
                                     plotrange=plotrange,
                                     legend=False)
            newsystem.databdl_write_csv(args.fnm,
                                        bfrange,
                                        y_databdl,
                                        'simu',
                                        plotrange=plotrange)
            # enable the disabled band again for next loop
            if idx_disabled:
                for idx in idx_disabled:
                    newsystem.get_band(idx).enable()
        system_stamp_csv(args)
        super_save(args.fnm, args.dir)

    else:
        sys.stderr.write('The arguments -nmax and -angle are needed\n')