<jupyter_start><jupyter_text>PolymagnetsMessing around with creating interesting magnetic configurations with 3d printing and little rare earth magnets. Here is a video from my first spring/latch configuration ![](assets/video.gif). Build SimulationCreate a calculator that calculates the potential energy as a function of angle at different heights. Use:$$U(\theta) = -\vec{\mu}\cdot\vec{B}$$with$U \textrm{potential}$$This will be made easier by not caring about actual units (we are only looking for pole configurations at this point) and because all the magnets are the same. All the $\vec\mu$ are in the $\hat{z}$ direction and either 1 or -1. We will calculate $U(\theta)$ for each magnet with respect to each other magnet. $$\vec{B}(\vec{r})=\frac{\mu_0}{4\pi r^3}\big [3(\vec\mu_r\cdot\hat{r})\hat{r}-\vec\mu_r\big ]$$$$U(r,\theta) = -\vec{\mu}\cdot\frac{\mu_0}{4\pi r^3}\big [3(\vec\mu_r\cdot\hat{r})\hat{r}-\vec\mu_r\big ] $$3 Cases:- Case 1: aligned N, - Case 2: aligned S, - Case 3: opposed.<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
import math as m
from mpl_toolkits.mplot3d import axes3d
from potential import *<jupyter_output><empty_output><jupyter_text>Find Potential as a function of $\theta$<jupyter_code>UUU = potential_sweep(MAGCONFIGR0, MAGCONFIGR1, MAGCONFIGM0, MAGCONFIGM1,500)
plt.plot(UUU[0], UUU[1])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13352685050798258, 'fraction_numerical': 0.018867924528301886, 'mean_word_length': 5.325688073394495, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '302738', 'license': 'MIT', 'n_tokens_mistral': 478, 'n_tokens_neox': 448, 'n_words': 150, 'path': 'README.ipynb', 'repo_name': 'dmiracle/magnetics', 'size': '1378'}