This is a MATLAB program to simulate Electrostatic phenomenon, particularly Coulomb's Law. We maintain a simulated 'Charge space', assumed to be an infinite homogenous insulating medium. The assumption is that every charged body in it remains stationary.
- Let
charge_space
be a Structure Array withx_coord
,y_coord
,z_coord
coordinates andmag
magnitude as properties of the Structure, representing the simulated medium obeying the necessary assumptions of Coulomb’s Law. - Then,
length(charged_space)
gives the number of Charged particles in charge_space. - Let
charge_space_permittivity
represents the permittivity of the medium. - The
charge_space
is visualized as a 3 Dimensional Scatter plot for the Simulation.
- Requires MATLAB for execution of CoulombsLaw.m script.
- Run CoulombsLaw.m in MATLAB and call any of the Client functions
menu()
,calc()
,plot_graphs()
,plot_space()
to use them as required. - Further instructions and detailed information about the functions are mentioned below.
A. The plot_space()
client function plots the entirety of the charge_space and all the charges present in it in 3 Dimensional Space as a Scatter plot.
B. The menu()
client function creates the "Charge Space Menu" and can be called to
- Add charged bodies into
charge_space
. Positive Charges are Red and Negative are Blue. - Remove charged bodies from
charge_space
. Or 6. Clear entirety of thecharge_space
. - Generate N random charged bodies in
charge_space
. - Display information i.e. Location and Magnitude of any charged body.
- Plot the charge_space as a 3-Dimensional scatter plot and Exit out of Charge Space Menu.
C. The calc()
client function creates the "Calculate Values with Coulomb's Law Menu" and can be called to
- Change permittivity, i.e
charge_space_permittivity
ofcharge_space
. - Calculate net force on any charge in
charge_space
. 3 Calculate force between any two charges incharge_space
. - Calculate force between any two temporary charges defined by parameters.
- Calculate net Electric Field strength in any point in
charge_space
. - Exit out of Calculate Values with Coulomb's Law Menu.
D. The plot_graphs()
client function can be used to graphically test the relationship of the parameters with the force.
A. Charge Space Manipulation
clear_charge_space()
: Removes all charges from Charge Space.charge_place()
: Creates a charge at coordinates pointed by parametersx, y, z
in charge space of magnitude given by parametermag
and plots it if parametershow
is 1 or [].display_charge()
: Display location and magnitude of charge given by parameterobj
in charge space.obj
can be numeric or Structure.charge_destroy()
: Removes charge given by parameterobj
from charge space.obj
can be numeric or Structure.n_random_charges()
: Generate number of random charges as given by parameternumber
.
B. Locating Charges
get_chargenum_bycoord()
: Get the number of the Charge pointed by given coordinate parametersx, y, z
in charge_space.get_charge_bynum()
: Get Charge object pointed by parametercharge_number
in charge_space.
C. Finding physical Force and Electric Field Strength values
charge_pair_force()
: Calculates the three Dimensional components of force on charge parameterobj
by charge parameterobj2
.charge_net_force()
: Superposition Theorem: Calculates the three dimensional components of the net force on charge parameterobj
by all other Charges.net_field_at()
: Superposition Theorem: Calculates the three dimensional components of the net Electric Field strength at coordinate parametersx, y, z
in Charge Space.
1. CoulombsLaw.m: The main MATLAB script containing all the utility and backend functions to make the Simulation work. Functions are explained above in detail.
2. CoulombsLaw.pptx Presentation prepared for the purpose of this project. Theoretical concepts explained from Ground Zero.
3. EMFT_Project.prj: Contains the project structure information. Can be ignored entirely during application.
4. examples folder: Contains example images of the things the script can accomplish.
5. resources folder: Contains the Project resources. Do not modify without expertise.
6. README.md: This Github Repository information file.
7. LICENSE: BSD 3 License information that governs the Software. Do not modify.
Fig: Simulation of a 3D Charge Space in MATLAB, where 3 charges were generated in
- (10, 0, 20); Magnitude = 100 C
- (-10, 0, 70); Magnitude = 1000 C
- (5, 12, -7); Magnitude = -20 C
Fig: Net Electric Field strength calculated in Charge Space at (0, 0, 0), and verified to be correct.
Fig: Net Force calculated on Charge 3 (5, 12, -7) by the other two Charges, and verified to be correct.