Skip to content

Commit 301943d

Browse files
authored
Merge pull request #173 from Varun-nair1997/main
example 7 bug fix and tests/test_ex07 inclusion
2 parents f31443b + 19a30f3 commit 301943d

File tree

3 files changed

+132
-22
lines changed

3 files changed

+132
-22
lines changed

examples/example_07/analysis.ipynb

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"id": "organized-shakespeare",
5+
"id": "bf354e59",
66
"metadata": {},
77
"source": [
88
"# Example 07: Upsampling calculations"
99
]
1010
},
1111
{
1212
"cell_type": "markdown",
13-
"id": "9dd01e04-93a1-4219-923f-08904414f558",
13+
"id": "f397582d",
1414
"metadata": {},
1515
"source": [
1616
"In this example, upsampling calculations which can be used to switch a system between two different interatomic potentials is illustrated. \n",
@@ -33,18 +33,18 @@
3333
{
3434
"cell_type": "code",
3535
"execution_count": 1,
36-
"id": "satisfactory-kinase",
36+
"id": "7d67fceb",
3737
"metadata": {},
3838
"outputs": [],
3939
"source": [
4040
"import numpy as np\n",
41-
"from calphy.input import read_report"
41+
"from calphy.postprocessing import read_report"
4242
]
4343
},
4444
{
4545
"cell_type": "code",
4646
"execution_count": 2,
47-
"id": "conditional-colombia",
47+
"id": "84a4c423",
4848
"metadata": {},
4949
"outputs": [],
5050
"source": [
@@ -54,13 +54,13 @@
5454
{
5555
"cell_type": "code",
5656
"execution_count": 3,
57-
"id": "established-vienna",
57+
"id": "72532dbd",
5858
"metadata": {},
5959
"outputs": [
6060
{
6161
"data": {
6262
"text/plain": [
63-
"-3.4389380251304913"
63+
"-3.440051166622059"
6464
]
6565
},
6666
"execution_count": 3,
@@ -74,7 +74,7 @@
7474
},
7575
{
7676
"cell_type": "markdown",
77-
"id": "5485eee8-5448-43b7-8376-22164d54a294",
77+
"id": "134dc9f1",
7878
"metadata": {},
7979
"source": [
8080
"Now we can transform FS to EAM potential (see input file above). After running the calculation, we can check the free energy of this alchemical transformation."
@@ -83,7 +83,7 @@
8383
{
8484
"cell_type": "code",
8585
"execution_count": 4,
86-
"id": "alive-farming",
86+
"id": "c21e8e87",
8787
"metadata": {},
8888
"outputs": [],
8989
"source": [
@@ -93,13 +93,13 @@
9393
{
9494
"cell_type": "code",
9595
"execution_count": 5,
96-
"id": "gorgeous-sunglasses",
96+
"id": "4845b921",
9797
"metadata": {},
9898
"outputs": [
9999
{
100100
"data": {
101101
"text/plain": [
102-
"-0.25451608590151586"
102+
"-0.2544850177491684"
103103
]
104104
},
105105
"execution_count": 5,
@@ -113,7 +113,7 @@
113113
},
114114
{
115115
"cell_type": "markdown",
116-
"id": "0d933ab0-bb82-4dcd-b307-03fd8e062c74",
116+
"id": "252cb4a4",
117117
"metadata": {},
118118
"source": [
119119
"The free energy of the EAM potential, $F_\\mathrm{EAM} = F_\\mathrm{FS} + F_\\mathrm{upsampling}$"
@@ -122,13 +122,13 @@
122122
{
123123
"cell_type": "code",
124124
"execution_count": 6,
125-
"id": "ec362ea8-cc19-4ff9-9462-d2335fdece19",
125+
"id": "8241e478",
126126
"metadata": {},
127127
"outputs": [
128128
{
129129
"data": {
130130
"text/plain": [
131-
"-3.693454111032007"
131+
"-3.694536184371227"
132132
]
133133
},
134134
"execution_count": 6,
@@ -142,7 +142,7 @@
142142
},
143143
{
144144
"cell_type": "markdown",
145-
"id": "51730d0f-d51c-495d-8c0d-8600f8034410",
145+
"id": "b728a4bd",
146146
"metadata": {},
147147
"source": [
148148
"We can verify this calculation by directly computing the free energy of the EAM potential. The input file is available at `pot2/input-fe.yaml`. "
@@ -151,7 +151,7 @@
151151
{
152152
"cell_type": "code",
153153
"execution_count": 7,
154-
"id": "opened-gates",
154+
"id": "e73096cb",
155155
"metadata": {},
156156
"outputs": [],
157157
"source": [
@@ -161,13 +161,13 @@
161161
{
162162
"cell_type": "code",
163163
"execution_count": 8,
164-
"id": "differential-robert",
164+
"id": "6a0ee06c",
165165
"metadata": {},
166166
"outputs": [
167167
{
168168
"data": {
169169
"text/plain": [
170-
"-3.6923377327832667"
170+
"-3.694201038169466"
171171
]
172172
},
173173
"execution_count": 8,
@@ -181,7 +181,7 @@
181181
},
182182
{
183183
"cell_type": "markdown",
184-
"id": "d79e509b-f0ac-4900-b5e3-18a343e7030d",
184+
"id": "b89d91c1",
185185
"metadata": {},
186186
"source": [
187187
"We can see that the directly calculation is in meV agreement with the upsampling calculations."
@@ -190,9 +190,9 @@
190190
],
191191
"metadata": {
192192
"kernelspec": {
193-
"display_name": "Python 3 (ipykernel)",
193+
"display_name": "pyiron",
194194
"language": "python",
195-
"name": "python3"
195+
"name": "pyiron"
196196
},
197197
"language_info": {
198198
"codemirror_mode": {
@@ -204,7 +204,7 @@
204204
"name": "python",
205205
"nbconvert_exporter": "python",
206206
"pygments_lexer": "ipython3",
207-
"version": "3.11.5"
207+
"version": "3.11.7"
208208
}
209209
},
210210
"nbformat": 4,

tests/test_ex07.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
def test_ex07():
2+
import calphy
3+
from calphy.postprocessing import read_report
4+
5+
# def test_example07_first_cell_runs():
6+
# notebook_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../examples/example_07/analysis.ipynb'))
7+
8+
# with open(notebook_path, "r", encoding="utf-8") as f:
9+
# nb = nbformat.read(f, as_version=4)
10+
11+
# # Filter just the first code cell
12+
# first_code_cell = next((cell for cell in nb.cells if cell.cell_type == "code"), None)
13+
14+
# if not first_code_cell:
15+
# pytest.fail("No code cell found in example07.ipynb")
16+
17+
# # Create a minimal notebook with only the first cell
18+
# nb_single = nbformat.v4.new_notebook()
19+
# nb_single.cells = [first_code_cell]
20+
21+
# try:
22+
# client = NotebookClient(nb_single, timeout=60, kernel_name="pyiron")
23+
# client.execute()
24+
# except Exception as e:
25+
# pytest.fail(f"First code cell in example07.analysis.ipynb failed: {e}")

tests/tests_NB.ipynb

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 2,
6+
"metadata": {
7+
"collapsed": true
8+
},
9+
"outputs": [
10+
{
11+
"ename": "ImportError",
12+
"evalue": "cannot import name 'SocketInterface' from 'pympipool' (/Users/varunnair/opt/anaconda3/lib/python3.7/site-packages/pympipool/__init__.py)",
13+
"output_type": "error",
14+
"traceback": [
15+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
16+
"\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)",
17+
"\u001b[0;32m<ipython-input-2-0422ff8f98f0>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;31m# import test_integrators\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;31m# import test_options\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 4\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mtest_solid_methods\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
18+
"\u001b[0;32m~/Desktop/ICAMS_HIWI/calphy/calphy/tests/test_solid_methods.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mpytest\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mcalphy\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0minput\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mread_inputfile\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mcalphy\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msolid\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mSolid\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mcalphy\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mliquid\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mLiquid\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mos\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
19+
"\u001b[0;32m~/opt/anaconda3/lib/python3.7/site-packages/calphy/__init__.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mcalphy\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0minput\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mCalculation\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mcalphy\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mliquid\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mLiquid\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mcalphy\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msolid\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mSolid\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mcalphy\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0malchemy\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mAlchemy\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mcalphy\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mroutines\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mMeltingTemp\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
20+
"\u001b[0;32m~/opt/anaconda3/lib/python3.7/site-packages/calphy/liquid.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 27\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mcalphy\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mintegrators\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 28\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mpyscal\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtraj_process\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mptp\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 29\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mcalphy\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlattice\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mpl\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 30\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mcalphy\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mhelpers\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mph\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 31\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mcalphy\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mphase\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mcph\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
21+
"\u001b[0;32m~/opt/anaconda3/lib/python3.7/site-packages/calphy/lattice.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 24\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mmendeleev\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0melement\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 25\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mos\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 26\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mpylammpsmpi\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mLammpsLibrary\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 27\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mnumpy\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 28\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mpyscal\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcore\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mpc\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
22+
"\u001b[0;32m~/opt/anaconda3/lib/python3.7/site-packages/pylammpsmpi/__init__.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mpylammpsmpi\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlammps_wrapper\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mLammpsLibrary\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0;34m.\u001b[0m\u001b[0m_version\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mget_versions\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0m__version__\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mget_versions\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"version\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
23+
"\u001b[0;32m~/opt/anaconda3/lib/python3.7/site-packages/pylammpsmpi/lammps_wrapper.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpylammpsmpi\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mutils\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcommands\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mcommand_list\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mthermo_list\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfunc_list\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mprop_list\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 6\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mpylammpsmpi\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mutils\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlammps\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mLammpsBase\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 7\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0m__author__\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m\"Sarath Menon, Jan Janssen\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
24+
"\u001b[0;32m~/opt/anaconda3/lib/python3.7/site-packages/pylammpsmpi/utils/lammps.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mos\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 6\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mpympipool\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mSocketInterface\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 7\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
25+
"\u001b[0;31mImportError\u001b[0m: cannot import name 'SocketInterface' from 'pympipool' (/Users/varunnair/opt/anaconda3/lib/python3.7/site-packages/pympipool/__init__.py)"
26+
]
27+
}
28+
],
29+
"source": [
30+
"import test_helpers as th"
31+
]
32+
},
33+
{
34+
"cell_type": "code",
35+
"execution_count": 1,
36+
"metadata": {},
37+
"outputs": [
38+
{
39+
"ename": "ModuleNotFoundError",
40+
"evalue": "No module named 'pyscal'",
41+
"output_type": "error",
42+
"traceback": [
43+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
44+
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
45+
"\u001b[0;32m<ipython-input-1-e8e6f8f7118e>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mpyscal\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
46+
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'pyscal'"
47+
]
48+
}
49+
],
50+
"source": [
51+
"th.test_nones()\n",
52+
"th.test_replace_nones()\n",
53+
"th.test_validate_spring_constants()"
54+
]
55+
},
56+
{
57+
"cell_type": "code",
58+
"execution_count": null,
59+
"metadata": {},
60+
"outputs": [],
61+
"source": []
62+
}
63+
],
64+
"metadata": {
65+
"kernelspec": {
66+
"display_name": "Python 3",
67+
"language": "python",
68+
"name": "python3"
69+
},
70+
"language_info": {
71+
"codemirror_mode": {
72+
"name": "ipython",
73+
"version": 3
74+
},
75+
"file_extension": ".py",
76+
"mimetype": "text/x-python",
77+
"name": "python",
78+
"nbconvert_exporter": "python",
79+
"pygments_lexer": "ipython3",
80+
"version": "3.7.6"
81+
}
82+
},
83+
"nbformat": 4,
84+
"nbformat_minor": 4
85+
}

0 commit comments

Comments
 (0)