zacel pripravljati primere za seminar
parent
70406c0d76
commit
747903f4e3
Binary file not shown.
14
boris.py
14
boris.py
|
@ -74,6 +74,20 @@ def plot3(X,enote='m',zemlja=False):
|
||||||
|
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
|
def rplot(X, enote='m', xy=[0,1],os='xy'):
|
||||||
|
fig = plt.figure()
|
||||||
|
ax = fig.subplots()
|
||||||
|
ax.plot(X[:,xy[0]],X[:,xy[1]], 'k')
|
||||||
|
ax.grid()
|
||||||
|
dx = X[-1,xy[0]]-X[-2,xy[0]]
|
||||||
|
dy = X[-1,xy[1]]-X[-2,xy[1]]
|
||||||
|
ax.arrow(X[-1,xy[0]],X[-1,xy[1]],dx,dy,head_width=0.1,head_length=0.2,
|
||||||
|
overhang=0.3, zorder=10,color='k')
|
||||||
|
ax.set_xlabel(r'${}$ [{}]'.format(os[0],enote))
|
||||||
|
ax.set_ylabel(r'${}$ [{}]'.format(os[1],enote))
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__": # testni del kode
|
if __name__ == "__main__": # testni del kode
|
||||||
E = lambda x: np.array([0.0,0.2,0.3])
|
E = lambda x: np.array([0.0,0.2,0.3])
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
from matplotlib import rc
|
||||||
|
rc('font',**{'family':'serif','serif':['Computer Modern']})
|
||||||
|
rc('text', usetex=True)
|
||||||
|
|
||||||
|
from boris import *
|
||||||
|
|
||||||
|
B = lambda x: np.array([0.,0.,x[0]**2+x[1]**2])
|
||||||
|
E = lambda x: np.array([0.,0.,0.])
|
||||||
|
|
||||||
|
x0 = np.array([0.,-1.,0.])
|
||||||
|
v0 = np.array([0.,1.,0.])
|
||||||
|
|
||||||
|
B = lambda x: np.array([0.,0.,1.])
|
||||||
|
E = lambda x: np.array([0.,-1.,0.])
|
||||||
|
E = lambda x: np.array([np.cos(x[0]),0.3,0.])
|
||||||
|
X,V = boris(x0,v0,E,B,1e-3, 100)
|
||||||
|
|
||||||
|
plot3(X)
|
||||||
|
rplot(X)
|
Loading…
Reference in New Issue