File : maketorus.adb


with Reps, Messages;
use Reps, Messages;

with Numerics, Numerics.Ops, Numerics.IO;
use Numerics, Numerics.Ops, Numerics.IO;
pragma Elaborate_All(Numerics, Numerics.Ops, Numerics.IO);

with Fouriers_Init;
use Fouriers_Init;
with Torus_Ops;

procedure MakeTorus is

  subtype Scalar is Numeric;

  Lmax: constant Positive := 40;
  Wmax: constant Positive := 40;
  Pdeg: constant Positive := 16;
  Dho:  constant Natural  :=  8;

  Sigma: constant Rep := 0.85001;
  Kappa: constant Rep := Sigma/0.4;

  package MakeTorus_Ops is new Torus_Ops (Lmax => Lmax, Wmax => Wmax, Pdeg => Pdeg, Dho => Dho,
                                          Sigma => Sigma, Kappa => Kappa, Scalar => Scalar);
  use MakeTorus_Ops;
  use Scal_Fou, Scal_Fou_Ops, Scal_Fou_IO;

  Iter: constant Integer := 100;           -- max number of iterations
  Eps:   constant Radius := 1.0E-14;       -- desired precision of torus
  HDec: constant Boolean := False;         -- decimal IO

  Rt: constant Rep     := 0.001;           -- for norm of tori
  Mu: constant Scalar  := Scal(0.2304601966125);
  B: constant Radius   := 2.0;

  Rd: Rep;
  T1,T2: Torus;
  U: Canonical;

begin
  Trace;

  Read("uzero",(Two,One),U,HDec);
  SetZero(Rt,T1);

  for I in 1 .. Iter loop
    Show(I'Img & " Computing NN(T)");
    NN(Mu,U,T1,T2);
    Rd := Sup(Norm(Rt,B,T2-T1));
    Show("|NN(T)=T| =",Rd);
    Write("tapprox-40-16-8",T2,HDec);
    exit when Rd<Eps;
    T1 := T2;
  end loop;

end MakeTorus;