Skip to content
Snippets Groups Projects
KIM_AlLi_MEAM.ipynb 8.62 KiB
Newer Older
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "94cda45d-8d84-4270-8635-99672fad15d8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
      ],
      "text/plain": []
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
      ],
      "text/plain": []
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from pyiron import Project\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "a815efef-461e-4797-ba33-85fb5794a46a",
   "metadata": {},
   "outputs": [],
   "source": [
    "pr = Project(\"AlLiMEAM\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "972d60b9-b4c9-4533-b90f-6c9d3d55e564",
   "metadata": {},
   "source": [
    "Using openkim potentials requires a kim init command, which has to be placed before the structure. This is not directly possible in pyiron due to the order in the control file.\n",
    "\n",
    "A somewhat hacky workaround is to place the read_data command into the potential file and delete it from the original control.inp file."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "41d45117-b80c-4d61-9800-ec432e614a06",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Parameter</th>\n",
       "      <th>Value</th>\n",
       "      <th>Comment</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>units</td>\n",
       "      <td>metal</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>dimension</td>\n",
       "      <td>3</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>boundary</td>\n",
       "      <td>p p p</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>atom_style</td>\n",
       "      <td>atomic</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>include</td>\n",
       "      <td>potential.inp</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>fix___ensemble</td>\n",
       "      <td>all nve</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>variable___dumptime</td>\n",
       "      <td>equal 100</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>variable___thermotime</td>\n",
       "      <td>equal 100</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>dump___1</td>\n",
       "      <td>all custom ${dumptime} dump.out id type xsu ys...</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>dump_modify___1</td>\n",
       "      <td>sort id format line \"%d %d %20.15g %20.15g %20...</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>thermo_style</td>\n",
       "      <td>custom step temp pe etotal pxx pxy pxz pyy pyz...</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>thermo_modify</td>\n",
       "      <td>format float %20.15g</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>thermo</td>\n",
       "      <td>${thermotime}</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>run</td>\n",
       "      <td>0</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                Parameter                                              Value  \\\n",
       "0                   units                                              metal   \n",
       "1               dimension                                                  3   \n",
       "2                boundary                                              p p p   \n",
       "3              atom_style                                             atomic   \n",
       "4                 include                                      potential.inp   \n",
       "5          fix___ensemble                                            all nve   \n",
       "6     variable___dumptime                                          equal 100   \n",
       "7   variable___thermotime                                          equal 100   \n",
       "8                dump___1  all custom ${dumptime} dump.out id type xsu ys...   \n",
       "9         dump_modify___1  sort id format line \"%d %d %20.15g %20.15g %20...   \n",
       "10           thermo_style  custom step temp pe etotal pxx pxy pxz pyy pyz...   \n",
       "11          thermo_modify                               format float %20.15g   \n",
       "12                 thermo                                      ${thermotime}   \n",
       "13                    run                                                  0   \n",
       "\n",
       "   Comment  \n",
       "0           \n",
       "1           \n",
       "2           \n",
       "3           \n",
       "4           \n",
       "5           \n",
       "6           \n",
       "7           \n",
       "8           \n",
       "9           \n",
       "10          \n",
       "11          \n",
       "12          \n",
       "13          "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = pr.create.structure.ase.bulk(\"Al\", cubic=True)\n",
    "s[1] = \"Li\"\n",
    "job = pr.create.job.Lammps(\"PotDF\", delete_existing_job=True)\n",
    "job.structure = s\n",
    "\n",
    "pot = pd.DataFrame(\n",
    "    {\n",
    "        \"Name\": \"KIM MEAM\",\n",
    "        \"Filename\": [[]],\n",
    "        \"Model\": [\"Custom\"],\n",
    "        \"Species\": [[\"Al\", \"Li\"]],\n",
    "        \"Config\": [\n",
    "            [\n",
    "                'kim init MEAM_LAMMPS_RoyDuttaChakraborti_2021_AlLi__MO_971738391444_000 metal\\n',\n",
    "                'read_data structure.inp\\n', # This is a really dirty fix for the kim init problem\n",
    "                'kim interactions Al Li\\n',\n",
    "            ]\n",
    "        ],\n",
    "    }\n",
    ")\n",
    "\n",
    "job.potential = pot\n",
    "del job.input.control[\"read_data\"]\n",
    "job.input.control"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "342e2237-afe9-4664-944b-2883b3807f3c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The job PotDF was saved and received the ID: 648448\n"
     ]
    }
   ],
   "source": [
    "job.run()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7c153be5-2c4c-4678-8f54-a184e5f46e8b",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}