Nonlinear Newton solver fails near resonance for porous moonpool model
Show older comments
I am solving a nonlinear moonpool problem in MATLAB. The code can run either the linear pressure-drop term, the quadratic nonlinear term, or both. For the present test I use:
% Change ONLY these two lines:
linear = false;
quadratic = true;
so only the quadratic nonlinear pressure-drop term is active.
Away from resonance, the nonlinear Newton solver converges well. However, near resonance, especially for porosity values approximately
.the Newton solver becomes very sensitive. The accepted Newton step becomes extremely small, the residual stops decreasing, and the solver fails to converge at many frequency/period points.
For example, near resonance the line search reduces the Newton step repeatedly, but the residual remains finite and eventually no residual-reducing step can be found. Because many points near resonance fail to converge, the resulting nonlinear response curve contains gaps, and the reported peak amplitudes are not reliable. Some very large amplitudes appear for tau = 0.8, 0.9, 0.95, but several neighboring resonance points fail to converge. The nonlinear equation is solved in the form
F(V) = V - v_base - K*(abs(V).*V) = 0
using a damped Newton method with backtracking.
I can provide the full MATLAB code(attached in a file) and the residual history at the failed resonance points.
Away from resonance, convergence is very good. For example at T=15.550 s, the residual decreases and the solution converges successfully. However, only 0.0050.005 s later, at T=15.555 s, the Newton method starts to fail. , while the residual remains around
The same difficulty occurs mainly near resonance for porosity values around \tau=0.7–0.95.
Answers (3)
John D'Errico
on 31 Aug 2026
Edited: John D'Errico
on 31 Aug 2026
0 votes
Um, so what should we do? First, Newton's method is generally a great scheme. (You even understand that aspect from what I read in your question.) It converges rapidly for most/many smooth, well-defined problems. The computations are not so difficult that many people can write code to implement it. At the same time, Newton also has issues. Make the problem a nasty one, and things go to hell. The solver can diverge easily. It can require extremely precise starting values. This is all known behavior. It is usually the kind of thing that gets given as a homework problem in any beginning class on optimization. The student is given a not obviously nasty problem to solve using Newton's method, and then is expected to go crazy trying to figure out why Newton is diverging. Yeah, some teachers are mean like that, but it hammers the point home.
Typically teachers will then use this as a starting point for a discussion about things like basins of attraction, where divergence is explained, and the student learns why some solvers converge to different solutions, or fail to converge completely.
But in general, all solvers will have similar problems. Virtually any nonlinear solver that uses a starting value can be caused to fail, by a creatively written function where you understand the solver that will be employed.
So what you are telling us is that Newton usually works well, BUT, when you change the problem and make it nastier, it fails. Absolutely no surprise in any of this.
The answer is then to either use a different solver and pray it will survive, or to get (MUCH) better starting values, or perhaps to use multi-start methods, etc. And that can be a jumping off point where the student learns about global optimization schemes. (Which are generally never truly global, but they are often more robust than other classically based schemes like Newton.) A multi-start scheme is a hybrid like thing where you just use multiple randomly generated starting points, each of which then calls a upon a traditional (perhaps Newton) method from each start point. Sadly, pretty much all such global schemes are less efficient, less rapidly convergent than is Newton's method. Some days you can't win, but there are always such tradeoffs to be found in this world.
I'm sorry though, but there is not really much we can do for you. This is all expected behavior for Newton's method. You probably want to do some reading about basins of attraction, to learn why starting values can be important for such a solver.
3 Comments
Javeria
on 31 Aug 2026
John D'Errico
on 31 Aug 2026
Edited: John D'Errico
on 31 Aug 2026
Again, just trying some other different initial guess may be insufficient. You may need to find an initial guess that is extremely accurate. It is possible to define a problem that is so unstable that any guess that is not in fact a solution will cause divergence, and even then floating point problems can still cause divergence.
Next, you have not yet convinced me there even is a solution at all, as that is a good reason for non-convergence. As such a VERY good place to start is to plot it. In fact, this is my advice to all those who get stuck: to plot everything. And then, plot something else. You also have not even said if this is a univariate problem or a multivariate one. But in 1 or 2 dimensions, you can easily plot the necessary response. See what you can learn. Just how nasty is it? How good starting values will you need? You can learn a great deal from a simple plot.
Finally, I might note that the problem as you describe it in your question has an absolute value in it. That in itself introduces a point of non-differentiability into the problem. It certainly makes it more nonlinear than you will want. It wil introduce additional basins of attraction that will be a prob;em. And it may even preclude any solution from existing at all.
The problem is of the form
F(T,x) = 0
where T is a parameter running from T = 5 to T = 35 in the code.
Each value of T will give a different solution vector for x.
The solution for T = 5 is easily obtained with Newton's method, and starting from x(T=5), the task is to follow the solution for x up to T = 35. A problematic region with large gradients is around 15.2 <= T <= 16 where convergence of Newton's method is difficult to achieve.
Usually, the numerical method used for such cases is a continuation method:
Do you know of a suitable MATLAB solver for such problems ?
I read about "hsolve" from the File Exchange, but I don't think it's really suited in this case because the homotopy is naturally given and not artificially to be constructed.
You cannot stick to the points "T" that you prescribe in advance to compute "eta". If the Newton solver diverges, you should half the step in "T" (thus insert a new "T" value) and restart iterating with the last successful Newton solution as initial guess. Using this strategy, I've always been successful with your equations in our old discussion. Of course, I don't know whether the equations or the way you formulate them has changed since then.
8 Comments
Javeria
on 1 Sep 2026
Javeria
on 1 Sep 2026
Javeria
on 1 Sep 2026
Do you understand what I suggest in my answer and what will most probably solve your problem ?
Say the Newton iteration converged at T_i, but it does not converge at T_(i+1). Then take the solution at T_i as initial guess to get an intermediate solution at T* = (T_i + T_(i+1))/2. If this iteration is successful, set the new solution interval to [T*,T_(i+1)] and continue, else set the solution interval to [T_i,(T_i + T*)/2] and continue. And so on. If T* is "near enough" to T_i, it is expected that the Newton method with the solution at T_i as initial guess will converge because the initial guess is "good enough".
The algorithm is coded in the program I supplied in our earlier discussion.
Javeria
on 1 Sep 2026
It seems you made substantial changes to your "old" model. E.g. the integral term is computed before you enter the Newton iteration and is not changed therein - although (according to your "old" model) the integrand depends on the solution "psi" of the Newton iteration. As a consequence, the peak heights for eta in the old and the enclosed model are quite different. Is the enclosed code some kind of "simplified" model version ? Or is it just a correction of the old version ?
Javeria
on 3 Sep 2026
I ran your code with "fsolve" as nonlinear solver and set the initial guess V0 in each step to the nonlinear solution for V of the preceeding step instead of "ctx.v_base".
With this modification, I could run all cases for tau without missing values for eta.
The case tau = 0.95 is special. For this tau-value, I ran one case with T increasing from 5 to 35 ("fw" for "forward" in the included data file) and another case with T decreasing from 35 to 5 ("bw" for "backward" in the included data file) (again with "fsolve" as nonlinear solver and V0 as solution for V of the preceeding step instead of "ctx.v_base"). It turned out that the T-values of the two cases for which there are solutions overlap, but these solutions are not the same. This phenomenon is called "hysteresis".
The curve going from 35 to 5 (red curve below) is complete while the curve going from 5 to 35 (blue curve below) still has missing values from T = 15.555 up to T = 15.64 (in the below plot, I artifically translated the blue curve by -0.5 units for better visibility). I don't know if the initial guesses are too bad or if your system of equations simply has no solution for the blue curve in this interval.
I got this information from AI for hysteresis phenomena in moonpool simulations:
When continuously varying the frequency of incident ocean waves (ω) in a simulation, one observes a discontinuous hysteresis effect in the wave amplitude within the moonpool:
1. Path from the left (wave frequency increasing slowly): Initially, the water in the moonpool oscillates moderately in response. Even upon reaching the actual resonant frequency, the amplitude remains on an intermediate, stable branch (linear/moderate resonance path). Only at a specific, higher frequency does the amplitude suddenly jump sharply upward (saddle-node bifurcation).
2. Path from the right (wave frequency decreasing slowly): Approaching from the high-frequency range, the water is already in a state of extreme agitation (known as sloshing or piston-mode resonance). If the frequency is then reduced, the amplitude remains extremely high for much longer than it did during the upward sweep; it drops back down suddenly, but only after a delay.
The result: At exactly the same ocean wave frequency and height, the water in the moonpool can—in both simulation and reality—exhibit two completely different states, depending on whether the wave frequency had previously been increasing or decreasing.
For engineers, this "two-value phenomenon" (multistability) poses a major challenge in simulations, as a ship can suddenly be subjected to much higher loads under identical environmental conditions if it enters the scenario from the "wrong" state.
A10 = dlmread('Results_quad_0.95_fw_old.txt');
A20 = dlmread('Results_quad_0.95_bw.txt');
figure(1)
hold on
plot(A10(:,1),A10(:,2)-5e-1)
plot(A20(:,1),A20(:,2))
hold off
xlim([15 16])
xlabel('T')
ylabel('eta')
grid on
Addendum:
I used this new strategy for the initial values:
First choice: V0 as solution of the preceeding step.
If the iteration of the preceeding step doen't converge or is not available (like at the start of the simulation), use ctx.v_base.
If this iteration doesn't converge, use the analytical solution of the system -v_base - K*V*|V| = 0 (since K is singular, in the least-squares sense):
K = beta_moon*(ctx.v_map*ctx.projection_matrix);
y = pinv(K)*(-ctx.v_base);
tol = eps(max(abs(y)));
mag_y = abs(y);
nonzero_idx = mag_y > tol;
V0 = zeros(size(y));
V0(nonzero_idx) = y(nonzero_idx) ./ sqrt(mag_y(nonzero_idx));
With these modifications, I could identify the hysteresis cycle:
A10 = dlmread('Results_quad_0.95_fw_new.txt');
A20 = dlmread('Results_quad_0.95_bw.txt');
figure(2)
hold on
plot(A10(:,1),A10(:,2)-5e-1)
plot(A20(:,1),A20(:,2))
hold off
xlim([15 16])
xlabel('T')
ylabel('eta')
grid on
bol
on 11 Sep 2026
0 votes
<h1>ih</h1>
Categories
Find more on Systems of Nonlinear Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





