# Setting derivative boundary conditions in NDSolve

GROUPS:
 Peter Bischet 1 Vote Hi, all I'm testing mathematica for 30 days. I've several questions: the first one: Is here the right place to do that? If not, please tell me, where I can do that!Actually I test PDE solutions ( transient heat conduction). Has anyone an idea, why the following PDE example from the Help Documentation worksNDSolve[{D[u[t, x], t] == D[u[t, x], x, x],  u[0, x] == 0,   u[t, 0] == Sin[t],  u[t, 5] == 0},                 u, {t, 0,   10}, {x, 0, 5}]while the following example ( I've changed one boundary condition- I hope, that was the only change- ) doesn't:NDSolve[{D[u[t, x], t] == D[u[t, x], x, x], u[0, x] == 0,   u[t, 0] == Sin[ t],    D[u[t, 5], x] == 0}, u, {t, 0, 10}, {x, 0,   5}]what is my mistake? hopefully, later on I want solve the following problem:a one dimensional bar (constant heat conductivity, density, heat capacity) is heated ( or cooled) at one end with a given, time dependent fluidtemperature distribution (as a function or at discrete times with interpolation). The heat transfer coefficient is assumed to be constant.The other end of the bar is assumed to be isolated( dT/dx=0)After my first insights in mathematica examples, I think this could be done with mathematica and in an CDF document ( with or without mathematica?) with the following options:changing the material coefficients ( perhaps from mathematica databases or a own one)changing the given, time dependent fluidtemperature distributionand, at top: changing the initial and the possible boundary conditions ( I've seen a comparable CDF document: beam deflection with different boundary conditions)choosing between different solution presentations:3D plot ( temperature distribution as function of space and time)2d plot temperature vs bar length ( at different times)table form temperature vs bar length ( at different times)maybe, that this example is too complicated for a newbie?but anyway, thank you so much for any help!Peter
5 years ago
5 Replies
 Arnoud Buzing 1 Vote The mistake is that this:D[u[t, 5], x] == 0evaluates to True, because u[t,5] does not depend on x anymore and so the derivative is zero.To write what you want to achieve, first take the derivative of u[t,x] and then replace x with zero:(D[u[t, x], x] /. x -> 0)The whole NDSolve expression then becomes:NDSolve[{ D[u[t, x], t] == D[u[t, x], x, x], u[0, x] == 0, u[t, 0] == Sin[t], (D[u[t, x], x] /. x -> 0) == 0}, u, {t, 0, 10}, {x, 0, 5}]
5 years ago
 Peter Bischet 1 Vote Hi Arnoud,thank you so much for your help. It works fine!Peter