I try to use BSplineFunction
to creat a initial condition for NDSolve
which has periodic boundary condition, that is realized by producing a coarse grid of random number:
ini = 1 + c*BSplineFunction[RandomReal[1, {30, 30, 1}], SplineClosed -> True];
SplineClosed -> True
makes sure I can use it to consist with periodic boundary conditions in NDSolve
.
I get into trouble: my BSplineFunction
seems to be not a function of x and y. How can I describe it to be a function of x and y on a square domain with side length L (see my code)? I think that is the reason why NDSolve
complains about when I try to use a spline surface acting as initial condition.
Working example:
Off[NDSolve::mxsst];
Clear["Global`*"]
L = 15;
c = -(1/20);
tmax = 1000;
a = 1/10;
b = 1;
m = 25;
ini = 1 + c*BSplineFunction[RandomReal[1, {30, 30, 1}], SplineClosed -> True];
sol = First[ h /. NDSolve[{D[h[x, y, t], t] +
Div[-a*h[x, y, t]^3*Grad[h[x, y, t], {x, y}], {x, y}] +
Div[(b*m*h[x, y, t]^2*
Grad[h[x, y, t], {x, y}])/(2*(1 + b*h[x, y, t])^2), {x, y}] +
Div[h[x, y, t]^3*Grad[Laplacian[h[x, y, t], {x, y}], {x, y}], {x, y}] == 0,
h[0, y, t] == h[L, y, t], h[x, 0, t] == h[x, L, t],
h[x, y, 0] == ini[x, y]},
h, {x, 0, L}, {y, 0, L}, {t, 0, tmax},
Method -> {"BDF", "MaxDifferenceOrder" -> 1},
MaxStepFraction -> 1/50]]
I have the following error:
NDSolve::ndnum: Encountered non-numerical value for a derivative at t == 0.`.
ReplaceAll::reps: "!({NDSolve[{<<1>>}, h, {x, 0, 15}, {y, 0, 15}, {t, 0, 1000}, Method -> {\"BDF\", \"MaxDifferenceOrder\" -> 1}, MaxStepFraction -> *FractionBox[(1), (50)]]}) is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing."
Aucun commentaire:
Enregistrer un commentaire