I was given a parabolic differential equation with the boundary condition of dT/dR = 0 when R = 0 but I am not quite sure how I am suppose to incorporate that into my Thomas algorithm/Crank-Nicolson program.
I currently have it in the program as u1 = du/dr but it tells me the value must be scalar. When I just get rid of it, there are complex answers in my solution.
First step of creating the PDE solution from the differential equations isn't too difficult.
Only issue is that there appears to be a singularity , to avoid this I've added a 10^-299 term in the first equation (keeps MathCad running).
Since you are using a du/dr term in the program later , the U.r() helper function has also been created.
Understanding of what the program is trying to achieve is a little harder.
The indices of the matrices & loops are quite confusing.
Can you explain the basic principles ?
Ok, so never trust the result without a 'sanity check'.
There does seem to be a problem with the initial condition & boundary condition
u(r,0)=0 & u(1,z)=1
at the point r=1,z=0
Need clarification here.
Otherwise the equations have been re-written & seem (now) to work a little better.
Last iteration there were major discrepancies in the A() & B() results.
They seem to work even better when expressed as in the attached (though I'm not sure this is any help in sorting out the problems in the Thomas and Crank-Nicholson method!).