Menu

#58 Error when following TR

---
closed
nobody
None
2024-04-17
2024-04-15
Marc
No

I have a system with two parameters (par1, par2).
After having detected e.g. HB and SN points when continuing as function of par1, I know how to follow these special points as function of par1 and par2.
However, when following the same logic to find TR points, I obtain an error message. Is the followed method correct?

% run1: continuation as functin of par1
...
% get TR label
TR1 = coco_bd_labs('run1', 'TR');

% run2: follow the TR point as function of par1 and par2
coco(prob, 'run2', 'ode', 'TR', 'TR', 'run1', TR1(1), {'par1' 'par2'} {[0 1] [0 1]})
% get last label
TR2 = max(coco_bd_labs('run2'));

% run3: continue to follow the TR point as function of par1 and par2
coco(prob, 'run3', 'ode', 'TR', 'TR', 'run2', TR2(1), {'par1' 'par2'} {[0 10] [0 10]})

Error message:

Index exceeds the number of array elements. Index must not exceed 10.

Error in po_TR_construct_eqn>FDF (line 59)
v2 = u(tr.v2_idx);

Error in efunc_call_F (line 11)
    [data, F] = func.F(opts, data, x);

Error in coco_add_func (line 466)
        efunc_call_F(prob, func.data, efunc.chart, func, x0);

Error in po_TR_construct_eqn (line 14)
prob = coco_add_func(prob, fid, @FDF, data, 'zero', 'uidx', uidx, ...

Error in po_add_TR (line 80)
[prob, data] = po_TR_construct_eqn(prob, data, sol);

Error in ode_po2TR (line 59)
prob = po_add_TR(prob, data, sol);

Error in ode_TR2TR (line 45)
  prob = ctor(prob, oid, str.put(args.run, args.soid, args.lab));

Error in coco (line 166)
prob = run.tbxctor(prob, '', p);

I verified that TR2 (number of the last run stored by run2) is bigger than 10.

Discussion

  • Harry Dankowicz

    Harry Dankowicz - 2024-04-15

    Hi Marc,

    The tor demo in the po toolbox folder shows the continuation of families of saddle-node, period-doubling, and torus bifurcations of periodic orbits. The script syntax you have shown above seems correct, so I am inclined to assume a coding error. Feel free to share your full set of files for debugging, or consider comparing your code against the demo (which I hope runs without difficulty for you).

    Best,

    Harry

     
  • Marc

    Marc - 2024-04-16

    Hello, thank you for your answer.
    I could not find a coding error so far. However, I was able to reproduce the error by modifing the file demo.m in the tor folder.

    1. PD

    %% Continuation of period-doubling bifurcations
    
    PDlabs = coco_bd_labs(bd2, 'PD');
    prob = coco_prob();
    prob = coco_set(prob, 'cont', 'NAdapt', 5);
    
    bd4 = coco(prob, 'pd1', 'ode', 'PD', 'PD', ...
      'po2', PDlabs(1), {'nu' 'po.period' 'be'}, [-0.65, -0.55]);
    
    %addendum
    prob2 = coco_prob();
    prob2 = coco_set(prob2, 'cont', 'NAdapt', 5, 'ItMX', [10 0]);
    
    Nmax = max(coco_bd_labs('pd1'))
    bd4b = coco(prob2, 'pd1b', 'ode', 'PD', 'PD', ...
      'pd1', Nmax, {'nu' 'be'}, [-.7, 0]);
    
    figure(2); clf; hold on
    coco_plot_bd('pd1','nu','be','||x||_{2,MPD}')
    coco_plot_bd('pd1b','nu','be','||x||_{2,MPD}')
    

    The figure confirms that an additional part of the PD branch was calculated, starting at its former endpoint with label Nmax.

    2. TR

    %% Continuation of torus bifurcations
    
    TRlabs = coco_bd_labs(bd2, 'TR');
    prob = coco_prob();
    prob = coco_set(prob, 'cont', 'NAdapt', 5);
    
    bd5 = coco(prob, 'tr1', 'ode', 'TR', 'TR', ...
      'po2', TRlabs(1), {'nu' 'po.period' 'be'}, [-0.65, -0.55]);
    
    %addendum
    
    Nmax = max(coco_bd_labs('tr1'))
    bd5b = coco(prob2, 'tr1b', 'ode', 'TR', 'TR', ...
      'tr1', Nmax, {'nu' 'be'}, [-.7, 0]); %error!
    
    figure(2)
    coco_plot_bd('tr1','nu','be','||x||_{2,MPD}')
    coco_plot_bd('tr1b','nu','be','||x||_{2,MPD}')
    

    The same error is raised by bd5b (with Nmax=18):

    Index exceeds the number of array elements. Index must not exceed 8.
    
    Error in po_TR_construct_eqn>FDF (line 59)
    v2 = u(tr.v2_idx);
    
    Error in efunc_call_F (line 11)
        [data, F] = func.F(opts, data, x);
    
    Error in coco_add_func (line 466)
            efunc_call_F(prob, func.data, efunc.chart, func, x0);
    
    Error in po_TR_construct_eqn (line 14)
    prob = coco_add_func(prob, fid, @FDF, data, 'zero', 'uidx', uidx, ...
    
    Error in po_add_TR (line 80)
    [prob, data] = po_TR_construct_eqn(prob, data, sol);
    
    Error in ode_po2TR (line 59)
    prob = po_add_TR(prob, data, sol);
    
    Error in ode_TR2TR (line 45)
      prob = ctor(prob, oid, str.put(args.run, args.soid, args.lab));
    
    Error in coco (line 166)
    prob = run.tbxctor(prob, '', p);
    

    I suppose that this would mean that somewhere, the n-th element (n>8) from a vector with length 8 is asked.

     
  • Harry Dankowicz

    Harry Dankowicz - 2024-04-16

    Thank you, Marc. I very much appreciate you bringing this to my attention. You have attempted to do something very logical, namely restart continuation of torus bifurcations from a point on a previously computed branch of torus bifurcations. As you note, the same functionality appears to work for period-doubling bifurcations, and it seems very reasonable that po constructors should support this. Indeed, I see no reason why they shouldn't. Obviously, I did not test this functionality or else I would have found the culprit:

    Please replace line 254 in po_read_solution.m with

    sol.var.v = chart.x([data.po_tr.v1_idx' data.po_tr.v2_idx']);
    

    Please let me know if this solves the problem for you.

    Best,

    Harry

     
  • Marc

    Marc - 2024-04-17

    Hello Harry
    This works perfectly, thank you!!
    Marc

     
  • Harry Dankowicz

    Harry Dankowicz - 2024-04-17
    • status: open --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB