I tried numerically solving a set of time-dependent PDEs with variables {u, v, w}
by NDSolve
over 2 regions with 2D grids, generated by FEM. The solution was exported to hard drive in the format of InterpolatingFunction
. But as I import from the saved file, the code fails to retrieve the stored data.
Needs["NDSolve`FEM`"]
dr = 0.5 10^-0; rx = 2./2 10^-0; xs = -(dr + rx); ys = 0.0;
ec = RegionUnion[Disk[{-rx, 0}, dr], Rectangle[{-rx, -dr}, {rx, dr}],
Disk[{rx, 0}, dr]];
bmesh = ToBoundaryMesh[ec, "MaxBoundaryCellMeasure" -> .05];
bmesh["Wireframe"];
f = Function[{vertices, area},
area > 0.002 (1. - 0.5 Norm[Mean[vertices]])];
(mesh = ToElementMesh[bmesh, MeshRefinementFunction -> f])["Wireframe"]
ndr = 0.3 10^-0; nrx =
1.2/2 10^-0; nxs = -(ndr + nrx); nys = 0.0; nlx = 0.4/1 10^-0;
nc = RegionUnion[Disk[{-nrx, 0}, ndr],
Rectangle[{-nrx, -ndr}, {(-nrx + nlx), ndr}],
Disk[{(-nrx + nlx), 0}, ndr], Disk[{(nrx - nlx), 0}, ndr],
Rectangle[{(nrx - nlx), -ndr}, {nrx, ndr}], Disk[{nrx, 0}, ndr]];
rPC = 0.00 10^-0;
xPC1 = rx + (dr - 1*rPC)*Cos[1 Pi/4]; yPC1 = (dr - 1*rPC)*
Sin[1 Pi/4];
xPC2 = -rx - (dr - 1*rPC)*Cos[-Pi/3]; yPC2 = (dr - 1*rPC)*Sin[-Pi/3];
PtChg1 = Disk[{xPC1, yPC1}, rPC];
PtChg2 = Disk[{xPC2, yPC2}, rPC];
PtChg = RegionUnion[PtChg1, PtChg2];
Show[Region[Style[nc, Cyan]], mesh["Wireframe"],
Graphics[{Magenta, Thick, PointSize[0.01], Point[{xPC1, yPC1}],
Point[{xPC2, yPC2}]}]]
Ck0 = 139.20 10^9; Ccl0 = 12.43 10^9;
u0 = Ck0/Ck0;
v0 = Ccl0/Ck0;
dk = 1.95 10^3; dcl = 2.02 10^3;
d0 = dcl/dk;
Tend = 0.0001 ;
V2 = -0.05*37.436;
q = 516.75 10^9; rho = (q/(\[Pi] ndr^2 + 4 ndr nrx) )/( Ck0);
Eqs = Inactivate[{D[u[t, x, y],
t] - (Laplacian[u[t, x, y], {x, y}] +
Div[(u[t, x, y]) Grad[w[t, x, y], {x, y}], {x, y}]),
D[v[t, x, y], t] -
d0 (Laplacian[v[t, x, y], {x, y}] -
Div[(v[t, x, y]) Grad[w[t, x, y], {x, y}], {x, y}]),
0.001 D[w[t, x, y], t] - Laplacian[w[t, x, y], {x, y}] -
4 \[Pi] (u[t, x, y] - v[t, x, y] -
rho Boole[{x, y} \[Element] nc])}, Laplacian | D];
ics = {u[0, x, y] == u0, v[0, x, y] == v0, w[0, x, y] == 0.0};
bcs = DirichletCondition[w[t, x, y] == V2, True];
sol = NDSolve[{Activate[Eqs] == {NeumannValue[0, True],
NeumannValue[0, True], 0}, ics, bcs}, {u, v,
w}, {x, y} \[Element] mesh, {t, 0, Tend},
InterpolationOrder -> All];
Export[FileNameJoin[{"C:\\Efield\\Expt_20240214\\a1\\K.vs.Cl-1_11.20\\", "Test1.m"}], sol];
isol = Import[FileNameJoin[{"C:\\Efield\\Expt_20240214\\a1\\K.vs.Cl-1_11.20\\",
"Test.m"}]];
Plot[Evaluate[{u[0.0001, x, 0], v[0.0001, x, 0]} /.First[isol]], {x, -1.5, 1.5}]
Evaluate[u[0.0001, 0, 0] /. First[isol]]
Evaluation the value of specific points also returned no results, but shows InterpolatingFunction like
I checked the data file and it looks like
( Created with the Wolfram Language : www.wolfram.com ) {{u -> InterpolatingFunction[{{0., 0.0001}, {-1.4999999999999998, 1.5}, {-0.5, 0.5}}, {5, 4225, 5, {42, 8018, 0}, {4, 3, 3}, 0, 0, 0, 0, Indeterminate & , {}, {}, False}, {{0., 1.^-8, 2.^-8, 4.^-8, 8.^-8, 1.6^-7, 2.4000000000000003*^-7, 3.2*^-7, 4.800000000000001*^-7, 6.4*^-7, 8.^-7, 1.1199999999999999^-6, 1.4399999999999998*^-6, 2.0799999999999996*^-6, 2.6559999999999996*^-6, 3.2319999999999997*^-6, 3.808*^-6, 4.384*^-6, 5.536*^-6, 6.688*^-6, 8.09254755698846*^-6, .... *
What is wrong with my code?
Tend
– you see, it is displayed in blue color. $\endgroup$Tend
is not defined. Also, doesEvaluate[v[0.0001, x, 0] /. First[isol]]
return anything? $\endgroup$Quit
). $\endgroup$"Test1.mx"
.....There was another problem withInterpolatingFunction
and the .m format here. It seems a different problem, but the .m format andInterpolatingFunction
do not seem to work well together in both cases. Maybe the bugs are related. $\endgroup$