0
$\begingroup$

I'm trying to solve a set of coupled pde equations of functions C1[t,x], C2[t,x]. all works fine but I need to specify a conditional initial conditions of the form:

when (t=t.min)  {
    C1 = if (x=x.min) 1 else 0
    C2 = 0;

I've tried to set:

C1[0,x]==0, (C1[0, x] /. x -> 0) == 1

or use

WhenEvent

but in either case I got:

NDSolve::bcedge: Boundary condition C1[0,0]==0 is not specified on a single edge of the boundary of the computational domain.

Is there any way around it?

Many thanks,

This question is a part of the post at http://community.wolfram.com/groups/-/m/t/1313375

edited:

Thanks. The code is:

Fp = 0.016666667; Vp = 0.07; Wp = 0.94; Dp = 
 10^-18; PSg = 0.05; Visfp = 0.35; Disf = 10^-18; L = 0.1;

sol = NDSolve[{Derivative[1, 0][C1][t, 
     x] == -Fp*L/Vp*Derivative[0, 1][C1][t, x] - 
     PSg/Vp*(C1[t, x]/Wp - C2[t, x]) + Dp*Derivative[0, 2][C1][t, x], 
   Derivative[1, 0][C2][t, x] == 
    PSg/Visfp*(C1[t, x]/Wp - C2[t, x]) + 
     Disf*Derivative[0, 2][C2][t, x], C1[t, 0] == Exp[-t], 
   C2[t, 0] == 0, C1[t, L] == 0, C2[t, L] == 0, 
   Derivative[0, 1][C1][t, 0] == 0, Derivative[0, 1][C2][t, 0] == 0, 
   Derivative[0, 1][C1][t, L] == 0, Derivative[0, 1][C2][t, L] == 0, 
   C1[0, x] == 1, C2[0, x] == 0}, {C1, C2}, {t, 0, 20}, {x, 0, L}]

Plot3D[Evaluate[C1[t, x] /. sol[[1]]], {t, 0, 20}, {x, 0, L}]

I've tried:

\[Phi][x_] := Piecewise[{{1, x == 0.}, {0, x > 0}}];

but it freezes the kernel (calculations never stop).

The solution should look like:

enter image description here

$\endgroup$
1
  • 4
    $\begingroup$ Its hard to test without the exact set of equations you are solving, but you might try to put your condition in a Piecewise or UnitStep form. $\endgroup$
    – Bill Watts
    Apr 3, 2018 at 22:28

1 Answer 1

3
$\begingroup$

With a few changes we can get some answers.

Clear["Global`*"]

Data

Fp = 0.016666667; 
Vp = 0.07; 
Wp = 0.94; 
Dp = 10^-18; 
PSg = 0.05; 
Visfp = 0.35; 
Disf = 10^-18; 
L = 0.1;

PDE's

eq1 = Derivative[1, 0][C1][t, x] == -((Fp*L*Derivative[0, 1][C1][t, x])/Vp) - 
    (PSg*(C1[t, x]/Wp - C2[t, x]))/Vp + Dp*Derivative[0, 2][C1][t, x];

eq2 = Derivative[1, 0][C2][t, x] == (PSg*(C1[t, x]/Wp - C2[t, x]))/Visfp + 
    Disf*Derivative[0, 2][C2][t, x];

bc's and ic's

bc1 = C1[t, 0] == Exp[-t];
bc2 = C2[t, 0] == 0;
bc3 = C1[t, L] == 0;
bc4 = C2[t, L] == 0;
bc5 = Derivative[0, 1][C1][t, 0] == 0;
bc6 = Derivative[0, 1][C2][t, 0] == 0;
bc7 = Derivative[0, 1][C1][t, L] == 0;
bc8 = Derivative[0, 1][C2][t, L] == 0;
(*ic1=Piecewise[[{{1,x==0},{0,x>0}}];*)
ic1 = C1[0, x] == Exp[-10000*x];
ic2 = C2[0, x] == 0;

Note I have commented out the Piecewise condition. I got NDSolve to give answers with that ic, but the solution was fairly unstable and not satisfactory. I have replaced the ic with a steep exponential fn that closely approximates the ic you want. Numerical analysis by its very nature is approximate, and if you need to replace a sharply varying condition with a smoother function that is a reasonable approximation, that is a good idea. I do not use bc5 and bc6 because NDSolve can get those derivatives from the ic's making them redundant and with the exponential ic, bc5 is conflicting.

Continuing

sol = NDSolve[{eq1, eq2, bc1, bc2, bc3, bc4,(*bc5,bc6,*)bc7, bc8, ic1,
    ic2}, {C1, C2}, {t, 0, 20}, {x, 0, L}];

Check our solution as to bc's and ic's

Plot[C1[0, x] /. sol[[1]], {x, 0, L}, PlotRange -> All]

enter image description here

Plot[C1[t, 0] /. sol[[1]], {t, 0, 20}, PlotRange -> All]

enter image description here

Plot[C2[0, x] /. sol[[1]], {x, 0, L}]

enter image description here

Plot[C2[t, 0] /. sol[[1]], {t, 0, 20}]

enter image description here

The bc's and ic's look numerically reasonable.

Plot3D[C1[t, x] /. sol[[1]], {t, 0, 20}, {x, 0, L}, PlotRange -> All]

enter image description here

Plot3D[C2[t, x] /. sol[[1]], {t, 0, 20}, {x, 0, L}, PlotRange -> All]

enter image description here

$\endgroup$
1
  • $\begingroup$ thank you so much! this helps a lot. $\endgroup$ Apr 6, 2018 at 20:19

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.