{
"cells": [
{
"cell_type": "markdown",
"id": "909cd1e2",
"metadata": {},
"source": [
"# Use Mdapy Efficiently"
]
},
{
"cell_type": "markdown",
"id": "bcaee006",
"metadata": {},
"source": [
"### The key point is re-using the neighborlist information."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "c12f2890",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'1.0.5a2'"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import mdapy as mp\n",
"mp.__version__"
]
},
{
"cell_type": "markdown",
"id": "22d00857",
"metadata": {},
"source": [
"### Build a Copper system with 4,000,000 atoms."
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "fc775eec",
"metadata": {},
"outputs": [],
"source": [
"system = mp.build_crystal('Cu', 'fcc', 3.615, nx=100, ny=100, nz=100)"
]
},
{
"cell_type": "markdown",
"id": "a7b67b89",
"metadata": {},
"source": [
"### Check the system information."
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "8ca9c22e",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Atom Number: 4000000\n",
"Box information:\n",
"[[361.5 0. 0. ]\n",
" [ 0. 361.5 0. ]\n",
" [ 0. 0. 361.5]]\n",
"Origin: [0. 0. 0.]\n",
"Triclinic: False\n",
"Boundary: [1 1 1]\n",
"Particle Information:\n",
"shape: (4_000_000, 4)\n",
"┌──────────┬──────────┬──────────┬─────────┐\n",
"│ x ┆ y ┆ z ┆ element │\n",
"│ --- ┆ --- ┆ --- ┆ --- │\n",
"│ f64 ┆ f64 ┆ f64 ┆ str │\n",
"╞══════════╪══════════╪══════════╪═════════╡\n",
"│ 0.0 ┆ 0.0 ┆ 0.0 ┆ Cu │\n",
"│ 1.8075 ┆ 1.8075 ┆ 0.0 ┆ Cu │\n",
"│ 0.0 ┆ 1.8075 ┆ 1.8075 ┆ Cu │\n",
"│ 1.8075 ┆ 0.0 ┆ 1.8075 ┆ Cu │\n",
"│ 0.0 ┆ 0.0 ┆ 3.615 ┆ Cu │\n",
"│ … ┆ … ┆ … ┆ … │\n",
"│ 359.6925 ┆ 357.885 ┆ 356.0775 ┆ Cu │\n",
"│ 357.885 ┆ 357.885 ┆ 357.885 ┆ Cu │\n",
"│ 359.6925 ┆ 359.6925 ┆ 357.885 ┆ Cu │\n",
"│ 357.885 ┆ 359.6925 ┆ 359.6925 ┆ Cu │\n",
"│ 359.6925 ┆ 357.885 ┆ 359.6925 ┆ Cu │\n",
"└──────────┴──────────┴──────────┴─────────┘"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"system"
]
},
{
"cell_type": "markdown",
"id": "fece836f",
"metadata": {},
"source": [
"### Direct calculation."
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "c07b1fa1",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 1min 36s, sys: 9.58 s, total: 1min 45s\n",
"Wall time: 8.72 s\n"
]
}
],
"source": [
"%%time\n",
"system.cal_centro_symmetry_parameter(12)\n",
"system.cal_ackland_jones_analysis()\n",
"system.cal_structure_entropy(rc=5.0, sigma=0.2)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "5020e204",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"
shape: (5, 7)| x | y | z | element | csp | aja | entropy |
|---|
| f64 | f64 | f64 | str | f64 | i32 | f64 |
| 0.0 | 0.0 | 0.0 | "Cu" | 3.2952e-26 | 1 | -8.645166 |
| 1.8075 | 1.8075 | 0.0 | "Cu" | 1.0984e-26 | 1 | -8.645166 |
| 0.0 | 1.8075 | 1.8075 | "Cu" | 1.0984e-26 | 1 | -8.645166 |
| 1.8075 | 0.0 | 1.8075 | "Cu" | 1.0984e-26 | 1 | -8.645166 |
| 0.0 | 0.0 | 3.615 | "Cu" | 2.1968e-26 | 1 | -8.645166 |
"
],
"text/plain": [
"shape: (5, 7)\n",
"┌────────┬────────┬────────┬─────────┬────────────┬─────┬───────────┐\n",
"│ x ┆ y ┆ z ┆ element ┆ csp ┆ aja ┆ entropy │\n",
"│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │\n",
"│ f64 ┆ f64 ┆ f64 ┆ str ┆ f64 ┆ i32 ┆ f64 │\n",
"╞════════╪════════╪════════╪═════════╪════════════╪═════╪═══════════╡\n",
"│ 0.0 ┆ 0.0 ┆ 0.0 ┆ Cu ┆ 3.2952e-26 ┆ 1 ┆ -8.645166 │\n",
"│ 1.8075 ┆ 1.8075 ┆ 0.0 ┆ Cu ┆ 1.0984e-26 ┆ 1 ┆ -8.645166 │\n",
"│ 0.0 ┆ 1.8075 ┆ 1.8075 ┆ Cu ┆ 1.0984e-26 ┆ 1 ┆ -8.645166 │\n",
"│ 1.8075 ┆ 0.0 ┆ 1.8075 ┆ Cu ┆ 1.0984e-26 ┆ 1 ┆ -8.645166 │\n",
"│ 0.0 ┆ 0.0 ┆ 3.615 ┆ Cu ┆ 2.1968e-26 ┆ 1 ┆ -8.645166 │\n",
"└────────┴────────┴────────┴─────────┴────────────┴─────┴───────────┘"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"system.data.head()"
]
},
{
"cell_type": "markdown",
"id": "b90a344b",
"metadata": {},
"source": [
"### Re-use neighborlist information."
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "7e7bdecf",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 1min 17s, sys: 891 ms, total: 1min 18s\n",
"Wall time: 6.39 s\n"
]
}
],
"source": [
"%%time\n",
"system.build_neighbor(rc=5.0, max_neigh=50) # Obtain the neighbor first, the following calculation can use it.\n",
"system.cal_structure_entropy(rc=5.0, sigma=0.2)\n",
"system.cal_ackland_jones_analysis()\n",
"system.cal_centro_symmetry_parameter(12)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "ecefac5e",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"
shape: (5, 7)| x | y | z | element | csp | aja | entropy |
|---|
| f64 | f64 | f64 | str | f64 | i32 | f64 |
| 0.0 | 0.0 | 0.0 | "Cu" | 3.2952e-26 | 1 | -8.645166 |
| 1.8075 | 1.8075 | 0.0 | "Cu" | 1.0984e-26 | 1 | -8.645166 |
| 0.0 | 1.8075 | 1.8075 | "Cu" | 1.0984e-26 | 1 | -8.645166 |
| 1.8075 | 0.0 | 1.8075 | "Cu" | 1.0984e-26 | 1 | -8.645166 |
| 0.0 | 0.0 | 3.615 | "Cu" | 2.1968e-26 | 1 | -8.645166 |
"
],
"text/plain": [
"shape: (5, 7)\n",
"┌────────┬────────┬────────┬─────────┬────────────┬─────┬───────────┐\n",
"│ x ┆ y ┆ z ┆ element ┆ csp ┆ aja ┆ entropy │\n",
"│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │\n",
"│ f64 ┆ f64 ┆ f64 ┆ str ┆ f64 ┆ i32 ┆ f64 │\n",
"╞════════╪════════╪════════╪═════════╪════════════╪═════╪═══════════╡\n",
"│ 0.0 ┆ 0.0 ┆ 0.0 ┆ Cu ┆ 3.2952e-26 ┆ 1 ┆ -8.645166 │\n",
"│ 1.8075 ┆ 1.8075 ┆ 0.0 ┆ Cu ┆ 1.0984e-26 ┆ 1 ┆ -8.645166 │\n",
"│ 0.0 ┆ 1.8075 ┆ 1.8075 ┆ Cu ┆ 1.0984e-26 ┆ 1 ┆ -8.645166 │\n",
"│ 1.8075 ┆ 0.0 ┆ 1.8075 ┆ Cu ┆ 1.0984e-26 ┆ 1 ┆ -8.645166 │\n",
"│ 0.0 ┆ 0.0 ┆ 3.615 ┆ Cu ┆ 2.1968e-26 ┆ 1 ┆ -8.645166 │\n",
"└────────┴────────┴────────┴─────────┴────────────┴─────┴───────────┘"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"system.data.head()"
]
}
],
"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.12.0"
}
},
"nbformat": 4,
"nbformat_minor": 5
}