2
$\begingroup$

I want to find the initial condition which fits mixed boundary condition of Phi[r, Theta, t].

The original initial condition in text is

Phi[r, Theta, 0] == 1

. I heard the information that the initial condition doesn't have to be strictly consistent (the value 1). It can be bigger or smaller than 1, or can vary.

The mixed boundary condition which should be consistent with initial condition and shouldn't be changed is

Derivative[1, 0, 0][Phi][s, Theta, t] == k/rc Phi[s, Theta, t]

I tried five kinds of initial conditions.

At first, as information in text

Phi[r, Theta, 0] == 1

At second, (using exponential function in small section)

Phi[r, Theta, 0] == If[r < (1 + a) s, Exp[k/rc (r - s)], If[r < (1 + 2 a) s, 
Exp[-(k/rc) (r - (1 + 2 a) s)], 1]]

At third, (using linear function in small section)

Phi[r, Theta, 0] == If[r < (1 + b) s, k/rc (r - s) + 1, If[r < (1 + 2 b) s, 
-(k/rc) (r - (1 + 2 b) s) + 1, 1]]

At fourth, (using exponential function again but some different from second)

Phi[r, Theta, 0] == If[r < (1 + c) s, 2 - Exp[-(k/rc) (r - s)], If[r < (1 + 2 c) s, 
2 - Exp[k/rc (r - (1 + 2 c) s)], 1]]

At fifth, (same function with second, but using Piecewise than If statement)

Phi[r, Theta, 0] == Piecewise[{{Exp[k/rc (r - s)], r < (1 + a) s}, {Exp[-(k/
  rc) (r - (1 + 2 a) s)], r < (1 + 2 a) s}, {1, r >= (1 + 2 a) s}}]

All five trial gave me 'ibcinc boundary and initial conditions are inconsistent' error message.

How can I set 'initial condition' to fit 'mixed boundary condition'?

Thanks in advance!



From here, it is the before-shortened question. (How to get over NDSolve ibcinc error message? (Inconsistent initial condition and mixed boundary condition))

I have a question about the error message which includes ibcinc. The problem is that I tried to adjust initial condition to satisfy the Mixed boundary condition, but I was still given ibcinc inconsistent message. The original initial condition is

Phi[r, Theta, 0] == 1

. I tried to make new initial condition (Fun1[r],Fun2[r],and Fun3[r] instead of 1) using this original initial condition. However, this gave same ibcinc inconsistent IC and BC error message.

The hole code is following.

Clear["Global`*"]
Dif = 1.33 10^11;
s = 8 ;
rc = s/0.0713;
k = 10^4;
a = 10^-3;
Fun1[r_] = 
If[r < (1 + a) s, Exp[k/rc (r - s)], 
If[r < (1 + 2 a) s, 
Exp[-(k/rc) (r - (1 + 2 a) s)], 1]]
b = 10^-3;
Fun2[r_] = 
If[r < (1 + b) s, k/rc (r - s) + 1, 
If[r < (1 + 2 b) s, -(k/
   rc) (r - (1 + 2 b) s) + 1, 1]]
c = 10^-3;
Fun3[r_] = 
If[r < (1 + c) s, 2 - Exp[-(k/rc) (r - s)], 
If[r < (1 + 2 c) s, 
2 - Exp[k/rc (r - (1 + 2 c) s)], 1]]
Fun11[r_] = Piecewise[{{Exp[k/rc (r - s)], 
r < (1 + a) s}, {Exp[-(k/rc) (r - (1 + 2 a) s)], r < (1 + 2 a) s}, {1, 
r >= (1 + 2 a) s}}]
Plot[Fun1[r],{r,s,(1+3 a)s}]
Plot[Fun2[r],{r,s,(1+3 b)s}]
Plot[Fun3[r],{r,s,(1+3 c)s}]
Plot[Fun11[r],{r,s,(1+3 a)s}]
t0 = 10^-3;
tmax = 10;
rmax = 1.5 s
e = 1.602 10^-19
Ef = 10^6
kB = 1.381 10^-23
T = 298
Const = (e Ef)/(kB T) /10^10 (* 1/(angstrom)*)
sol = NDSolve[{D[Phi[r, Theta, t], {t, 1}] == 
Dif (D[Phi[r, Theta, t], {r, 2}] + 
   1/r^2 D[Phi[r, Theta, t], {Theta, 2}] + (2/r - 
      rc/r^2 + Const Cos[Theta]) D[Phi[r, Theta, 
      t], {r, 1}] + (1/r^2 Cos[Theta]/Sin[Theta] - 
      Const/r Sin[Theta]) D[Phi[r, Theta, 
      t], {Theta, 1}]), Phi[r, Theta, 0] == 
Fun3[r], Phi[rmax, Theta, t] == 
1, ( Derivative[1, 0, 0][Phi][s, Theta, 
  t]) == k/rc (Phi[s, Theta, t]), ( 
 D[Phi[r, Theta, t], {Theta, 1}] /. Theta -> 
   10^-3) == 
0, ( D[Phi[r, Theta, t], {Theta, 
    1}] /. Theta -> (\[Pi] - 10^-3)) == 
0}, Phi, {r, s, rmax}, {Theta, 
10^-3, \[Pi] - 10^-3}, {t, 0, tmax}, PrecisionGoal -> 4, 
StartingStepSize -> 0.0001, 
Method -> {"MethodOfLines", 
"SpatialDiscretization" -> {"TensorProductGrid", 
  "MinPoints" -> 100, "MaxPoints" -> 200}}]

(*BCtest1*)Plot3D[
 First[(Phi[rmax, Theta, t] - 1) /. sol], {Theta, 
 10^-3, \[Pi] - 10^-3}, {t, 0, tmax}]
(*BCtest2-1*)Plot3D[
 First[((( D[Phi[r, Theta, t], {r, 1}]) - k/
    rc Phi[r, Theta, t]) /. sol) /. 
 r -> s], {Theta, 10^-3, \[Pi] - 10^-3}, {t, 0, tmax}]
(*BCtest2-1-1*)Plot3D[
 First[((( D[Phi[r, Theta, t], {r, 1}])) /. sol) /. 
 r -> s], {Theta, 10^-3, \[Pi] - 10^-3}, {t, 0, tmax}]
(*BCtest2-1-1-1*)Plot3D[
 First[((( D[Phi[r, Theta, t], {r, 1}])) /. 
 r -> s) /. sol], {Theta, 10^-3, \[Pi] - 10^-3}, {t, 0, 
 tmax}]
(*BCtest2-2*)Plot3D[
 First[((( D[Phi[r, Theta, t], {r, 1}]) - k/
     rc Phi[r, Theta, t]) /. sol) /. 
 r -> s] + k/rc, {Theta, 
 10^-3, \[Pi] - 10^-3}, {t, 0, tmax}]
(*BCtest2-3*)Plot3D[
 First[((( D[Phi[r, Theta, t], {r, 1}]) - k/
    rc (Phi[r, Theta, t] - 1)) /. sol) /. 
 r -> s], {Theta, 10^-3, \[Pi] - 10^-3}, {t, 0, tmax}]
(*BCtest3*)Plot3D[
 First[( D[Phi[r, Theta, t], {Theta, 1}] /. Theta -> 
  10^-3) /. sol], {r, s, rmax}, {t, 0, tmax}]
(*BCtest4*)Plot3D[
 First[( D[Phi[r, Theta, t], {Theta, 
   1}] /. Theta -> (\[Pi] - 10^-3)) /. sol], {r, s, 
 rmax}, {t, 0, tmax}]

Phin = First[Phi /. sol]
Plot3D[Phin[s, Theta, t], {Theta, 
10^-3, \[Pi] - 10^-3}, {t, 0, tmax}]
Plot3D[Phin[r, 10^-3, t], {r, s, rmax}, {t, 0, tmax}]

If solution is well investigated, boundary conditions should have consistency so that the boudary condition test gives the value nearly zero (BCtest 1~4) using Plot3D, but the second boundary condition

( Derivative[1, 0, 0][Phi][s, Theta, t]) == k/rc (Phi[s, Theta, t])

is not satisfied (That is, in boundary condition test (BCtest2-1) using Plot3D, (Derivative[1,0,0][Phi][s, Theta, t]- (k/rc) Phi[s, Theta, t]) should give nearly zero, but k/rc ), and is expected to have conflicts with initial condition

Phi[r, Theta, 0] == Fun1[r]

,

Phi[r, Theta, 0] == Fun2[r]

, or

Phi[r, Theta, 0] == Fun3[r]

Could I get a suggestion for adjust the initial condition to new one which doesn't deviate much from the original initial condition

Phi[r, Theta, 0] == 1

?

Or can I receive new insights to get over inconsistent IC and BC error message?

Thanks in advance!

$\endgroup$
5
  • $\begingroup$ I am not sure I understood (perhaps you could shorten the question by including minimal code), but, are you asking what initial condition to choose? $\endgroup$
    – acl
    Aug 1, 2012 at 10:43
  • $\begingroup$ By the way, welcome to Mathematica.SE! Please consider registering your account, so that any votes you might get for this question are added to those received for future questions. As you gain reputation points, you will be able to do more things like participate in the chat room. $\endgroup$
    – Verbeia
    Aug 1, 2012 at 13:45
  • $\begingroup$ Yes, I'm asking what initial condition to choose so that no inconsistent IC and BC error message comes. As your advice, I will make the question shortened. ^^ $\endgroup$ Aug 2, 2012 at 4:58
  • $\begingroup$ @JaehoonKim, just a short note, the intersection of the initial and boundary condition need to be consistent. If they are not NDSolve will (rightly) complain and try to find a consistent set. $\endgroup$
    – user21
    Aug 2, 2012 at 14:50
  • $\begingroup$ Your help taught me the principle to harmonize the initial and boundary condition. Thank you. ^^ $\endgroup$ Aug 3, 2012 at 7:26

2 Answers 2

2
$\begingroup$

An initial condition consistent with the boundary conditions Derivative[1,0,0][Phi][s,Theta,t]==(k/rc)Phi[s,Theta,t] and Phi[rmax,Theta,t]==1 would be:

Phi[r, Theta, 0] == Exp[ (k/rc) (r - rmax) ]

I'm not sure if that meets your requirements, but it gets rid of the NDSolve::ibcinc error.

$\endgroup$
1
  • $\begingroup$ Your advice helped me to solve the problem. At this time, I realized initial condition should satisfy all the boundary conditions, not only one. Thank you. ^^ $\endgroup$ Aug 3, 2012 at 7:23
1
$\begingroup$

Have you tried the function Piecewise? That one might work better than a function that involves If's.

Also, have you absolutely convinced yourself that your initial conditions should (in principle) be consistent?

$\endgroup$
1
  • $\begingroup$ Thank you for your advice. As following your recommendation, I changed 'If' statement to 'Piecewise' in Fun1[r]. However, the same message was printed. As following your second advice, I found the original initial condition is arbitrary so that Phi[r, Theta, t=0] can be bigger or smaller than 1. As a result, initial condition doesn't have to be consistent. It was my fault that initial condition should be consistent. $\endgroup$ Aug 2, 2012 at 4:49

Your Answer

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

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