"'\\n1. Show a cicuit diagram with a key to switch between charging and discharging circuits as in the youtube video\\n2. Show the graph of Voltage and Current as a function of time.\\n3. Vary the time as multiples of the time constant. Show how much percent of the total voltage and current is present. May be it can be indicated with two progress bars.\\n\\nRef:\\nhttps://www.youtube.com/watch?v=X5bzjs3ByBU\\nhttps://electronicspani.com/charging-and-discharging-of-capacitor/\\n'"
]
},
- "execution_count": 12,
+ "execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#charge and discharge of a condensator\n",
"\"\"\"\n",
"1. Show a cicuit diagram with a key to switch between charging and discharging circuits as in the youtube video\n",
"2. Show the graph of Voltage and Current as a function of time.\n",
"3. Vary the time as multiples of the time constant. Show how much percent of the total voltage and current is present. May be it can be indicated with two progress bars.\n",
"Let us spend a few minutes to think through the following questions.\n",
"\n",
"Have you seen a flash camera? How is there a sudden burst of light when you click on the flash button? \n",
"\n",
"How does a smart phone touch screen react to your touch?\n",
"\n",
"Where does your computer/smart phone store the so called binary data?\n",
"\n",
"Intriguing...........?\n",
"\n",
"Now, consider a water tank. It has a pipe at the bottom with a valve. The tank can be filled by a pump. It can be emptied when the valve is open. A capacitor is a similar storage tank for the charges, which is filled by a volatage source (pump). It can be filled or emptied gradually leading to its extensive applications in electronic circuits.\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Charging a capacitor\n",
"Let us see the charging and discharging of the circuit through the circuit below.<br>\n",
"Let us begin with the switch in position A, when the circuit closes with voltage source, capacitor and the resistor. The voltage source will start accumulating charge in the capacitor plates through current in the cicuit. The charge accumulates until the voltage across the capacitor is equal the the applied voltage source and then the current stops flowing.\n",
"\n",
"At any given time,\n",
"\n",
"$V_{c}$ = Potential difference across the capacitor.<br>\n",
"$I_{c}$ = The instantaneous charging current.<br>\n",
"By seperation of variables and integrating the equation, we get\n",
"\\begin{equation}\n",
"\\log_e (V-V_c) = -\\frac{t}{CR}+constant\n",
"\\end{equation}<br>\n",
"As $V_c$ = 0 at the beginning (t=0), the constant turns out to be $log_{e}V$.\n",
"The variation of voltage across the capacitor is given by,\n",
"\\begin{equation}\n",
"V_c = V (1 - e^{\\frac{-t}{\\tau}})\n",
"\\end{equation}<br>\n",
"where $\\tau$ = RC is called the time constant. During the time $\\tau$ the capacitor gains 63.2$\\%$ of it's final value.<br><br>\n",
"We can also obtain the relation for charging current as \n",
"\\begin{equation}\n",
"I_c = \\frac{V}{R} e^{\\frac{-t}{\\tau}}\n",
"\\end{equation}\n",
"\n",
"## Charging table\n",
"Time | Volatage ($\\%$ of maximum) | Current ($\\%$ of maximum)\n",
"--- | --- | --- \n",
"0.5$\\tau$|39.3%|60.7%\n",
"0.7$\\tau$|50.3%|49.7%\n",
"1$\\tau$|63.2%|36.8%\n",
"2$\\tau$|86.5%|13.5%\n",
"3$\\tau$|95.0%|5.0%\n",
"4$\\tau$|98.2%|1.8%\n",
"5$\\tau$|99.3%|0.7%\n",
"\n",
"As the charging curve for a RC charging circuit is exponential, the capacitor in reality never becomes 100% fully charged due to the energy stored in the capacitor. So for all practical purposes, after five time constants a capacitor is considered to be fully charged."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Discharging a capacitor\n",
"Let us consider a time much larger than $\\tau$. The capacitor is fully charged. The switch is now flipped to position B, where the circuit closes with just the capacitor and the resistor.<br>\n",
"The potential built across the capacitor will drop through the load R. The discharging current flows in the opposite direction of the charging current as the potential built across the capacitor is opposite to the voltage across the intial source. The relations for voltage and current can be derived as,\n",
"\n",
"\\begin{equation}\n",
"V_c = V. e^{- \\frac{t}{\\tau}}\n",
"\\end{equation}\n",
"\n",
"\\begin{equation}\n",
"I_c = -\\frac{V}{R} e^{\\frac{-t}{\\tau}}\n",
"\\end{equation}\n",
"\n",
"## Discharging table\n",
"Time | Volatage ($\\%$ of maximum) | Current ($\\%$ of maximum)\n",
"--- | --- | --- \n",
"0.5$\\tau$|60.7%|39.3%\n",
"0.7$\\tau$|49.7%|50.3%\n",
"1$\\tau$|36.6%|63.4%\n",
"2$\\tau$|13.5%|86.5%\n",
"3$\\tau$|5.0%|95.0%\n",
"4$\\tau$|1.8%|98.2%\n",
"5$\\tau$|0.7%|99.3%\n",
"\n",
"After five time constants the capacitor is considered to be fully discharged."
]
},
{
"cell_type": "code",
- "execution_count": 13,
+ "execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "464d089a995f4506b54dcd93263609be",
+ "model_id": "5e260cdc747b4f018f192b5447fce0af",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(Button(description='Charging of Capacitor', style=ButtonStyle()), Button(description='Dischargi…"
" taw[\"args\"][1][i] = True # Toggle i'th trace to \"visible\"\n",
" taws.append(taw)\n",
"\n",
"sliders = [dict(\n",
" active=10,\n",
" currentvalue={\"prefix\": \"Time Constant T : \"},\n",
" pad={\"t\": 90}, #distance of the sliding bar from the x axis\n",
" steps=taws\n",
")]\n",
"\n",
"fig.update_layout(\n",
" sliders=sliders\n",
")\n",
"fig.data[0].visible = True\n",
"fig.show()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'\\n1. State the expression for both and explain the analogy\\n2. Show both the systems in animation. \\n3. Allow variation of\\n - position and velocity for the mechanical oscillator\\n - current and charge for the LC circuit\\n4. Varying one system should simulatenously affect the other system.\\n5. Show the plots of \\n - Kinetic and potential energy for the mechanical oscillator\\n - Energy from the inductor and capacitor for the LC circuit\\n \\nRef: https://www.youtube.com/watch?v=tIreqOg7zYw\\n'"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#Analogy of LC circuit and mechanical oscillator (A spring mass system or Pendulum)\n",
"\"\"\"\n",
"1. State the expression for both and explain the analogy\n",
"2. Show both the systems in animation. \n",
"3. Allow variation of\n",
" - position and velocity for the mechanical oscillator\n",
" - current and charge for the LC circuit\n",
"4. Varying one system should simulatenously affect the other system.\n",
"5. Show the plots of \n",
" - Kinetic and potential energy for the mechanical oscillator\n",
" - Energy from the inductor and capacitor for the LC circuit\n",
"plt.plot(x, U, 'r', label='Electric Field Energy') # plotting t, a separately \n",
"plt.plot(x, E, 'b', label='Total Energy') # plotting t, b separately \n",
"plt.plot(x, K, 'g', label='Magnetic Field Energy') # plotting t, c separately \n",
"plt.xlabel('Q(c)')\n",
"plt.ylabel('energy(j))')\n",
"plt.legend(loc='center')\n",
"plt.title('LC Circuit Energies')\n",
"plt.subplots_adjust(bottom=0.5, wspace=0.35)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'\\n1. Extend the analogy from previous section to the RLC circuit. Add friction to the mechanical oscillator.\\n2. Vary the value of R or the viscous constant to show different damping case. \\n3. Show graphs of the oscillation (position vs time / charge vs time)\\n\\n\\nRef: \\nhttp://www.ux1.eiu.edu/~cfadd/1360/32Ind/RLC.html\\nhttps://www.youtube.com/watch?v=sP1DzhT8Vzo\\nhttps://brilliant.org/wiki/damped-harmonic-oscillators/\\n'"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#RLC circuit. Analogy with damped mechanical oscillator.\n",
"\"\"\"\n",
"1. Extend the analogy from previous section to the RLC circuit. Add friction to the mechanical oscillator.\n",
"2. Vary the value of R or the viscous constant to show different damping case. \n",
"3. Show graphs of the oscillation (position vs time / charge vs time)\n",
"AttributeError: 'NoneType' object has no attribute 'remove_callback'\n"
]
}
],
"source": [
"\"\"\" # (Arnaud) Lorentz Force in a uniform magnetic field on a point charge (Cyclotron motion) and on a current-carrying wire. \n",
"\tMotion of a charged particle in perpendicular B and E fields (cycloid curve)\n",
"\tMagnetic bottle \n",
"\tMagnetic dipole in a uniform B field. \n",
"\"\"\"\n",
"###################################\n",
"\"\"\"\n",
"Some instructions\n",
"-----------------\n",
"\n",
"1. Start every section with a brief description of the concept. It can be a latex snippet.\n",
"2. Add illustration if needed.\n",
"3. Finally add the animation or the interactive module. Explicity display the parameters modified and the output result along with the animation\n",
"4. Keep each section in a single jupyter cell.\n",
"\"\"\"\n",
"#import libraries\n",
"\n",
"%matplotlib notebook\n",
"import numpy as np\n",
"import math\n",
"import matplotlib.pyplot as plt\n",
"import matplotlib.image as mpimg\n",
"\n",
"from mpl_toolkits.mplot3d import Axes3D\n",
"from matplotlib.animation import FuncAnimation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Electromagnetic force\n",
"\n",
"Attempts to describe electromagnetic force started as early as the 18th century. Johann Tobias Mayer (1760) and Henry Cavendish (1762) were the first to suggest the force on magnetic poles and electrically charged objects obey an inverse-square law.\n",
"\n",
"## Miscalculations ;)\n",
"Sir Joseph John Thomson was first in attempting the derivation of the electromagnetic forces on a moving charged particle from Maxwell's equations (1881). In the paper he published, he gave the force as:\n",
"\n",
"<font color=\"red\">\n",
"\\begin{equation}\n",
"\\vec{F} = \\frac{1}{2}q\\vec{v}x\\vec{B}\n",
"\\end{equation}\n",
"</font>\n",
"\n",
"where,\n",
"$\\vec{v}$ - velocity of the charged particle<br>\n",
"q - charge of the particle<br>\n",
"$\\vec{B}$ - magnetic field\n",
"\n",
"Thomson had the correct form of the equation, but due to some miscalculations and an incomplete description of the displacement current, included an incorrect scale of one-half at the front of the formula. Oliver Heaviside, who is responsible for the modern vector notation and also applied it to Maxwell's equations, fixed Thomson's mistakes and derived the correct form of the formula. For the modern formulation, Hendrik Lorentz (1892) arrived at the modern form which takes into account the total force from both the electric and magnetic fields.\n",
"\n",
"<font color=\"#00cc00\">\n",
"\\begin{equation}\n",
"\\vec{F} = q\\vec{E}+ q\\vec{v}x\\vec{B}\n",
"\\end{equation}\n",
"</font>\n"
]
},
{
"cell_type": "code",
- "execution_count": 11,
+ "execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"\"\"\" Vector utilities \"\"\"\n",
"\n",
"def get_arrows(vecs, theta):\n",
" x = [ vec(theta)[0] for vec in vecs ]\n",
" y = [ vec(theta)[1] for vec in vecs ]\n",
" z = [ vec(theta)[2] for vec in vecs ]\n",
" u = [ vec(theta)[3] for vec in vecs ]\n",
" v = [ vec(theta)[4] for vec in vecs ]\n",
" w = [ vec(theta)[5] for vec in vecs ]\n",
" return x,y,z,u,v,w\n",
"\n",
"def get_colors(vecs):\n",
" ret = []\n",
" for v in vecs:\n",
" ret.append(v(0)[6])\n",
" for v in vecs:\n",
" ret.append(v(0)[6])\n",
" ret.append(v(0)[6])\n",
" return ret"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Magnetic Force on a Moving Electric Charge\n",
"\n",
"The magnetic force on a charged particle q moving in a magnetic field $\\vec{B}$ with a velocity $\\vec{v}$ is \n",
"\\begin{equation}\n",
"\\vec{F} = q\\vec{v}x\\vec{B}\n",
"\\end{equation}\n",
"\n",
"The magnitude of the force is given by qvBsin($\\theta$), where $\\theta$ is the angle between velocity and the magnetic field vector.\n",
"\n",
"The direction of the force is perpendicular to the plane containing $\\vec{v}$ and $\\vec{B}$ and can be determined by the right hand rule.\n",
"It states that, to determine the direction of the magnetic force on a positive moving charge, you point the thumb of the right hand in the direction of $\\vec{v}$, the fingers in the direction of $\\vec{B}$, and a perpendicular to the palm points in the direction of $\\vec{F}.\n",
"\n",
"You can try to remember it with the following trick!<br>\n",
- "\n",
+ "<font color =\"#00cc00\">\n",
"<center>\n",
"$\\vec{v}$ Velocity is just <b>one direction</b> - so the <b>thumb</b> points it<br>\n",
"$\\vec{B}$ Magnetic field has <b>many lines</b> - so the <b>fingers</b> point them<br>\n",
"$\\vec{F}$ Force is in the direction you would <b>push</b> with your <b>palm</b><br>\n",
"</b>\n",
"<center>\n",
+ "</font>\n",
"<br>\n",
"<font color=\"blue\">\n",
"Try to visualize the right hand rule with the illustration below. \n",
"</font>\n"
]
},
{
"cell_type": "code",
- "execution_count": 12,
+ "execution_count": 9,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"application/javascript": [
"/* Put everything inside the global mpl namespace */\n",
"window.mpl = {};\n",
"\n",
"\n",
"mpl.get_websocket_type = function() {\n",
" if (typeof(WebSocket) !== 'undefined') {\n",
" return WebSocket;\n",
" } else if (typeof(MozWebSocket) !== 'undefined') {\n",
" return MozWebSocket;\n",
" } else {\n",
" alert('Your browser does not have WebSocket support. ' +\n",
"Consider a charged particle which moves perpendicular to a uniform B-field. Since the magnetic force is perpendicular to the direction of travel, a charged particle follows a curved path in a magnetic field. The particle continues to follow this curved path until it forms a complete circle. \n",
"\n",
"As the magnetic force is always perpendicular to velocity, it does no work on the charged particle. The particle’s kinetic energy and speed thus remain constant. The direction of motion is affected but not the speed.\n",
"\n",
"Since the velocity is perpendicular to the magnetic field, the magnetic force experienced by the particle is F = qvB. This supplies the centripetal force $F_{c}$ = $\\frac{mv^{2}}{2}$. Equating the two equations we obtain the radius of the circular motion as\n",
"\\begin{equation}\n",
"r = \\frac{mv}{qB}\n",
"\\end{equation}\n",
"\n",
"The time period of the circular motion is \n",
"\\begin{equation}\n",
"T = \\frac{2\\pi r}{v} = \\frac{2\\pi m}{qB}\n",
"\\end{equation}\n",
"\n",
"If the velocity is not perpendicular to the magnetic field, then we can compare each component of the velocity separately with the magnetic field. \n",
"\n",
"\\begin{equation}\n",
"v_{perpendicular} = v\\: sin \\theta\n",
"\\end{equation}\n",
"\n",
"\\begin{equation}\n",
"v_{parallel} = v\\: cos \\theta\n",
"\\end{equation}\n",
"\n",
"where $theta$ is the angle between v and B.\n",
"\n",
"The component of the velocity perpendicular to the magnetic field produces a magnetic force perpendicular to both this velocity and the field.\n",
"\n",
"The component parallel to the magnetic field creates constant motion along the same direction as the magnetic field. The result is a helical motion\n",
"\n",
"The parallel motion determines the pitch p of the helix, which is the distance between adjacent turns. This distance equals the parallel component of the velocity times the period:\n",
"\\begin{equation}\n",
"p = v\\: cos \\theta\\:T\n",
"\\end{equation}\n",
"\n",
"<font color=\"blue\">\n",
"Observe the helical motion in the illustration below\n",
"</font>\n"
]
},
{
"cell_type": "code",
- "execution_count": 13,
+ "execution_count": 10,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"application/javascript": [
"/* Put everything inside the global mpl namespace */\n",
"window.mpl = {};\n",
"\n",
"\n",
"mpl.get_websocket_type = function() {\n",
" if (typeof(WebSocket) !== 'undefined') {\n",
" return WebSocket;\n",
" } else if (typeof(MozWebSocket) !== 'undefined') {\n",
" return MozWebSocket;\n",
" } else {\n",
" alert('Your browser does not have WebSocket support. ' +\n",
"The circular motion of the charged particle in a magnetic has various practical applications. Cyclotron is one such device. It is a type of particle accelerator in which charged particles accelerate outwards from the center along a spiral path. The particles are held to a spiral trajectory by a static magnetic field and accelerated by a rapidly varying electric field.\n",
"\n",
"Cyclotrons accelerate charged particle beams using a high frequency alternating voltage which is applied between two “D”-shaped electrodes (also called “dees”). An additional static magnetic field is applied in perpendicular direction to the electrode plane. Every time the particle finishes its half-circle, the electric field just reverses direction and accerates the particle across the gap. So during the next half-circle, the particle has higher velocity and traverses a semi-circle of bigger radius. In this way, the particle traverses a spiral path and comes out with a very high speed.\n",
"\n",
"The time to complete one orbit is:\n",
"\\begin{equation}\n",
"T = \\frac{2\\pi m}{qB}\n",
"\\end{equation}\n",
"which is <b>independant of the radius</b>. Thus each circle is traversed in the same time.\n",
" \n",
"If a particle enters the cyclotron with a velocity $v_{0}$, its velocity at the output end after traversing n circles is given by\n",
"See the illustration below to observe the cyclotron motion with exaggerated middle section. You can see the charge particle accelerating with each crossing.\n",
"</font>\n",
"\n"
]
},
{
"cell_type": "code",
- "execution_count": 14,
+ "execution_count": 11,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"application/javascript": [
"/* Put everything inside the global mpl namespace */\n",
"window.mpl = {};\n",
"\n",
"\n",
"mpl.get_websocket_type = function() {\n",
" if (typeof(WebSocket) !== 'undefined') {\n",
" return WebSocket;\n",
" } else if (typeof(MozWebSocket) !== 'undefined') {\n",
" return MozWebSocket;\n",
" } else {\n",
" alert('Your browser does not have WebSocket support. ' +\n",
"'\\n1. Start with the charge in circular motion in magnetic field.\\n2. Given an option to switch between parallel and perpendicular electric field.\\n3. Show the path traced by the particle.\\n\\nRef:\\nhttps://cnx.org/contents/I1swyvWa@2/Motion-of-a-charged-particle-in-electric-and-magnetic-fields\\n'"
]
},
- "execution_count": 15,
+ "execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#Motion of charge in Electric and Magenetic field\n",
"\"\"\"\n",
"1. Start with the charge in circular motion in magnetic field.\n",
"2. Given an option to switch between parallel and perpendicular electric field.\n",
+ "Let us consider a bar magnet in a uniform magnetic field $\\vec{B}$. Let m be strength of each pole and 2l its length. The force acting on the North pole is mB along the field and that in the South pole is mB opposite to the field. The magnetic moment M of the bar magnet is M = m* 2l which points in the direction from South pole to North pole.\n",
+ "\n",
+ "## Situation 1\n",
+ "When the magnet is placed parallel to the magnetic field such that the magnetic moment is along the direction of the field, the net force and torque is zero.\n",
+ "If the magnet is placed in this position it remains in the same place. The magenet is in stable equilibrium.\n",
+ "\n",
+ "## Situation 2\n",
+ "When the magnet is placed parallel to the magnetic field such that the magnetic moment is opposite to the direction of the field, the net force and torque is zero.\n",
+ "When released, the magnet swings towards the equlibrium postition. But because of the velocity it gained, it further moves away from the equilibrium and develops a simple Harmonic oscillation.\n",
+ "\n",
+ "If I is the moment of inertia of the bar magnet the torque is given by I$\\alpha$ ($\\alpha$ = $\\frac{d^{2}\\theta}{dt}$ is the angular acceleration). This equals the restoring torque due to the magnetic field.\n",
+ "\n",
+ "At equilibrium, \n",
+ "\\begin{equation}\n",
+ "I \\frac{d^{2}\\theta}{dt} = −mBsin\\theta\n",
+ "\\end{equation}\n",
+ "where $\\theta$ is the angle between the direction of the magnetic moment (m) and the direction of the magnetic field (B).\n",
+ "\n",
+ "For small values of displacement,\n",
+ "\\begin{equation}\n",
+ "I \\frac{d^{2}\\theta}{dt} = −mB\\theta\n",
+ "\\end{equation}\n",
+ "This represents a simple harmonic motion with time period,\n",
+ "\\begin{equation}\n",
+ "T = 2\\pi \\sqrt{\\frac{I}{mB}}\n",
+ "\\end{equation}\n"
+ ]
+ },
{
"cell_type": "code",
- "execution_count": 18,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
- "# Magnetic dipole in a uniform B field"
+ "\"\"\"\n",
+ "Magnetic dipole in uniform field\n",
+ "\n",
+ "1. Get input from the user for 𝜃 = 0, 180 or some small angle. It can be a drop down list\n",
+ "2. Based on the input show the bar magnet reaching the equilibrium position.\n",
+ " - for 𝜃 = 0, the magnet does not move\n",
+ " - for 𝜃 = 180, the magnet flips\n",
+ " - for 𝜃 = small angle, the magnet oscillates\n",