{ "cells": [ { "cell_type": "code", "execution_count": 26, "id": "88f4bdb3", "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "color": "#2e91e5", "colorscale": [ [ 0, "#00b050" ], [ 0.16, "#00b050" ], [ 0.26, "#dddddd" ], [ 0.74, "#dddddd" ], [ 0.8400000000000001, "#e71111" ], [ 1, "#e71111" ] ], "i": { "bdata": "BwAAAAQEAgYEAAMHDwgICAwMCg4MCAsPFxAQEBQUEhYUEBMXHxgYGBwcGh4cGBsfJyAgICQkIiYkICMnLygoKCwsKi4sKCsvNzAwMDQ0MjY0MDM3Pzg4ODw8Oj48ODs/", "dtype": "i1" }, "intensity": { "bdata": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAPA/AAAAAAAA8D8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA8D8AAAAAAADwPwAAAAAAAAAAAAAAAAAAAAAAAAAAAADwPwAAAAAAAPA/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAPA/AAAAAAAA8D8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA8D8AAAAAAADwPwAAAAAAAAAAAAAAAAAAAAAAAAAAAADwPwAAAAAAAPA/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAPA/AAAAAAAA8D8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA8D8AAAAAAADwPwAAAAAAAAAAAAAAAAAAAAAAAAAAAADwPwAAAAAAAPA/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAPA/AAAAAAAA8D8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA8D8AAAAAAADwPwAAAAAAAAAAAAAAAAAAAAAAAAAAAADwPwAAAAAAAPA/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAPA/AAAAAAAA8D8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA8D8AAAAAAADwPwAAAAAAAAAAAAAAAAAAAAAAAAAAAADwPwAAAAAAAPA/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAPA/AAAAAAAA8D8=", "dtype": "f8" }, "j": { "bdata": "AAcBAgYHAQIFBQICCA8JCg4PCQoNDQoKEBcREhYXERIVFRISGB8ZGh4fGRodHRoaICchIiYnISIlJSIiKC8pKi4vKSotLSoqMDcxMjY3MTI1NTIyOD85Oj4/OTo9PTo6", "dtype": "i1" }, "k": { "bdata": "AwQCAwUGBQUAAQcGCwwKCw0ODQ0ICQ8OExQSExUWFRUQERcWGxwaGx0eHR0YGR8eIyQiIyUmJSUgIScmKywqKy0uLS0oKS8uMzQyMzU2NTUwMTc2Ozw6Oz0+PT04OT8+", "dtype": "i1" }, "legendgroup": "Collection(id=137832074478496)", "name": "Collection (8 sources)", "opacity": 1, "showlegend": true, "showscale": false, "type": "mesh3d", "x": { "bdata": "uB6F61G4jr+4HoXrUbiOv7gehetRuI6/uB6F61G4jr+4HoXrUbiOP7gehetRuI4/uB6F61G4jj+4HoXrUbiOP5qZmZmZmZk/mpmZmZmZmT+amZmZmZmZP5qZmZmZmZk/KVyPwvUorD8pXI/C9SisPylcj8L1KKw/KVyPwvUorD+4HoXrUbiOv7gehetRuI6/uB6F61G4jr+4HoXrUbiOv7gehetRuI4/uB6F61G4jj+4HoXrUbiOP7gehetRuI4/mpmZmZmZmT+amZmZmZmZP5qZmZmZmZk/mpmZmZmZmT8pXI/C9SisPylcj8L1KKw/KVyPwvUorD8pXI/C9SisP7gehetRuI6/uB6F61G4jr+4HoXrUbiOv7gehetRuI6/uB6F61G4jj+4HoXrUbiOP7gehetRuI4/uB6F61G4jj+amZmZmZmZP5qZmZmZmZk/mpmZmZmZmT+amZmZmZmZPylcj8L1KKw/KVyPwvUorD8pXI/C9SisPylcj8L1KKw/uB6F61G4jr+4HoXrUbiOv7gehetRuI6/uB6F61G4jr+4HoXrUbiOP7gehetRuI4/uB6F61G4jj+4HoXrUbiOP5qZmZmZmZk/mpmZmZmZmT+amZmZmZmZP5qZmZmZmZk/KVyPwvUorD8pXI/C9SisPylc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P4MUrkfhemQ/cxSuR+F6ZL9zFK5H4Xpkv3MUrkfhemQ/cxSuR+F6ZD+DFK5H4Xpkv4MUrkfhemS/gxSuR+F6ZD+DFK5H4XpkP3MUrkfhemS/cxSuR+F6ZL9zFK5H4XpkP3MUrkfhemQ/gxSuR+F6ZL+DFK5H4Xpkv4MUrkfhemQ/gxSuR+F6ZD9zFK5H4Xpkv3MUrkfhemS/cxSuR+F6ZD9zFK5H4XpkP4MUrkfhemS/gxSuR+F6ZL+DFK5H4XpkP4MUrkfhemQ/cxSuR+F6ZL9zFK5H4Xpkv3MUrkfhemQ/cxSuR+F6ZD+DFK5H4Xpkv4MUrkfhemS/gxSuR+F6ZD+DFK5H4XpkP3MUrkfhemS/cxSuR+F6ZL8=", "dtype": "f8" } } ], "layout": { "legend": { "itemsizing": "constant" }, "scene": { "aspectmode": "manual", "aspectratio": { "x": 1, "y": 1, "z": 1 }, "camera": { "eye": { "x": 1, "y": -1.5, "z": 1.4 } }, "xaxis": { "autorange": false, "range": [ -0.0475, 0.08750000000000001 ], "title": { "text": "x (m)" } }, "yaxis": { "autorange": false, "range": [ -0.007500000000000007, 0.1275 ], "title": { "text": "y (m)" } }, "zaxis": { "autorange": false, "range": [ -0.0675, 0.0675 ], "title": { "text": "z (m)" } } }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "histogram": [ { "marker": { "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "fillpattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermap": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermap" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } } } } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import magpylib as magpy\n", "from scipy.spatial.transform import Rotation as R\n", "import pyvista as pv\n", "import numpy as np\n", "\n", "# Creation of our magnets including place and orientation in the space (all dimensions guessed, need to put in correct ones)\n", "# magnetic polarization of 1.5 T pointing in x-direction \n", "# Dimensions assumed are 0.5, 1.5 and 3 cm (x,y,z) \n", "\n", "\n", "# Question: Is there a more elegant way to do this? Should I make a for-loop for creating our magnet array?\n", "\n", "magnet1 = magpy.magnet.Cuboid(polarization=(1.5, 0, 0), dimension=(0.005, 0.015, 0.03)) \n", "magnet1.position = (0, 0, 0)\n", "magnet1.orientation = R.from_euler(\"y\", 90, degrees=True)\n", "\n", "magnet2 = magpy.magnet.Cuboid(polarization=(1.5, 0, 0), dimension=(0.005, 0.015, 0.03)) \n", "magnet2.position = (0.04, 0, 0)\n", "magnet2.orientation = R.from_euler(\"y\", 90, degrees=True)\n", "\n", "magnet3 = magpy.magnet.Cuboid(polarization=(1.5, 0, 0), dimension=(0.005, 0.015, 0.03)) \n", "magnet3.position = (0, 0.04, 0)\n", "magnet3.orientation = R.from_euler(\"y\", 90, degrees=True)\n", "\n", "magnet4 = magpy.magnet.Cuboid(polarization=(1.5, 0, 0), dimension=(0.005, 0.015, 0.03)) \n", "magnet4.position = (0.04, 0.04, 0)\n", "magnet4.orientation = R.from_euler(\"y\", 90, degrees=True)\n", "\n", "magnet5 = magpy.magnet.Cuboid(polarization=(1.5, 0, 0), dimension=(0.005, 0.015, 0.03)) \n", "magnet5.position = (0, 0.08, 0)\n", "magnet5.orientation = R.from_euler(\"y\", 90, degrees=True)\n", "\n", "magnet6 = magpy.magnet.Cuboid(polarization=(1.5, 0, 0), dimension=(0.005, 0.015, 0.03)) \n", "magnet6.position = (0.04, 0.08, 0)\n", "magnet6.orientation = R.from_euler(\"y\", 90, degrees=True)\n", "\n", "magnet7 = magpy.magnet.Cuboid(polarization=(1.5, 0, 0), dimension=(0.005, 0.015, 0.03)) \n", "magnet7.position = (0, 0.12, 0)\n", "magnet7.orientation = R.from_euler(\"y\", 90, degrees=True)\n", "\n", "magnet8 = magpy.magnet.Cuboid(polarization=(1.5, 0, 0), dimension=(0.005, 0.015, 0.03)) \n", "magnet8.position = (0.04, 0.12, 0)\n", "magnet8.orientation = R.from_euler(\"y\", 90, degrees=True)\n", "\n", "\n", "# Grouping the magnets to collection\n", "coll = magpy.Collection(magnet1, magnet2, magnet3, magnet4, magnet5, magnet6, magnet7, magnet8)\n", "\n", "# Plotting the magnet array\n", "magpy.show(coll, backend=\"plotly\")" ] }, { "cell_type": "code", "execution_count": null, "id": "70a4312d", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "31021d1f168d4c86a26e512b68ff75d1", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Widget(value='