Yes. The most likely issue is a sign error in the coefficient term.
For the boundary data you used, the intended exact solution is
u(x,y)=\cos(\cos(x(y+1))).
Let . Then
\Delta u=(x^2+(y+1)^2)\left[\cos(\cos s)\sin^2s+\sin(\cos s)\cos s\right].
Therefore,
\Delta u-\bigl(x^2+(y+1)^2\bigr)\sin^2(s)\,u
=
\bigl(x^2+(y+1)^2\bigr)\cos(s)\sin(\cos s).
So the operator should use minus, not plus:
N = chebop2(@(x,y,u) lap(u) ...
- (x.^2 + (y+1).^2).*sin(x.*(y+1)).^2.*u);
N.lbc = @(y) cos(cos(-y-1));
N.rbc = @(y) cos(cos( y+1));
N.dbc = @(x) cos(cos(-x-1));
N.ubc = @(x) cos(cos( x+1));
f = chebfun2(@(x,y) ...
(x.^2 + (y+1).^2).*cos(x.*(y+1)).*sin(cos(x.*(y+1))));
u = N \ f;
The error
Solution was unresolved on a 65 by 65 grid.
means Chebfun’s adaptive PDE solver tried its available grid sizes and did not see enough Chebyshev-coefficient decay to accept the result. Chebfun’s guide notes that differential equations are solved on successively larger grids such as 33, 65, etc., until convergence is detected.
Two further points:
chebop2 is experimental. The current source documentation says chebop2 is for linear PDEs on rectangles with unique globally smooth solutions, and warns that the PDE solver is an experimental feature.
The plus-sign problem is not just cosmetic. With the plus sign, the right-hand side and boundary conditions no longer match the manufactured solution from the paper. The resulting boundary value problem may still have a solution, but Chebfun’s automatic resolver may fail to certify it at the default resolution.
A good diagnostic is to check against the manufactured solution:
uexact = chebfun2(@(x,y) cos(cos(x.*(y+1))));
norm(u - uexact)
clear classes, and test a simpler Poisson/Helmholtz chebop2 example first to confirm your installation. The exact question and error are also visible in the Chebfun users group, so it may be a current-version regression or limitation if the corrected sign still persists.Your question is technically clear, but it can be strengthened. The important point is that this is probably not just a Chebfun resolution problem; it may be a mistyped manufactured-solution example, especially the sign in the operator.A stronger critique:
You wrote:
lap(u) + (x.^2+(y+1).^2).*sin(x.*(y+1)).^2.*u
But the boundary conditions and right-hand side strongly suggest that the manufactured solution is
u = cos(cos(x*(y+1)))
For that solution, the compatible PDE is more naturally:
lap(u) - (x.^2+(y+1).^2).*sin(x.*(y+1)).^2.*u = f
not with a plus sign.
So the first criticism is: before increasing the grid size, verify the sign of the zero-order coefficient. If the sign is wrong, Chebfun may be trying to solve a different PDE from the one intended in the article.
The message
Solution was unresolved on a 65 by 65 grid.
does not necessarily mean the PDE has no solution. It means Chebfun’s adaptive solver did not accept the numerical approximation at the default maximum resolution. Possible causes include:
chebop2’s experimental solver reached an internal resolution limit.So the error should not immediately be interpreted as “Chebfun cannot solve this PDE.” It means the adaptive convergence test failed.
A good way to test the problem is to define
uexact = chebfun2(@(x,y) cos(cos(x.*(y+1))));
Then symbolically or numerically check whether
lap(uexact) + coefficient*uexact
or
lap(uexact) - coefficient*uexact
matches the given f.
This is the cleanest critique: the code should be checked by substitution before blaming the solver.
For ,
cos(cos((-1)*(y+1))) = cos(cos(-y-1))
For ,
cos(cos(y+1))
For ,
cos(cos(x*0)) = cos(cos(0))
Your posted lower boundary is
N.dbc = @(x) cos(cos(-x-1));
This is suspicious depending on the domain convention. If the domain is , then at , , so the lower boundary should be constant:
N.dbc = @(x) cos(cos(0));
At , one would expect:
N.ubc = @(x) cos(cos(2*x));
So there may be a second issue: the boundary conditions may not correspond to on the standard square. They look more like someone has confused or transformed the variables.
This is more serious than the sign issue. The boundary conditions should be checked carefully against the actual domain and the exact solution stated in the paper.
To make the question easier to answer, it should include:
ver
chebfunpref
and ideally:
chebfun2(@(x,y) ...)
test cases showing whether simpler Poisson or Helmholtz examples work. Since chebop2 has changed over time and is not as mature as 1D chebop, version information matters.
A stronger version would be:
I am trying to reproduce Example 2 from Townsend and Olver,
JCP 299 (2015), pp. 106–123, using chebop2.
The code I used is:
[code]
Chebfun returns:
"Solution was unresolved on a 65 by 65 grid."
Before assuming this is a resolution issue, I am trying to verify whether I have transcribed the PDE correctly. The boundary data appear to suggest a manufactured solution of the form
u(x,y) = cos(cos(x*(y+1))),
but substituting this into the operator seems to give a different sign, and possibly different top/bottom boundary data on [-1,1]^2.
Can anyone confirm the exact PDE, domain, and boundary conditions for this example, or advise whether newer Chebfun versions require a different formulation?
Your original post is good as a bug report, but it frames the issue too much as “how do I overcome the unresolved grid error?” The deeper issue is probably:
Does the MATLAB code correctly reproduce the PDE in the article?
I would first check:
Only after those are verified would I try increasing resolution or modifying Chebfun solver settings. The most likely issue is a sign error in the coefficient term.
For the boundary data you used, the intended exact solution is
u(x,y)=\cos(\cos(x(y+1))).
Let . Then
\Delta u=(x^2+(y+1)^2)\left[\cos(\cos s)\sin^2s+\sin(\cos s)\cos s\right].
Therefore,
\Delta u-\bigl(x^2+(y+1)^2\bigr)\sin^2(s)\,u
=
\bigl(x^2+(y+1)^2\bigr)\cos(s)\sin(\cos s).
So the operator should use minus, not plus:
N = chebop2(@(x,y,u) lap(u) ...
- (x.^2 + (y+1).^2).*sin(x.*(y+1)).^2.*u);
N.lbc = @(y) cos(cos(-y-1));
N.rbc = @(y) cos(cos( y+1));
N.dbc = @(x) cos(cos(-x-1));
N.ubc = @(x) cos(cos( x+1));
f = chebfun2(@(x,y) ...
(x.^2 + (y+1).^2).*cos(x.*(y+1)).*sin(cos(x.*(y+1))));
u = N \ f;
The error
Solution was unresolved on a 65 by 65 grid.
means Chebfun’s adaptive PDE solver tried its available grid sizes and did not see enough Chebyshev-coefficient decay to accept the result. Chebfun’s guide notes that differential equations are solved on successively larger grids such as 33, 65, etc., until convergence is detected.
Two further points:
chebop2 is experimental. The current source documentation says chebop2 is for linear PDEs on rectangles with unique globally smooth solutions, and warns that the PDE solver is an experimental feature.
The plus-sign problem is not just cosmetic. With the plus sign, the right-hand side and boundary conditions no longer match the manufactured solution from the paper. The resulting boundary value problem may still have a solution, but Chebfun’s automatic resolver may fail to certify it at the default resolution.
A good diagnostic is to check against the manufactured solution:
uexact = chebfun2(@(x,y) cos(cos(x.*(y+1))));
norm(u - uexact)
If the corrected operator is accepted, this norm should be small. If it still fails, then the next things to try are: update Chebfun from the current GitHub version, restart MATLAB and run clear classes, and test a simpler Poisson/Helmholtz chebop2 example first to confirm your installation. The exact question and error are also visible in the Chebfun users group, so it may be a current-version regression or limitation if the corrected sign still fails.
Yes. The
--
You received this message because you are subscribed to the Google Groups "chebfun-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chebfun-user...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/chebfun-users/1f3d6b63-ab92-46c4-9ca5-8a46ea2766den%40googlegroups.com.
If the corrected operator is accepted, this norm should be small. If it still fails, then the next things to try are: update Chebfun from the current GitHub version, restart MATLAB and run clear classes, and test a simpler Poisson/Helmholtz chebop2 example first to confirm your installation. The exact question and error are also visible in the Chebfun users group, so it may be a current-version regression or limitation if the corrected sign still fails.