1
$\begingroup$

I am trying to solve the free particle Schrodinger equation in 1D (hbar =1, Energy = 1, mass = 1), But specifying conditions only on x==0:

k = Sqrt[2];
op = Inactivate[Div[{{-0.5}}.Grad[u[x], {x}], {x}], Div | Grad] - u[x];
sol = NDSolveValue[{op == NeumannValue[0, x == 0], 
DirichletCondition[u[x] == Cos[k x], x == 0]}, u, {x, 0, 1}]

Plot[{sol[x] , Cos[k x]}, {x, 0, 1}]

enter image description here

The blue line is the numeric solution, and it is obviously not the expected solution (in orange), since the derivative in x==0 is not zero. I understand that specifying the Neumann value is not needed since its default is zero, but it isn't zero here!

What is going on?

$\endgroup$
1
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$
    – user9660
    Commented Feb 26, 2015 at 13:35

1 Answer 1

3
$\begingroup$

Both NeumannValue and DirichletCondition are set to apply at x==0. In such cases the DirichletCondition will trump the NeumannValue. Besides the NeumannValue is set to zero which means that the natural boundary condition is 0, the boundary integral vanishes. I think you want the DirichletCondition at x==1:

k = Sqrt[2];
op = Inactivate[Div[{{-0.5}}.Grad[u[x], {x}], {x}], Div | Grad] - u[x];
sol = NDSolveValue[{op == NeumannValue[0, x == 0], 
    DirichletCondition[u[x] == Cos[k x], x == 1]}, u, {x, 0, 1}];

But NeumannValue[0,...] is equivalent to not specifying anything at all:

k = Sqrt[2];
op = Inactivate[Div[{{-0.5}}.Grad[u[x], {x}], {x}], Div | Grad] - u[x];
sol = NDSolveValue[{op == 0, 
    DirichletCondition[u[x] == Cos[k x], x == 1]}, u, {x, 0, 1}];

Plot[{sol[x] - Cos[k x]}, {x, 0, 1}]

enter image description here

$\endgroup$
9
  • $\begingroup$ I am actually interested in solving using conditions only at x == 0. I want to use DiriclehtCondition and NeumannValue to get the equivalent solution to this: NDSolveValue[{-1/2 u''[x] - u[x] == 0, u[0] == Cos[k 0] , u'[0] == -k Sin [k 0]}, u, {x, 0, 1}] Is it not possible? $\endgroup$
    – Amit Abir
    Commented Feb 26, 2015 at 16:24
  • $\begingroup$ @AmitAbir, no, that's not possible. Why do you have that restriction? $\endgroup$
    – user21
    Commented Feb 26, 2015 at 16:53
  • $\begingroup$ @AmitAbir, note that the above NDSolve does a time integration, while the FEM is a spatial discretization method. $\endgroup$
    – user21
    Commented Feb 26, 2015 at 18:17
  • $\begingroup$ Well, eventually I wish to solve this problem in 3 dimensions. In my problem there are two concentric spheres and I wish to solve Schrodinger's equation in the region between the spheres. The problem is I have boundary condition only on the inner sphere (Both Dirichlet and Neumann). Is it not solvable? Is it not possible to specify both Neumann and Dirichlet condition on the same part of the boundary? Is there any other method to solve this other then FEM? $\endgroup$
    – Amit Abir
    Commented Feb 27, 2015 at 7:54
  • $\begingroup$ @AmitAbir, if one does not specify boundary conditions on the outer sphere that implies that a Neumann zero boundary condition is used; it's not possible to have both Dirichlet and Neumann conditions at the same position. Is it generally not solvable, that I do not know. $\endgroup$
    – user21
    Commented Feb 27, 2015 at 10:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.