Skip to content

Commit

Permalink
Merge pull request #18 from samwaseda/joss_final_check
Browse files Browse the repository at this point in the history
update notebook and setup
  • Loading branch information
samwaseda authored Feb 27, 2024
2 parents e87adc9 + e10c749 commit 49283cb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 8 deletions.
36 changes: 30 additions & 6 deletions notebooks/first_steps.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
"id": "38c184fb",
"metadata": {},
"source": [
"Here, as we chose the parameter randomly, the Curie temperature is somewhat higher than what it is supposed to be. In addition, since the system is relatively small, the total magnetization after the transition does not completely vanish."
"Here, as we chose the Heisenberg parameter randomly, the Curie temperature is somewhat higher than the experimental value of 1,043 K. In addition, since the system is relatively small, the total magnetization after the transition does not completely vanish. The residual magnetization values above the Curie temperature can therefore vary each time you run the simulation. The unit if the magnetization is given by the Heisenberg parameter."
]
},
{
Expand All @@ -132,6 +132,14 @@
"## Thermodynamic integration"
]
},
{
"cell_type": "markdown",
"id": "ef3e00f3-6e53-44d7-ab4e-3ebd60133215",
"metadata": {},
"source": [
"Let's now take a look at the energy difference of iron in the two most prominent phases: Face-Centered-Cubic (fcc) and Body-Centered-Cubic (bcc). The energy difference can be calculated using [Thermodynamic Integration](https://en.wikipedia.org/wiki/Thermodynamic_integration), where we vary the unitless $\\lambda$ parameter (cf. [Wikipedia](https://en.wikipedia.org/wiki/Thermodynamic_integration#Derivation)) and integrate over the measured potential energies."
]
},
{
"cell_type": "code",
"execution_count": 37,
Expand Down Expand Up @@ -228,20 +236,20 @@
},
{
"cell_type": "code",
"execution_count": 53,
"execution_count": 18,
"id": "b70a0bb0",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The free energy difference between bcc and fcc at 300 K is 0.956543594612767\n"
"The free energy difference between bcc and fcc at 300 K is 0.9558411678020047 eV\n"
]
}
],
"source": [
"print(\"The free energy difference between bcc and fcc at 300 K is\", E_diff.sum() * np.diff(ti_lambda).mean())"
"print(\"The free energy difference between bcc and fcc at 300 K is\", E_diff.sum() * np.diff(ti_lambda).mean(), \"eV\")"
]
},
{
Expand All @@ -252,6 +260,14 @@
"## Metadynamics"
]
},
{
"cell_type": "markdown",
"id": "a992c792-8fe8-41be-ba54-cc8f726cee5f",
"metadata": {},
"source": [
"[Metadynamics](https://en.wikipedia.org/wiki/Metadynamics) is a simulation method which allows for the free energy distribution along a collective variable defined by the user. In mamonca, you can use the total magnetization as the collective variable, meaning you can obtain the free energy distribution along the total magnetization. For this, you only need to call `set_metadynamics` before `run`, where you must also specify the maximum magnetization value. In order to obtain a reliable result, you should also test the robustness by varying `energy_increment` and `length_scale` (cf. [Wikipedia](https://en.wikipedia.org/wiki/Metadynamics#Algorithm), where `energy_increment` is called $\\omega$ and `length_scale` is called $\\sigma$)"
]
},
{
"cell_type": "code",
"execution_count": 54,
Expand Down Expand Up @@ -316,10 +332,18 @@
"plt.plot(meta[\"magnetization\"], meta[\"free_energy\"])"
]
},
{
"cell_type": "markdown",
"id": "b8bf7959-f89f-43a1-ba9f-ca4e30678c2d",
"metadata": {},
"source": [
"The free energy minimum shows the most stable state. In this case it is around 0.5. Metadynamics, however, often requires a meticulous sampling, meaning with the standard energy increment of 0.001, you might overshoot and miss the global minimum. For a real measurement, it is recommended to make it as small as possible, meaning you should estimate the amount of time needed to run your calculation with Metadynamics with a small energy increment value and see what would be an acceptable total computation time."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "55339279",
"id": "9bf9c044-1a27-45b1-a582-cf72fddc5bb8",
"metadata": {},
"outputs": [],
"source": []
Expand All @@ -341,7 +365,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
"version": "3.11.8"
}
},
"nbformat": 4,
Expand Down
9 changes: 7 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

setup(
name='mamonca',
version='0.0.7',
version='0.0.8',
description='mamonca - interactive Magnetic Monte Carlo code',
long_description=readme,
long_description_content_type='text/markdown',
Expand All @@ -26,5 +26,10 @@
cmdclass={"build_ext": build_ext},
ext_modules=cythonize([ext], language_level="3"),
options={'build': {'build_lib': 'mamonca'}},
install_requires=["numpy", "cython"],
setup_requires=[
# Setuptools 18.0 properly handles Cython extensions.
'setuptools>=18.0',
'cython',
'numpy',
],
)

0 comments on commit 49283cb

Please sign in to comment.