-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from ColwynGulliford/cgull-add_rectangular_geo…
…metry_to_write_gpt Adding test functions
- Loading branch information
Showing
2 changed files
with
1,062 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,250 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "4980f318-dad5-4471-be80-e092e1b2fd4a", | ||
"metadata": {}, | ||
"source": [ | ||
"# Field Analysis\n", | ||
"---\n", | ||
"## Checking Maxwell Equations\n", | ||
"The degree to which fieldmaps satisify Maxwell Equations often limits the fidelity of beam tracking solutions, and as such, several convenience functions are provided for inspecting FieldMesh data." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "f8a49260-4664-4d79-9d89-c91a9653d62a", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from pmd_beamphysics.fields.analysis import (\n", | ||
" check_static_div_equation,\n", | ||
" plot_maxwell_curl_equations,\n", | ||
")\n", | ||
"from pmd_beamphysics import FieldMesh" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "908c57d6-3f46-4197-9aee-b54e51f22744", | ||
"metadata": {}, | ||
"source": [ | ||
"### Time Varying Fields\n", | ||
"\n", | ||
"In this case, one seeks to verify $\\vec\\nabla\\times \\vec{E}=-\\frac{\\partial \\vec{B}}{\\partial t}$ and $\\vec\\nabla\\times \\vec{B}= \\frac{1}{c^2}\\frac{\\partial \\vec{E}}{\\partial t}$. This can be done for both rectangular and cylrindrical field geometries." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "a93cab8f-cac0-48cd-b1c3-2841d1ca6dbb", | ||
"metadata": {}, | ||
"source": [ | ||
"#### Example: 3D RF GUN From ANSYS" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "2bdfde81-403f-4010-8df4-0e8772ae44c9", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"FM3D = FieldMesh.from_ansys_ascii_3d(\n", | ||
" efile=\"../data/ansys_rfgun_2856MHz_E.dat\",\n", | ||
" hfile=\"../data/ansys_rfgun_2856MHz_H.dat\",\n", | ||
" frequency=2856e6,\n", | ||
")\n", | ||
"\n", | ||
"\n", | ||
"FM3D" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "43bb3821-025f-4c40-a87d-e381393e9b51", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"plot_maxwell_curl_equations(FM3D, ix=2, iy=2)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "88fbfda3-a39c-47f9-83e2-0f0d9bacea32", | ||
"metadata": {}, | ||
"source": [ | ||
"#### Example: 2D RF GUN " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "1e54d538-e0a9-44d4-894a-25f20ddc117e", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"FM2D = FieldMesh(\"../data/rfgun.h5\")\n", | ||
"\n", | ||
"plot_maxwell_curl_equations(FM2D, ir=10)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "613b5131-dc3a-42d5-b14d-6a60cb0ddd8b", | ||
"metadata": {}, | ||
"source": [ | ||
"#### Example: 3D RF GUN" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "70f18414-d6cd-4a1b-b516-dc1fee349a35", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"FM3D2 = FieldMesh(\"../data/rfgun_rectangular.h5\")\n", | ||
"\n", | ||
"plot_maxwell_curl_equations(FM3D2, ix=1, iy=1)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "2d26b67a-ad78-498b-9210-6eca7d1c31e8", | ||
"metadata": {}, | ||
"source": [ | ||
"### Static Electric or Magnetic Fields\n", | ||
"\n", | ||
"In this case, one seeks to verify $\\vec\\nabla\\cdot \\vec{E}=0$ or $\\vec\\nabla\\cdot \\vec{B}=0$. This can be done for both rectangular and cylrindrical field geometries." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "c5e58b95-5010-4858-b4a2-f9c88b29da2f", | ||
"metadata": {}, | ||
"source": [ | ||
"#### Example: Solenoid" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "66e153b3-9717-4c57-ab88-76b03371c4af", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"FMS = FieldMesh(\"../data/solenoid.h5\")\n", | ||
"\n", | ||
"check_static_div_equation(FMS, plot=True, rtol=1)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "503fd40e-3734-4a2d-9b51-b421ccd51bb2", | ||
"metadata": {}, | ||
"source": [ | ||
"#### Example: Aircore Corrector" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "d546eade-1c97-4bac-a981-a970afb615fe", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from pmd_beamphysics.fields.corrector_modeling import make_dipole_corrector_fieldmesh\n", | ||
"import numpy as np\n", | ||
"\n", | ||
"R = 2 * 2.54e-2 # 2\" radius [m]\n", | ||
"L = 0.1 # Length along z [m]\n", | ||
"theta = np.pi / 2 # Opening angle [rad]\n", | ||
"current = 1 # Current [Amp]\n", | ||
"\n", | ||
"FMC = make_dipole_corrector_fieldmesh(\n", | ||
" current=current,\n", | ||
" xmin=-0.9 * R,\n", | ||
" xmax=0.9 * R,\n", | ||
" nx=301,\n", | ||
" ymin=-0.9 * R,\n", | ||
" ymax=0.9 * R,\n", | ||
" ny=301,\n", | ||
" zmin=-5 * L / 2,\n", | ||
" zmax=5 * L / 2,\n", | ||
" nz=305,\n", | ||
" mode=\"rectangular\",\n", | ||
" a=R,\n", | ||
" h=R,\n", | ||
" b=L,\n", | ||
" plot_wire=True,\n", | ||
")\n", | ||
"FMC.plot_onaxis([\"Bx\", \"By\", \"Bz\"])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "1050cc1c-49c5-4b1f-999e-4635622e00ca", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"check_static_div_equation(FMC, plot=True, rtol=0.09, ix=211, iy=211)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "fb414275-aaef-466f-8d13-1c921daf4aeb", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "363858b1-6fc4-4fb5-ae0b-9d2ddc32b6c0", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "ad593b18-e324-4fce-baa4-c33105015733", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "a424e637-ad29-46aa-bfe8-60147b402cd6", | ||
"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.9.18" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.