Exemple #1
0
    def get_panel(self):
        """Build panel with widgets to interact with the structure either in a notebook or in a bokeh app"""
        tabs = pn.Tabs()
        app = tabs.append
        row = pn.Row(
            bkw.PreText(text=self.structure.to_string(verbose=self.verbose),
                        sizing_mode="scale_both"))
        app(("Summary", row))
        ws = pn.Column('# Spglib options', self.spglib_symprec,
                       self.spglib_angtol)
        app(("Spglib", pn.Row(ws, self.spglib_summary)))
        ws = pn.Column('# K-path options', self.kpath_format,
                       self.line_density)
        app(("Kpath", pn.Row(ws, self.get_kpath)))
        app(("Convert",
             pn.Row(pn.Column("# Convert structure", self.output_format),
                    self.convert)))
        app(("View",
             pn.Row(
                 pn.Column("# Visualize structure", self.viewer,
                           self.viewer_btn), self.view)))
        ws = pn.Column('# Generate GS input', self.gs_type, self.spin_mode,
                       self.kppra, self.gs_input_btn)
        app(("GS-input", pn.Row(ws, self.on_gs_input_btn)))
        app(("MP-match",
             pn.Row(pn.Column(self.mp_match_btn), self.on_mp_match_btn)))

        return tabs
Exemple #2
0
 def on_debug_btn(self):
     if self.debug_btn.clicks == 0: return
     #TODO https://github.com/ralphbean/ansi2html ?
     stream = StringIO()
     #flow.debug(status=options.task_status, nids=selected_nids(flow, options))
     self.flow.debug(stream=stream)
     return pn.Row(bkw.PreText(text=stream.getvalue()))
Exemple #3
0
 def on_history_btn(self):
     if self.history_btn.clicks == 0: return
     stream = StringIO()
     #flow.show_history(status=options.task_status, nids=selected_nids(flow, options),
     #                  full_history=options.full_history, metadata=options.metadata)
     self.flow.show_history(stream=stream)
     return pn.Row(bkw.PreText(text=stream.getvalue()))
Exemple #4
0
    def get_panel(self):
        """Return tabs with widgets to interact with the DDB file."""
        tabs = pn.Tabs()
        app = tabs.append
        row = pn.Row(
            bkw.PreText(text=self.ddb.to_string(verbose=self.verbose),
                        sizing_mode="scale_both"))
        app(("Summary", row))
        app(("Ph-bands",
             pn.Row(
                 pn.Column(
                     "# PH-bands options", *[
                         self.param[k]
                         for k in ("nqsmall", "ndivsm", "asr", "chneut",
                                   "dipdip", "lo_to_splitting", "dos_method")
                     ], self.temp_range, self.plot_phbands_btn),
                 self.plot_phbands_and_phdos)))
        app(("BECs",
             pn.Row(
                 pn.Column(
                     "# Born effective charges options", *[
                         self.param[k]
                         for k in ("asr", "chneut", "dipdip", "gamma_ev")
                     ], self.get_epsinf_btn), self.get_epsinf)))
        app(("eps0",
             pn.Row(
                 pn.Column(
                     "# epsilon_0", *[
                         self.param[k]
                         for k in ("asr", "chneut", "dipdip", "gamma_ev")
                     ], self.w_range, self.plot_eps0w_btn), self.plot_eps0w)))
        app(("Speed of sound",
             pn.Row(
                 pn.Column(
                     "# Speed of sound options",
                     *[self.param[k] for k in ("asr", "chneut", "dipdip")],
                     self.plot_vsound_btn), self.plot_vsound)))
        app(("Check ASR and DIPDIP",
             pn.Row(
                 pn.Column(
                     "# Options", *[
                         self.param[k]
                         for k in ("nqsmall", "ndivsm", "dos_method")
                     ], self.plot_check_asr_dipdip_btn),
                 self.plot_without_asr_dipdip)))

        app(("IFCs",
             pn.Row(
                 pn.Column(
                     "# Options",
                     *[self.param[k] for k in ("asr", "dipdip", "chneut")],
                     self.plot_ifc_btn), self.plot_ifc)))

        app(("Global Opts",
             pn.Column(
                 "# Global Options",
                 *[self.param[k] for k in ("units", "mpi_procs", "verbose")])))

        return tabs
Exemple #5
0
 def on_handlers_btn(self):
     #if self.handlers_btn.clicks == 0: return
     stream = StringIO()
     #if options.doc:
     #    flowtk.autodoc_event_handlers()
     #else:
     #show_events(self, status=None, nids=None, stream=sys.stdout):
     self.flow.show_event_handlers(verbose=self.verbose.value,
                                   stream=stream)
     return pn.Row(bkw.PreText(text=stream.getvalue()))
Exemple #6
0
    def on_plot_ebands_btn(self):
        """Button triggering ebands plot."""
        if self.plot_ebands_btn.clicks == 0: return
        if self.set_fermie_to_vbm.value:
            self.ebands.set_fermie_to_vbm()

        fig1 = self.ebands.plot(e0="fermie",
                                ylims=None,
                                with_gaps=self.with_gaps.value,
                                max_phfreq=None,
                                fontsize=8,
                                **self.fig_kwargs)

        fig2 = self.ebands.kpoints.plot(**self.fig_kwargs)
        row = pn.Row(self._mp(fig1),
                     self._mp(fig2))  #, sizing_mode='scale_width')
        text = bkw.PreText(text=self.ebands.to_string(verbose=self.verbose))
        return pn.Column(row, text, sizing_mode='scale_width')
Exemple #7
0
    def get_panel(self):
        """Return tabs with widgets to interact with the FATBANDS.nc file."""
        tabs = pn.Tabs()
        app = tabs.append
        app(("Summary",
             pn.Row(
                 bkw.PreText(text=self.ncfile.to_string(verbose=self.verbose),
                             sizing_mode="scale_both"))))
        app(("e-Bands",
             pn.Row(self.get_plot_ebands_widgets(), self.on_plot_ebands_btn)))

        if self.ncfile.ebands.kpoints.is_ibz:
            # Add DOS tab only if k-sampling.
            app(("e-DOS",
                 pn.Row(self.get_plot_edos_widgets(), self.on_plot_edos_btn)))

            # Plot the L-PJDOS grouped by atomic type.
            #self.ncfile.plot_pjdos_typeview(lmax=lmax, **self.fig_kwargs)
            # Plot the L-PJDOS grouped by L.
            #self.ncfile.plot_pjdos_lview(lmax=lmax, **self.fig_kwargs)

            # Fermi surface requires a gamma-centered k-mesh
            if self.ncfile.ebands.supports_fermi_surface:
                app(("Fermi Surface",
                     pn.Row(self.get_plot_fermi_surface_widgets(),
                            self.on_plot_fermi_surface_btn)))

        elif self.ncfile.ebands.kpoints.is_path:
            # NC files have contributions up to L=4 (g channel)
            # but here we are intererested in s,p,d terms only so
            # we use the optional argument lmax
            lmax = 2

            # Plot the electronic fatbands grouped by atomic type.
            #self.ncfile.plot_fatbands_typeview(lmax=lmax, **self.fig_kwargs)
            # Plot the electronic fatbands grouped by L.
            #self.ncfile.plot_fatbands_lview(lmax=lmax, **self.fig_kwargs)

        else:
            raise ValueError("Neither a IBZ nor k-path!")

        return tabs
Exemple #8
0
    def get_panel(self):
        """Return tabs with widgets to interact with the Abinit output file."""
        tabs = pn.Tabs()
        app = tabs.append
        app(("Summary",
             pn.Row(
                 bkw.PreText(text=self.outfile.to_string(verbose=self.verbose),
                             sizing_mode="scale_both"))))
        df = self.outfile.get_dims_spginfo_dataframe().transpose()
        df.index.name = "Dataset"
        app(("Dims", self._df(df)))

        # Add tabs with plots for the GS/DFPT SCF cycles.
        for what in ("GS", "DFPT"):
            box = self._get_gridbox(what)
            if box is not None:
                app(("%s Cycles" % what, box))

        #timer = self.get_timer()
        #timer.plot_all(**self.fig_kwargs)

        return tabs
Exemple #9
0
    def get_panel(self):
        """Return tabs with widgets to interact with the |GsrRobot|."""
        tabs = pn.Tabs()
        app = tabs.append
        app(("Summary",
             pn.Row(
                 bkw.PreText(text=self.robot.to_string(verbose=self.verbose),
                             sizing_mode="scale_both"))))
        app(("e-Bands",
             pn.Row(self.get_ebands_plotter_widgets(),
                    self.on_ebands_plotter_btn)))

        # Add e-DOS tab only if all ebands have k-sampling.
        if all(abifile.ebands.kpoints.is_ibz
               for abifile in self.robot.abifiles):
            app(("e-DOS",
                 pn.Row(self.get_edos_plotter_widgets(),
                        self.on_edos_plotter_btn)))

        app(("GSR-DataFrame",
             pn.Row(self.gsr_dataframe_btn, self.on_gsr_dataframe_btn)))

        return tabs
Exemple #10
0
    def get_panel(self):
        """Return tabs with widgets to interact with the DDB file."""
        tabs = pn.Tabs()
        app = tabs.append
        app(("Summary",
             pn.Row(
                 bkw.PreText(text=self.gsr.to_string(verbose=self.verbose),
                             sizing_mode="scale_both"))))
        app(("e-Bands",
             pn.Row(self.get_plot_ebands_widgets(), self.on_plot_ebands_btn)))

        # Add DOS tab only if k-sampling.
        kpoints = self.gsr.ebands.kpoints
        if kpoints.is_ibz:
            app(("e-DOS",
                 pn.Row(self.get_plot_edos_widgets(), self.on_plot_edos_btn)))

            if self.gsr.ebands.supports_fermi_surface:
                # Fermi surface requires gamma-centered k-mesh
                app(("Fermi Surface",
                     pn.Row(self.get_plot_fermi_surface_widgets(),
                            self.on_plot_fermi_surface_btn)))

        return tabs
Exemple #11
0
    def __init__(self, plot, tabs):  # pylint: disable=redefined-outer-name
        """Initialize form.

        :param plot: IsothermPlot instance for validation of results.
        :param tabs: Panel tabs instance for triggering tab switching.
        """
        self.plot = plot
        self.tabs = tabs

        # isotherm metadata
        self.inp_doi = pw.TextInput(name='Article DOI',
                                    placeholder='10.1021/jacs.9b01891')
        self.inp_doi.param.watch(self.on_change_doi, 'value')
        self.inp_temperature = pw.TextInput(name='Temperature',
                                            placeholder='303')
        self.inp_adsorbent = pw.AutocompleteInput(
            name='Adsorbent Material',
            options=QUANTITIES['adsorbents']['names'],
            placeholder='Zeolite 5A',
            case_sensitive=False,
            **restrict_kwargs)
        self.inp_isotherm_type = pw.Select(
            name='Isotherm type',
            options=['Select'] + QUANTITIES['isotherm_type']['names'])
        self.inp_measurement_type = pw.Select(
            name='Measurement type',
            options=['Select'] + QUANTITIES['measurement_type']['names'])
        self.inp_pressure_scale = pw.Checkbox(
            name='Logarithmic pressure scale')
        self.inp_isotherm_data = pw.TextAreaInput(
            name='Isotherm Data',
            height=200,
            placeholder=config.SINGLE_COMPONENT_EXAMPLE)
        self.inp_figure_image = pw.FileInput(name='Figure snapshot')

        # units metadata
        self.inp_pressure_units = pw.Select(
            name='Pressure units',
            options=['Select'] + QUANTITIES['pressure_units']['names'])
        self.inp_pressure_units.param.watch(self.on_change_pressure_units,
                                            'value')
        self.inp_saturation_pressure = pw.TextInput(
            name='Saturation pressure [bar]', disabled=True)
        self.inp_adsorption_units = pw.AutocompleteInput(
            name='Adsorption Units',
            options=QUANTITIES['adsorption_units']['names'],
            placeholder='mmol/g',
            case_sensitive=False,
            **restrict_kwargs)

        # digitizer info
        self.inp_source_type = pw.TextInput(name='Source description',
                                            placeholder='Figure 1a')
        self.inp_tabular = pw.Checkbox(
            name='Tabular Data (i.e., not digitized from a graphical source)')
        self.inp_digitizer = pw.TextInput(name='Digitized by',
                                          placeholder='Your full name')

        # fill form from JSON upload
        self.inp_json = pw.FileInput(name='Upload JSON Isotherm')

        # buttons
        self.btn_prefill = pn.widgets.Button(
            name='Prefill (default or from JSON)', button_type='primary')
        self.btn_prefill.on_click(self.on_click_prefill)
        self.out_info = bw.PreText(
            text='Press "Plot" in order to download json.')
        self.inp_adsorbates = Adsorbates(show_controls=False, )
        self.btn_plot = pn.widgets.Button(name='Plot', button_type='primary')
        self.btn_plot.on_click(self.on_click_plot)

        for inp in self.required_inputs:
            inp.css_classes = ['required']

        # create layout
        self.layout = pn.Column(
            pn.pane.HTML('<h2>Isotherm Digitizer</h2>'),
            self.inp_digitizer,
            self.inp_doi,
            pn.pane.HTML('<hr>'),
            self.inp_source_type,
            pn.Row(pn.pane.HTML("""Attach Figure Graphics"""),
                   self.inp_figure_image),
            self.inp_measurement_type,
            self.inp_adsorbent,
            self.inp_adsorbates.column,
            self.inp_temperature,
            self.inp_isotherm_type,
            pn.Row(self.inp_pressure_units, self.inp_saturation_pressure),
            self.inp_pressure_scale,
            self.inp_adsorption_units,
            pn.pane.HTML("""We recommend the
                <b><a href='https://apps.automeris.io/wpd/' target="_blank">WebPlotDigitizer</a></b>
                for data extraction."""),
            self.inp_isotherm_data,
            self.inp_tabular,
            pn.Row(self.btn_plot, self.btn_prefill, self.inp_json),
            self.out_info,
        )
Exemple #12
0
 def get_kpath(self):
     s = self.structure.get_kpath_input_string(
         fmt=self.kpath_format.value, line_density=self.line_density.value)
     return pn.Row(bkw.PreText(text=s, sizing_mode='stretch_width'))
Exemple #13
0
 def spglib_summary(self):
     s = self.structure.spget_summary(
         symprec=self.spglib_symprec.value,
         angle_tolerance=self.spglib_angtol.value)
     return pn.Row(bkw.PreText(text=s, sizing_mode='stretch_width'))
Exemple #14
0
 def convert(self):
     return pn.Row(bkw.PreText(text=self.structure.convert(
         fmt=self.output_format.value)),
                   sizing_mode='stretch_width')
Exemple #15
0
 def on_status_btn(self):
     if self.status_btn.clicks == 0: return
     stream = StringIO()
     self.flow.show_status(stream=stream, verbose=self.verbose.value)
     return pn.Row(bkw.PreText(text=stream.getvalue()))
Exemple #16
0
 def on_corrections_btn(self):
     if self.corrections_btn.clicks == 0: return
     stream = StringIO()
     self.flow.show_corrections(stream=stream)
     #flow.show_corrections(status=options.task_status, nids=selected_nids(flow, options))
     return pn.Row(bkw.PreText(text=stream.getvalue()))