Beispiel #1
0
    def compute_limit_cycle(self):
        PCargs = args()
        PCargs.name = 'LC1'
        PCargs.type = 'LC-C'
        PCargs.MaxNumPoints = 2500  # // 10
        PCargs.NumIntervals = 30
        PCargs.NumCollocation = 6
        PCargs.initpoint = 'EQ1:H1'
        PCargs.SolutionMeasures = 'all'
        PCargs.NumSPOut = 200
        PCargs.FuncTol = 1e-4
        PCargs.VarTol = 1e-4
        PCargs.TestTol = 1e-3
        PCargs.SaveEigen = True
        self.pc.newCurve(PCargs)

        print('Computing limit-cycle curve...')
        start = perf_counter()
        self.pc['LC1'].forward()
        # PyCont['LC1'].backward()
        print('done in %.3f seconds!' % (perf_counter() - start))

        # Get the lower branch of the cycle.
        self.pc['LC1'].display(('mu', 'R_min'), stability=True, figure=1)
        self.pc['LC1'].display(('mu', 'R'), stability=True, figure=1)

        self.pc['LC1'].display(stability=True, figure='new', axes=(1, 2, 1))
        self.pc['LC1'].plot_cycles(coords=('R', 'r'),
                                   linewidth=1,
                                   axes=(1, 2, 2),
                                   figure='fig2')
Beispiel #2
0
    def _limit_cycle_curve(self, pars, index=-1):
        (name, PyCont) = self.cont_classes[index]

        # Limit cycle curve
        PCargs = args(freepars=PyCont[name].freepars)
        PCargs.name = 'LC1'
        PCargs.type = 'LC-C'
        PCargs.MaxNumPoints = 2500  # // 10
        PCargs.NumIntervals = 20
        PCargs.NumCollocation = 6
        PCargs.initpoint = name + ':H1'
        PCargs.SolutionMeasures = 'all'
        PCargs.NumSPOut = 50
        PCargs.FuncTol = 1e-10
        PCargs.VarTol = 1e-10
        PCargs.TestTol = 1e-8
        PyCont.newCurve(PCargs)

        print('Computing limit-cycle curve...')
        start = perf_counter()
        PyCont['LC1'].backward()
        PyCont['LC1'].forward()
        print('done in %.3f seconds!' % (perf_counter() - start))

        PyCont['LC1'].display(pars, stability=True)
        PyCont['LC1'].display((pars[0], pars[1] + '_min'), stability=True)

        # TODO(matthew-c21): Keep track of associated figures.
        PyCont['LC1'].display(stability=True, figure='new', axes=(1, 2, 1))
        PyCont['LC1'].plot_cycles(coords=('R', 'r'),
                                  linewidth=1,
                                  axes=(1, 2, 2),
                                  figure='fig2')
        pass
Beispiel #3
0
    def compute_HO(self, initpoint='', name='HO1', ax=None, p1='a1', p2='a2'):
        PCargs = args()
        PCargs.name = name
        PCargs.type = 'H-C2'
        PCargs.initpoint = initpoint
        PCargs.freepars = [p1, p2]
        PCargs.MaxNumPoints = 800
        PCargs.MinStepSize = 1e-5
        PCargs.MaxStepSize = 1e-2
        PCargs.StepSize = 1e-3
        PCargs.LocBifPoints = 'all'
        PCargs.SaveEigen = True
        self.pc.newCurve(PCargs)

        print('Computing Hopf curve...')
        start = perf_counter()
        # PyCont[name].forward()
        self.pc[name].backward()
        print('done in %.3f seconds!' % (perf_counter() - start))

        #PCargs.MaxNumPoints = 2000
        # PyCont[name].forward()
        self.pc[name].display([p1, p2], figure=3)

        sol = self.pc[name].sol
        a1 = sol.coordarray[sol.coordnames.index(p1)]
        b1 = sol.coordarray[sol.coordnames.index(p2)]
        if not ax:
            fig, ax = plt.subplots(figsize=(4, 4))
            fig.subplots_adjust(left=.2, bottom=0.17, right=0.98)
        ax.plot(a1, b1, label=name)
        return ax
Beispiel #4
0
    def compute(self, pcargs, msg=None):
        self.pc.newCurve(pcargs)

        if msg is not None:
            print(msg)
            start = perf_counter()
            self.pc[pcargs.name].forward()
            print('Time elapsed: %.3f' % (perf_counter() - start))
        else:
            self.pc[pcargs.name].forward()
Beispiel #5
0
    def display_cont_class(self, pars, index=-1):
        (name, PyCont) = self.cont_classes[index]

        # Go ahead and compute it upon registration
        print('Computing curve...')
        start = perf_counter()
        PyCont[name].backward()
        PyCont[name].forward()
        print('done in %.3f seconds!' % (perf_counter() - start))

        PyCont[name].display(pars, figure='new')
        PyCont.plot.toggleAll('off', bytype='P')

        if PyCont[name].getSpecialPoint('H1'):
            self._limit_cycle_curve(pars, index)
Beispiel #6
0
#PCargs.StepSize = 3e-6
#PCargs.MaxStepSize = 3e-5
#PCargs.MinStepSize = 3e-7
PCargs.StepSize = 3e-4
PCargs.MaxStepSize = 3e-3
PCargs.MinStepSize = 3e-5
#PCargs.MaxNumPoints = 8000
PCargs.MaxNumPoints = 500
PCargs.LocBifPoints = 'all'
PCargs.verbosity = 2
#PCargs.StopAtPoints = ['H2']
#PCargs.StopAtPoints = ['H1']
PyCont.newCurve(PCargs)

print('Computing curve...')
start = perf_counter()
PyCont['EQ1'].forward()
# PyCont['EQ1'].backward()
print('done in %.3f seconds!' % (perf_counter()-start))

PyCont['EQ1'].display(('mu', 'R'), figure='new')
PyCont.plot.toggleAll('off', bytype='P')

if PyCont['EQ1'].getSpecialPoint('H1'):
    if 0:  # Limit cycle curve
        PCargs.name = 'LC1'
        PCargs.type = 'LC-C'
        PCargs.MaxNumPoints = 2500  # // 10
        PCargs.NumIntervals = 30
        PCargs.NumCollocation = 6
        PCargs.initpoint = 'EQ1:H1'