-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #295 from pyiron/interactive_units
Interactive units
- Loading branch information
Showing
5 changed files
with
221 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"This notebooks compares the outputs from two static LAMMPS jobs one of which is an interactive job. This is to ensure that the outputs from interactive and non-interactive jobs are consistent." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from pyiron import Project\n", | ||
"import numpy as np" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"pr = Project(\"water_interactive\")\n", | ||
"pr.remove_jobs_silently()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"dx = 0.7\n", | ||
"cell = np.eye(3) * 10\n", | ||
"r_O = [0, 0, 0]\n", | ||
"r_H1 = [dx, dx, 0]\n", | ||
"r_H2 = [-dx, dx, 0]\n", | ||
"water = pr.create_atoms(elements=['H', 'H', 'O'],\n", | ||
" positions=[r_H1, r_H2, r_O],\n", | ||
" cell=cell, pbc=True)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"/cmmc/u/chandu/programs/pyiron_mpie/pyiron_atomistics/pyiron_atomistics/lammps/base.py:210: UserWarning: WARNING: Non-'metal' units are not fully supported. Your calculation should run OK, but results may not be saved in pyiron units.\n", | ||
" \"WARNING: Non-'metal' units are not fully supported. Your calculation should run OK, but \"\n", | ||
"/cmmc/u/chandu/programs/pyiron_mpie/pyiron_atomistics/pyiron_atomistics/lammps/base.py:262: UserWarning: No potential set via job.potential - use default potential, H2O_tip3p\n", | ||
" warnings.warn(\"No potential set via job.potential - use default potential, \" + lst_of_potentials[0])\n" | ||
] | ||
}, | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"The job test was saved and received the ID: 15458456\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# Interactive job\n", | ||
"job_int = pr.create.job.Lammps(\"test\", delete_existing_job=True)\n", | ||
"job_int.structure = water\n", | ||
"job_int.interactive_open()\n", | ||
"job_int.calc_static()\n", | ||
"job_int.run()\n", | ||
"job_int.interactive_close()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"The job test_ni was saved and received the ID: 15458457\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# Non-interactive job\n", | ||
"job = pr.create.job.Lammps(\"test_ni\", delete_existing_job=True)\n", | ||
"job.structure = water\n", | ||
"job.calc_static()\n", | ||
"job.run()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"cells\n", | ||
"energy_pot\n", | ||
"energy_tot\n", | ||
"forces\n", | ||
"indices\n", | ||
"positions\n", | ||
"pressures\n", | ||
"steps\n", | ||
"temperature\n", | ||
"volume\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"# Assert that the unit converstions work even in the interactive mode\n", | ||
"\n", | ||
"int_nodes = job_int[\"output/generic\"].list_nodes()\n", | ||
"usual_nodes = job[\"output/generic\"].list_nodes()\n", | ||
"for node in int_nodes:\n", | ||
" if node in usual_nodes:\n", | ||
" print(node)\n", | ||
" assert np.allclose(job_int[\"output/generic/\" + node], job[\"output/generic/\" + node])" | ||
] | ||
}, | ||
{ | ||
"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.9" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters