Skip to content
Extraits de code Groupes Projets
capacitor.py 1007 octets
Newer Older
  • Learn to ignore specific revisions
  • Martin Delcourt's avatar
    Martin Delcourt a validé
    from integrator import RombergIntegrator as integral
    import math
    
    
    def d_field(rx,ry,rz,Q):
        den = rx**2 + ry**2 + rz**2
        if den == 0:
            return 0
    
        return Q * rz / math.pow(den, 1.5)
    
    
    def I_x(x, ry, rz, Q, L):
    
        def ix(rx):
            return d_field(rx,ry,rz,Q)
    
        return integral(ix, x-L, x+L, precision = 1e-2)
    
    def E_z(x,y,rz, Q = 1, L = 10):
    
        def iy(ry):
            return I_x(x,ry,rz,Q,L)
    
        return integral(iy,y-L, y+L, precision = 1e-2)
    
    
    def V(x,y, z0 = 1, Q = 1, L = 10):
        def vz(rz):
            return 2*E_z(x,y,rz,Q, L)
        return integral(vz,0,2*z0,precision = 1e-2,silent = False)
    
    
    
    Martin Delcourt's avatar
    Martin Delcourt a validé
    distance = 0.1
    
    Martin Delcourt's avatar
    Martin Delcourt a validé
    potential = V(0,0,distance)
    theory = distance*8*math.pi
    
    Martin Delcourt's avatar
    Martin Delcourt a validé
    print("In the center : potential = {} - theory = {};  diff = {:.2f}%".format(potential,theory, 200*(potential-theory)/(potential + theory)))
    
    
    potential = V(10,10,distance)
    print("In the corner : potential = {} - theory = {};  diff = {:.2f}%".format(potential,theory, 200*(potential-theory)/(potential + theory)))