Beispiel #1
0
    def plotField(self, xs, ys, zs):
        x, y, z = np.mgrid[xs[0]:xs[1]:10j, ys[0]:ys[1]:10j, zs[0]:zs[1]:10j]

        Ex, Ey, Ez = self.E_Total([x, y, z])

        mlab.figure(size=(1000, 1000))
        for C in self.get_Charge3DList():
            if Charge3D.getCharge(C) < 0:
                color = (0, 0, 1)
            else:
                color = (1, 0, 0)
            mlab.points3d(Charge3D.getPosition(C)[0],
                          Charge3D.getPosition(C)[1],
                          Charge3D.getPosition(C)[2],
                          color=color,
                          scale_factor=1)
        mlab.quiver3d(x,
                      y,
                      z,
                      Ex,
                      Ey,
                      Ez,
                      line_width=2,
                      scale_factor=1,
                      colormap='gist_rainbow',
                      opacity=0.6)
        mlab.show()
Beispiel #2
0
    def E_Total(self, fieldPos):
        Ex_total, Ey_total, Ez_total = 0, 0, 0

        for C in self.get_Charge3DList():
            Ex_total += Charge3D.electricField(C, fieldPos)[0]
            Ey_total += Charge3D.electricField(C, fieldPos)[1]
            Ez_total += Charge3D.electricField(C, fieldPos)[2]

        return Ex_total, Ey_total, Ez_total
Beispiel #3
0
 def V_Total(self, fieldPos):
     V_Total = 0
     for C in self.get_Charge3DList():
         V_Total += Charge3D.potentialField(C, fieldPos)
     return V_Total
Beispiel #4
0
Usage: Requires math, numpy, matplotlib.pyplot libraries, and EMPY.Electrostatics.Charge.

This code and Charge library was inspired by Robert Martin's ElectrodynamicsPy Project.
https://github.com/robertmartin8/ElectrodynamicsPy
'''

import numpy as np
from EMPY.Electrostatics.Charge3D import Charge3D
from EMPY.Electrostatics.System3D import ContinuousSystem3D

N=10
L=5e0
R=1.5e0
charge=50
numpts=10000
q = charge / numpts


charges = []

z = np.linspace(0, L, numpts)
theta = 2 * np.pi * N / L * z
x = R * np.cos(theta)
y = R * np.sin(theta)

for i in range(len(z)):
    charges.append(Charge3D(q,[x[i],y[i],0]))

circularLoop = ContinuousSystem3D(charges)
circularLoop.plotField([-6,6],[-6,6],[-6,6], (x,y,np.zeros(len(x))))
Beispiel #5
0
Usage: Requires math, numpy, matplotlib.pyplot libraries, and EMPY.Electrostatics.Charge.

This code and Charge library was inspired by Robert Martin's ElectrodynamicsPy Project.
https://github.com/robertmartin8/ElectrodynamicsPy
'''

import numpy as np
from EMPY.Electrostatics.Charge3D import Charge3D
from EMPY.Electrostatics.System3D import ContinuousSystem3D

N = 10
L = 5e0
R = 1.5e0
charge = 50
numpts = 10000
q = charge / numpts

charges = []

z = np.linspace(0, L, numpts)
theta = 2 * np.pi * N / L * z
x = R * np.cos(theta)
y = R * np.sin(theta)

for i in range(len(z)):
    charges.append(Charge3D(q, [x[i], y[i], z[i]]))

solenoid = ContinuousSystem3D(charges)
solenoid.plotField([-6, 6], [-6, 6], [-6, 6], (x, y, z))
Beispiel #6
0
             DiscreteSystem is child class of System which is used for system of discrete charges.
             ContinuousSystem is child class of System which is used for system of continuous charges.

             System object requires input a charge to be initialized.

Usage: Requires math, numpy, matplotlib.pyplot libraries, and EMPY.Electrostatics.Charge.

This code and Charge library was inspired by Robert Martin's ElectrodynamicsPy Project.
https://github.com/robertmartin8/ElectrodynamicsPy
'''

from EMPY.Electrostatics.System3D import DiscreteSystem3D
from EMPY.Electrostatics.Charge3D import Charge3D

# 3D Plot of Electric Field of a Point Charge
charge3d = Charge3D(1, (0, 0, 1))
charge3d.plotField([-5, 5], [-5, 5], [-5, 5])

# 3D Plot of Electric Field of a Dipole
charge3d_01 = Charge3D(-1, (-2, 0, 0))
charge3d_02 = Charge3D(1, (2, 0, 0))
discreteSys_01 = DiscreteSystem3D([charge3d_01, charge3d_02])
discreteSys_01.plotField([-5, 5], [-5, 5], [-5, 5])

# Create a Infinitesimal Line Charge consisting of 5 3D Charge Objects
charge3d_03 = Charge3D(1, (-2, 0, 0))
charge3d_04 = Charge3D(1, (-1, 0, 0))
charge3d_05 = Charge3D(1, (0, 0, 0))
charge3d_06 = Charge3D(1, (1, 0, 0))
charge3d_07 = Charge3D(1, (2, 0, 0))
discreteSys_02 = DiscreteSystem3D(
Beispiel #7
0
from EMPY.Electrostatics.System3D import DiscreteSystem3D
from EMPY.Electrostatics.Charge3D import Charge3D

# Create a Parallel Plate Capacitor in a Discrete Charge System
z = 0e0
dz = 2e0
charge = 10e0
numpts = 9e0
q = charge / numpts
charges = []
for x in range(-3, 4):
    for y in range(-3, 4):
        charges.append(Charge3D(q, (x, y, z + dz)))
        charges.append(Charge3D(-q, (x, y, z - dz)))
parallelPlate = DiscreteSystem3D(charges)
parallelPlate.plotField([-5, 5], [-5, 5], [-5, 5])