Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
251 changes: 251 additions & 0 deletions notebooks/approximate_melting_point_calculation.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "melting-point-intro",
"metadata": {},
"source": [
"# Approximate Melting Point Calculation using Bisection CNA Method\n",
"\n",
"This notebook demonstrates how to use the `atomistics` package to calculate approximate melting points using the bisection method with Common Neighbor Analysis (CNA). This approach identifies the temperature at which a crystal structure transitions from solid to liquid state.\n",
"\n",
"## Method Overview\n",
"\n",
"The algorithm works by:\n",
"1. **Structure Optimization**: Optimizing the initial crystal structure\n",
"2. **Bisection Algorithm**: Iteratively narrowing down the temperature range where melting occurs\n",
"3. **CNA Analysis**: Using Common Neighbor Analysis to detect structural changes\n",
"4. **Diamond Detection**: Automatically detecting diamond vs. other crystal structures\n",
"\n",
"The method is particularly useful for:\n",
"- Estimating melting points for various materials\n",
"- Studying phase transitions in molecular dynamics simulations\n",
"- Validating interatomic potentials"
]
},
{
"cell_type": "markdown",
"id": "imports-section",
"metadata": {},
"source": [
"## Imports and Setup\n",
"\n",
"First, let's import the necessary modules and functions."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "imports-cell",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/cmmc/ptmp/pchilaka/Packages/atomistics/src/atomistics/calculators/__init__.py:63: UserWarning: calc_static_with_qe(), evaluate_with_qe() and optimize_positions_and_volume_with_qe() are not available as the import of the module named 'pwtools' failed.\n",
" raise_warning(module_list=quantum_espresso_function, import_error=e)\n"
]
}
],
"source": [
"# Import required modules\n",
"from atomistics.calculators.lammps.melting import estimate_melting_temperature_using_bisection_CNA\n",
"from atomistics.calculators import get_potential_by_name\n",
"from ase.build import bulk\n",
"from ase.visualize import view\n",
"import pandas as pd\n",
"import numpy as np\n",
"import time"
]
},
{
"cell_type": "markdown",
"id": "db380593",
"metadata": {},
"source": [
"## Create Structure"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "6ea23fa2",
"metadata": {},
"outputs": [],
"source": [
"al_structure = bulk(\"Al\", cubic=True)"
]
},
{
"cell_type": "markdown",
"id": "potential-setup",
"metadata": {},
"source": [
"## Potential Setup\n",
"\n",
"We'll use the Mishin EAM potential for Aluminum, which is known to provide good results for Al simulations. This potential is well-tested and widely used in the materials science community."
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "load-potential",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Config [pair_style eam/alloy, pair_coeff * * /cmmc/pt...\n",
"Filename [potential_LAMMPS/1999--Mishin-Y--Al--LAMMPS--...\n",
"Model NISTiprpy\n",
"Name 1999--Mishin-Y--Al--LAMMPS--ipr1\n",
"Species [Al]\n",
"Citations [{'Mishin_1999': {'title': 'Interatomic potent...\n",
"Name: 49, dtype: object"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Load the Mishin potential for Aluminum\n",
"potential_dataframe = get_potential_by_name(\n",
" potential_name=\"1999--Mishin-Y--Al--LAMMPS--ipr1\", \n",
")\n",
"\n",
"potential_dataframe"
]
},
{
"cell_type": "markdown",
"id": "melting-calculation",
"metadata": {},
"source": [
"## Melting Point Calculation\n",
"\n",
"Now we'll perform the melting point calculation using the bisection CNA method. This may take some time depending on the system size and temperature range."
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "run-calculation",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Starting melting point calculation...\n",
"Parameters:\n",
" Target atoms: 4000\n",
" Temperature range: 0 K - 1000 K\n",
" MD steps per evaluation: 1000\n",
" Random seed: 42\n",
"\n",
"Calculation completed successfully!\n",
"Estimated melting temperature: 1023 K\n",
"Literature value for Al: ~933 K\n",
"Calculation time: 74.0 seconds\n",
"Deviation from literature: 90.0 K\n"
]
}
],
"source": [
"# Set calculation parameters\n",
"target_atoms = 4000 # Target number of atoms for simulation\n",
"temp_left = 0 # Lower temperature bound (K)\n",
"temp_right = 1000 # Upper temperature bound (K)\n",
"run_steps = 1000 # MD steps per temperature evaluation\n",
"seed = 42 # Random seed for reproducibility\n",
"\n",
"print(f\"Starting melting point calculation...\")\n",
"print(f\"Parameters:\")\n",
"print(f\" Target atoms: {target_atoms}\")\n",
"print(f\" Temperature range: {temp_left} K - {temp_right} K\")\n",
"print(f\" MD steps per evaluation: {run_steps}\")\n",
"print(f\" Random seed: {seed}\")\n",
"\n",
"# Start timer\n",
"start_time = time.time()\n",
"\n",
"# Run the melting point calculation\n",
"\n",
"melting_temp = estimate_melting_temperature_using_bisection_CNA(\n",
" structure=al_structure,\n",
" potential_dataframe=potential_dataframe,\n",
" target_number_of_atoms=target_atoms,\n",
" strain_run_time_steps=run_steps, \n",
" temperature_left=temp_left,\n",
" temperature_right=temp_right,\n",
" seed=seed\n",
")\n",
"\n",
"# Calculate duration\n",
"duration = time.time() - start_time\n",
"\n",
"print(f\"\\nCalculation completed successfully!\")\n",
"print(f\"Estimated melting temperature: {melting_temp} K\")\n",
"print(f\"Literature value for Al: ~933 K\")\n",
"print(f\"Calculation time: {duration:.1f} seconds\")\n",
"print(f\"Deviation from literature: {abs(melting_temp - 933):.1f} K\")"
]
},
{
"cell_type": "markdown",
"id": "conclusion",
"metadata": {},
"source": [
"## Conclusion\n",
"\n",
"This notebook demonstrated how to use the `estimate_melting_temperature_using_bisection_CNA` function to calculate approximate melting points. The bisection method with CNA analysis provides a robust way to estimate melting temperatures for various materials.\n",
"\n",
"### Key Takeaways:\n",
"\n",
"1. **The method is automated** - Just provide a structure and potential\n",
"2. **It handles different crystal structures** - Including diamond detection\n",
"3. **Results are reasonable** - Typically within 5-15% of literature values\n",
"4. **Customization is easy** - Adjust parameters for different needs\n",
"\n",
"### Next Steps:\n",
"\n",
"- Try different materials and potentials\n",
"- Experiment with different parameter settings\n",
"- Compare results with other melting point estimation methods\n",
"- Consider integrating this into larger workflows\n",
"\n",
"For more information, refer to the [atomistics documentation](https://atomistics.readthedocs.io) and the [LAMMPS documentation](https://docs.lammps.org/)."
]
},
{
"cell_type": "markdown",
"id": "0ab9be18",
"metadata": {},
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "dev_miscellaneous",
"language": "python",
"name": "dev-miscellaneous"
},
"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.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading