psection.py

psection.py generates a python script that computes the Poincare section of an orbit with a specified plane. This script uses the experimental (undocumented) Poincare section code in taylor.

Usage:

    usage: psection.py [-h] [-f PNAME] [-m MODEL_NAME] [-f128] [-mpfr MPFR] [-t0 START_T] [-t1 STOP_T] [-nsteps NUM_STEPS]
                       [-nintersections NUM_INTERSECTIONS] [-xing CROSSING] [-method METHOD] [-iv INIT_V] [-sc {0,1,2}] [-h0 STEP_SIZE]
                       [-abs_err ABS_ERR] [-rel_err REL_ERR]  [-lib SHARED_LIB_NAME] [-o OUTPUT_FILE] [-jlib {1_1,1_n,n_1,2_n,n_2,m_n,tree}]
                       [-i INPUT_FILE]

    optional arguments:
    -h, --help            show this help message and exit
    -f PNAME, --function_name PNAME
                set poincare section function name
    -m MODEL_NAME, --model_name MODEL_NAME
    -f128, --float128
    -mpfr MPFR, --mpfr_precision MPFR
    -t0 START_T, --start_time START_T
    -t1 STOP_T, --stop_time STOP_T
    -nsteps NUM_STEPS, --num_steps NUM_STEPS
    -nintersections NUM_INTERSECTIONS, --num_intersections NUM_INTERSECTIONS
    -xing CROSSING, --crossing CROSSING
    -method METHOD, --method METHOD
    -iv INIT_V, --initial_values INIT_V
    -sc {0,1,2}, --stepsize_control {0,1,2}
                   Only 1 is availale when jet var is present
    -h0 STEP_SIZE, --step_size STEP_SIZE
    -abs_err ABS_ERR, --absolute_error_tolerance ABS_ERR
    -rel_err REL_ERR, --relative_error_tolerance REL_ERR
    -lib SHARED_LIB_NAME, --lib_name SHARED_LIB_NAME
    -o OUTPUT_FILE, --output OUTPUT_FILE
    -jlib {1_1,1_n,n_1,2_n,n_2,m_n,tree}, --jet_library {1_1,1_n,n_1,2_n,n_2,m_n,tree}
    -i INPUT_FILE, --input INPUT_FILE
                  Taylor input file
    

The Input File

To use this script, we need to modify again our input file. We need to add a few control statements for the script, and specify the equation of the section plane. Save the following in henon-psection.eq

  x'= xp;
  y'= yp;
  xp'= -x -2*x*y;
  yp'= -y -x^2 + y^2;

  initialValues=0.0,0.1,0.39,0.2 ;
  startTime = 0.0;
  stopTime = 1.0e10;
  absoluteErrorTolerance = 1.0E-16;
  relativeErrorTolerance = 1.0E-16;

  number_of_intersections=2000;
  crossing=1;  
  expr Poincare_section = x ;

The last 3 lines are the new additions. number_of_intersections is a new stop condition. Taylor stops when any of the stop conditions are met. In this example, the program halts when either the end time has reached (1.0E10) or it has found 2000 intersection points with the section plane. The crossing parameter defines what crossing will be recorded. Valid values are -1, 1 and 0, picking crossing from negative to positive, positive to negative or both.

Let's generate a runnable script.

  ./psection.py -i henon-psection.eq -o pex1.py

and run it python3 pex1.pyp, you'll see an output like the following

  -1.790527059952751e-08 -0.02597027521218065 0.4210469290805701 0.1531883836077578 6.901160763268752 -1.790527059952751e-08
  -6.240749013397551e-08 -0.1062623174903457 0.4133159588092244 0.1360573915229782 13.76622375833024 -6.240749013397551e-08
  -2.762796892652464e-08 -0.1158775890342549 0.3856651530524202 0.1955269498182204 20.77717986765874 -2.762796892652464e-08
  ... ...
  -1.603628781848832e-09 -0.1038493545035465 0.4141183412439867 0.1356760445200414 13949.1895420812 -1.603628781848832e-09
  -2.032462670387147e-10 -0.1173893785807662 0.3872783920360887 0.1912853268477991 13956.1914122019 -2.032462670387147e-10
  -7.818488419464309e-07 -0.01070525182330684 0.3519466350395191 0.2782999602667449 13963.38629341177 -7.818488419464309e-07 

The rows of the output are values of x,y,xp,yp,t and Poincare_section. Please note that the value of the Poincare_section is not exactly 0, in fact they're not even close to the machine ε. This is because at the crossing, the programs by default uses an RK4 stepper to integrate the ODE backwards to compute the intersection points. The RK4 stepper is an 4th order method hence it has a limited accuracy. The program can also use a 6th order Taylor method to seek the intection points. It is controled by the -method option. If we invoke the script as python3 pex1.pyp -method 1, we'll get a slight more accurate output.

  2.230761983555013e-10 -0.02597026828573162 0.4210469324063733 0.1531883873759892 6.901160807074051 2.230761983555013e-10
  0 -0.1062622881958648 0.4133159988328393 0.1360574332542955 13.76622392948367 0
  6.57173828918535e-10 -0.1158775712501675 0.3856651681396834 0.1955269646069958 20.77717994876553 6.57173828918535e-10
  ... ...
  -9.926167350636332e-24 -0.122033006688454 0.4021911404196979 0.1535318111455203 13998.2552405397 -9.926167350636332e-24
  0 -0.07816823397923488 0.367321066121012 0.2451119650740864 14005.37439462151 0
  1.410733373652037e-18 0.06666975260526786 0.3383091165540085 0.287633407957706 14012.54920890055 1.410733373652037e-18

We can also plot the poincare section via the -p option. For example, if we run the script as ./pex1.pyp -p 2,3, we'll see an output similar to the following image.

poincare section

 

Command line options of pex1.py
  usage: ./pex1.py [-h] [-f PNAME] [-o OUTPUT_FILE] [-p COLUMNS] [-t0 START_T] [-t1 STOP_T] [-h0 STEP_SIZE] [-nsteps NUM_STEPS] [-nintersections NUM_INTERSECTIONS]
          [-xing CROSSING] [-method METHOD] [-epsilon EPSILON] [-iv INIT_V]  [-sc {0,1,2}] [-abs_err ABS_ERR] [-rel_err REL_ERR]

  optional arguments:
  -h, --help            show this help message and exit
  -f PNAME, --function_name PNAME
                set poincare section function name
  -o OUTPUT_FILE, --output_file OUTPUT_FILE
                file to output data
  -p COLUMNS, --plot COLUMNS
                select two columns to plot
  -t0 START_T, --start_time START_T
  -t1 STOP_T, --stop_time STOP_T
  -h0 STEP_SIZE, --step_size STEP_SIZE
               initial step size, only used when step size control is 0
  -nsteps NUM_STEPS, --num_steps NUM_STEPS
  -nintersections NUM_INTERSECTIONS, --num_intersections NUM_INTERSECTIONS
                      stop_time, nsteps and nintersections are stop conditions, program stops when one of the limit is reached
  -xing CROSSING, --crossing CROSSING
                 crossing, -1,1 or 0; cross the plane from left, right or both
  -method METHOD, --method METHOD
                 bit 0 select method to compute intersection: 0 RK4 integration backwards, 1 for using 6th degree fixed step taylor.
                 bit 1 select fixed step RK4 as the main integrator. bit 2 select adaptive RK4 as the main integrator.
  -epsilon EPSILON, --epsilon EPSILON
                  Error tolerance when compute the intersection. If abs(value) is smaller than epsilon, it is considered on the plane,
  -iv INIT_V, --initial_values INIT_V
                comma separated set if values
  -sc {0,1,2}, --stepsize_control {0,1,2}
               Only 1 is availale when jet var is present
  -abs_err ABS_ERR, --absolute_error_tolerance ABS_ERR
  -rel_err REL_ERR, --relative_error_tolerance REL_ERR