Skip to content

Commit

Permalink
notebook works
Browse files Browse the repository at this point in the history
added test
  • Loading branch information
DavideTisi committed Dec 8, 2023
1 parent 8448a83 commit d16eb37
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 8 deletions.
72 changes: 64 additions & 8 deletions examples/06_example_cepstrum_viscosity_h2o.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Temp\ts_xy\t_xz\ts_yz \n"
"Temp\ts_xy\ts_xz\ts_yz \n"
]
}
],
Expand All @@ -74,9 +74,63 @@
"metadata": {
"tags": []
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Temp\ts_xy\ts_xz\ts_yz \n",
" #####################################\n",
" all_ckeys = [('Temp', [0]), ('s_xy', [1]), ('s_xz', [2]), ('s_yz', [3])]\n",
" #####################################\n",
"Data length = 100000\n",
" ckey = [('Temp', [0]), ('s_xy', [1]), ('s_xz', [2]), ('s_yz', [3])]\n",
" step = 100000 - 100.00% completed\n",
" ( 100000 ) steps read.\n",
"DONE. Elapsed time: 1.4065170288085938 seconds\n"
]
},
{
"data": {
"text/plain": [
"{'Temp': array([[408.14857],\n",
" [404.83967],\n",
" [400.74475],\n",
" ...,\n",
" [375.49635],\n",
" [374.86153],\n",
" [373.89371]]),\n",
" 's_xy': array([[788.37874],\n",
" [636.10743],\n",
" [478.48531],\n",
" ...,\n",
" [501.14159],\n",
" [552.52985],\n",
" [564.72988]]),\n",
" 's_xz': array([[ 14.137608],\n",
" [ -89.647884],\n",
" [-201.87593 ],\n",
" ...,\n",
" [-251.91173 ],\n",
" [-302.26323 ],\n",
" [-333.25187 ]]),\n",
" 's_yz': array([[-171.66794],\n",
" [-178.72951],\n",
" [-164.36904],\n",
" ...,\n",
" [ 633.03153],\n",
" [ 419.70789],\n",
" [ 191.02963]])}"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data = np.loadtxt('data/h2o/h2o.dat', skiprows = 1)"
"jfile = st.i_o.TableFile('./data/h2o/h2o.dat')\n",
"jfile.read_datalines()"
]
},
{
Expand Down Expand Up @@ -106,11 +160,12 @@
],
"source": [
"DT_FS = 1 # time step [fs]\n",
"TEMPERATURE = np.mean(data[:,0]) # temperature [K] (983.173 K)\n",
"TEMPERATURE = np.mean(jfile.data['Temp']) # temperature [K] (983.173 K)\n",
"VOLUME = 1918.4149658 # volume [A^3]\n",
"print(DT_FS, TEMPERATURE, VOLUME)\n",
"\n",
"j = st.StressCurrent(data[:,1:], UNITS='real', DT_FS=DT_FS, TEMPERATURE=TEMPERATURE, VOLUME=VOLUME)"
"j = st.StressCurrent(np.column_stack([jfile.data['s_xy'], jfile.data['s_xz'], jfile.data['s_yz']]),\n",
" UNITS='real', DT_FS=DT_FS, TEMPERATURE=TEMPERATURE, VOLUME=VOLUME)"
]
},
{
Expand Down Expand Up @@ -629,15 +684,16 @@
"tgap = 10 # see Allen-Tildelsey's book for better understanding\n",
"tcor = 10000 # maximum value of time (in timesteps) at which we want to compute the ACF \n",
"acf_ = []\n",
"n = len(data[:,1:])//segments\n",
"data = np.column_stack([jfile.data['s_xy'], jfile.data['s_xz'], jfile.data['s_yz']])\n",
"n = len(data[:,1])//segments\n",
"print(n)\n",
"for i in range(segments):\n",
" tmp , norm = ACF(data[(i*n):(i*n+n),0],tcor,n-tcor,tgap=tgap)\n",
" acf_.append(tmp)\n",
" tmp , norm = ACF(data[(i*n):(i*n+n),1],tcor,n-tcor,tgap=tgap)\n",
" acf_.append(tmp)\n",
" tmp , norm = ACF(data[(i*n):(i*n+n),2],tcor,n-tcor,tgap=tgap)\n",
" acf_.append(tmp)\n",
" tmp , norm = ACF(data[(i*n):(i*n+n),3],tcor,n-tcor,tgap=tgap)\n",
" acf_.append(tmp)\n",
" \n",
"\n",
"acf = np.column_stack(acf_)\n",
Expand Down
7 changes: 7 additions & 0 deletions tests/test_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ def test_doublecomp_NaCl(tb, file_regression):
def test_singlecomp_silica(tb, file_regression):
res = tb.cell_output_text('results_cell')
file_regression.check(res, basename='final_result2')

@local_dir
@testbook(test_folder_path + '/../examples/06_example_cepstrum_viscosity_h2o.ipynb', execute=True)
def test_singlecomp_silica(tb, file_regression):
res = tb.cell_output_text('results_cell')
file_regression.check(res, basename='final_result6')



@local_dir
Expand Down

0 comments on commit d16eb37

Please sign in to comment.