I'm trying to address a mass diffusion problem, and I'm encountering two problems.
m1 = 2;
m2 = 36;
Z1 = 1;
Z2 = 6;
kT = 5;
D0 = 1;
g = 2.1;
n20[z_] :=
Piecewise[{{1/(1 + Z2)*Exp[-m2*g*z/(1 + Z2)/kT],
z >= 0}, {1/(1 + Z2) + z*10, -1/(1 + Z2)/10 < z < 0}}, 0];
sol = NDSolve[{((1 + Z1)*D[n1[z], z] + (1 + Z2)*D[n20[z], z])*
kT == -(m1*n1[z] + m2*n20[z])*g, n1[1] == 0}, n1[z], {z, -1, 1}]
The first comes from the NDSolve here, where it returns NDSolve::nlnum, however merely turning to DSolve will result in a correct solution.
The second problem appears when I tried to solve the time-dependent problem
sol = NDSolve[{((1 + Z1)*D[n1[z, t], z] + (1 + Z2)*D[n2[z, t], z])*
kT == -(m1*n1[z, t] + m2*n2[z, t])*g,
D[n1[z, t], t] == D[D0*D[n1[z, t], z] + D0/kT*m1*n1[z, t]*g, z],
n2[z, 0] == n20[z], n1[1, 0] == 0}, n1, {z, -1, 1}, {t, 0, 1}]
And I get NDSolve::bcedge, which tells me the boundary condition n1[1, 0] == 0 'is not specified on a single edge of the boundary of the domain', which confuses me.
I'm not sure if the two problems are related. Any suggestions will help.
Simplify`PWToUnitStep
. As to the second question, as pointed out by Nasser below, your ic and bc is a mess. I can spot at least 2 problems: 1.n1[1, 0] == 0
is not a well-posed constraint in 2D space: ... $\endgroup$n2
doesn't even involve in here), to determine a solution, boundary condition atz==1
andz==-1
is necessary. $\endgroup$