Skip to content

Commit

Permalink
Small profiling notebook for model instantation
Browse files Browse the repository at this point in the history
Also tests GERG-2008
  • Loading branch information
ianhbell committed Dec 12, 2023
1 parent 4f4db41 commit 5d32718
Showing 1 changed file with 140 additions and 0 deletions.
140 changes: 140 additions & 0 deletions notebooks/Bench schema validation.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "fdae749b",
"metadata": {},
"outputs": [],
"source": [
"j1 = {\n",
" \"kind\": \"vdW1\",\n",
" \"model\": {\n",
" \"a\": 1,\n",
" \"b\": 2\n",
" }\n",
"}\n",
"j2 = {\n",
" \"kind\": \"PCSAFT\",\n",
" \"model\": {\n",
" \"names\": [\"Methane\", \"Ethane\"],\n",
" \"kmat\": [[0.0, 0.0],[0.0,0.0]]\n",
" }\n",
"}\n",
"j3 = {\"kind\": \"SAFT-VR-Mie\", \"model\": {\"coeffs\": [{\"name\": \"R1234YF\", \"BibTeXKey\": \"Paricaud\", \"m\": 1.3656, \"sigma_Angstrom\": 4.5307, \"epsilon_over_k\": 299.424, \"lambda_r\": 21.7779, \"lambda_a\": 6.0, \"mu_D\": 2.2814, \"nmu\": 1.0, \"Q_DA\": 1.4151, \"nQ\": 1.0}, {\"name\": \"?\", \"BibTeXKey\": \"Paricaud\", \"m\": 1.4656, \"sigma_Angstrom\": 4.7307, \"epsilon_over_k\": 289.424, \"lambda_r\": 21.7779, \"lambda_a\": 6.0, \"mu_D\": 2.2814, \"nmu\": 1.0, \"Q_DA\": 1.4151, \"nQ\": 1.0}], \"polar_model\": \"GubbinsTwu+GubbinsTwu\"}}\n",
"import teqp"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "3efd41cd",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"10.2 µs ± 54.7 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)\n",
"240 µs ± 4.39 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)\n",
"520 µs ± 1.56 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)\n"
]
}
],
"source": [
"%timeit teqp.make_model(j1)\n",
"%timeit teqp.make_model(j2)\n",
"%timeit teqp.make_model(j3)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "788e6678",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"3.22 µs ± 38.3 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)\n",
"9.89 µs ± 46.7 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)\n",
"28.3 µs ± 101 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each)\n"
]
}
],
"source": [
"%timeit teqp.make_model(j1, validate=False)\n",
"%timeit teqp.make_model(j2, validate=False)\n",
"%timeit teqp.make_model(j3, validate=False)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "a285b19b",
"metadata": {},
"outputs": [],
"source": [
"names = [\"methane\", \"ethane\", \"propane\", \"n-butane\"]\n",
"\n",
"j1 = {\n",
" \"kind\": \"GERG2004resid\",\n",
" \"model\": {\n",
" \"names\": names\n",
" }\n",
"}\n",
"\n",
"j2 = {\n",
" \"kind\": \"GERG2008resid\",\n",
" \"model\": {\n",
" \"names\": names\n",
" }\n",
"}\n",
"m1 = teqp.make_model(j1)\n",
"m2 = teqp.make_model(j2)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "21b3242c",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"25.9 µs ± 168 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each)\n",
"26.2 µs ± 37.2 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each)\n"
]
}
],
"source": [
"%timeit teqp.make_model(j1, validate=False)\n",
"%timeit teqp.make_model(j2, validate=False)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.10.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

0 comments on commit 5d32718

Please sign in to comment.