
Title:
06ps01 Conduction

Description:

In this problem, we're going to deal with heat conduction along the wire.

Just like you saw in the unit, we're going to split the wire that we had into discrete chunks.

In fact, we're going to split it into 100 different chunks and went from 0 to 99.

We can then measure the temperature of each chunk and labeled that with a proper number.

So for example the temperature in the last chunk is going to be labeled to 99.

As you already heard from Jörn, the temperature in any given segmentlet's take the 8th segment

that's simpledepends on the temperature in the surrounding two segments.

In those segments that are touching one another are going to feed energy into each other.

So this segment and that segment can both be energy into the 8th.

In the same way, the 8th segment is going to feed energy into both the 7th and the 9th segments.

To express the temperature of the 8th segment after time step done,

we can use the finite difference scheme to come up with this equation right here.

This equation tells us that the temperature after the time step, right here, is equal to the temperature

before the time step plus this term, which we can see depends on

the initial temperatures of the 7th, 9th and 8th segments.

This is obviously an explicit method for calculating T₈(h), but just for a change of pace

since this is a pretty unstable solution, we're going to try an implicit method instead.

Remember that implicit means that you're going to have this term over on this side as well.

So we're just going to switch all these 0s to h's.

We're going to use this implicit method, of course, converting it to code in this problem.

One problem that we have to deal with is how to end with segments in other end of our wire.

Both of these have an adjacent segment to one direction but not to the other.

Since the segments start at 0 and count to 99, our problem was explicitly

is that we don't have a segment numbered 1 nor a segment number 100.

To deal with this, we're just going to set the value of T₋₁ to equal T₀

and similarly for T₁₀₀ set in out to T₉₉.

This is going to be true for all times t.

Your main job in this problem is going to be to define the coefficient

for every equation in the set of equations right here.

Each equation involves an expression, which is just the sum of all the different temperatures

of every segment along with some coefficients stuck in front of certain one,

and all these equals the initial temperature at that certain segment.

There seem to be the set of a 100 different equations.

If we're going to consider this system of equations as a whole,

we can actually think of it more conveniently as dealing with matrices.

This website right here numpy.matalg.solve deals with equations involving matrices.

We have a matrix as the coefficients which are all these pink question marks

multiplied by a single column factor, which contains all the temperatures after time step each.

These multiplied together equals this vector, which contains all the initial values of the temperatures.

As we already know the temperatures at times 0 and you have created a matrix of coefficients,

we can use this method numpy.matalg.solve and input the main information

and solve the vector that we wantthe one containing the temperatures after time step h.

Taking a look at our supplied code, we can see that we've created an initial temperature distribution for you.

We've also created a parameter for you called c, which I think if you look back at the

finite difference formula, you'll see if's going to be very useful for you.

As I told you earlier, your first task is going to fill in the array named

coefficients with the appropriate values.

Remember, a lot of the coefficients will be 0.

Another hint that I want to give you is that using for loops could be a great way

to fill in your coefficients to all the different slots in the matrix.

Once coefficients are filled in, come back up to the step size and set it to 0.5 and then submit.

In the end, you should have a curve that looks nice and smooth like this

despite the pretty large step size that we're going to be using.