poincare.py

poincare.py is program that compute Poincare sections interactively. It works only for systems where one can solve the initial conditions algebrically for any user picked points on the section plane. Henon-Heiles is such a system when the section plane is X=0. The Hamiltonian is

  H = 1/2 * (xp^2 + yp^2) + 1/2 * (x^2 + y^2 + 2*x^2*y - 2./3. * y^3);
Given x=0, and user picks a point (y,yp), we can solve xp as
  xp= 1./3.* sqrt(6.*y**3 - 9.*y**2 -9*yp **2 + 18. * H)
This script uses the experimental (undocumented) Poincare section code in taylor.

Usage:
    usage: poincare.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] [-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
    -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

poincare.py uses shell comments begins with # poincare_section_ to setup its UI elements. Available commands are:

Let's save the following in henon-poincare.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 ;

# poincare_section_initials = 0, y,  1./3.*sqrt(6.*y*y*y-9.*y*y-9*yp*yp+18.*HH), yp;
# poincare_section_xlimit = -0.6,0.6;
# Poincare_section_ylimit = -0.7,0.7;
# Poincare_section_slider1 = "Hamiltonian", 0.0, 0.16, 0.01, 0.04166666667, HH;
# poincare_section_mouse = y, yp;

Let's now generate a runnable script.

  ./poincare.py -i henon-poincare.eq -o pheono.py

When run, ./phenon.py should start an UI like shown in the following image. Clicking on the plot window should generate a new poincare section for the correspoinding orbit.

poincare section

 

Command line options of phenon.py
  usage: ./phenon.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
  -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,
  -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