コード例 #1
0
def test_actual_vasp_files(test_data_files: Path):
    vasprun_file = str(test_data_files / "MgO_dos_vasprun.xml")
    vasprun = Vasprun(vasprun_file)
    dos_data = DosDataFromVasp(vasprun, base_energy=1,
                               vertical_lines=[0.0]).make_dos_data()
    plot_data = dos_data.dos_plot_data({"Mg": [0], "O": [1]})
    plotter = DosPlotter(plot_data)
    plotter.construct_plot()
    plotter.plt.show()
コード例 #2
0
ファイル: test_plot_dos.py プロジェクト: toyamanya/vise
def mock_plt_list(mocker):
    mock_plt = mocker.patch("vise.analyzer.plot_dos.plt", auto_spec=True)
    mock_1st_ax = mocker.MagicMock()
    mock_2nd_ax = mocker.MagicMock()
    other_axs_len = dos_data_len - 2

    mock_axs = [mock_1st_ax, mock_2nd_ax] + [mocker.MagicMock()] * other_axs_len

    mock_plt.subplots.return_value = (None, mock_axs)
    plotter = DosPlotter(dos_plot_data=dos_plot_data)
    plotter.construct_plot()

    return mock_plt, mock_1st_ax, mock_2nd_ax
コード例 #3
0
ファイル: test_plot_dos.py プロジェクト: toyamanya/vise
def test_axs_is_list_when_single_dos_passed():
    single_dos = [[DosBySpinEnergy("", [total_up, total_down])]]
    dos_info = DosPlotData(relative_energies=relative_energies,
                           doses=single_dos, names=["total"], energy_range=xlim,
                           dos_ranges=ylim_set, energy_lines=[0.0, 1.0])
    plotter = DosPlotter(dos_plot_data=dos_info)
    assert isinstance(plotter._axs, list)
    assert len(plotter._axs) == 1
コード例 #4
0
def test_dos_data_pdos_single(pdos_list, dos_data_list):
    _, dos_plot_data_w_lim, _ = dos_data_list
    pdos_sum = pdos_list[1] + pdos_list[2]

    assert dos_plot_data_w_lim.names == ["total", "H", "He"]

    assert dos_plot_data_w_lim.doses[1][0].name == "s"
    assert dos_plot_data_w_lim.doses[1][1].name == "p"
    assert dos_plot_data_w_lim.doses[2][0].name == "s"

    assert_array_equal(dos_plot_data_w_lim.doses[1][0].dos, pdos_list[0].s)
    assert_array_equal(dos_plot_data_w_lim.doses[1][1].dos, pdos_list[0].p)

    assert_array_equal(dos_plot_data_w_lim.doses[2][0].dos, pdos_sum.s)

    plotter = DosPlotter(dos_plot_data_w_lim)
    plotter.construct_plot()
    plotter.plt.show()
コード例 #5
0
ファイル: test_plot_dos.py プロジェクト: toyamanya/vise
def test_actual_plot():
    plotter = DosPlotter(dos_plot_data)
    plotter.construct_plot()
    plotter.plt.show()


# def test_plotly_actual_plot():
#     pploter = PlotlyDosPlotter(dos_plot_data)
#     pploter.show()


# # 1. imports of your dash app
# import dash
# import dash_html_components as html


# # 2. give each testcase a tcid, and pass the fixture
# # as a function argument, less boilerplate
# def test_bsly001_falsy_child(dash_duo):

    # # 3. define your app inside the test function
    # app = dash.Dash(__name__)
    # app.layout = html.Div(id="nully-wrapper", children=0)

    # # 4. host the app locally in a thread, all dash server configs could be
    # # passed after the first app argument
    # dash_duo.start_server(app)

    # # 5. use wait_for_* if your target element is the result of a callback,
    # # keep in mind even the initial rendering can trigger callbacks
    # dash_duo.wait_for_text_to_equal("#nully-wrapper", "0", timeout=4)

    # # 6. use this form if its present is expected at the action point
    # assert dash_duo.find_element("#nully-wrapper").text == "0"

    # # 7. to make the checkpoint more readable, you can describe the
    # # acceptance criterion as an assert message after the comma.
    # assert dash_duo.get_logs() == [], "browser console should contain no error"

    # # 8. visual testing with percy snapshot
    # dash_duo.percy_snapshot("bsly001-layout")
コード例 #6
0
def plot_dos(args: Namespace):
    vasprun = Vasprun(args.vasprun)
    outcar = Outcar(args.outcar)
    band_edge = VaspBandEdgeProperties(vasprun, outcar)

    if band_edge.band_gap:
        vertical_lines = [band_edge.vbm_info.energy, band_edge.cbm_info.energy]
    else:
        vertical_lines = [vasprun.efermi]

    if args.base_energy is None:
        base = vertical_lines[0]
    else:
        base = args.base_energy

    dos_data_from_vasp = \
        DosDataFromVasp(vasprun, vertical_lines, base, args.crop_first_value)
    dos_data = dos_data_from_vasp.make_dos_data()

    ylim_set = None
    if args.y_max_ranges:
        if dos_data.spin:
            ylim_set = [[-y_max, y_max] for y_max in args.y_max_ranges]
        else:
            ylim_set = [[0, y_max] for y_max in args.y_max_ranges]

    structure = vasprun.final_structure
    grouped_atom_indices = args.type.grouped_atom_indices(
        structure, args.target)
    logger.info(f"Grouped atom indices: {grouped_atom_indices}")
    plot_data = dos_data.dos_plot_data(grouped_atom_indices,
                                       xlim=args.x_range,
                                       ylim_set=ylim_set)
    plot_data.to_json_file()
    plotter = DosPlotter(plot_data, args.legend)
    plotter.construct_plot()
    plotter.plt.savefig(args.filename, format="pdf")