# Solving a system of PDE-ODE with Dirichlet condition

I'm trying to solve a system of one PDE and one ODE that are dependent on time and distance (H[x,t] and P[x,t]) with the distance varying between x = 0 and x = xmax. The value for function P is 0 at x >= xmax/100. H takes positive values between x=0 and x=xmax. The solution I'm expecting is something like this

The solution I'm getting is this

With blue being the solution for H and yellow for P. The problem is that P doesn't drop back to zero at x=xmax/100 as I'm expecting.

I used the following Dirichlet condition for P

DirichletCondition[P[x, t] == 0, x == xmax/100]

but I get the same answer. Maybe I should use a piecewise function but maybe I'm missing something very simple. The full code I'm using is this

(* Function definitions *)

Cxt[name_, xx_,tt_] := (Evaluate[name[x, t] /. x -> xx /. t -> tt] /. sol )*1000

(*Constants*)
f = 38.94; logL = -2;
Ls = 10^logL; a = 0.5;
C1 = 1*^-5; dH = 1*^-6;
Ea = 0.5;
tmax = 40;(*Time in seconds*)
xmax = 10 Sqrt[dH] Sqrt[tmax];(*Maximum distance to simulate.cm*)

(*PDE system*)
eqsH = {D[H[x, t], t] - dH D[H[x, t], x, x] == NeumannValue[Ls Exp[a f Ea] P[x, t] - LsExp[-a f Ea] H[x, t],
x == 0], H[x, 0] == 0};

eqsP = {D[P[x, t], t] == NeumannValue[-Ls Exp[a f Ea] P[x, t] + Ls Exp[-a f Ea] H[x, t],
x == 0], DirichletCondition[P[x, t] == 0, x == xmax/100],P[x, 0] == 1};

(*Solution of the differential equations*)
prec = 7; msf = 0.001;

sol = NDSolve[{eqsH, eqsP}, {H, P}, {x, 0, xmax}, {t, 0, tmax},AccuracyGoal -> prec, PrecisionGoal -> prec, Method -> {"MethodOfLines","SpatialDiscretization" -> {"FiniteElement"}}] // First //
Quiet;
(* Plot *)
Plot[{Cxt[H, x, 10], Cxt[P, x, 10]/15}, {x, 0, xmax},
PlotRange -> All];


Any help or advice in how to get the answer I'm expecting is more than welcome! Thanks!

• Boundary condition DirichletCondition[P[x, t] == 0, x == xmax/100] generates error NDSolve::bcnop: No places were found on the boundary where x==1/(500 Sqrt[10]) was True, so DirichletCondition[P==0,x==1/(500 Sqrt[10])] will effectively be ignored. – Alex Trounev Dec 12 '20 at 0:20
• Your expectations like "The value for function P is 0 at x >= xmax/100" contradict to the initial condition P[x, 0] == 1 – Alex Trounev Dec 12 '20 at 12:23
• Thanks for the feedback Alex. – Afmo Dec 13 '20 at 9:21
• Thanks @AlexTrounev you were right the initial conditions wasn't properly written. I solved it by adding a piecewise initial condition. – Afmo Dec 17 '20 at 8:28