Electromagnetismo¶
Una partícula con una carga positiva de 1C, se mueve cun una rapidez de 100m/s en la direccion X+ hacia un campo magnético uniforme de 10 T en la dirección Z+
¿Cúal es la trayectoria que sigue la patícula?
De la ecuación de Lorens
$$m\frac{dv}{dt}=q(\vec{v} \times \vec{B})(1)$$Se asume $\vec{B}=B_0 \widehat{z}$
El producto cruz seria
$$\vec{v} \times \vec{B}=(v_y \widehat{x} - v_x \widehat{y})B (2)$$y reemplanzando resulta. $$\frac{d\vec{v}}{dt}=\frac{qB}{m}(v_z \widehat{x} - v_x \widehat{y})$$(3)
se obtienen dos velocidades, que van a representar el movimiento en el plano siguiendo la fuerza que siente la particula en el campo magnético.
Para x: $$\frac{dv_x}{dt}=\frac{qB}{m}v_y$$(4) $$v_y= \frac{m}{qB}\frac{dv_x}{dt}$$(5)
para y
$$\frac{dv_y}{dt}=\frac{qB}{m}v_x $$(6)
reemplazando $v_y$ en 5 resulta $$\frac{d^2 v_x}{dt^2}+(\frac{qB}{m})^2 v_x=0$$(7)
$$v_x(t)=v_0 sin(\frac{qB}{m}t)$$(8) $$v_y (t)=v_0 cos(\frac{qB}{m}t)$$(9)
la ecuación total de la velocidad etaría dad por,
$$v_{x}^{2} + v_{y}^{2}=v_{0}^{2} sin^{2}(\frac{qB}{m}t)+v_{0}^{2}cos^{2}(\frac{qB}{m}t)$$(10)
Luego el movimiento perpendicular es compuesto de dos movimientos armónicos independientes dado por,
$$x(t)=\frac{mv_0}{qB} sin (\frac{qB}{m}t) + x_0$$(11)
$$y(t)=-\frac{mv_0}{qB} cos(\frac{qB}{m}t)+y_{0}$$(12)
from __future__ import division
import numpy as np
import string
import random
import sys
import pylab as p
import mpl_toolkits.mplot3d.axes3d as p3
from matplotlib import pyplot as p
from matplotlib import animation
from pip._vendor.distlib.compat import raw_input
%matplotlib auto
masa = 1
carga = 1
posicion = np.array([-1000, 0, -1000])
velocidad = np.array([0, 10, 0])
B = np.array([0, 0, 0.09])
E = np.array([0, 0, 0.09])
dt = 0
paso = 0.05
while True:
texto = raw_input("ingrese la masa:\n")
masa = float(texto)
if masa == 0:
print("entrada mala.")
else:
break
while True:
texto = raw_input("ingrese la carga:\n")
carga = float(texto)
if masa == 0:
print("entrada mala.")
else:
break
while True:
texto = raw_input("ingrese la posicion de la carda separado por espcios:\n")
ind = texto.split(" ")
if len(ind) != 3:
print("entrada mala.")
else:
posicion[0] = float(ind[0])
posicion[1] = float(ind[1])
posicion[2] = float(ind[2])
break
while True:
texto = raw_input("ingrese la velocidad inicial de la carda separado por espcios:\n")
ind = texto.split(" ")
if len(ind) != 3:
print("entrada mala.")
else:
velocidad[0] = float(ind[0])
velocidad[1] = float(ind[1])
velocidad[2] = float(ind[2])
break
while True:
texto = raw_input("ingrese el campo electrico separado por espcios:\n")
ind = texto.split(" ")
if len(ind) != 3:
print("entrada mala.")
else:
E[0] = float(ind[0])
E[1] = float(ind[1])
E[2] = float(ind[2])
break
while True:
texto = raw_input("ingrese el campo magnetico separado por espcios:\n")
ind = texto.split(" ")
if len(ind) != 3:
print("entrada mala.")
else:
B[0] = float(ind[0])
B[1] = float(ind[1])
B[2] = float(ind[2])
break
color = "m"
if carga < 0:
color = "b"
tamanoCaja = 1000
titulo = "Masa = " + str(masa) + "; carga = " + str(carga) + "; Vo= " + str(velocidad)
fig = p.figure()
fig.suptitle(titulo, fontsize=8, fontweight='bold')
ax = p3.Axes3D(fig)
ax.set_xlim3d({- tamanoCaja, tamanoCaja})
ax.set_ylim3d({- tamanoCaja, tamanoCaja})
ax.set_zlim3d({- tamanoCaja, tamanoCaja})
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
fig.suptitle(ax)
contador = 0
def anima(a):
global dt, posicion, velocidad, paso, carga, B, E, masa, color, contador
contador += 1
# ax.elev = 90
dt += paso
t = 0.5 * carga * B * dt / masa
t_2 = np.linalg.norm(t) * np.linalg.norm(t)
s = 2 * t / (1 + t_2)
v_minus = velocidad + 0.5 * carga * E * dt / masa
v_prime = v_minus + np.cross(v_minus, t)
v_plus = v_minus + np.cross(v_prime, s)
velocidad = v_plus + 0.5 * carga * E * dt / masa
posicion = posicion + velocidad * dt
ax.scatter(posicion[0], posicion[1],
posicion[2], s=1, c=color, marker="o")
if posicion[0] < - tamanoCaja or posicion[0] > tamanoCaja:
sys.exit()
if posicion[1] < - tamanoCaja or posicion[1] > tamanoCaja:
sys.exit()
if posicion[2] < - tamanoCaja or posicion[2] > tamanoCaja:
sys.exit()
print(contador, posicion)
# fig.savefig("imgs/" + str(i) + ".png"
anim = animation.FuncAnimation(fig, anima, frames=10000, interval=1)
p.show()
Using matplotlib backend: TkAgg ingrese la masa: 1 ingrese la carga: 1 ingrese la posicion de la carda separado por espcios: 0 0 0 ingrese la velocidad inicial de la carda separado por espcios: 100 0 0 ingrese el campo electrico separado por espcios: 0 0 0 ingrese el campo magnetico separado por espcios: 0 0 10 1 [ 4.41176471 -2.35294118 0. ] 2 [ 5.94117647 -12.23529412 0. ] 3 [ -7.64705882 -18.58823529 0. ] 4 [-16.11764706 -0.47058824 0. ] 5 [8.30129125 4.88809182 0. ] 6 [ 2.96678071 -24.63381525 0. ] 7 [-23.54684913 -1.7858956 0. ] 8 [15.52345216 6.7879925 0. ] 9 [ -6.77068028 -32.30128556 0. ] 10 [-18.78634235 16.23348409 0. ] 11 [ 25.63683043 -16.19461669 0. ] 12 [-34.35814996 -16.97071455 0. ] 13 [18.92145891 20.26211074 0. ] 14 [ -8.61248314 -44.09534443 0. ] 15 [-17.36307916 30.39242013 0. ] 16 [ 28.26271264 -35.32125518 0. ] 17 [-46.26173758 5.55791213 0. ] 18 [43.55181842 -0.23217932 0. ] 19 [-45.66858295 -32.86222651 0. ] 20 [27.8127596 34.96470249 0. ] 21 [-17.75918534 -59.63021194 0. ] 22 [-7.95563901 49.93205565 0. ] 23 [ 21.06817027 -61.34515897 0. ] 24 [-45.23951199 38.67129604 0. ] 25 [ 52.88950111 -38.76058879 0. ] 26 [-68.65070109 7.36943669 0. ] 27 [66.03183588 -1.88335945 0. ] 28 [-70.73884988 -31.77950499 0. ] 29 [57.24487197 36.37595658 0. ] 30 [-52.05376453 -66.35577201 0. ] 31 [30.24244929 64.99236536 0. ] 32 [-18.71979425 -87.33195544 0. ] 33 [-7.21938139 77.26677027 0. ] 34 [ 20.61320246 -90.43936342 0. ] 35 [-46.25070937 71.28329206 0. ] 36 [ 57.3605613 -75.90605739 0. ] 37 [-78.99927778 49.11791747 0. ] 38 [ 84.71244501 -47.31066659 0. ] 39 [-99.89876924 15.48821535 0. ] 40 [ 98.45094236 -10.15143966 0. ] 41 [-106.10334672 -23.66228045 0. ] 42 [97.06043379 29.48354053 0. ] 43 [-97.33549411 -62.35993074 0. ] 44 [81.37324 65.9490259 0. ] 45 [-75.38545682 -95.45639833 0. ] 46 [53.97267421 94.71845262 0. ] 47 [ -43.46066197 -119.13136618 0. ] 48 [ 18.52428715 112.72606002 0. ] 49 [ -5.52716813 -131.09052576 0. ] 50 [-20.85065674 118.43941372 0. ] 51 [ 34.26887785 -130.53214471 0. ] 52 [-60.09488237 111.73935745 0. ] 53 [ 72.05554825 -117.95884387 0. ] 54 [-95.60100067 93.68066474 0. ] 55 [104.55243735 -94.90247673 0. ] 56 [-124.46222892 66.19464501 0. ] 57 [129.25844546 -63.61606099 0. ] 58 [-144.60204013 31.78013617 0. ] 59 [144.52884876 -26.77179881 0. ] 60 [-154.80463179 -6.78511768 0. ] 61 [149.56530308 12.80933946 0. ] 62 [-154.67055063 -46.69314214 0. ] 63 [144.34296771 52.38216179 0. ] 64 [-144.52087003 -85.30474116 0. ] 65 [129.49688716 89.45014072 0. ] 66 [-125.27047242 -120.29635505 0. ] 67 [106.18638899 121.88688405 0. ] 68 [ -98.28728703 -149.75721364 0. ] 69 [ 75.95240163 148.01036501 0. ] 70 [ -65.25046059 -172.2422723 0. ] 71 [ 40.57880806 166.61634999 0. ] 72 [ -28.01681156 -186.78800903 0. ] 73 [ 1.96553914 176.97848015 0. ] 74 [ 11.4982427 -192.89869887 0. ] 75 [-37.9817784 178.82260467 0. ] 76 [ 51.42170233 -190.51060211 0. ] 77 [-77.44312624 172.28252897 0. ] 78 [ 90.00440644 -179.94087145 0. ] 79 [-114.75563732 157.84356348 0. ] 80 [ 125.68284838 -161.82710235 0. ] 81 [-148.465956 136.27930996 0. ] 82 [ 157.12245092 -137.06246431 0. ] 83 [-177.36487513 108.58612353 0. ] 84 [ 183.24407075 -106.73036015 0. ] 85 [-200.50625557 75.91872156 0. ] 86 [203.23590813 -72.0416287 0. ] 87 [-217.21251679 39.52952339 0. ] 88 [216.55317473 -34.27647133 0. ] 89 [-227.06907451 0.71352692 0. ] 90 [222.90788257 5.26743711 0. ] 91 [-229.91004577 -39.24013272 0. ] 92 [222.25100859 45.31979232 0. ] 93 [-225.79739104 -79.08933752 0. ] 94 [214.74910424 84.67508319 0. ] 95 [-214.99545135 -117.67267919 0. ] 96 [200.75718898 122.22259392 0. ] 97 [-197.94259485 -153.93584316 0. ] 98 [180.78951463 156.96926976 0. ] 99 [-175.22143196 -186.95107844 0. ] 100 [155.48953274 188.05593193 0. ] 101 [-147.52880593 -215.93031341 0. ] 102 [125.60015023 214.76746149 0. ] 103 [-115.64652733 -240.23258309 0. ] 104 [ 91.93512966 236.53765055 0. ] 105 [ -80.41360189 -259.3664881 0. ] 106 [ 55.35228286 252.949454 0. ] 107 [ -42.70050601 -272.98842312 0. ] 108 [ 16.72892393 263.73137608 0. ] 109 [ -3.38589402 -280.89729935 0. ] 110 [-23.06010991 268.75070186 0. ] 111 [ 36.66402394 -283.02645229 0. ] 112 [-63.16169423 268.00424195 0. ] 113 [ 76.61331544 -279.43337703 0. ] 114 [-102.76084407 261.60720454 0. ] 115 [ 115.67135147 -270.2878753 0. ] 116 [-141.09435369 249.78074773 0. ] 117 [ 153.10508332 -255.85913525 0. ] 118 [-177.46174073 232.83870067 0. ] 119 [ 188.24869014 -236.50219969 0. ] 120 [-211.23363823 211.17387664 0. ] 121 [ 220.51076081 -212.64421393 0. ] 122 [-241.85781544 185.24433792 0. ] 123 [ 249.37920551 -184.77078238 0. ] 124 [-268.86303388 155.55991167 0. ] 125 [ 274.42411161 -153.4127045 0. ] 126 [-291.86095967 122.66920009 0. ] 127 [ 295.29876948 -119.13330706 0. ] 128 [-310.54635987 87.14727673 0. ] 129 [311.73909636 -82.51654077 0. ] 130 [-324.69581032 49.58421455 0. ] 131 [323.5616837 -44.15596596 0. ] 132 [-334.1651369 10.57455071 0. ] 133 [330.66068539 -4.64471374 0. ] 134 [-338.88580241 -29.29224262 0. ] 135 [333.00375335 35.43352406 0. ] 136 [-338.86043902 -69.44024297 0. ] 137 [330.62721323 75.51245097 0. ] 138 [-334.1577117 -109.31450483 0. ] 139 [323.63065779 115.05006671 0. ] 140 [-324.90668183 -148.38743843 0. ] 141 [312.17111926 153.53453056 0. ] 142 [-311.29082449 -186.16416637 0. ] 143 [296.45696545 190.48902136 0. ] 144 [-293.54183554 -222.18689851 0. ] 145 [276.74164794 225.47564011 0. ] 146 [-271.93334884 -256.03837622 0. ] 147 [253.31741438 258.09841078 0. ] 148 [-246.77466781 -287.34444538 0. ] 149 [226.50908156 288.00544172 0. ] 150 [-218.40460054 -315.77582288 0. ] 151 [196.66795131 314.89031439 0. ] 152 [-187.18547345 -341.04912512 0. ] 153 [164.16593744 338.49276915 0. ] 154 [-153.4973855 -362.92722861 0. ] 155 [129.38995957 358.59875845 0. ] 156 [-117.7327527 -381.21903336 0. ] 157 [ 92.73664807 375.03993772 0. ] 158 [ -80.29118179 -395.7786986 0. ] 159 [ 54.6073937 387.69266293 0. ] 160 [ -41.57470211 -406.50441869 0. ] 161 [ 15.40376675 396.47656122 0. ] 162 [ -1.98337588 -413.33680449 0. ] 163 [-24.47667838 401.35273843 0. ] 164 [ 38.08870054 -416.25693211 0. ] 165 [-64.64420395 402.32168375 0. ] 166 [ 78.25699889 -415.2841175 0. ] 167 [-104.72029248 399.42092781 0. ] 168 [ 118.14976458 -410.47347128 0. ] 169 [-144.34065564 392.72250686 0. ] 170 [ 157.41083076 -401.91328422 0. ] 171 [-183.15785583 382.33028108 0. ] 172 [ 195.70205016 -389.72228942 0. ] 173 [-220.84355141 368.37715116 0. ] 174 [ 232.70535723 -374.04684325 0. ] 175 [-257.0903796 351.0222129 0. ] 176 [ 268.124476 -355.0580626 0. ] 177 [-291.61349375 330.44788574 0. ] 178 [ 301.68629138 -332.94895248 0. ] 179 [-324.15177349 306.85704668 0. ] 180 [ 333.14190307 -307.93155337 0. ] 181 [-354.46872753 280.47019771 0. ] 182 [ 362.26738259 -280.23413476 0. ] 183 [-382.35311019 251.522691 0. ] 184 [ 388.86425462 -250.09845711 0. ] 185 [-407.61927301 220.26203254 0. ] 186 [ 412.75972438 -217.77712169 0. ] 187 [-430.10727336 186.94528208 0. ] 188 [ 433.80667285 -183.53102424 0. ] 189 [-449.68276164 151.83656385 0. ] 190 [ 451.88344137 -147.62692572 0. ] 191 [-466.23666868 115.20470008 0. ] 192 [ 466.89342708 -110.33515091 0. ] 193 [-479.68471433 77.32097665 0. ] 194 [478.76450979 -71.92742296 0. ] 195 [-489.96675768 38.45704801 0. ] 196 [487.44833047 -32.67483986 0. ] 197 [-497.04600858 -1.11701366 0. ] 198 [492.91944046 7.1540029 0. ] 199 [-500.90811922 -41.13452183 0. ] 200 [495.17433992 47.29474135 0. ] 201 [-501.56017369 -81.33383004 0. ] 202 [494.23042271 87.48882287 0. ] 203 [-499.0295923 -121.45983733 0. ] 204 [490.12484411 127.48493755 0. ] 205 [-493.36296658 -161.26534594 0. ] 206 [482.91332678 167.04030281 0. ] 207 [-484.62483968 -200.5122736 0. ] 208 [472.66891901 205.92180418 0. ] 209 [-472.89644576 -238.97272373 0. ] 210 [459.48071845 243.90699594 0. ] 211 [-458.27442117 -276.4299177 0. ] 212 [443.4525736 280.78496624 0. ] 213 [-440.86949892 -312.67899396 0. ] 214 [424.70177385 316.35707159 0. ] 215 [-420.80519682 -347.52767936 0. ] 216 [403.35773825 350.43754646 0. ] 217 [-398.21650916 -380.79683859 0. ] 218 [379.56071207 382.85399401 0. ] 219 [-373.2486102 -412.3209077 0. ] 220 [353.46047921 413.44776413 0. ] 221 [-346.05557726 -441.94821829 0. ] 222 [325.21509769 442.0742254 0. ] 223 [-316.79914018 -469.54121894 0. ] 224 [294.98966454 468.60293757 0. ] 225 [-285.64746308 -494.97660041 0. ] 226 [262.95511568 492.91773128 0. ] 227 [-252.77396348 -518.1453315 0. ] 228 [229.28706541 514.91670169 0. ] 229 [-218.3561733 -538.95261223 0. ] 230 [194.16468984 534.51212285 0. ] 231 [-182.57464535 -557.31775094 0. ] 232 [157.76965726 551.63028917 0. ] 233 [-145.61190847 -573.17397183 0. ] 234 [120.28510852 566.21129065 0. ] 235 [-107.65147361 -586.46815939 0. ] 236 [ 81.89468945 578.20872802 0. ] 237 [ -68.87689299 -597.16054583 0. ] 238 [ 42.781637 587.58937406 0. ] 239 [ -29.47087355 -605.22434766 0. ] 240 [ 3.12792029 594.33278672 0. ] 241 [ 10.38555429 -610.64535696 0. ] 242 [-36.8865628 598.43088007 0. ] 243 [ 50.51381202 -613.42149316 0. ] 244 [-77.08473302 599.88745814 0. ] 245 [ 90.73849251 -613.56232037 0. ] 246 [-117.29302126 598.71771711 0. ] 247 [ 130.88802369 -611.08853553 0. ] 248 [-157.34200459 594.94772048 0. ] 249 [ 170.79527701 -606.03143189 0. ] 250 [-197.06698733 588.61385206 0. ] 251 [ 210.29812144 -598.43234255 0. ] 252 [-236.30852821 579.76225109 0. ] 253 [ 249.23992402 -588.34206811 0. ] 254 [-274.91291463 568.44823343 0. ] 255 [ 287.46999818 -575.82029248 0. ] 256 [-312.73258545 554.73570286 0. ] 257 [ 324.84400136 -560.93499047 0. ] 258 [-349.62650372 538.69655591 0. ] 259 [ 361.22428327 -543.76183065 0. ] 260 [-385.46048099 520.41008347 0. ] 261 [ 396.48018672 -524.38357662 0. ] 262 [-420.10745507 499.96237239 0. ] 263 [ 430.4883027 -502.88948948 0. ] 264 [-453.4477229 477.44570965 0. ] 265 [ 463.13268158 -479.37473438 0. ] 266 [-485.36913061 452.95799177 0. ] 267 [ 494.30500254 -453.93979344 0. ] 268 [-515.76722274 426.6021418 0. ] 269 [ 523.90470301 -426.68988724 0. ] 270 [-544.54535253 398.48553583 0. ] 271 [ 551.83907039 -397.73440689 0. ] 272 [-571.6147555 368.71944109 0. ] 273 [ 578.02329802 -367.18635852 0. ] 274 [-596.8945883 337.4184672 0. ] 275 [ 602.38050736 -335.16182165 0. ] 276 [-620.31193486 304.70003199 0. ] 277 [ 624.8417387 -301.77942292 0. ] 278 [-641.80178207 270.68384341 0. ] 279 [ 645.34591224 -267.15982629 0. ] 280 [-661.3069668 235.49139841 0. ] 281 [ 663.83976165 -231.42524091 0. ] 282 [-678.7780965 199.2454999 0. ] 283 [ 680.27774211 -194.69894737 0. ] 284 [-694.17344517 162.06979252 0. ] 285 [ 694.62191481 -157.1048432 0. ] 286 [-707.45882684 124.08831796 0. ] 287 [ 706.84180973 -118.76700808 0. ]