Skip to main content
deleted 69 characters in body
Source Link
xzczd
  • 68.4k
  • 9
  • 174
  • 489
w2 = 6;
m = 2;
T = 2.0;
sol = NDSolveValue[{q'[t] == \[Zeta][t]ζ[t], \[Zeta]'[t]ζ'[t] + w2*Sin[q[t]] == 0, 
     0,               q[0] == Pi/3., \[Zeta][0]ζ[0] == 0}, {q, \[Zeta]ζ}, {t, 0, T}]
Plot[sol[[1]]'[t], {t, 0, T}]
solFEM = NDSolveValue[{q'[t] == \[Zeta][t]ζ[t], \[Zeta]'[t]ζ'[t] + w2*Sin[q[t]] == 0,
                       DirichletCondition[{q[t] == Pi/3., \[Zeta][t]ζ[t] == 0}, 
 t == 0]}, 
                      {q, \[Zeta]ζ}, t \[Element] Line[{{0}, {T}}], Method -> {"FiniteElement"}]
Plot[solFEM[[1]]'[t], {t, 0, T}]
 solFEM = 
 NDSolveValue[{q'[t] == \[Zeta][t]ζ[t], \[Zeta]'[t]ζ'[t] + w2*Sin[q[t]] == 0, 
   DirichletCondition[{q[t] == Pi/3., \[Zeta][t]ζ[t] == 0}, 
    t == 0]}, 
   {q, \[Zeta]ζ}, t \[Element] Line[{{0}, {T}}], 
   Method -> {"FiniteElement", 
    "MeshOptions" -> {MaxCellMeasure -> 0.01}}]
In[26]:=FindMinimum[sol[[1]]'[t]FindMinimum[sol[[1]]'[t], {t, 0.5}]
Out[26]=(* {-2.44949, {t -> 0.688223}} *)
In[27]:=FindMinimum[solFEM[[1]]'[t]FindMinimum[solFEM[[1]]'[t], {t, 0.5}]
 
••• FindMinimum: The line search decreased the step size to within the tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the function. You may need more than MachinePrecision digits of working precision to meet these

••• FindMinimum: The line search decreased the step size to within the tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the function. You may need more than MachinePrecision digits of working precision to meet these tolerances.

(* tolerances.

Out[27]={-2.1981, {t -> 0.5}} *)
In[28]:=FindMinimum[solFEM[[1]]'[t]FindMinimum[solFEM[[1]]'[t], {t, 0.688223}]
 
••• FindMinimum: Line search unable to find a sufficient decrease in the function value with MachinePrecision digit

••• FindMinimum: Line search unable to find a sufficient decrease in the function value with MachinePrecision digit precision.

(* precision.

Out[28]={-2.45211, {t -> 0.69}} *)
w2 = 6;
m = 2;
T = 2.0;
sol = NDSolveValue[{q'[t] == \[Zeta][t], \[Zeta]'[t] + w2*Sin[q[t]] ==
     0, q[0] == Pi/3., \[Zeta][0] == 0}, {q, \[Zeta]}, {t, 0, T}]
Plot[sol[[1]]'[t], {t, 0, T}
solFEM = NDSolveValue[{q'[t] == \[Zeta][t], \[Zeta]'[t] + w2*Sin[q[t]] == 0,DirichletCondition[{q[t] == Pi/3., \[Zeta][t] == 0}, 
 t == 0]}, {q, \[Zeta]}, t \[Element] Line[{{0}, {T}}], Method -> {"FiniteElement"}]
Plot[solFEM[[1]]'[t], {t, 0, T}
 solFEM = 
 NDSolveValue[{q'[t] == \[Zeta][t], \[Zeta]'[t] + w2*Sin[q[t]] == 0, 
   DirichletCondition[{q[t] == Pi/3., \[Zeta][t] == 0}, 
    t == 0]}, {q, \[Zeta]}, t \[Element] Line[{{0}, {T}}], 
  Method -> {"FiniteElement", 
    "MeshOptions" -> {MaxCellMeasure -> 0.01}}]
In[26]:=FindMinimum[sol[[1]]'[t], {t, 0.5}]
Out[26]={-2.44949, {t -> 0.688223}}
In[27]:=FindMinimum[solFEM[[1]]'[t], {t, 0.5}]
 
••• FindMinimum: The line search decreased the step size to within the tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the function. You may need more than MachinePrecision digits of working precision to meet these tolerances.

Out[27]={-2.1981, {t -> 0.5}}
In[28]:=FindMinimum[solFEM[[1]]'[t], {t, 0.688223}]
 
••• FindMinimum: Line search unable to find a sufficient decrease in the function value with MachinePrecision digit precision.

Out[28]={-2.45211, {t -> 0.69}}
w2 = 6;
m = 2;
T = 2.0;
sol = NDSolveValue[{q'[t] == ζ[t], ζ'[t] + w2*Sin[q[t]] == 0, 
                    q[0] == Pi/3., ζ[0] == 0}, {q, ζ}, {t, 0, T}]
Plot[sol[[1]]'[t], {t, 0, T}]
solFEM = NDSolveValue[{q'[t] == ζ[t], ζ'[t] + w2*Sin[q[t]] == 0,
                       DirichletCondition[{q[t] == Pi/3., ζ[t] == 0}, t == 0]}, 
                      {q, ζ}, t  Line[{{0}, {T}}], Method -> {"FiniteElement"}]
Plot[solFEM[[1]]'[t], {t, 0, T}]
 solFEM = 
 NDSolveValue[{q'[t] == ζ[t], ζ'[t] + w2*Sin[q[t]] == 0, 
   DirichletCondition[{q[t] == Pi/3., ζ[t] == 0}, t == 0]}, 
   {q, ζ}, t  Line[{{0}, {T}}], 
   Method -> {"FiniteElement", "MeshOptions" -> {MaxCellMeasure -> 0.01}}]
FindMinimum[sol[[1]]'[t], {t, 0.5}]
(* {-2.44949, {t -> 0.688223}} *)
FindMinimum[solFEM[[1]]'[t], {t, 0.5}]

••• FindMinimum: The line search decreased the step size to within the tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the function. You may need more than MachinePrecision digits of working precision to meet these tolerances.

(* {-2.1981, {t -> 0.5}} *)
FindMinimum[solFEM[[1]]'[t], {t, 0.688223}]

••• FindMinimum: Line search unable to find a sufficient decrease in the function value with MachinePrecision digit precision.

(* {-2.45211, {t -> 0.69}} *)
Added a practical example of the issue consequences
Source Link
Meclassic
  • 1.1k
  • 1
  • 9
  • 15

EDIT 1

On appearance, an easy fix would have been to reduce the cell size of the FEM method. This can be achieved by setting the "MaxCellMeasure" size to something smaller (like 0.01 or 0.001 for example):

 solFEM = 
 NDSolveValue[{q'[t] == \[Zeta][t], \[Zeta]'[t] + w2*Sin[q[t]] == 0, 
   DirichletCondition[{q[t] == Pi/3., \[Zeta][t] == 0}, 
    t == 0]}, {q, \[Zeta]}, t \[Element] Line[{{0}, {T}}], 
  Method -> {"FiniteElement", 
    "MeshOptions" -> {MaxCellMeasure -> 0.01}}]

However, this only "hides" the issue to the bare eye. One can still see the chattering effect when zooming around the minimum for example:

enter image description here enter image description here

Why would this matter?

My problem with this issue has nothing to do with the curve appearance. On a practical level, if I want to determine, say, the local minimum (or maximum) near some region, then FindMinimum (or FindMaximum) will inevitably fail. I can easily find the local minimum near t->0.5 for the "default" solution:

In[26]:=FindMinimum[sol[[1]]'[t], {t, 0.5}]
Out[26]={-2.44949, {t -> 0.688223}}

However, this is not possible with the FEM solution because chattering obviously affects FindMinimum:

In[27]:=FindMinimum[solFEM[[1]]'[t], {t, 0.5}]

••• FindMinimum: The line search decreased the step size to within the tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the function. You may need more than MachinePrecision digits of working precision to meet these tolerances.

Out[27]={-2.1981, {t -> 0.5}}

Because of chattering, this simple operation becomes impossible even when directly feeding a very close initial guess:

In[28]:=FindMinimum[solFEM[[1]]'[t], {t, 0.688223}]

••• FindMinimum: Line search unable to find a sufficient decrease in the function value with MachinePrecision digit precision.

Out[28]={-2.45211, {t -> 0.69}}

This is only one example of the consequences of that chattering effect.

EDIT 1

On appearance, an easy fix would have been to reduce the cell size of the FEM method. This can be achieved by setting the "MaxCellMeasure" size to something smaller (like 0.01 or 0.001 for example):

 solFEM = 
 NDSolveValue[{q'[t] == \[Zeta][t], \[Zeta]'[t] + w2*Sin[q[t]] == 0, 
   DirichletCondition[{q[t] == Pi/3., \[Zeta][t] == 0}, 
    t == 0]}, {q, \[Zeta]}, t \[Element] Line[{{0}, {T}}], 
  Method -> {"FiniteElement", 
    "MeshOptions" -> {MaxCellMeasure -> 0.01}}]

However, this only "hides" the issue to the bare eye. One can still see the chattering effect when zooming around the minimum for example:

enter image description here enter image description here

Why would this matter?

My problem with this issue has nothing to do with the curve appearance. On a practical level, if I want to determine, say, the local minimum (or maximum) near some region, then FindMinimum (or FindMaximum) will inevitably fail. I can easily find the local minimum near t->0.5 for the "default" solution:

In[26]:=FindMinimum[sol[[1]]'[t], {t, 0.5}]
Out[26]={-2.44949, {t -> 0.688223}}

However, this is not possible with the FEM solution because chattering obviously affects FindMinimum:

In[27]:=FindMinimum[solFEM[[1]]'[t], {t, 0.5}]

••• FindMinimum: The line search decreased the step size to within the tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the function. You may need more than MachinePrecision digits of working precision to meet these tolerances.

Out[27]={-2.1981, {t -> 0.5}}

Because of chattering, this simple operation becomes impossible even when directly feeding a very close initial guess:

In[28]:=FindMinimum[solFEM[[1]]'[t], {t, 0.688223}]

••• FindMinimum: Line search unable to find a sufficient decrease in the function value with MachinePrecision digit precision.

Out[28]={-2.45211, {t -> 0.69}}

This is only one example of the consequences of that chattering effect.

Became Hot Network Question
Tweeted twitter.com/StackMma/status/1593574743063801861
edited tags
Link
xzczd
  • 68.4k
  • 9
  • 174
  • 489
Source Link
Meclassic
  • 1.1k
  • 1
  • 9
  • 15
Loading