Ledger Nano X - The secure hardware wallet
SHARE
TWEET

COCO

a guest Mar 28th, 2020 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. %% ========================================================================
  2.  
  3.  
  4.  
  5. % dydt = ...;  % define your continuation equation (vectorized, so don’t need to tell COCO otherwise)
  6.  
  7. x0 = zeros(22,1);
  8. p0 = [0.0001];
  9.  
  10. p_range = [p0 10];   % parameter range for continuation
  11.  
  12. prob = coco_prob();        % define a new problem structure
  13.  
  14. ode_fcns = {@Coupled_Model, @Coupled_Modeldx,@Coupled_Modeldp};   % can append jacobian to this cell if you have it explicitly (ie. {dydt, dfdt, dfdp})
  15.  
  16. eq_path = {'path', 'to', 'isol2ep'};  % savdir/’run name’ (eg. /wd/data/path/to/isol2ep) by default sav dir is /wd/data/’run name’. input your path,
  17.  
  18. % helpful for saving different runs under different folder structures.
  19.  
  20.  
  21. prob = ode_isol2ep(prob, '', ode_fcns{:}, x0, 'N(beta)', p0);  % initialize ‘initial sol to equilibrium point’ toolbox. x0, p0 from ode45/ode15s/etc…
  22.  
  23. % prob = coco_set(prob, 'cont', 'h_min', 0.1,'h0', 1,'h_max',10);    % stepsize preferences, can play around with these
  24. %
  25. % prob = coco_set(prob, 'cont', 'ItMX', [0 1e3], 'NPR', 1);      % max steps in run. print info every step.
  26. %
  27. % prob = coco_set(prob, 'corr', 'TOL', 1e-3,'ResTOL', 1e-3);        % correction tolerance, can play around with these
  28.  
  29.  
  30.  
  31. disp('  ')
  32.  
  33. disp('    initialising eq continuation.')
  34.  
  35. disp('-------------------------------------')
  36.  
  37. bd_eq = coco(prob, eq_path, [], 1, 'N(beta)', p_range);  % 1 is the solution dimension
  38.  
  39.  
  40.  
  41. %% ========================================================================
  42.  
  43. %///setup po continuation
  44.  
  45.  
  46.  
  47. labs = coco_bd_labs(bd_eq, 'HB');  % get the labels of the hopf bifurcations
  48.  
  49. bd_po = cell(1,length(labs));
  50.  
  51.  
  52.  
  53. if ~isempty(labs)
  54.  
  55.     disp('  ')
  56.  
  57.     disp('    initialising po continuation.')
  58.  
  59.     disp('-------------------------------------')
  60.  
  61.     disp('  ')
  62.  
  63.     for i = 1:length(labs) % you can parallelise continuation of multiple bifurcations to speed up the process if needed
  64.  
  65.         prob = coco_prob(); % new continuation problem structure
  66.  
  67.         prob = ode_HB2po(prob, '', eq_path, labs(i)); % HB2po toolbox, follows PO from HB
  68.  
  69. %        prob = coco_add_slot(prob, 'get_PO', @coco_savpo, [], 'bddat');  % needed to save complete PO data (but not min/max), can help you with @coco_savpo if needed
  70.  
  71.         prob = coco_add_event(prob, 'HB', 'BP', 'atlas.test.BP', 0); % stops continuation repeating itself if it rejoins the eq branch
  72.  
  73.         prob = coco_set(prob, 'corr', 'TOL', 1e-3,'ResTOL', 1e-3, 'ItMX', 15);        
  74.  
  75.         prob = coco_set(prob, 'coll', 'NTST', 80);   % number of mesh points on which the collocation is performed                                  
  76.  
  77.         prob = coco_set(prob, 'cont', 'NAdapt', 5, 'NPR', 1, 'PtMX', 1000);    % mesh adaption every 5 steps
  78.  
  79.         prob = coco_set(prob,...
  80.             'cont', 'h_min', 0.1,'h0', 1,'h_max', 5,'ItMX', 1e3, 'al_max', 45);  
  81.  
  82.         disp('done.')
  83.  
  84.        
  85.  
  86.         disp('  ')
  87.  
  88.         disp(['    starting po continuation at ', datestr(clock)])
  89.  
  90.         disp('--------------------------------------------------------')
  91.  
  92.        
  93.  
  94.         bd_po{i} = coco(prob,...
  95.             {'path', 'to', strcat(sprintf('hb2po_%d', i))}, [], 1, {'N(beta)' 'po.period'}, p_range);  % output N(beta) and PO period during continuation
  96.  
  97.     end
  98.  
  99. else
  100.  
  101.     disp('no hopf points found for po continuation')
  102.  
  103. end
  104.  
  105.  
  106.  
  107. %% ========================================================================
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top