home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / fractal / kaos.lha / userlib / userds2_def.c < prev   
Encoding:
C/C++ Source or Header  |  1990-02-06  |  2.7 KB  |  107 lines

  1. /*
  2. Initialize all parameters for a given dynamical system to be installed
  3. Parameters are assigned to the default values before this program is called.
  4. -----------------------------------------------------------------------
  5. This is a GENERIC subroutine. If you want, you can change
  6. the name string "userds2" to a proper one globally in this program
  7. but then you need to change the same strings in the header file defining
  8. the current class of dynamical systems.
  9. */
  10.  
  11. /*
  12. Example 1: vector field with no periodic variable
  13. */
  14. #include "model.h"
  15.  
  16. int userds2_init()
  17. {
  18.     /* title label */
  19.     title_label = "Meanders of the Ardenne";
  20.  
  21.     /* mapping toggle: 1: map, 0: vector field */
  22.     mapping_on = 1;
  23.     /* inverse toggle: vector field: always 1,
  24.        maps: 1=explicit inverse is defined, 0=otherwise  */    /*  mrm (2/6/90)   */
  25.     inverse_on = 1;
  26.     /* jacobian toggle: 1=Jacobian is explicitly given, 0=otherwise */
  27.     fderiv_on = 0;
  28.     /* polar toggle: 1=enable polar coordinate feature, 0=otherwise */
  29.     enable_polar = 0;
  30.     /* period toggle: 1=enable periodicity of phase space, 0=otherwise */
  31.     enable_period = 1;
  32.  
  33.     /* phase space dimension */
  34.     var_dim = 2;
  35.     /* parameter space dimension */
  36.     param_dim = 3;
  37.     /* function space dimension */
  38.     func_dim = 2;
  39.  
  40.     (void) malloc_init();
  41.  
  42.     /*periodicity of phase space variables (DIM=var_dim)*/
  43.     /* do not have to be defined if enable_period = 0 */
  44.     period_len[0] =1;
  45.     period_len[1] =1;
  46.  
  47.     /* primary phase space variable label (DIM=var_dim)*/
  48.     var_label[0] = "x";
  49.     var_label[1] = "y";
  50.     /* parameter variable label (DIM=param_dim)*/
  51.     param_label[0] = "alpha";
  52.     param_label[1] = "beta";
  53.     param_label[2] = "k";
  54.     /* function variable label (DIM=func_dim)*/
  55.     func_label[0] = "Undefined";
  56.     func_label[1] = "Undefined";
  57.  
  58.     /* starting parameter values (DIM=param_dim)*/
  59.     param[0] = 1.5;
  60.     param[1] = -.85;
  61.     param[2] = 1.0;
  62.  
  63.     /* starting primary phase space variable values (DIM=param_dim)*/
  64.     var_i[0] = 0;
  65.     var_i[1] = 0;
  66.  
  67.     /* starting bounds of parameter window box */
  68.     param_min[0]= -5; param_max[0]= 5;
  69.     param_min[1]= -5; param_max[1]= 5;
  70.  
  71.     /* starting bounds of primary phase space window box */
  72.     var_min[0]= 0; var_max[0]= 1;
  73.     var_min[1]= 0; var_max[1]= 1;
  74.  
  75.     /* dynamical system and function pointer assignments */
  76.     f_p = userds2_f;
  77.     func_p = userds2_func;
  78. }
  79. /*
  80. third user dynamical system 
  81. */
  82.     
  83. int userds2_f(f,index,x,p,t,dim)
  84. int index,dim;
  85. double f[],x[],p[],t;
  86. {
  87.     double sin(),cos();
  88.     extern double pi;
  89.  
  90.     if(index ==1) {
  91.         f[1] = x[1] - p[2] / (2 * pi) * sin(2 * pi * x[0]);
  92.         f[0] = x[0] + p[1] + p[0] / (2 * pi) * cos(2 * pi * f[1]);
  93.     }
  94.     /* define an inverse if you have time */
  95. }
  96. /*
  97. third user function subroutine
  98. */
  99.  
  100. int userds2_func(f,x,p,t,dim)
  101. double f[],x[],p[],t;
  102. int dim;
  103. {
  104.     f[0] = 0;
  105.     f[1] = 0;
  106. }
  107.