184_notes:b_sup_comp

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
184_notes:b_sup_comp [2018/03/06 18:17] – created dmcpadden184_notes:b_sup_comp [2021/06/16 19:16] (current) bartonmo
Line 1: Line 1:
 +/*[[184_notes:b_shapes|Next Page: Shapes of Wire and Magnetic Field]]
 +
 +[[184_notes:b_current|Previous Page: Currents Make Magnetic Fields]]*/
 +
 ===== Using Superposition of Magnetic Field and the Computer ===== ===== Using Superposition of Magnetic Field and the Computer =====
  
Line 5: Line 9:
 $$\vec{B}_{tot}= \int \frac{\mu_0}{4 \pi}\frac{I \cdot d\vec{l}\times \hat{r}}{r^2}$$ $$\vec{B}_{tot}= \int \frac{\mu_0}{4 \pi}\frac{I \cdot d\vec{l}\times \hat{r}}{r^2}$$
  
-This equation is  +This equation tells us that if we split a line of current ($I$) into small chunks of length ($d\vec{l}$), we can calculate the magnetic field at an observation point from that chunk of length (using the $\vec{r}$)The integral then allows us to add the magnetic field from each little chunk to find the net magnetic field at the observation point. 
-The principle of superposition is an overarching and powerful tool in much of physicsIt is useful well beyond the electric field as you will see with the magnetic field (and as you might see in future physics courses in quantum mechanics)The fact that the electric field obeys the principle of superposition means we can define a powerful algorithm for computing the electric field at any given location from any distribution of charge. In these notes, you will read about how you can structure code to calculate the electric field from many sources charge (though you could apply this procedure to electric potential as well).+ 
 +While calculating the integral will give you an exact value for the magnetic field, it is possible to end up with an integral that is difficult or impossible to solveInstead we can use the fact that the magnetic field obeys the principle of superposition to define a powerful algorithm for computing the magnetic field at any given location from any shape of current/wire. This is very similar to what we did with the [[184_notes:comp_super|electric field from a line before]]. In these notes, you will read about how you can structure code to calculate the magnetic field from any shape of current-carrying wire.
  
-==== The Superposition Principle ====+===== The Superposition Principle =====
  
-The principle of superposition states that the electric field at any given location in space is determined by vector sum of the electric field due to each charge that contributes.+[[184_notes:b_current|As we said before]], the principle of superposition states that the magnetic field at any given location in space is determined by vector sum of the magnetic field due to the current in each part of wire.
  
-$$\vec{E}_{net} = \sum \vec{E}_i = \vec{E}_1 + \vec{E}_2 + \vec{E}_3 + \dots$$+$$\vec{B}_{net} = \sum \vec{B}_i = \vec{B}_1 + \vec{B}_2 + \vec{B}_3 + \dots$$
  
-where $\vec{E}_1$ would be the electric field from one point charge, $\vec{E}_2$ would be the electric field from a second point charge, and so on. For this week, we will focus on superposition of point charges and how we can model a line of charge using points. (Next week we will use the idea of superposition to model a continuous line of charge and other distribution of charges.)+where $\vec{B}_1$ would be the magnetic field from one piece of the wire, $\vec{B}_2$ would be the magnetic field from a second piece of the wire, and so on. This idea of adding together the magnetic field from each chunk of the wire will form the basis of what we want the computer to calculate for us.
  
-==== How can we use a computer for this? ====+===== How can we use a computer for this? =====
  
-For most real-world situations, the electric field integral cannot be solved analytically. That is, you could most likely write down the integral, but it cannot be computed because there's no anti-derivative for the function that you would be trying to integrate. So we have to think of another approach -- one that makes use of the principle of superposition, which we know the electric field obeys.+For most real-world situations, the magnetic field integral cannot be solved analytically. That is, you could most likely write down the integral, but it cannot be computed because there's no anti-derivative for the function that you would be trying to integrate. So we have to think of another approach -- one that makes use of the principle of superposition, which we know the magnetic field obeys.
  
-Let's think through the process for computing the electric field due to a distribution of charges:+Let's think through the process for computing the magnetic field due to the current in any kind of wire:
  
-  - Identify the "chunksof charge that you will treat as point charges +  - Split the total length of the wire into small chunks of length (this is the equivalent of setting the $d\vec{l}$) 
-  - Compute the electric field due to that chunk at the specified location+  - Compute the magnetic field due to that chunk at the observation location
   - Write down or otherwise keep track of that value   - Write down or otherwise keep track of that value
-  - Move to the another chunk, which you treat as a point charge +  - Move to the another chunk of the wire 
-  - Compute the electric field due to the new chunk at the specified location+  - Compute the magnetic field due to the new chunk at the observation location
   - Add that new value to the old value from steps 3 and 4   - Add that new value to the old value from steps 3 and 4
-  - Repeat steps 5-7 for another chunk; and continue repeating until you've done this for all chunks+  - Repeat steps 5-7 for another chunk; and continue repeating until you've done this for all chunks of the wire
  
-These somewhat monotonous steps will give us an approximate value for the electric field at the point of interest. The smaller the chunks, the better the approximation. You can probably see why setting up a computer to do this makes a lot of sense. Computers are really good at doing the same calculation over and over again!+These somewhat monotonous steps will give us an approximate value for the magnetic field at the point of interest. **The smaller the chunks, the better the approximation.** You can probably see why setting up a computer to do this makes a lot of sense. Computers are really good at doing the same calculation over and over again!
  
-So if we want to compute the electric field at a given location due to a distribution of charges, the algorithm is just cutting the distribution into chunks, computing the electric field of each chunk as a point charge, and adding all the contributions together. This is a form of [[https://en.wikipedia.org/wiki/Numerical_integration|numerical integration]], which is a powerful technique in computational science. As a tool for thinking through these computational algorithms, we will sometimes write out the steps we want the computer to take in plain words rather than code - this is called **pseudocode**. The pseudocode for the electric field algorithm above is the following:+So if we want to compute the magnetic field at a given location due to any length/shape of wire, the algorithm is just splitting the wire into chunks, computing the magnetic field of each chunk, and adding all the contributions together. This is a form of [[https://en.wikipedia.org/wiki/Numerical_integration|numerical integration]], which is a powerful technique in computational science. As a tool for thinking through these computational algorithms, we will sometimes write out the steps we want the computer to take in plain words rather than code - this is called **pseudocode**. The pseudocode for the magnetic field algorithm above is the following:
  
 <code> <code>
  
-Choose location of interest+Choose an observation location (or locations)
 Choose size of chunks Choose size of chunks
 Choose starting chunk Choose starting chunk
-Set net electric field to zero+Set net magnetic field to zero
  
-For all the chunks in the distribution:+For all the chunks in the current-carrying wire:
        
-   Determine vector distance between chunk and location of interest +   Determine vector distance between chunk and observation location 
-   Compute point charge electric field due to chunk +   Compute magnetic field due to that chunk 
-   Add contribution of chunk to net electric field+   Add contribution of chunk to net magnetic field
  
 </code> </code>
  
 You can also use pseudocode (and may have already) to help you plan and understand the code you are writing. You can also use pseudocode (and may have already) to help you plan and understand the code you are writing.
  • 184_notes/b_sup_comp.1520360275.txt.gz
  • Last modified: 2018/03/06 18:17
  • by dmcpadden