cadCAD/simulations/example_run.ipynb

187 lines
6.0 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"from tabulate import tabulate\n",
"\n",
"# The following imports NEED to be in the exact order\n",
"from cadCAD.engine import ExecutionMode, ExecutionContext, Executor\n",
"from validation import config1, config2, config3\n",
"from cadCAD import configs\n",
"\n",
"exec_mode = ExecutionMode()"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"config[0]\n",
"single_proc: [<cadCAD.configuration.Configuration object at 0x10a61b8d0>]\n",
" run s1 s2 s3 s4 substep timestep\n",
"0 1 0 0 1 1 0 0\n",
"1 1 1 4 5 1.178862847343031816649272514 1 1\n",
"2 1 ab 6 5 1.178862847343031816649272514 2 1\n",
"3 1 [c, d] [30, 300] 5 1.178862847343031816649272514 3 1\n",
"4 1 1 4 5 1.230321371869816411424320371 1 2\n",
"\n",
"config[1]\n",
"single_proc: [<cadCAD.configuration.Configuration object at 0x10a61be48>]\n",
" run s1 s2 s3 \\\n",
"0 1 0 0 1 \n",
"1 1 1 0 0.9583242152594528828757347583 \n",
"2 1 a 0 0.9583242152594528828757347583 \n",
"3 1 [c, d] [30, 300] 0.9583242152594528828757347583 \n",
"4 1 1 [30, 300] 0.9529320289547716885340867310 \n",
"\n",
" s4 substep timestep \n",
"0 1 0 0 \n",
"1 1.178862847343031816649272514 1 1 \n",
"2 1.178862847343031816649272514 2 1 \n",
"3 1.178862847343031816649272514 3 1 \n",
"4 1.230321371869816411424320371 1 2 \n",
"\n",
"config[2]\n",
"single_proc: [<cadCAD.configuration.Configuration object at 0x10a6282b0>]\n",
" run s1 s2 s3 s4 substep timestamp timestep\n",
"0 1 0 0 1 1 0 2018-10-01 15:16:24 0\n",
"1 1 [1] 0 1 1 1 2018-10-01 15:16:24 1\n",
"2 1 [1] 0 1 1 1 2018-10-01 15:16:24 2\n",
"3 1 [1] 0 1 1 1 2018-10-01 15:16:24 3\n",
"4 1 [1] 0 1 1 1 2018-10-01 15:16:24 4\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/markusbkoch/Documents/GitHub/DiffyQ-SimCAD/cadCAD/utils/__init__.py:86: FutureWarning: The use of a dictionary to describe Partial State Update Blocks will be deprecated. Use a list instead.\n",
" FutureWarning)\n"
]
}
],
"source": [
"for idx, c in enumerate(configs):\n",
" print()\n",
" print(f\"config[{idx}]\")\n",
" single_proc_ctx = ExecutionContext(context=exec_mode.single_proc)\n",
" run1 = Executor(exec_context=single_proc_ctx, configs=[c])\n",
" run1_raw_result, raw_tensor_field = run1.main()\n",
" result = pd.DataFrame(run1_raw_result)\n",
" print(result.head())\n",
"# tensor_field = pd.DataFrame(raw_tensor_field)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"multi_proc: [<cadCAD.configuration.Configuration object at 0x10a61b8d0>, <cadCAD.configuration.Configuration object at 0x10a61be48>, <cadCAD.configuration.Configuration object at 0x10a6282b0>, <cadCAD.configuration.Configuration object at 0x10a637c88>, <cadCAD.configuration.Configuration object at 0x10a637cc0>]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/markusbkoch/Documents/GitHub/DiffyQ-SimCAD/cadCAD/utils/__init__.py:86: FutureWarning: The use of a dictionary to describe Partial State Update Blocks will be deprecated. Use a list instead.\n",
" FutureWarning)\n"
]
}
],
"source": [
"from validation import sweep_config\n",
"multi_proc_ctx = ExecutionContext(context=exec_mode.multi_proc)\n",
"run2 = Executor(exec_context=multi_proc_ctx, configs=configs)\n",
"results = []\n",
"tensor_fields = []\n",
"for raw_result, raw_tensor_field in run2.main():\n",
" results.append(pd.DataFrame(raw_result))\n",
" tensor_fields.append(pd.DataFrame(raw_tensor_field))\n",
"\n",
"for idx, r in enumerate(results):\n",
" print()\n",
" print(f\"result[{idx}]\")\n",
" print(r.head())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"\n",
"print(\"Tensor Field A:\")\n",
"tensor_fields[0]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(\"Output A:\")\n",
"results[0]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(\"Tensor Field B:\")\n",
"tensor_fields[1]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(\"Output B:\")\n",
"results[1]"
]
}
],
"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.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 1
}