In [1]:

import numpy as np
import scipy
import scipy.misc
import matplotlib.pyplot as plt




In [2]:




In [3]:

siz = (65, 65)
Lx = 6.4
Ly = 3.2
dx = Lx / siz[0]
dy = Ly / siz[1]
i_siz = (siz[0]-1, siz[1]-1)
V_vermelho = 0
V_azul = 9.05
N = 100




In [4]:

im.shape




Out[4]:

(400, 800, 3)




In [5]:

im = scipy.misc.imresize(im, siz)
V_im = np.zeros(siz)
for i in range(0, im.shape[0]):
for j in range(0, im.shape[1]):
#vermelho
if im[i,j,0] > 50:
V_im[i,j] = 1

#azul
if im[i,j,2] > 50:
V_im[i,j] = 2




In [6]:

#V_im = np.zeros((14, 25))
#V_im[3:11,8] = np.ones(8)
#V_im[3:11,15] = 2 * np.ones(8)
#Lx = 14
#Ly = 25




In [7]:

V = V_vermelho * (V_im == 1) + V_azul * (V_im == 2)




In [8]:

V = V_vermelho * (V_im == 1) + V_azul * (V_im == 2)
V_c = (V_im == 1) + (V_im == 2)

for n in range(0, N):
for i in range(1, i_siz[0]):
for j in range(1, i_siz[1]):
if V_c[i, j] == True:
continue
else:
V[i, j] = (V[i+1, j] + V[i-1, j] + V[i, j+1] + V[i, j-1]) / 4
for j in range(1, i_siz[1]):
V[0, j] = (V[1, j] + V[0, j-1] + V[0, j+1]) / 4
V[i_siz[0], j] = (V[i_siz[0]-1, j] + V[i_siz[0], j-1] + V[i_siz[0], j+1]) / 4
for i in range(1, i_siz[0]):
V[i, 0] = (V[i+1, 0] + V[i-1, 0] + V[i, 1]) / 4
V[i, i_siz[1]] = (V[i+1, i_siz[1]] + V[i-1, i_siz[1]] + V[i, i_siz[1] - 1]) / 4
V[0, 0] = (V[1, 0] + V[0, 1]) / 2
V[i_siz[0], 0] = (V[i_siz[0]-1, 0] + V[i_siz[0], 1]) / 4
V[0, i_siz[1]] = (V[1, i_siz[1]] + V[0, i_siz[1]-1]) / 4
V[i_siz[0], i_siz[1]] = (V[i_siz[0], i_siz[1]] + V[i_siz[0], i_siz[1]-1]) / 4




In [9]:

e_x = (V[48,:] - V[47, :]) / dy




In [27]:

plt.matshow(V)
plt.colorbar()
plt.xlabel('Distância do centro (cm)')
plt.ylabel('Distância do centro (cm)')
plt.xticks(np.linspace(0, i_siz[0], 5),np.linspace(-Lx/2, Lx/2, 5))
plt.yticks(np.linspace(0, i_siz[1], 5),np.linspace(-Ly/2, Ly/2, 5))
plt.show()




In [18]:

e_x = (V[31,:] - V[30, :]) / dy
plt.plot(np.linspace(-Lx/2, Lx/2, 65),e_x, '.')
plt.xlabel('Distância do centro (cm)')
plt.ylabel('Campo elétrico (V/cm)')
plt.show()




In [26]:

alfa_x = e_x / 9.1
x = np.linspace(-Lx/2, Lx/2, 65)
x = x
plt.plot(x, 100*alfa_x, 'k.')
plt.title(r'$\alpha(x)$ simulado', fontsize=20)
plt.xlim(-Lx/2, Lx/2)
plt.ylabel(r'$\alpha(x) [1/m]$', fontsize=20)
plt.show()




In [193]:

alfa_x*100




Out[193]:

array([   1.01786153,    2.07829496,    3.28775308,    4.69245759,
6.35802353,    8.35469671,   10.75797194,   13.64870082,
17.11236744,   21.23702768,   26.10917848,   31.80660003,
38.38714406,   45.87283713,   54.23004816,   63.34943899,
73.03407191,   83.00856488,   92.96103467,  102.61460249,
111.79692774,  120.46422214,  128.68005391,  136.57731015,
144.32373645,  152.12386678,  160.23444818,  168.91297664,
178.35788857,  188.68132055,  200.02859395,  212.48102295,
225.91475196,  240.96643772,  259.04102654,  279.98629607,
301.00011892,  326.80750842,  360.18612591,  387.47625199,
399.41534214,  403.85826429,  405.35458419,  405.68089091,
405.24155977,  403.45835068,  398.07387261,  382.77416024,
342.51959763,  254.77287133,  177.83440249,  123.3341219 ,
86.86198173,   62.45813627,   45.78367521,   34.08294406,
25.65708528,   19.44771152,   14.77715533,   11.19643457,
8.39693115,    6.1582069 ,    4.31624852,    2.74338991,
1.33498855])




In [ ]: