{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:46:42.208171Z", "start_time": "2020-07-17T05:46:40.705929Z" } }, "outputs": [], "source": [ "from pyiron import Project\n", "import numpy as np" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:46:42.965734Z", "start_time": "2020-07-17T05:46:42.209701Z" } }, "outputs": [], "source": [ "pr = Project('SPX_CHECK_ALL')" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:46:42.968689Z", "start_time": "2020-07-17T05:46:42.966912Z" } }, "outputs": [], "source": [ "a_Fe = 2.83\n", "a_Al = 4.024" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:46:46.438112Z", "start_time": "2020-07-17T05:46:42.969610Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The job spx_Fe_nonmag was saved and received the ID: 1\n" ] } ], "source": [ "job = pr.create_job(pr.job_type.Sphinx, 'spx_Fe_nonmag')\n", "job.structure = pr.create_structure('Fe', 'bcc', a_Fe)\n", "job.calc_static()\n", "job.run()" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:46:46.493542Z", "start_time": "2020-07-17T05:46:46.468312Z" } }, "outputs": [], "source": [ "if np.linalg.norm(job['output/generic/forces'])>1.0e-4:\n", " raise ValueError('Forces wrong')" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:46:46.516194Z", "start_time": "2020-07-17T05:46:46.494893Z" } }, "outputs": [], "source": [ "if np.linalg.norm(job.structure.positions-job['output/generic/positions'][-1])>1.0e-4:\n", " raise ValueError('Positions not correctly parsed')" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:46:46.538382Z", "start_time": "2020-07-17T05:46:46.517467Z" } }, "outputs": [], "source": [ "if np.linalg.norm(job.structure.cell-job['output/generic/cells'][-1])>1.0e-4:\n", " raise ValueError('Cells not correctly parsed')" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:46:46.561921Z", "start_time": "2020-07-17T05:46:46.540634Z" } }, "outputs": [], "source": [ "if 'atom_spins' in job['output/generic/dft'].list_nodes():\n", " raise AssertionError('spins present')" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:46:46.588769Z", "start_time": "2020-07-17T05:46:46.563524Z" } }, "outputs": [], "source": [ "if np.abs(job['output/generic/volume']-np.linalg.det(job.structure.cell)) > 1.0e-4:\n", " raise ValueError('Volume wrong')" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:46:46.607700Z", "start_time": "2020-07-17T05:46:46.589830Z" } }, "outputs": [], "source": [ "if np.linalg.norm(job.structure.positions-job['output/generic/positions'][0])>1.0e-4:\n", " raise ValueError('Positions not parsed properly')" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:46:51.452912Z", "start_time": "2020-07-17T05:46:46.609304Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The job spx_Fe_ferro was saved and received the ID: 2\n" ] } ], "source": [ "job = pr.create_job(pr.job_type.Sphinx, 'spx_Fe_ferro')\n", "job.structure = pr.create_structure('Fe', 'bcc', a_Fe)\n", "job.structure.set_initial_magnetic_moments([2, 2])\n", "job.calc_static()\n", "job.run()" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:46:51.547233Z", "start_time": "2020-07-17T05:46:51.492672Z" } }, "outputs": [], "source": [ "if pr.inspect('spx_Fe_ferro')['output/generic/energy_tot'][0]-pr.inspect('spx_Fe_nonmag')['output/generic/energy_tot'][0]>0:\n", " raise ValueError('BCC Fe erromagnetic state has lower energy than nonmagnetic state')" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:47:00.787397Z", "start_time": "2020-07-17T05:46:51.548600Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The job spx_Fe_ferro_C was saved and received the ID: 3\n" ] } ], "source": [ "job = pr.create_job(pr.job_type.Sphinx, 'spx_Fe_ferro_C')\n", "job.structure = pr.create_structure('Fe', 'bcc', a_Fe)\n", "job.structure.set_initial_magnetic_moments([2, 2])\n", "job.structure += pr.create_atoms(elements=['C'], positions=[[0, 0, 0.5*a_Fe]], magmoms=[0])\n", "job.calc_static()\n", "job.run()" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:47:00.843790Z", "start_time": "2020-07-17T05:47:00.821981Z" } }, "outputs": [], "source": [ "if np.linalg.norm(job.structure.positions-job['output/generic/positions'][-1])>1.0e-4:\n", " raise ValueError('Positions not correctly parsed')" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:47:04.485726Z", "start_time": "2020-07-17T05:47:00.844846Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The job spx_Al was saved and received the ID: 4\n" ] } ], "source": [ "job = pr.create_job(pr.job_type.Sphinx, 'spx_Al')\n", "job.structure = pr.create_structure('Al', 'fcc', a_Al)\n", "job.calc_static()\n", "job.run()" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:47:08.940653Z", "start_time": "2020-07-17T05:47:04.523612Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "WARNING:\n", "job.input.structure != job.structure. The current job.structure will overwrite any changes you may might have made to job.input.structure in the meantime. To disable this overwrite, set job.input.structure.locked = True. To disable this warning, call job.load_structure_group() after making changes to job.structure.\n", "The job spx_Al_restart was saved and received the ID: 5\n" ] } ], "source": [ "job = job.restart()\n", "job.run()" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:47:09.238299Z", "start_time": "2020-07-17T05:47:08.980361Z" } }, "outputs": [], "source": [ "if 'spx_Al_restart' not in list(pr.job_table().job):\n", " raise AssertionError('restart job not found')" ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:47:09.310923Z", "start_time": "2020-07-17T05:47:09.239289Z" } }, "outputs": [], "source": [ "if np.abs(pr.inspect('spx_Al')['output/generic/energy_tot'][-1]-pr.inspect('spx_Al_restart')['output/generic/energy_tot'][-1])>1.0e-3:\n", " raise ValueError('Energy value after restart too different')" ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:47:15.362892Z", "start_time": "2020-07-17T05:47:09.311826Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The job spx_Al_minimize was saved and received the ID: 6\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/srv/conda/envs/notebook/lib/python3.7/site-packages/pyiron/base/generic/hdfio.py:694: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray\n", " np.array([np.array(v) for v in value]),\n" ] } ], "source": [ "job = pr.create_job(pr.job_type.Sphinx, 'spx_Al_minimize')\n", "job.structure = pr.create_structure('Al', 'fcc', a_Al)\n", "job.structure.positions[0,0] += 0.01\n", "job.calc_minimize()\n", "job.run()" ] }, { "cell_type": "code", "execution_count": 20, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:47:15.427542Z", "start_time": "2020-07-17T05:47:15.402604Z" } }, "outputs": [], "source": [ "E = job['output/generic/energy_tot']\n", "if E[0]-E[1]<0:\n", " raise AssertionError('Energy not decreased')" ] }, { "cell_type": "code", "execution_count": 21, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:47:19.138907Z", "start_time": "2020-07-17T05:47:15.428992Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The job spx_check_overlap was saved and received the ID: 7\n" ] } ], "source": [ "job = pr.create_job(pr.job_type.Sphinx, 'spx_check_overlap')\n", "job.structure = pr.create_structure('Fe', 'bcc', 2.832)\n", "job.set_check_overlap(False)\n", "job.calc_static()\n", "job.run()" ] }, { "cell_type": "code", "execution_count": 22, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:47:22.861989Z", "start_time": "2020-07-17T05:47:19.178541Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The job spx_symmetry was saved and received the ID: 8\n" ] } ], "source": [ "job = pr.create_job(pr.job_type.Sphinx, 'spx_symmetry')\n", "job.structure = pr.create_structure('Fe', 'bcc', 2.832)\n", "job.fix_symmetry = False\n", "job.calc_static()\n", "job.run()" ] }, { "cell_type": "code", "execution_count": 23, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:47:31.746110Z", "start_time": "2020-07-17T05:47:22.907737Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The job spx_Fe_ferro_constraint was saved and received the ID: 9\n" ] } ], "source": [ "job = pr.create_job(pr.job_type.Sphinx, 'spx_Fe_ferro_constraint')\n", "job.structure = pr.create_structure('Fe', 'bcc', a_Fe)\n", "job.structure.set_initial_magnetic_moments([2, 2])\n", "job.fix_spin_constraint = True\n", "job.calc_static()\n", "job.run()" ] }, { "cell_type": "code", "execution_count": 24, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:47:31.809375Z", "start_time": "2020-07-17T05:47:31.788100Z" } }, "outputs": [], "source": [ "if np.linalg.norm(job['output/generic/dft/atom_spins']-job.structure.get_initial_magnetic_moments())>1.0e-4:\n", " raise AssertionError('Magnetic moments either not properly parsed or constraining not working')" ] }, { "cell_type": "code", "execution_count": 25, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:47:35.491657Z", "start_time": "2020-07-17T05:47:31.810415Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The job spx_Al_submit was saved and received the ID: 10\n" ] } ], "source": [ "job = pr.create_job(pr.job_type.Sphinx, 'spx_Al_submit')\n", "job.structure = pr.create_structure('Al', 'fcc', a_Al)\n", "job.calc_static()\n", "# job.server.queue = 'impi_hy'\n", "job.run()" ] }, { "cell_type": "code", "execution_count": 26, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:47:39.231264Z", "start_time": "2020-07-17T05:47:35.532094Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The job spx_Al_save_memory was saved and received the ID: 11\n" ] } ], "source": [ "job = pr.create_job(pr.job_type.Sphinx, 'spx_Al_save_memory')\n", "job.structure = pr.create_structure('Al', 'fcc', a_Al)\n", "job.input['SaveMemory'] = True\n", "job.calc_static()\n", "job.run()" ] }, { "cell_type": "code", "execution_count": 27, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:47:55.861379Z", "start_time": "2020-07-17T05:47:39.270380Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The job sxextopt_Al was saved and received the ID: 12\n", "The job spx_Al_interactive was saved and received the ID: 13\n", "Ending calculation\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/srv/conda/envs/notebook/lib/python3.7/site-packages/pyiron/base/generic/hdfio.py:694: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray\n", " np.array([np.array(v) for v in value]),\n", "/srv/conda/envs/notebook/lib/python3.7/site-packages/h5io/_h5io.py:610: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray\n", " return np.array(array_restore)\n" ] } ], "source": [ "job = pr.create_job(pr.job_type.Sphinx, 'spx_Al_interactive')\n", "job.structure = pr.create_structure('Al', 'fcc', a_Al)\n", "job.structure.positions[0,0] += 0.01\n", "job.server.run_mode.interactive = True\n", "job.calc_static()\n", "minim = job.create_job(pr.job_type.SxExtOptInteractive, 'sxextopt_Al')\n", "minim.run()" ] }, { "cell_type": "code", "execution_count": 28, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:48:00.053512Z", "start_time": "2020-07-17T05:47:55.928137Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The job nonmodal2 was saved and received the ID: 14\n" ] } ], "source": [ "job = pr.create_job(pr.job_type.Sphinx, 'nonmodal2')\n", "job.structure = pr.create_structure('Al', 'fcc', a_Al)\n", "job.calc_static()\n", "job.save()\n", "job_reload = pr.load(job.job_name)\n", "job_reload.run()" ] }, { "cell_type": "code", "execution_count": 29, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:48:00.122114Z", "start_time": "2020-07-17T05:48:00.095619Z" } }, "outputs": [ { "data": { "text/plain": [ "array([6.013783, 5.85485 ])" ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "job['output/generic/dft/bands_e_fermi']" ] }, { "cell_type": "code", "execution_count": 30, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:48:11.122617Z", "start_time": "2020-07-17T05:48:00.123052Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The job sxextopt_Fe was saved and received the ID: 15\n", "WARNING:\n", "job.input.structure != job.structure. The current job.structure will overwrite any changes you may might have made to job.input.structure in the meantime. To disable this overwrite, set job.input.structure.locked = True. To disable this warning, call job.load_structure_group() after making changes to job.structure.\n", "The job spx_sxextopt_Fe was saved and received the ID: 16\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/srv/conda/envs/notebook/lib/python3.7/site-packages/pyiron/sphinx/interactive.py:134: UserWarning: Spin constraint not set -> set fix_spin_constraint = True\n", " warnings.warn(\"Spin constraint not set -> set fix_spin_constraint = True\")\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Ending calculation\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/srv/conda/envs/notebook/lib/python3.7/site-packages/pyiron/base/generic/hdfio.py:694: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray\n", " np.array([np.array(v) for v in value]),\n", "/srv/conda/envs/notebook/lib/python3.7/site-packages/h5io/_h5io.py:610: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray\n", " return np.array(array_restore)\n" ] } ], "source": [ "spx = pr.create_job('Sphinx', 'spx_sxextopt_Fe')\n", "spx.structure = pr.create_structure('Fe', 'bcc', 2)\n", "spx.structure.set_initial_magnetic_moments([2, 2])\n", "spx.server.run_mode.interactive = True\n", "spx.calc_static()\n", "sxextopt = pr.create_job('SxExtOptInteractive', 'sxextopt_Fe')\n", "sxextopt.ref_job = spx\n", "\n", "sxextopt.save()\n", "sxextopt = pr.load('sxextopt_Fe')\n", "sxextopt.run()" ] }, { "cell_type": "code", "execution_count": 31, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:48:11.418036Z", "start_time": "2020-07-17T05:48:11.155629Z" } }, "outputs": [], "source": [ "if not all(pr.job_table().status=='finished'):\n", " jt = pr.job_table()\n", " print(jt[jt.status!='finished'])\n", " raise AssertionError('Some simulations failed')" ] }, { "cell_type": "code", "execution_count": 32, "metadata": { "ExecuteTime": { "end_time": "2020-07-17T05:48:16.320813Z", "start_time": "2020-07-17T05:48:11.419490Z" } }, "outputs": [], "source": [ "pr.remove(enable=True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "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.6" }, "latex_envs": { "LaTeX_envs_menu_present": true, "autoclose": false, "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": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 2 }