Jan 16, 2011

Mathematica Fun"s": Solving Electromagnetic HW1 Prob1

Prob1:
A conducting thin wire has a total length of 4 cm and is bent into a square with its
center at the origin. There is a total of 4 nano Coul of electric charges on it. Use moment method to find the potential of this wire V, accurately to the second digit of decimal. (You must carry out all the calculations. Just list out equations will get you no points)

The main idea of this program is pretty easy: Using finite number of charges of various value to approximate the continuous charge distribution on the square conductor shown in the following figure:




















The hardest part of this program is to build up the matrix to be solved.
(1)Calculate the position of charges on 4 sections of wire based on the user define value: n(shown in the picture above)
(2)Calculate the position of observation points on the X axis which also based on the user defined n.
(3)Calculate the voltage on each of the observation points.
(4)All the values of calculated voltage should be the same otherwise it won't be stable and will lead to currents on the conducting wire that result in the true stable state. Solve the matrix consist of n*n 1st-order equations
(5)Use the charge distribution gained from step (4), calculate the steady-state voltage of this wire.
That's ALL!

p.s. this is the 1st program I've ever written in Mathematica at the beginning of this semester, so please forgive me for the crappy coding style XD. Due to my unfamiliarity with Mathematica, the efficiency of this program wasn't very good,either! Sorry guys!

readme file: http://www.megaupload.com/?d=3SULVG4Q
main program: http://www.megaupload.com/?d=L5V5VCIJ
the graph showing the converging results: http://www.megaupload.com/?d=USLLAK6E