.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/crystal_phase/create_crystal_phase.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_crystal_phase_create_crystal_phase.py: ==================== Create crystal phase ==================== This example shows various ways to create a crystal :class:`~orix.crystal_map.Phase`. For alignment of the crystal axes with a Cartesian coordinate system, see the example on :doc:`/examples/crystal_phase/crystal_reference_frame`. .. GENERATED FROM PYTHON SOURCE LINES 29-34 .. code-block:: Python from diffpy.structure import Atom, Lattice, Structure from orix.crystal_map import Phase .. GENERATED FROM PYTHON SOURCE LINES 35-42 From a Crystallographic Information File (CIF) file. E.g. one for titanium from an online repository like the Americam Mineralogist Crystal Structure Database: https://rruff.geo.arizona.edu/AMS/download.php?id=13417.cif&down=text phase_ti = Phase.from_cif("ti.cif") print(phase_ti) .. GENERATED FROM PYTHON SOURCE LINES 44-45 From a space group (note that the point group is derived) .. GENERATED FROM PYTHON SOURCE LINES 45-48 .. code-block:: Python phase_m3m = Phase(space_group=225) print(phase_m3m) .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 49-51 From a point group (note that the space group is unknown since there are multiple options) .. GENERATED FROM PYTHON SOURCE LINES 51-54 .. code-block:: Python phase_432 = Phase(point_group="432") print(phase_432) .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 55-56 Non-crystalline phase .. GENERATED FROM PYTHON SOURCE LINES 56-59 .. code-block:: Python phase_non = Phase() print(phase_non) .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 60-61 Hexagonal alpha-titanium with a lattice and atoms .. GENERATED FROM PYTHON SOURCE LINES 61-67 .. code-block:: Python structure_ti = Structure( lattice=Lattice(4.5674, 4.5674, 2.8262, 90, 90, 120), atoms=[Atom("Ti", [0, 0, 0]), Atom("Ti", [1 / 3, 2 / 3, 1 / 2])], ) print(structure_ti) .. rst-class:: sphx-glr-script-out .. code-block:: none lattice=Lattice(a=4.5674, b=4.5674, c=2.8262, alpha=90, beta=90, gamma=120) Ti 0.000000 0.000000 0.000000 1.0000 Ti 0.333333 0.666667 0.500000 1.0000 .. GENERATED FROM PYTHON SOURCE LINES 68-71 .. code-block:: Python phase_ti = Phase(space_group=191, structure=structure_ti) print(phase_ti) print(phase_ti.structure) .. rst-class:: sphx-glr-script-out .. code-block:: none lattice=Lattice(base=array([[ 4.5674 , 0. , 0. ], [-2.2837 , 3.95548443, 0. ], [ 0. , 0. , 2.8262 ]])) Ti 0.000000 0.000000 0.000000 1.0000 Ti 0.577350 0.577350 0.500000 1.0000 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.200 seconds) **Estimated memory usage:** 548 MB .. _sphx_glr_download_examples_crystal_phase_create_crystal_phase.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: create_crystal_phase.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: create_crystal_phase.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: create_crystal_phase.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_