Author 
Comment/Response 
Luka

03/10/13 03:13am
Thank you very much for your answers! I learned something new.. :)
I made a mistake: the second boundary condition should be n[0] == n0*Exp[V], instead of n[0] == n0*Exp[V]. But I think that is not a problem.
Please, tell me where I can see the error messages you mentioned (I have Mathematica 8.0).
What is the difference between the codes below?
The one you proposed to me:
eq = Gx + D[Dif*\!\(
\*SubscriptBox[\(\[PartialD]\), \(x\)]\(n[x]\)\), x] 
Kr (n[x]  n0) == 0;
bcs = {n'[d] == 0, n[0] == n0*Exp[V]};
d = 20*10^6;
Gx = 10^19;
n0 = 10^21;
Dif = 4*10^9;
Kr = 31*10^10;
Show[Table[sol = DSolve[{eq, bcs}, n[x], x];
Plot[n[x] /. sol, {x, 0, d}],
{V, 0, 7/10, 1/10}]]
And this one:
eq = Gx + D[Dif*\!\(
\*SubscriptBox[\(\[PartialD]\), \(x\)]\(n[x]\)\), x] 
Kr (n[x]  n0) == 0;
bcs = {n'[d] == 0, n[0] == n0*Exp[V]};
d = 20*10^6;
Gx = 10^19;
n0 = 10^21;
Dif = 4*10^9;
Kr = 31*10^10;
sol := {V, DSolve[{eq, bcs}, n[x], x] [[1, 1, 2]]}
res = Table[sol, {V, 0, 7/10, 1/10}];
ListPlot[Table[res, {x, 0, d}], Joined > True]
Both results make sense and I don't see any error messages. The plot of the result of the first code has x on the x axis and the plot for result of the second code has values for V on x axis.
Actually I want to get gradient of n[x] at x=0 as a function of V.
I thought my code should look like this:
eq = Gx + D[Dif*\!\(
\*SubscriptBox[\(\[PartialD]\), \(x\)]\(n[x]\)\), x] 
Kr (n[x]  n0) == 0;
bcs = {n'[d] == 0, n[0] == n0*Exp[V]};
d = 20*10^6;
Gx = 10^19;
n0 = 10^21;
Dif = 4*10^9;
Kr = 31*10^10;
sol := {V, D[#, x] &@DSolve[{eq, bcs}, n[x], x] [[1, 1, 2]]}
res = Table[sol, {V, 0, 7/10, 1/10}];
ListPlot[Table[res, {x, 0, d}], Joined > True]
The shape of the function I get looks right, but the values on y axis are much higher than they should be. Maybe I need to look at the input values again.
And I almost forgot that this code does not do what I really want  a gradient at x=0. How to execute this task?
You gave me lots to think about. I should also learn about precision ..
Thank you,
Luka
URL: , 
