Ejemplo n.º 1
0
 def test_loadfn(self):
     with warnings.catch_warnings():
         warnings.simplefilter("ignore")
         obj = loadfn(os.path.join(test_dir, "Li2O.cif"))
         self.assertIsInstance(obj, Structure)
         obj = loadfn(os.path.join(test_dir, "POSCAR"))
         self.assertIsInstance(obj, Structure)
         obj = loadfn(os.path.join(test_dir, "vasprun.xml"))
         self.assertIsInstance(obj, Vasprun)
Ejemplo n.º 2
0
 def test_loadfn(self):
     with warnings.catch_warnings():
         warnings.simplefilter("ignore")
         obj = loadfn(os.path.join(test_dir, "Li2O.cif"))
         self.assertIsInstance(obj, Structure)
         obj = loadfn(os.path.join(test_dir, "POSCAR"))
         self.assertIsInstance(obj, Structure)
         obj = loadfn(os.path.join(test_dir, "LiFePO4.vasp"))
         self.assertIsInstance(obj, Structure)
         obj = loadfn(os.path.join(test_dir, "vasprun.xml"))
         self.assertIsInstance(obj, Vasprun)
Ejemplo n.º 3
0
 def test_loadfn(self):
     with warnings.catch_warnings():
         warnings.simplefilter("ignore")
         obj = loadfn(os.path.join(PymatgenTest.TEST_FILES_DIR, "Li2O.cif"))
         self.assertIsInstance(obj, Structure)
         obj = loadfn(os.path.join(PymatgenTest.TEST_FILES_DIR, "POSCAR"))
         self.assertIsInstance(obj, Structure)
         obj = loadfn(
             os.path.join(PymatgenTest.TEST_FILES_DIR, "LiFePO4.vasp"))
         self.assertIsInstance(obj, Structure)
         obj = loadfn(
             os.path.join(PymatgenTest.TEST_FILES_DIR, "vasprun.xml"))
         self.assertIsInstance(obj, Vasprun)
Ejemplo n.º 4
0
    def __init__(self,
                 use_online_pubchem: bool = True,
                 name_preference: Tuple[str] = name_sources):
        """Class to match molecule graphs to known molecule names.

        Args:
            use_online_pubchem: Whether to try using the Pubchem website for
                matching molecules if a match is not found in the offline
                database. Defaults to ``True``. Requires a working internet
                connection and for the ``pubchempy`` package to be installed.
            name_preference: The order of preference for determining compound
                names. Options are "traditional", and "iupac". If the
                first option is not available, the subsequent options will be
                used. Should be provided as a tuple of options, from 1st choice
                to last.
        """

        db_file = resource_filename('robocrys.condense', 'molecule_db.json.gz')
        self.molecule_db = loadfn(db_file)
        self.matched_molecules = {}
        self.use_online_pubchem = use_online_pubchem

        # append the sources list to the end in case the user only supplies
        # a single preference
        self.name_preference = tuple(
            list(name_preference) + list(self.name_sources))
def test_auto_repr(sample):
    """
    Test that the symmetry group created with the automatic representation matrix
    is the matches a reference.
    """
    pos_In = (0, 0, 0)  # pylint: disable=invalid-name
    pos_As = (0.25, 0.25, 0.25)  # pylint: disable=invalid-name

    orbitals = []
    for spin in (sr.SPIN_UP, sr.SPIN_DOWN):
        orbitals.extend([
            sr.Orbital(position=pos_In, function_string=fct, spin=spin)
            for fct in sr.WANNIER_ORBITALS['s'] + sr.WANNIER_ORBITALS['p']
        ])
        orbitals.extend([
            sr.Orbital(position=pos_As, function_string=fct, spin=spin)
            for fct in sr.WANNIER_ORBITALS['p']
        ])

    symops, symops_cart = mg.loadfn(sample('InAs_symops.json'))

    symmetry_group = sr.SymmetryGroup(symmetries=[
        sr.SymmetryOperation.from_orbitals(
            orbitals=orbitals,
            real_space_operator=sr.RealSpaceOperator.from_pymatgen(
                sym_reduced),
            rotation_matrix_cartesian=sym_cart.rotation_matrix,
            numeric=True)
        for sym_reduced, sym_cart in zip(symops, symops_cart)
    ],
                                      full_group=True)
    reference = sr.io.load(sample('symmetries_InAs.hdf5'))
    assert symmetry_group.full_group == reference.full_group
    for sym1, sym2 in zip(symmetry_group.symmetries, reference.symmetries):
        assert_allclose(sym1.real_space_operator.rotation_matrix,
                        sym2.real_space_operator.rotation_matrix,
                        atol=1e-12)
        assert_allclose(sym1.real_space_operator.translation_vector,
                        sym2.real_space_operator.translation_vector,
                        atol=1e-12)
        assert sym1.repr.has_cc == sym2.repr.has_cc
        assert_allclose(sym1.repr.matrix, sym2.repr.matrix, atol=1e-12)
Ejemplo n.º 6
0
import crystal_toolkit.components as ctc

#
#def test_plotly_actual_plot(test_files):
#     dos_data = loadfn(str(test_files / "KAlSi3O8_dos_data.json"))
#     pploter = PlotlyDosPlotter(dos_data)
#     fig = pploter.show({"O": [10, 11]})
#     fig.show()

app = Dash(suppress_callback_exceptions=True,
           assets_folder=SETTINGS.ASSETS_PATH)
ctc.register_app(app)

test_files = Path(__file__).parent / ".." / ".." / "tests" / "test_data_files"
band_plot_data = loadfn(str(test_files / "KAlSi3O8_band_plot_info.json"))
dos_plot_data = loadfn(str(test_files / "KAlSi3O8_dos_plot_data.json"))
band_dos_component = BandDosComponent(dos_plot_data, band_plot_data)
#dos_component = BandDosComponent(None, band_plot_info)
#dos_component = BandDosComponent(dos_plot_data, band_plot_info, band_plot_info_2)

# example layout to demonstrate capabilities of component
my_layout = html.Div([
    html.H1("BandDosComponent Example"),
    band_dos_component.layout(),
])
# {'K_i1': [0, 1],
#  'Al_i1': [2, 3],
#  'Si_i1': [4, 5],
#  'Si_i2': [6, 7],
#  'Si_i3': [8, 9],