modules/agent-framework/deployments/jupyterhub/data/gkeyll/plotE_z.ipynb (164 lines of code) (raw):
{
"cells": [
{
"cell_type": "markdown",
"id": "ec13f649-d9ee-47a2-9761-131abb1e2858",
"metadata": {},
"source": [
"#### Initialize, Authenticate, and Configure Remote Execution Environment\n",
"\n",
"##### Start a Cybershuttle Remote Executor: This will submit a remote job to Anvil\n",
"- **Cluster** - Anvil\n",
"- **Community Allocation** - Gkeyll\n",
"- **Requested Resources** - 4 CPUs, 4GB Memory, 60 Minutes, Shared Queue"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ae3f8f6f-2c94-44de-9a33-073a02bf05a4",
"metadata": {},
"outputs": [],
"source": [
"%pip install --force-reinstall airavata-jupyter-magic\n",
"import airavata_jupyter_magic\n",
"\n",
"%authenticate\n",
"%request_runtime test_cpu --cluster=Anvil --cpus=4 --memory=4096 --walltime=60 --queue=shared --group=Gkeyll\n",
"%switch_runtime test_cpu"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "aebd5d11-8f1d-4251-99e2-60bd06bed837",
"metadata": {},
"outputs": [],
"source": [
"!ls /anvil/projects/x-phy220105/gkylMarch2025/vlabApps/gemReconnection"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4c5308aa-a6d2-4b8e-8e9e-ad6c2a6b7380",
"metadata": {},
"outputs": [],
"source": [
"from pathlib import Path\n",
"import matplotlib.pyplot as plt\n",
"import postgkyl as pg\n",
"\n",
"data_base_path = \"/anvil/projects/x-phy220105/gkylMarch2025/vlabApps/gemReconnection\"\n",
"run = Path.cwd()\n",
"\n",
"def getModelType():\n",
" frame = 0\n",
" models = [\"5m\", \"10m\"]\n",
" for model in models:\n",
" path = Path(f\"{data_base_path}/rt_{model}_gem_gzero-field_{frame}.gkyl\")\n",
" if path.is_file():\n",
" return model\n",
" error = \"Failed to find input file \" + str(path)\n",
" assert False, error"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9723cde9-abad-4d95-85cb-c618b383ae48",
"metadata": {},
"outputs": [],
"source": [
"frame = 0\n",
"model = getModelType()\n",
"filename = run / f\"{data_base_path}/rt_{model}_gem_gzero-field_{frame}.gkyl\"\n",
"filename = str(filename)\n",
"print(filename)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bcc09aec-5821-4e58-ad38-3765afc28fc3",
"metadata": {},
"outputs": [],
"source": [
"gdata = pg.GData(filename)\n",
"\n",
"vals = gdata.get_values() # cell-center values, shape is Ny * Nx * Ncomponents\n",
"grid = gdata.get_grid() # cell corner coordinates\n",
"ndim = gdata.get_num_dims() # number of spatial dimensions\n",
"\n",
"assert len(vals.shape) == ndim+1 and len(grid) == ndim\n",
"\n",
"icomp = 3\n",
"compName = r'$E_z^2$'\n",
"fileName = \"E_z.png\"\n",
"\n",
"my_vals = vals[..., icomp]\n",
"x, y = grid\n",
"\n",
"fig, ax = plt.subplots()\n",
"\n",
"im = ax.pcolormesh(x, y, my_vals.T)\n",
"fig.colorbar(im, ax=ax)\n",
"\n",
"ax.set_xlabel('x')\n",
"ax.set_ylabel('y')\n",
"ax.set_title(compName)\n",
"ax.set_aspect(1)\n",
"\n",
"plt.savefig(fileName)"
]
},
{
"cell_type": "markdown",
"id": "eee0d482-0d84-41d0-bf6d-820ac7c3bbf3",
"metadata": {},
"source": [
"#### To Stop the Agent Run"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2a5581f6-e963-4e2b-bd6e-8a122e906ca6",
"metadata": {},
"outputs": [],
"source": [
"%stop_runtime test_cpu\n",
"%switch_runtime local"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5d87f6d9-2547-473d-987a-af5306d6f00b",
"metadata": {},
"outputs": [],
"source": []
}
],
"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.11.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}