<s> """<STR_LIT>""" <EOL> from __future__ import division <EOL> from PyDSTool import * <EOL> from PyDSTool . Toolbox . phaseplane import * <EOL> icdict = { '<STR_LIT:x>' : <NUM_LIT> , '<STR_LIT:y>' : <NUM_LIT> } <EOL> pardict = { '<STR_LIT>' : - <NUM_LIT:9> , '<STR_LIT>' : - <NUM_LIT:5> , <EOL> '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : - <NUM_LIT:3> , <EOL> '<STR_LIT>' : <NUM_LIT:7> , '<STR_LIT>' : <NUM_LIT:1> } <EOL> DSargs = args ( ) <EOL> DSargs . name = '<STR_LIT>' <EOL> DSargs . ics = icdict <EOL> DSargs . pars = pardict <EOL> DSargs . tdata = [ <NUM_LIT:0> , <NUM_LIT:10> ] <EOL> DSargs . varspecs = { '<STR_LIT:x>' : '<STR_LIT>' , <EOL> '<STR_LIT:y>' : '<STR_LIT>' } <EOL> DSargs . fnspecs = { '<STR_LIT>' : ( [ '<STR_LIT:t>' , '<STR_LIT:x>' , '<STR_LIT:y>' ] , <EOL> """<STR_LIT>""" ) } <EOL> DS = Generator . Vode_ODEsystem ( DSargs ) <EOL> def test_ic ( icdict = None , pardict = None ) : <EOL> if icdict is not None : <EOL> DS . set ( ics = icdict ) <EOL> if pardict is not None : <EOL> DS . set ( pars = pardict ) <EOL> traj = DS . compute ( '<STR_LIT:test>' ) <EOL> pts = traj . sample ( ) <EOL> return pts <EOL> def do_plots ( pts , fig_offset = <NUM_LIT:0> ) : <EOL> plt . figure ( <NUM_LIT:1> + fig_offset ) <EOL> plt . plot ( pts [ '<STR_LIT:t>' ] , pts [ '<STR_LIT:x>' ] , '<STR_LIT:g>' ) <EOL> plt . plot ( pts [ '<STR_LIT:t>' ] , pts [ '<STR_LIT:y>' ] , '<STR_LIT:r>' ) <EOL> plt . figure ( <NUM_LIT:2> + fig_offset ) <EOL> plt . plot ( pts [ '<STR_LIT:x>' ] , pts [ '<STR_LIT:y>' ] , '<STR_LIT:k>' ) <EOL> pts1 = test_ic ( ) <EOL> do_plots ( pts1 ) <EOL> fp_coords = find_fixedpoints ( DS , n = <NUM_LIT:4> , eps = <NUM_LIT> , <EOL> subdomain = { '<STR_LIT:x>' : [ - <NUM_LIT:2> , <NUM_LIT:2> ] , <EOL> '<STR_LIT:y>' : [ - <NUM_LIT:2> , <NUM_LIT:2> ] } ) <EOL> print "<STR_LIT>" % len ( fp_coords ) <EOL> fp = fixedpoint_2D ( DS , Point ( fp_coords [ <NUM_LIT:0> ] ) , coords = [ '<STR_LIT:x>' , '<STR_LIT:y>' ] , <EOL> eps = <NUM_LIT> ) <EOL> print fp . point , '<STR_LIT:\n>' , fp . stability , fp . classification <EOL> plt . figure ( <NUM_LIT:3> ) <EOL> for x0 in linspace ( - <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:10> ) : <EOL> pts = test_ic ( { '<STR_LIT:x>' : x0 } ) <EOL> plt . plot ( pts [ '<STR_LIT:x>' ] , pts [ '<STR_LIT:y>' ] , '<STR_LIT:b>' ) <EOL> for y0 in linspace ( <NUM_LIT:1> , - <NUM_LIT:1> , <NUM_LIT:10> ) : <EOL> pts = test_ic ( { '<STR_LIT:y>' : y0 } ) <EOL> plt . plot ( pts [ '<STR_LIT:x>' ] , pts [ '<STR_LIT:y>' ] , '<STR_LIT:y>' ) <EOL> for x0 in linspace ( <NUM_LIT:1> , - <NUM_LIT:1> , <NUM_LIT:10> ) : <EOL> pts = test_ic ( { '<STR_LIT:x>' : x0 , '<STR_LIT:y>' : - <NUM_LIT:1> } ) <EOL> plt . plot ( pts [ '<STR_LIT:x>' ] , pts [ '<STR_LIT:y>' ] , '<STR_LIT:b>' ) <EOL> for y0 in linspace ( - <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:10> ) : <EOL> pts = test_ic ( { '<STR_LIT:y>' : y0 } ) <EOL> plt . plot ( pts [ '<STR_LIT:x>' ] , pts [ '<STR_LIT:y>' ] , '<STR_LIT:y>' ) <EOL> plt . plot ( fp . point [ '<STR_LIT:x>' ] , fp . point [ '<STR_LIT:y>' ] , '<STR_LIT>' , markersize = <NUM_LIT:8> ) <EOL> e1 = fp . evals [ <NUM_LIT:0> ] <EOL> e2 = fp . evals [ <NUM_LIT:1> ] <EOL> ev1 = fp . evecs [ <NUM_LIT:0> ] <EOL> ev2 = fp . evecs [ <NUM_LIT:1> ] <EOL> plt . plot ( [ fp . point [ '<STR_LIT:x>' ] , fp . point [ '<STR_LIT:x>' ] + ev1 [ '<STR_LIT:x>' ] ] , [ fp . point [ '<STR_LIT:y>' ] , fp . point [ '<STR_LIT:y>' ] + ev1 [ '<STR_LIT:y>' ] ] , '<STR_LIT:k>' , linewidth = <NUM_LIT:3> ) <EOL> plt . plot ( [ fp . point [ '<STR_LIT:x>' ] , fp . point [ '<STR_LIT:x>' ] + ev2 [ '<STR_LIT:x>' ] ] , [ fp . point [ '<STR_LIT:y>' ] , fp . point [ '<STR_LIT:y>' ] + ev2 [ '<STR_LIT:y>' ] ] , '<STR_LIT:k>' , linewidth = <NUM_LIT:3> ) <EOL> def get_real_sol ( IC ) : <EOL> """<STR_LIT>""" <EOL> c1 , c2 = np . dot ( np . linalg . inv ( array ( [ ev1 , ev2 ] ) . T ) , IC - fp . point ) <EOL> def real_sol ( t ) : <EOL> """<STR_LIT>""" <EOL> assert isreal ( e1 ) <EOL> assert isreal ( e2 ) <EOL> return c1 * ev1 * np . exp ( e1 * t ) + c2 * ev2 * np . exp ( e2 * t ) + fp . point <EOL> ts = linspace ( <NUM_LIT:0> , <NUM_LIT:7> , <NUM_LIT> ) <EOL> vs = [ ] <EOL> for t in ts : <EOL> vs . append ( real_sol ( t ) ) <EOL> vs = array ( vs ) . T <EOL> return Pointset ( coorddict = { '<STR_LIT:x>' : vs [ <NUM_LIT:0> ] , '<STR_LIT:y>' : vs [ <NUM_LIT:1> ] } , <EOL> indepvararray = ts ) <EOL> plt . figure ( <NUM_LIT:3> ) <EOL> sol = get_real_sol ( Point ( { '<STR_LIT:x>' : <NUM_LIT:1> , '<STR_LIT:y>' : <NUM_LIT> } ) ) <EOL> plt . plot ( sol [ '<STR_LIT:x>' ] , sol [ '<STR_LIT:y>' ] , '<STR_LIT:m>' , linewidth = <NUM_LIT:3> ) <EOL> print "<STR_LIT>" <EOL> from time import sleep <EOL> plt . figure ( <NUM_LIT:4> ) <EOL> plt . xlabel ( '<STR_LIT:x>' ) <EOL> plt . ylabel ( '<STR_LIT:y>' ) <EOL> for a1 in linspace ( - <NUM_LIT:10> , <NUM_LIT:8> , <NUM_LIT:8> ) : <EOL> print "<STR_LIT>" , a1 <EOL> pts2 = test_ic ( pardict = { '<STR_LIT>' : - <NUM_LIT:8> , '<STR_LIT>' : a1 } ) <EOL> fp_coords2 = find_fixedpoints ( DS , n = <NUM_LIT:4> , eps = <NUM_LIT> , <EOL> subdomain = { '<STR_LIT:x>' : [ - <NUM_LIT:10> , <NUM_LIT:5> ] , <EOL> '<STR_LIT:y>' : [ - <NUM_LIT:5> , <NUM_LIT:5> ] } ) <EOL> if len ( fp_coords2 ) > <NUM_LIT:0> : <EOL> fp2 = fixedpoint_2D ( DS , Point ( fp_coords2 [ <NUM_LIT:0> ] ) , coords = [ '<STR_LIT:x>' , '<STR_LIT:y>' ] , <EOL> eps = <NUM_LIT> ) <EOL> if fp2 . stability == '<STR_LIT:s>' : <EOL> line = '<STR_LIT:->' <EOL> fpcol = '<STR_LIT:r>' <EOL> s = '<STR_LIT>' <EOL> else : <EOL> line = '<STR_LIT>' <EOL> fpcol = '<STR_LIT:g>' <EOL> s = '<STR_LIT>' <EOL> print "<STR_LIT>" % ( a1 , fp2 . point [ '<STR_LIT:x>' ] , <EOL> fp2 . point [ '<STR_LIT:y>' ] , s , fp2 . classification ) <EOL> print "<STR_LIT>" , fp2 . evals <EOL> plt . plot ( pts2 [ '<STR_LIT:x>' ] , pts2 [ '<STR_LIT:y>' ] , line , label = '<STR_LIT>' % a1 ) <EOL> plt . plot ( fp2 . point [ '<STR_LIT:x>' ] , fp2 . point [ '<STR_LIT:y>' ] , fpcol + '<STR_LIT:o>' , markersize = <NUM_LIT:8> ) <EOL> else : <EOL> print "<STR_LIT>" % a1 <EOL> plt . plot ( pts2 [ '<STR_LIT:x>' ] , pts2 [ '<STR_LIT:y>' ] , label = '<STR_LIT>' % a1 ) <EOL> plt . xlim ( [ - <NUM_LIT:15> , <NUM_LIT:5> ] ) <EOL> plt . ylim ( [ - <NUM_LIT:2> , <NUM_LIT:2> ] ) <EOL> print "<STR_LIT>" <EOL> plt . xlim ( [ - <NUM_LIT:15> , <NUM_LIT:5> ] ) <EOL> plt . ylim ( [ - <NUM_LIT:2> , <NUM_LIT:2> ] ) <EOL> plt . show ( ) </s>
