{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Creating structures in pyiron" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This section gives a brief introduction about some of the tools available in pyiron to construct atomic structures. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For the sake of compatibility, our structure class is written to be compatible with the popular Atomistic Simulation Environment package ([ASE](https://wiki.fysik.dtu.dk/ase/)). This makes it possible to use routines from ASE to help set-up structures.\n", "\n", "Furthermore, pyiron uses the [NGLview](http://nglviewer.org/nglview/latest/api.html) package to visualize the structures and trajectories interactively in 3D using NGLview-widgets." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "As preparation for the following discussion we import a few python libraries" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "ExecuteTime": { "end_time": "2018-02-10T08:32:28.838135Z", "start_time": "2018-02-10T08:32:26.787708Z" } }, "outputs": [], "source": [ "import numpy as np\n", "%matplotlib inline\n", "import matplotlib.pylab as plt" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "and create a pyiron project named 'structures':" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "from pyiron.project import Project\n", "pr = Project(path='structures')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Bulk crystals" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In this section we discuss various possibilities to create bulk crystal structures." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Using `create_structure()`" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The simplest way to generate simple crystal structures is using the inbuilt `create_structure()` function specifying the element symbol, Bravais basis and the lattice constant(s)\n", "\n", "Note: The output gives a cubic cell rather than the smallest non-orthogonal unit cell." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "ExecuteTime": { "end_time": "2018-02-10T08:36:09.587677Z", "start_time": "2018-02-10T08:36:08.971155Z" } }, "outputs": [], "source": [ "structure = pr.create_structure('Al', \n", " bravais_basis='fcc', \n", " lattice_constant=4.05)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To plot the structure interactively in 3D simply use:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "d6d41f5f787f458f963db58d887f69cb", "version_major": 2, "version_minor": 0 }, "text/plain": [ "_ColormakerRegistry()" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "c729cf4c00094e12bf31d78184355e12", "version_major": 2, "version_minor": 0 }, "text/plain": [ "NGLWidget()" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "structure.plot3d()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Using `create_ase_bulk()`\n", "\n", "Another convenient way to set up structures is using the `create_ase_bulk()` function which is built on top of the ASE build package for [bulk crystals](https://wiki.fysik.dtu.dk/ase/ase/build/build.html#ase.build.bulk). This function returns an object which is of the pyiron structure object type." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Example:** fcc bulk aluminum in a cubic cell" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "ExecuteTime": { "end_time": "2018-02-11T08:48:16.795460Z", "start_time": "2018-02-11T08:48:16.525956Z" } }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "1c3a009bffd14d8287125e8ec46bc64a", "version_major": 2, "version_minor": 0 }, "text/plain": [ "NGLWidget()" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "structure = pr.create_ase_bulk('Al', cubic=True)\n", "structure.plot3d()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Example:** wurtzite GaN in a 3x3x3 repeated orthorhombic cell.\n", "\n", "Note: \n", "- In contrast to new_structure = structure.repeat() which creates a new object, set_repeat() modifies the existing structure object.\n", "- Setting `spacefill=False` in the `plot3d()` method changes the atomic structure style to \"ball and stick\"." ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "ExecuteTime": { "end_time": "2018-02-11T08:51:10.251891Z", "start_time": "2018-02-11T08:51:09.957494Z" } }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "0b5439dadaa242a682b8271bab6bdf1e", "version_major": 2, "version_minor": 0 }, "text/plain": [ "NGLWidget()" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "structure = pr.create_ase_bulk('AlN', \n", " crystalstructure='wurtzite', \n", " a=3.5, orthorhombic=True)\n", "structure.set_repeat([3,3,3])\n", "structure.plot3d(spacefill=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Creating surfaces (using ASE)\n", "\n", "Surfaces can be created using the `create_surface()` function which is also built on top of the ASE build package for [surfaces](https://wiki.fysik.dtu.dk/ase/_modules/ase/build/surface.html)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Example:** Creating a 3x4 fcc Al(111) surface with 4 layers and a vacuum of 10 Ångström" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "ea0f7bf09600445fa596d9b6f22ff3bd", "version_major": 2, "version_minor": 0 }, "text/plain": [ "NGLWidget()" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "Al_111 = pr.create_surface(\"Al\", surface_type=\"fcc111\", \n", " size=(3, 4, 4), vacuum=10, orthogonal=True)\n", "Al_111.plot3d()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Creating structures without importing the project class\n", "\n", "In all the examples shown above, the structures are create from the pyiron `Project` object. It is also possible to do this without importing/initializing this object. For this the appropriate imports must be made." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "from pyiron import create_ase_bulk, create_surface" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "16b554dd32cb4639ac3e2233b9b511f8", "version_major": 2, "version_minor": 0 }, "text/plain": [ "NGLWidget()" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "structure = create_ase_bulk('AlN', \n", " crystalstructure='wurtzite', \n", " a=3.5, orthorhombic=True)\n", "structure.set_repeat([3,3,3])\n", "structure.plot3d(spacefill=False)" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "255d7e806b574609a6a8210d79ed90d5", "version_major": 2, "version_minor": 0 }, "text/plain": [ "NGLWidget()" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "Al_111 = create_surface(\"Al\", surface_type=\"fcc111\", \n", " size=(3, 4, 4), vacuum=10, orthogonal=True)\n", "Al_111.plot3d()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Using the ASE spacegroup class" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "ExecuteTime": { "end_time": "2018-02-11T09:37:06.542461Z", "start_time": "2018-02-11T09:37:06.310283Z" } }, "outputs": [], "source": [ "from ase.spacegroup import crystal\n", "from pyiron import ase_to_pyiron\n", "\n", "a = 9.04\n", "skutterudite = crystal(('Co', 'Sb'),\n", " basis=[(0.25, 0.25, 0.25), (0.0, 0.335, 0.158)],\n", " spacegroup=204,\n", " cellpar=[a, a, a, 90, 90, 90])\n", "skutterudite = ase_to_pyiron(skutterudite)" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "ExecuteTime": { "end_time": "2018-02-11T09:37:47.604586Z", "start_time": "2018-02-11T09:37:47.457434Z" } }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "96c71cd15e774a329a7d57f3ccba1012", "version_major": 2, "version_minor": 0 }, "text/plain": [ "NGLWidget()" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "skutterudite.plot3d()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Accessing the properties of the structure object" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Using the bulk aluminum fcc example from before the structure object can be created by" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "structure = pr.create_ase_bulk('Al', cubic=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A summary of the information about the structure is given by using" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Al: [0. 0. 0.]\n", "Al: [0. 2.025 2.025]\n", "Al: [2.025 0. 2.025]\n", "Al: [2.025 2.025 0. ]\n", "pbc: [ True True True]\n", "cell: \n", "[[4.05 0. 0. ]\n", " [0. 4.05 0. ]\n", " [0. 0. 4.05]]\n", "\n" ] } ], "source": [ "print(structure)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The cell vectors of the structure object can be accessed and edited through" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[4.05, 0. , 0. ],\n", " [0. , 4.05, 0. ],\n", " [0. , 0. , 4.05]])" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "structure.cell" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The positions of the atoms in the structure object can be accessed and edited through" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[0. , 0. , 0. ],\n", " [0. , 2.025, 2.025],\n", " [2.025, 0. , 2.025],\n", " [2.025, 2.025, 0. ]])" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "structure.positions" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Point defects" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Creating a single vacancy" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We start by setting up a 4x4x4 supercell" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "ExecuteTime": { "end_time": "2018-02-12T09:07:41.713136Z", "start_time": "2018-02-12T09:07:41.358933Z" } }, "outputs": [], "source": [ "structure = pr.create_ase_bulk('Al', cubic=True)\n", "structure.set_repeat([4,4,4])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To create the vacancy at position index \"0\" simply use:" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [], "source": [ "del structure[0]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To plot the structure that now contains a vacancy run:" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "6f8d6aa814494b14877625310afb05d3", "version_major": 2, "version_minor": 0 }, "text/plain": [ "NGLWidget()" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "structure.plot3d()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Creating multiple vacancies" ] }, { "cell_type": "code", "execution_count": 20, "metadata": { "ExecuteTime": { "end_time": "2018-02-12T09:17:37.707055Z", "start_time": "2018-02-12T09:17:37.321281Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Number of atoms in the repeat unit: 256\n" ] } ], "source": [ "# First create a 4x4x4 supercell\n", "structure = pr.create_ase_bulk('Al', cubic=True)\n", "structure.set_repeat([4,4,4])\n", "print('Number of atoms in the repeat unit: ',structure.get_number_of_atoms())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The `del` command works for passing a list of indices to the structure object. For example, a random set of n$_{\\text{vac}}$ vacancies can be created by using" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [], "source": [ "# Generate a list of indices for the vacancies\n", "n_vac = 24\n", "vac_ind_lst = np.random.permutation(len(structure))[:n_vac]\n", "\n", "# Remove atoms according to the \"vac_ind_lst\"\n", "del structure[vac_ind_lst]" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Number of atoms in the repeat unit: 232\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "b351697dfa9e45f085cfbbaec04e8439", "version_major": 2, "version_minor": 0 }, "text/plain": [ "NGLWidget()" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Visualize the structure\n", "print('Number of atoms in the repeat unit: ',structure.get_number_of_atoms())\n", "structure.plot3d()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Random substitutial alloys" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [], "source": [ "# Create a 4x4x4 supercell\n", "structure = pr.create_ase_bulk('Al', cubic=True)\n", "structure.set_repeat([4,4,4])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Substitutional atoms can be defined by changing the atomic species accessed through its position index.\n", "\n", "Here, we set $n_{\\text{sub}}$ magnesium substitutional atoms at random positions" ] }, { "cell_type": "code", "execution_count": 24, "metadata": { "ExecuteTime": { "end_time": "2018-02-12T09:19:45.031085Z", "start_time": "2018-02-12T09:19:44.598754Z" } }, "outputs": [], "source": [ "n_sub = 24\n", "structure[np.random.permutation(len(structure))[:n_sub]] = 'Mg'" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Number of atoms in the repeat unit: 256\n", "Chemical formula: Al232Mg24\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "c8b46b23d7e8488f9a6cd413cac88321", "version_major": 2, "version_minor": 0 }, "text/plain": [ "NGLWidget()" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Visualize the structure and print some additional information about the structure\n", "print('Number of atoms in the repeat unit: ',structure.get_number_of_atoms())\n", "print('Chemical formula: ',structure.get_chemical_formula())\n", "structure.plot3d()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Explicit definition of the structure\n", "\n", "You can also set-up structures through the explicit input of the cell parameters and positions" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "1356d7f3e2224fb19dd4db4ef7c9397f", "version_major": 2, "version_minor": 0 }, "text/plain": [ "NGLWidget()" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "cell = 10.0 * np.eye(3) # Specifying the cell dimensions\n", "positions = [[0.25, 0.25, 0.25], [0.75, 0.75, 0.75]]\n", "elements = ['O', 'O']\n", "\n", "# Now use the Atoms class to create the instance.\n", "O_dimer = pr.create_atoms(elements=elements, scaled_positions=positions, cell=cell)\n", "\n", "O_dimer.plot3d()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Importing from cif/other file formats\n", "\n", "Parsers from ASE can be used to import structures from other formats. In this example, we will download and import a Nepheline structure from the [Crystallography Open Database (COD)](http://www.crystallography.net/cod/index.php)" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [], "source": [ "# The COD structures can be accessed through their unique COD identifier\n", "cod = 1008753\n", "filename = '{}.cif'.format(cod)\n", "url = 'http://www.crystallography.net/cod/{}'.format(filename)" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [], "source": [ "# Download and save the structure file locally\n", "import urllib\n", "urllib.request.urlretrieve(url=url, filename='strucs.'+filename);" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/surendralal/miniconda3/envs/pyiron_workshop/lib/python3.7/site-packages/ase/io/cif.py:375: UserWarning: crystal system 'hexagonal' is not interpreted for space group Spacegroup(173, setting=1). This may result in wrong setting!\n", " setting_name, spacegroup))\n" ] } ], "source": [ "# Using ase parsers to read the structure and then convert to a pyiron instance\n", "import ase\n", "from pyiron import ase_to_pyiron\n", "\n", "structure = ase_to_pyiron(ase.io.read(filename='strucs.'+filename,\n", " format='cif'))\n", "structure.info[\"cod\"] = cod" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [ { "ename": "ImportError", "evalue": "The package nglview needs to be installed for the plot3d() function!", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m~/science/phd/dev/pyiron/pyiron/atomistics/structure/atoms.py\u001b[0m in \u001b[0;36mplot3d\u001b[0;34m(self, show_cell, show_axes, camera, spacefill, particle_size, select_atoms, background, color_scheme, colors, scalar_field, scalar_start, scalar_end, scalar_cmap, vector_field, vector_color, magnetic_moments, custom_array, custom_3darray, view_plane, distance_from_camera)\u001b[0m\n\u001b[1;32m 1326\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;31m# If the graphical packages are not available, the GUI will not work.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1327\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mnglview\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1328\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mImportError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'nglview'", "\nDuring handling of the above exception, another exception occurred:\n", "\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mstructure\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mplot3d\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[0;32m~/science/phd/dev/pyiron/pyiron/atomistics/structure/atoms.py\u001b[0m in \u001b[0;36mplot3d\u001b[0;34m(self, show_cell, show_axes, camera, spacefill, particle_size, select_atoms, background, color_scheme, colors, scalar_field, scalar_start, scalar_end, scalar_cmap, vector_field, vector_color, magnetic_moments, custom_array, custom_3darray, view_plane, distance_from_camera)\u001b[0m\n\u001b[1;32m 1327\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mnglview\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1328\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mImportError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1329\u001b[0;31m raise ImportError(\n\u001b[0m\u001b[1;32m 1330\u001b[0m \u001b[0;34m\"The package nglview needs to be installed for the plot3d() function!\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1331\u001b[0m )\n", "\u001b[0;31mImportError\u001b[0m: The package nglview needs to be installed for the plot3d() function!" ] } ], "source": [ "structure.plot3d()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Structures can be stored indepently from jobs in HDF5 by using the special `StructureContainer` job. To save to disk, call `run()`." ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The job nepheline was saved and received the ID: 47\n" ] } ], "source": [ "container = pr.create_job(pr.job_type.StructureContainer, \"nepheline\")\n", "container.structure = structure\n", "container.run()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "It's also possible to store multiple structures in one container and to store directly from a job. Let's use this here to store the equilibrated structures at finite temperatures." ] }, { "cell_type": "code", "execution_count": 46, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "This group does not exist in the HDF5 file al_temp\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2020-08-22 14:05:03,496 - pyiron_log - WARNING - The job T_400 is being loaded instead of running. To re-run use the argument 'delete_existing_job=True in create_job'\n", "2020-08-22 14:05:04,282 - pyiron_log - WARNING - The job T_600 is being loaded instead of running. To re-run use the argument 'delete_existing_job=True in create_job'\n", "2020-08-22 14:05:05,065 - pyiron_log - WARNING - The job T_800 is being loaded instead of running. To re-run use the argument 'delete_existing_job=True in create_job'\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "The job al_temp was saved and received the ID: 51\n" ] } ], "source": [ "al_container = pr.create_job(pr.job_type.StructureContainer, \"al_temp\", delete_existing_job=True)\n", "for T in (400, 600, 800):\n", " j = pr.create_job(pr.job_type.Lammps, \"T_{}\".format(T))\n", " j.structure = pr.create_ase_bulk(\"Al\", cubic = True)\n", " j.potential = j.list_potentials()[0]\n", " j.calc_md(temperature=T, n_ionic_steps=1000, pressure=0)\n", " j.run()\n", " structure = j.get_structure(-1)\n", " structure.info[\"T\"] = T\n", " structure.info[\"P\"] = 0\n", " al_container.append(structure)\n", " \n", "al_container.run()" ] }, { "cell_type": "code", "execution_count": 47, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'T': 400, 'P': 0}" ] }, "execution_count": 47, "metadata": {}, "output_type": "execute_result" } ], "source": [ "al_container.structure_lst[0].info" ] }, { "cell_type": "code", "execution_count": 49, "metadata": {}, "outputs": [ { "data": { "application/json": [ "Al: [0.13389146 3.96541338 4.05893092]\nAl: [3.99018226 2.0071096 1.95618182]\nAl: [1.98560236 3.88778884 2.0465924 ]\nAl: [2.04906472 2.05913422 0.09311447]\npbc: [ True True True]\ncell: \nCell([[4.079370396328773, 2.497893949200251e-16, 2.497893949200251e-16], [0.0, 3.973148678151775, 2.4328519056175543e-16], [0.0, 0.0, 4.077409804014061]])\n", "Al: [0.0070279 4.03832899 0.08383998]\nAl: [4.08339864 2.06533333 2.03444326]\nAl: [2.20534808 4.07618808 1.94632881]\nAl: [1.91118709 2.15964157 0.05514228]\npbc: [ True True True]\ncell: \nCell([[4.103480856873615, 2.5126573483663555e-16, 2.5126573483663555e-16], [0.0, 4.113163987813141, 2.518586556021763e-16], [0.0, 0.0, 4.11975432838738]])\n", "Al: [3.7382874 0.12171228 4.27645154]\nAl: [0.05199557 1.91099383 2.20493355]\nAl: [1.92074788 0.03592662 2.13915097]\nAl: [1.89264518 1.93451826 0.04368514]\npbc: [ True True True]\ncell: \nCell([[3.801838019513017, 2.3279543807366644e-16, 2.3279543807366644e-16], [0.0, 4.003150985990484, 2.4512230207484086e-16], [0.0, 0.0, 4.332110602330073]])\n" ], "text/plain": [ "InputList([Al: [0.13389146 3.96541338 4.05893092]\n", "Al: [3.99018226 2.0071096 1.95618182]\n", "Al: [1.98560236 3.88778884 2.0465924 ]\n", "Al: [2.04906472 2.05913422 0.09311447]\n", "pbc: [ True True True]\n", "cell: \n", "Cell([[4.079370396328773, 2.497893949200251e-16, 2.497893949200251e-16], [0.0, 3.973148678151775, 2.4328519056175543e-16], [0.0, 0.0, 4.077409804014061]])\n", ", Al: [0.0070279 4.03832899 0.08383998]\n", "Al: [4.08339864 2.06533333 2.03444326]\n", "Al: [2.20534808 4.07618808 1.94632881]\n", "Al: [1.91118709 2.15964157 0.05514228]\n", "pbc: [ True True True]\n", "cell: \n", "Cell([[4.103480856873615, 2.5126573483663555e-16, 2.5126573483663555e-16], [0.0, 4.113163987813141, 2.518586556021763e-16], [0.0, 0.0, 4.11975432838738]])\n", ", Al: [3.7382874 0.12171228 4.27645154]\n", "Al: [0.05199557 1.91099383 2.20493355]\n", "Al: [1.92074788 0.03592662 2.13915097]\n", "Al: [1.89264518 1.93451826 0.04368514]\n", "pbc: [ True True True]\n", "cell: \n", "Cell([[3.801838019513017, 2.3279543807366644e-16, 2.3279543807366644e-16], [0.0, 4.003150985990484, 2.4512230207484086e-16], [0.0, 0.0, 4.332110602330073]])\n", "])" ] }, "execution_count": 49, "metadata": {}, "output_type": "execute_result" } ], "source": [ "al_container.structure_lst" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.7" }, "latex_envs": { "LaTeX_envs_menu_present": true, "autocomplete": true, "bibliofile": "biblio.bib", "cite_by": "apalike", "current_citInitial": 1, "eqLabelWithNumbers": true, "eqNumInitial": 1, "hotkeys": { "equation": "Ctrl-E", "itemize": "Ctrl-I" }, "labels_anchors": false, "latex_user_defs": false, "report_style_numbering": false, "user_envs_cfg": false }, "toc": { "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "toc_cell": false, "toc_position": {}, "toc_section_display": "block", "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 4 }