1 //=============================================================================
4 // contains all the magic math
6 //=============================================================================
9 //== INCLUDES =================================================================
11 #include "calculator.h"
14 //== IMPLEMENTATION ===========================================================
17 Calculator::Calculator(QuPlot
*parent
) :
25 Calculator::~Calculator()
30 //-----------------------------------------------------------------------------
31 void Calculator::derive_init()
33 file_rk_bif
= "../rk_bifurcate.dat";
34 file_rk_avg
= "../rk_bif_avg_velo.dat";
35 file_rk_out
= "../rk_out.dat";
36 file_rk_pt1
= "../rk_point1.dat";
37 file_rk_pt2
= "../rk_point2.dat";
38 file_rk_biv
= "../rk_bif_velo.dat";
39 file_rk_vel
= "../rk_velo.dat";
41 file_eu_bif
= "../eu_bifurcate.dat";
42 file_eu_avg
= "../eu_bif_avg_velo.dat";
43 file_eu_out
= "../eu_out.dat";
44 file_eu_pt1
= "../eu_point1.dat";
45 file_eu_pt2
= "../eu_point2.dat";
46 file_eu_biv
= "../eu_bif_velo.dat";
47 file_eu_vel
= "../eu_velo.dat";
49 file_rk_conv
= "../rk_conv.dat";
50 file_eu_conv
= "../eu_conv.dat";
52 file_rk_variance
= "../rk_variance.dat";
53 file_rk_distance
= "../rk_msd.dat";
54 file_rk_defangle
= "../rk_defangle.dat";
55 file_eu_variance
= "../eu_variance.dat";
56 file_eu_distance
= "../eu_msd.dat";
57 file_eu_defangle
= "../eu_defangle.dat";
59 file_rk_dualbif
= "../rk_dualbif.dat";
60 file_eu_dualbif
= "../eu_dualbif.dat";
62 v
= c
->valuesMap
.value(1);
66 void Calculator::derivs(const Doub x
, VecDoub_I
&y
, VecDoub_O
&dydx
,
88 //static Doub G, xi, xi1, xi2, c, s, st, ax, ay, e0, e1, e2, e3, eta, l1, l2;
89 static Doub xi
, G
, s
, c
, st
, ax
, ay
, cp
, sp
, m1
, m2
, p1
, p2
;
90 static Doub x1
, y1
, x2
, y2
, F1x
, F1y
, F2x
, F2y
, stx
, sty
;
91 //for (Int i = 0;i<10;i++)
92 // qDebug() << "params["<<i<<"] :" << params[i];
96 G
= sqrt(2.0*params
[5]*params
[9])*xi
;
98 dydx
[1] = -params
[5]*y
[1]-sin(y
[0])+params
[1]*sin(params
[4]*x
)+params
[2]+G
;
102 dydx
[1] = -params
[5]*y
[1]-y
[0];
117 eta = params[5]+params[6];
119 e1 = 1.0/(params[5]*params[3]);
120 e2 = 1.0/(params[6]*params[3]);
121 e3 = 1.0/params[3]*((1.0/params[5])-(1.0/params[6]));
123 l1 = params[3]*e0*params[5];
124 l2 = params[3]*e0*params[6];
128 //qDebug() << eta << "=" << params[5] << "+" << params[6];
129 //qDebug() << e0 << "=" << "1.0/"<< eta;
130 //qDebug() << e1 << "=" << "1.0/"<<params[5]<<"*"<<params[3];
131 //qDebug() << e2 << "=" << "1.0/"<<params[6]<<"*"<<params[3];
132 //qDebug() << e3 << "=" << "1.0/"<<params[5]<<"-"<<"1.0/"<<params[6];
134 //G = sqrt(2.0*eta*params[9]);
140 x1
= y
[0] + params
[7]*c
;
141 y1
= y
[1] + params
[7]*s
;
142 x2
= y
[0] - params
[8]*c
;
143 y2
= y
[1] - params
[8]*s
;
145 st
= sin(params
[4]*x
);
147 //qDebug() << st << "=" << "sin("<<params[4]<<"*"<<x<<")";
149 ax
= cos(params
[1])*params
[0]*st
;
150 ay
= sin(params
[1])*params
[0]*st
;
152 //fx = cos(params[10])*params[2];
153 //fy = sin(params[10])*params[2];
158 //qDebug() << "ax =" << ax << "=" << params[0] << "*" << "cos("<<params[1]<<")";
159 //qDebug() << "ay =" << ay << "=" << params[0] << "*" << "sin("<<params[1]<<")";
160 //qDebug() << "fx =" << fx << "=" << "cos("<<params[10]<<")*"<<params[2];
161 //qDebug() << "fy =" << fy << "=" << "sin("<<params[10]<<")*"<<params[2];
162 //qDebug() << "stx =" << stx <<"="<< ax << "*" << st << "+"<< fx;
163 //qDebug() << "sty =" << sty <<"="<< ay << "*" << st << "+" << fy;
167 //qDebug() << y[0] + params[7]*c << "=" << y[0] << "+" << params[7] << "*" << c;
168 //qDebug() << y[1] + params[7]*c << "=" << y[1] << "+" << params[7] << "*" << s;
169 //qDebug() << y[0] - params[8]*c << "=" << y[0] << "-" << params[8] << "*" << c;
170 //qDebug() << y[1] - params[8]*c << "=" << y[1] << "-" << params[8] << "*" << s;
172 cp
= cos(params
[17]);
173 sp
= sin(params
[17]);
180 F1x
= params
[18]*(sin(m1
)*cos(p1
)*cp
+cos(m1
)*sin(p1
)*sp
+sin(m1
)*cp
+sin(p1
)*sp
);//+1.6*sin(x1)+1.0*cos(y1);
181 F1y
= params
[18]*(-sin(m1
)*cos(p1
)*sp
+cos(m1
)*sin(p1
)*cp
-sin(m1
)*sp
+sin(p1
)*cp
);//+1.6*cos(x1)+1.0*sin(y1);
182 F2x
= params
[18]*(sin(m2
)*cos(p2
)*cp
+cos(m2
)*sin(p2
)*sp
+sin(m2
)*cp
+sin(p2
)*sp
);//+1.6*sin(x2)+1.0*cos(y2);
183 F2y
= params
[18]*(-sin(m2
)*cos(p2
)*sp
+cos(m2
)*sin(p2
)*cp
-sin(m2
)*sp
+sin(p2
)*cp
);//+1.6*cos(x2)+1.0*sin(y2);
185 dydx
[0] = (F1x
+F2x
+2.0*stx
/*+sqrt(2*params[9])*(xix1+xix2)*/)*params
[11];
186 dydx
[1] = (F1y
+F2y
+2.0*sty
/*+sqrt(2*params[9])*(xiy1+xiy2)*/)*params
[11];
187 dydx
[2] = params
[12]*(c
*F1y
-s
*F1x
)-params
[13]*(c
*F2y
-s
*F2x
)+params
[14]*(c
*sty
-s
*stx
)/*+sqrt(2*params[9])*(params[12]*(-s*xix1+c*xiy1)-params[13]*(-s*xix2+c*xiy2))*/;
193 void Calculator::derivw(const Doub x
, VecDoub_I
&y
, VecDoub_O
&dW
,
194 const Doub params
[], Normaldev
&gauss
)
206 //params[10] = theta;
216 Doub xix1
, xix2
, xiy1
, xiy2
;
217 Doub c
, s
, T
, l
, eta1
, eta2
;
225 l
= params
[7] + params
[8];
234 dW
[0] = sqrt(2*T
)*(sqrt(eta1
)*xix1
+sqrt(eta2
)*xix2
);
235 dW
[1] = sqrt(2*T
)*(sqrt(eta1
)*xiy1
+sqrt(eta2
)*xiy2
);
236 dW
[2] = (sqrt(2*T
)/l
)*((1/sqrt(eta1
))*(-s
*xix1
+c
*xiy1
)-(1/sqrt(eta2
))*(-s
*xix2
+c
*xiy2
));
240 //-----------------------------------------------------------------------------
243 void Calculator::rk4(VecDoub_I
&y
, VecDoub_I
&dydx
, const Doub x
, const Doub h
,
244 VecDoub_O
&yout
, const Doub params
[])
247 VecDoub
dym(n
),dyt(n
),yt(n
);
251 for (Int i
=0;i
<n
;i
++) yt
[i
] = y
[i
]+hh
*dydx
[i
];
252 derivs(xh
,yt
,dyt
,params
);
253 for (Int i
=0;i
<n
;i
++) yt
[i
] = y
[i
]+hh
*dyt
[i
];
254 derivs(xh
,yt
,dym
,params
);
255 for (Int i
=0;i
<n
;i
++) {
256 yt
[i
] = y
[i
]+h
*dym
[i
];
259 derivs(x
+h
,yt
,dyt
,params
);
260 for (Int i
=0;i
<n
;i
++) {
261 yout
[i
] = y
[i
]+h6
*(dydx
[i
]+dyt
[i
]+2.0*dym
[i
]);
266 void Calculator::euler(VecDoub_I
&y
, VecDoub_I
&dydx
, VecDoub_I
&dW
, const Doub x
,
267 const Doub h
, VecDoub_O
&yout
)
270 for (Int i
=0;i
<n
;i
++) {
271 yout
[i
] = y
[i
]+h
*dydx
[i
]+sqrt(h
)*dW
[i
];
274 //-----------------------------------------------------------------------------
278 * returns a random number between 0 and 2*pi
280 double Calculator::randpi(Ran
&r
)
282 Doub s
= 2.0*M_PI
*r
.doub();
286 //-----------------------------------------------------------------------------
289 * Writes the of two maps into a tab-separated file
290 * The second map *must* be specified.
292 void Calculator::write_to_file(const QString
& name
,
293 const QMap
<double, double> & map_x
,
294 const QMap
<double, double> & map_y
,
295 const QMap
<double, double> & map_phi
,
298 qDebug() << "writing to file" << name
;
302 QTextStream
out(&file
);
303 file
.open(QIODevice::WriteOnly
);
305 for (Int i
=0;i
<10;i
++)
306 out
<< "params["<<i
<<"] = " << params
[i
] << " ";
308 out
<< "r\tx\ty\tphi" << endl
;
309 QMapIterator
<double,double> x(map_x
);
310 QMapIterator
<double,double> y(map_y
);
311 QMapIterator
<double,double> phi(map_phi
);
314 while (x
.hasNext()) {
316 out
<< x
.key() << "\t" << x
.value() << endl
;
320 if (map_x
.size() > 0 && map_y
.size() == 0 && map_phi
.size() == 0) {
321 while (x
.hasNext()) {
323 out
<< x
.key() << "\t" << x
.value() << endl
;
326 else if (map_x
.size() > 0 && map_y
.size() > 0 && map_phi
.size() > 0) {
327 while (x
.hasNext() && y
.hasNext() && phi
.hasNext()) {
331 //qDebug() << x.key() << "\t" << x.value() << "\t" << y.value() << "\t" << phi.value();
332 out
<< x
.key() << "\t" << x
.value() << "\t" << y
.value() << "\t" << phi
.value() << endl
;
338 qDebug () << "done.";
342 //-----------------------------------------------------------------------------
345 void Calculator::diffusion(VecDoub_I
&msd
, const Int
& samples
, Doub
& sigma
)
348 VecDoub
var(samples
,0.0);
351 for(Int i
=0;i
<samples
;i
++) {
352 //qDebug() << "msd["<<i<<"]" << msd[i];
356 //qDebug() << "mu:" << mu;
358 for(Int i
=0;i
<samples
;i
++) {
359 var
[i
] = SQR(msd
[i
])-SQR(mu
);
360 //qDebug() << "var["<<i<<"]" << var[i];
363 for(Int j
=0;j
<samples
;j
++) {
369 //qDebug() << "sigma:" << sigma;
373 * This function is kinda redundant right now, but will be needed later
375 void Calculator::gen_gnuplot(const QString
& name
)
378 qDebug() << "generating gnuplot file";
381 QTextStream
out(&file
);
382 file
.open(QIODevice::WriteOnly
);
386 out
<< "set lmargin 10;";
387 out
<< "set rmargin 3;";
388 out
<< "set multiplot;";
389 out
<< "set tmargin = 3;";
390 out
<< "set bmargin = 0;";
391 out
<< "set border 2+4+8;";
392 out
<< "set size 1,0.66667;";
393 out
<< "set origin 0.0,0.33333;";
395 out
<< "set format x \"\";";
396 out
<< "unset xlabel;";
397 out
<< "set ylabel \"x(kT) mod L \";";
398 out
<< "set ytics (\"0\" 0, \"L/2\", \"L\" L);";
399 out
<< "set yrange [0:L];";
400 out
<< "plot \""<<file_rk_bif
<<"\" w dots 1;";
401 out
<< "unset title;";
402 out
<< "set tmargin 0;";
403 out
<< "set bmargin 3;";
404 out
<< "unset format;";
405 out
<< "set size 1,0.33333;";
406 out
<< "set border 1+2+4+8;";
407 out
<< "set origin 0.0,0.0;";
408 out
<< "set xtics 0,0.1;";
409 out
<< "set xlabel \"a\";";
410 out
<< "set ylabel \"v\";";
411 out
<< "set yrange [-0.75:0.75];";
412 out
<< "set ytics -0.5,0.5;";
413 out
<< "plot \""<<file_rk_avg
<<"\" w dots 3;";
414 out
<< "unset multiplot;";
418 void Calculator::filter(QMap
<double, double> & map
, const Doub
& eps
)
420 qDebug() << "filter crap smaller than " << eps
;
423 QList
<double> values
, list
;
424 list
= map
.uniqueKeys();
427 //qDebug() << "size of map:" << size;
428 for(Int i
= 0; i
< size
; i
++) {
430 //qDebug() << "["<<key<<"]" << "writing values into list";
431 values
= map
.values(key
);
432 //qDebug() << "["<<key<<"]" << values.size() << "values for" << key;
434 for(Int k
=0;k
<values
.size()-1;k
++) {
435 diff
= abs(values
.at(k
+1) - values
.at(k
));
436 //qDebug() << values.at(k+1) <<"-"<< values.at(k) << "=" << diff;
438 //qDebug() << diff << "<=" << eps;
439 //qDebug() << "["<<k<<"]" << "removing" << values.at(k) << "from list";
440 values
.replace(k
+1,values
.at(k
));
443 for (int j
= 0; j
< values
.size(); j
++)
444 //qDebug() << "["<<j<<"]" << values.at(j);
445 //qDebug() << "removing" << key << "from map";
447 for (int j
= 0; j
< values
.size(); j
++) {
448 //qDebug() << "inserting" << values.at(j) << "into map at" << key;
449 map
.insertMulti(key
,values
.at(j
));
451 //qDebug() << map.values(key);
452 //qDebug() << endl << "end while" << endl;
456 void Calculator::IC_setup(VecDoub
&y
, Doub x0
, Doub y0
, Doub xdot0
, Doub ydot0
,
457 Doub phi0
, Doub params
[])
460 const Int sys
= c
->valuesMap
.value(1);
463 qDebug() << "using " << "\tx0 = " << x0 << "\ty0 = " << y0
464 << "\txdot0 = " << xdot0 << "\tydot0 = " << ydot0
465 << "\tphi0 = " << fmod(phi0,360) << endl;
470 params
[0] = c
->valuesMap
.value(2); // a;
471 params
[1] = c
->valuesMap
.value(3); // A;
472 params
[2] = c
->valuesMap
.value(4); // F;
473 params
[3] = c
->valuesMap
.value(5); // l;
474 params
[4] = c
->valuesMap
.value(6); // w;
475 params
[5] = c
->valuesMap
.value(25); // eta1;
477 params
[9] = c
->valuesMap
.value(32); // T;
479 y
[0] = x0
, y
[1] = xdot0
;
482 params
[0] = c
->valuesMap
.value(2); // a;
483 params
[1] = fmod(c
->valuesMap
.value(3),360)*PI
/180; // alpha;
484 params
[2] = c
->valuesMap
.value(4); // F;
485 params
[3] = c
->valuesMap
.value(5); // l;
486 params
[4] = c
->valuesMap
.value(6); // w;
487 params
[5] = c
->valuesMap
.value(25); // eta1;
488 params
[6] = c
->valuesMap
.value(26); // eta2;
489 params
[9] = c
->valuesMap
.value(32); // T;
490 params
[10] = fmod(c
->valuesMap
.value(40),360)*PI
/180; // theta;
491 params
[17] = fmod(c
->valuesMap
.value(41),360)*PI
/180; // psi;
492 params
[18] = c
->valuesMap
.value(42); // U;
493 Doub e0
= 1.0/(params
[5]+params
[6]);
494 Doub e1
= 1.0/(params
[5]*params
[3]);
495 Doub e2
= 1.0/(params
[6]*params
[3]);
496 Doub e3
= 1.0/params
[3]*((1.0/params
[5])-(1.0/params
[6]));
497 Doub fx
= cos(params
[10])*params
[2];
498 Doub fy
= sin(params
[10])*params
[2];
499 params
[11] = e0
; // 1/eta
505 params
[7] = params
[3]*params
[11]*params
[5]; // l1;
506 params
[8] = params
[3]*params
[11]*params
[6]; // l2;
507 y
[0] = x0
, y
[1] = y0
, y
[2] = phi0
;
511 for (Int i = 0; i<n;i++)
512 qDebug() << "y("<<i<<") =" << y[i];
513 qDebug() << "eta1 = " << eta1 << "\teta2 = " << eta2 << "\tA = " << A << "\tF = " << F;
517 void Calculator::bifparam(const int &v
, const QString
¶m
, const Doub
&r
,
524 else if (param
== "F")
526 else if (param
== "A")
529 throw ("Fatal error!");
533 params
[1] = fmod(r
,360)*PI
/180;
534 else if (param
== "F") {
536 params
[15] = cos(params
[10])*params
[2];
537 params
[16] = sin(params
[10])*params
[2];
539 else if (param
== "a")
541 else if (param
== "w")
543 else if (param
== "l") {
545 params
[11] = 1.0/(params
[5]+params
[6]);
546 params
[12] = 1.0/(params
[5]*params
[3]);
547 params
[13] = 1.0/(params
[6]*params
[3]);
548 params
[14] = 1.0/params
[3]*((1.0/params
[5])-(1.0/params
[6]));
549 params
[7] = params
[3]*params
[11]*params
[5]; // l1;
550 params
[8] = params
[3]*params
[11]*params
[6]; // l2;
552 else if (param
== "e") {
554 params
[11] = 1.0/(params
[5]+params
[6]);
555 params
[12] = 1.0/(params
[5]*params
[3]);
556 params
[13] = 1.0/(params
[6]*params
[3]);
557 params
[14] = 1.0/params
[3]*((1.0/params
[5])-(1.0/params
[6]));
558 params
[7] = params
[3]*params
[11]*params
[5]; // l1;
559 params
[8] = params
[3]*params
[11]*params
[6]; // l2;
561 else if (param
== "t") {
562 params
[10] = fmod(r
,360)*PI
/180;
563 params
[15] = cos(params
[10])*params
[2];
564 params
[16] = sin(params
[10])*params
[2];
567 throw("Fatal error!");
569 qDebug() << "Bifurcation parameter is " << param
;
573 void Calculator::set_color(const Doub vel
, QString
& color
)
576 if (vel
> 1.0-ctol
&& vel
< 1.0+ctol
)
578 else if (vel
> 0.5-ctol
&& vel
< 0.5+ctol
)
580 else if (vel
> 0.0-ctol
&& vel
< 0.0+ctol
)
582 else if (vel
> -0.5-ctol
&& vel
< -0.5+ctol
)
584 else if (vel
> -1.0-ctol
&& vel
< -1.0+ctol
)
586 else color
= "black";
589 void Calculator::calc2(const Int n
)
591 // setting up a few start values
592 qDebug() << "calc2 has been called: " << "calc2("<<n
<<")";
593 Normaldev
gauss(0,1,time(NULL
));
595 Doub x1
,x2
,y1
,y2
,xtest
;
597 Doub x0
, xdot0
, y0
, ydot0
, phi0
;
598 x0
= c
->valuesMap
.value(8);
599 xdot0
= c
->valuesMap
.value(10);
600 ydot0
= c
->valuesMap
.value(24);
601 y0
= c
->valuesMap
.value(23);
602 phi0
= fmod(c
->valuesMap
.value(27),360)*PI
/180;
603 const Int samples
= c
->valuesMap
.value(35);
604 const Int v
= c
->valuesMap
.value(1);
605 const Int M
= c
->valuesMap
.value(11);
606 const Doub fromt
= c
->valuesMap
.value(22);
607 const Int s
= c
->valuesMap
.value(14);
608 const Doub h
= c
->valuesMap
.value(13);
609 const Doub t0
= c
->valuesMap
.value(7);
610 const Doub fromr1
= c
->valuesMap
.value(17);
611 const Doub fromr2
= c
->valuesMap
.value(37);
612 const Doub tor1
= c
->valuesMap
.value(18);
613 const Doub tor2
= c
->valuesMap
.value(38);
614 const Doub stepr1
= c
->valuesMap
.value(19);
615 const Doub stepr2
= c
->valuesMap
.value(39);
616 const Doub eps
= c
->valuesMap
.value(36);
617 const Doub from
= c
->valuesMap
.value(15);
618 const Doub to
= c
->valuesMap
.value(16);
619 const Doub hstep
= c
->valuesMap
.value(43);
622 const bool ruk
= c
->ruk
;
623 const bool eul
= c
->eul
;
624 QString param1
= c
->str1
;
625 QString param2
= c
->str2
;
626 qDebug() << "System" << v
;
629 Doub trajectory_length
, deflection
, velocity_angle
, bias_angle
;
632 Doub xpi
[samples
][s
];
633 Doub ypi
[samples
][s
];
634 Doub phipi
[samples
][s
];
644 qDebug() << "standard mode";
645 qDebug() << "stepsize:" << h
;
646 qDebug() << "number of steps:" << s
;
648 IC_setup(y
,x0
,xdot0
,y0
,ydot0
,phi0
,params
);
649 qDebug() << phi0
<< y
[2];
652 tau
= 2*PI
/params
[4];
655 if (xtest
>= k
*tau
) {
658 derivs(x
,y
,dydx
,params
); // sets first dydx[] for rk4()
659 rk4(y
,dydx
,x
,h
,yout
,params
);
660 for (Int j
=0;j
<n
;j
++)
666 rkValues_x
.insert(x
,yout
[0]);
669 //xpi = ABS(fmod(yout[0],(2*PI)));
670 //ypi = ABS(fmod(yout[1],(2*PI)));
671 rkValues_x
.insert(x
,yout
[0]);
672 rkValues_y
.insert(x
,yout
[1]);
673 //rkValues_x.insert(x,xpi);
674 //rkValues_y.insert(x,ypi);
675 rkValues_phi
.insert(x
,(180/PI
)*ABS(fmod(yout
[2],(2*PI
))));
676 x1
= y
[0] + params
[7]*cos(yout
[2]);
677 y1
= y
[1] + params
[7]*sin(yout
[2]);
678 x2
= y
[0] - params
[8]*cos(yout
[2]);
679 y2
= y
[1] - params
[8]*sin(yout
[2]);
680 rkValues_p1x
.insert(x
,x1
);
681 rkValues_p1y
.insert(x
,y1
);
682 rkValues_p2x
.insert(x
,x2
);
683 rkValues_p2y
.insert(x
,y2
);
684 rkValues_vx
.insert(x
,dydx
[0]);
685 rkValues_vy
.insert(x
,dydx
[1]);
686 rkValues_vphi
.insert(x
,dydx
[2]);
691 qDebug() << "sizeof(rkValues_x) =" << rkValues_x
.size();
692 qDebug() << "sizeof(rkValues_y) =" << rkValues_y
.size();
693 qDebug() << "sizeof(rkValues_phi) =" << rkValues_phi
.size();
694 write_to_file(file_rk_out
, rkValues_x
, rkValues_y
, rkValues_phi
, params
);
695 write_to_file(file_rk_pt1
, rkValues_p1x
, rkValues_p1y
, rkValues_phi
, params
);
696 write_to_file(file_rk_pt2
, rkValues_p2x
, rkValues_p2y
, rkValues_phi
, params
);
697 write_to_file(file_rk_vel
, rkValues_vx
, rkValues_vy
, rkValues_vphi
, params
);
700 qDebug() << "converge mode";
703 for (iter
=1;from
+(iter
*hstep
)<=to
;iter
++) {
704 for (Int z
=0;z
<samples
;z
++) {
705 qDebug() << "at step" << z
<< "of" << samples
;
707 hh
= from
+(iter
*hstep
);
709 qDebug() << "stepsize is" << hh
<< "with" << ss
<< "total steps.";
710 //x0 = randpi(ran), xdot0 = randpi(ran), y0 = randpi(ran), ydot0 = randpi(ran), phi0 = randpi(ran);
711 IC_setup(y
,x0
,xdot0
,y0
,ydot0
,phi0
,params
);
714 tau
= 2*PI
/params
[4];
716 //qDebug() << k << "<" << s;
717 //qDebug() << k << tau << k*tau;
719 if (xtest
>= k
*tau
) {
720 //qDebug() << xtest << ">=" << k << "*" << tau << "("<<k*tau<<")";
722 derivs(x
,y
,dydx
,params
);
723 rk4(y
,dydx
,x
,hnew
,yout
,params
);
728 //qDebug() << xtest << "=" << x<<"+"<<hh;
729 derivs(x
,y
,dydx
,params
);
730 rk4(y
,dydx
,x
,hh
,yout
,params
); // xold
733 for (Int j
=0;j
<n
;j
++)
738 rkValues_x
.insert(hh
,yout
[0]);
741 rkValues_x
.insert(hh
,yout
[0]);
742 rkValues_y
.insert(hh
,yout
[1]);
743 rkValues_phi
.insert(hh
,yout
[2]);
747 //x0 = randpi(ran), xdot0 = randpi(ran), y0 = randpi(ran), ydot0 = randpi(ran), phi0 = randpi(ran);
748 IC_setup(y
,x0
,xdot0
,y0
,ydot0
,phi0
,params
);
751 tau
= 2*PI
/params
[4];
754 if (xtest
>= k
*tau
) {
756 derivs(x
,y
,dydx
,params
);
757 derivw(x
,y
,dW
,params
,gauss
);
758 euler(y
,dydx
,dW
,x
,hnew
,yout
);
762 derivs(x
,y
,dydx
,params
);
763 derivw(x
,y
,dW
,params
,gauss
);
764 euler(y
,dydx
,dW
,x
,hh
,yout
);
767 for (Int j
=0;j
<n
;j
++)
772 euValues_x
.insert(hh
,yout
[0]);
775 euValues_x
.insert(hh
,yout
[0]);
776 euValues_y
.insert(hh
,yout
[1]);
777 euValues_phi
.insert(hh
,yout
[2]);
782 qDebug() << "sizeof(rkValues_x) =" << rkValues_x
.size();
783 write_to_file(file_rk_conv
, rkValues_x
, rkValues_y
, rkValues_phi
, params
);
784 write_to_file(file_eu_conv
, euValues_x
, euValues_y
, euValues_phi
, params
);
787 qDebug() << "bifurcation mode";
788 qDebug() << "bifurcation parameter: " << param1
;
789 qDebug() << "Number of samples : " << samples
;
791 for (Int j
=0;(j
*stepr1
)<=(tor1
-fromr1
);j
++) {
793 qDebug() << "at step" << j
<< "of" << (tor1
-fromr1
)/stepr1
;
794 for (Int z
=0;z
<samples
;z
++) {
796 x0
= randpi(ran
), xdot0
= randpi(ran
), y0
= randpi(ran
), ydot0
= randpi(ran
), phi0
= randpi(ran
);
797 //qDebug() << "sample" << z << "using" << x0 << xdot0 << y0 << ydot0 << phi0;
798 IC_setup(y
,x0
,xdot0
,y0
,ydot0
,phi0
,params
);
799 bifparam(v
,param1
,r
,params
);
800 //qDebug() << x << y[0] << y[1] << y[2];
801 //for(Int i = 0;i<=10;i++)
802 // qDebug() << params[i];
803 // inner for: iterate over runge-kutta
806 tau
= 2*PI
/params
[4];
808 //qDebug() << "tau: " << tau << "\tL: " << L;
810 xtest
= x
+h
; // test next x increment
811 //if (xtest < k*tau) { qDebug() << "["<<k<<"]" << xtest << "<" << k*tau << "..."; }
812 if (xtest
>= k
*tau
) {
813 //qDebug() << "["<<k<<"]" << xtest << ">" << k*tau << "!";
814 //qDebug() << "new h is" << k << "*" << tau << "-" << x << "=" << hnew;
816 //qDebug() << "making rk4() with stepsize"<<hnew<<"at"<<r;
817 derivs(x
,y
,dydx
,params
);
818 rk4(y
,dydx
,x
,hnew
,yout
,params
);
821 xpi
[z
][k
] = ABS(fmod(yout
[0],(2*PI
)));
822 //qDebug() << "xpi["<<z<<"]["<<k<<"]:" << xpi[z][k];
824 rkValues_x
.insert(r
,xpi
[z
][k
]);
825 rkValues_xdot
.insert(r
,dydx
[0]);
830 //qDebug() << "xpi["<<z<<"]["<<k<<"]:" << xpi[z][k];
832 phipi
[z
][k
] = yout
[2];
833 rkDist_x
.insert(r
,SQR(yout
[0]-x0
));
834 rkDist_y
.insert(r
,SQR(yout
[1]-y0
));
835 rkDist_phi
.insert(r
,SQR(yout
[2]-phi0
));
837 rkValues_x
.insert(r
,ABS(fmod(xpi
[z
][k
],L
)));
838 rkValues_y
.insert(r
,ABS(fmod(ypi
[z
][k
],L
)));
839 rkValues_phi
.insert(r
,ABS(fmod(phipi
[z
][k
],L
)));
840 rkValues_xdot
.insert(r
,dydx
[0]);
841 rkValues_ydot
.insert(r
,dydx
[1]);
842 rkValues_phidot
.insert(r
,dydx
[2]);
848 derivs(x
,y
,dydx
,params
);
849 rk4(y
,dydx
,x
,h
,yout
,params
); // xold
850 for (Int j
=0;j
<n
;j
++)
851 y
[j
] = yout
[j
]; // y[x+h] !!!!!!!
852 x
+= h
; // do it for real
854 //qDebug() << "at" << x << "in time for k = " << k;
859 avg
[0] = (Doub
) m_x
/k
;
860 rkAvgvelo_x
.insert(r
,avg
[0]);
863 m_x
= yout
[0]/L
; m_y
= yout
[1]/L
; m_phi
= yout
[2]/L
;
864 avg
[0] = (Doub
) m_x
/k
; avg
[1] = (Doub
) m_y
/k
; avg
[2] = (Doub
) m_phi
/k
;
865 // makes only sense with r = params[10]
866 trajectory_length
= sqrt(SQR(yout
[0]-x0
)+SQR(yout
[1])-y0
);
867 if (abs(yout
[0]-x0
) > trajectory_length
) {
870 velocity_angle
= (acos((yout
[0]-x0
)/trajectory_length
));
872 bias_angle
= params
[10];
873 deflection
= (180/PI
)*ABS(velocity_angle
- bias_angle
);
875 qDebug() << velocity_angle << "("<<yout[0]-x0<<")"
876 << "-" << bias_angle << "="
878 << "[ length:"<<trajectory_length<<"]";
880 rkAvgvelo_x
.insert(r
,avg
[0]);
881 rkAvgvelo_y
.insert(r
,avg
[1]);
882 rkAvgvelo_phi
.insert(r
,avg
[2]);
883 rkDefAngle
.insert(r
,deflection
);
887 VecDoub
msd_x(samples
,0.0);
888 VecDoub
msd_y(samples
,0.0);
889 VecDoub
msd_phi(samples
,0.0);
893 //qDebug() << "samples:" << samples << "steps:" << s;
894 for(Int i
=0;i
<s
;i
++) {
895 //qDebug() << "["<<i<<"]:---------------------------------";
896 for(Int j
=0;j
<samples
;j
++) {
897 //qDebug() << "xpi["<<j<<"]["<<i<<"]:" << xpi[j][i];
898 msd_x
[j
] = xpi
[j
][i
];
899 //qDebug() << "["<<j<<"]:" << sper_x[j];
900 msd_y
[j
] = ypi
[j
][i
];
901 msd_phi
[j
] = phipi
[j
][i
];
903 diffusion(msd_x
, samples
, sigma
);
905 diffusion(msd_y
, samples
, sigma
);
907 diffusion(msd_phi
, samples
, sigma
);
908 sigma_phi
[i
] = sigma
;
909 //qDebug() << "sigma_x["<<i<<"]:" << sigma_x[i];
911 // the lists of keys in QMultiMap are read out backwards...
912 for(Int k
=(s
-1);k
>=0;k
--) {
913 rkVariance_x
.insert(r
,sigma_x
[k
]);
914 rkVariance_y
.insert(r
,sigma_y
[k
]);
915 rkVariance_phi
.insert(r
,sigma_phi
[k
]);
917 //qDebug() << rkVariance_x;
920 * we need to do something about this
923 filter(rkValues_x,eps);
924 filter(rkValues_y,eps);
925 filter(rkValues_xdot,eps);
926 filter(rkValues_ydot,eps);
927 filter(rkAvgvelo_x, eps);
928 filter(rkAvgvelo_y, eps);
929 filter(rkAvgvelo_phi,eps);*/
930 qDebug() << "sizeof(rkValues_x) =" << rkValues_x
.size();
931 qDebug() << "sizeof(rkValues_y) =" << rkValues_y
.size();
932 qDebug() << "sizeof(rkValues_xdot) =" << rkValues_xdot
.size();
933 qDebug() << "sizeof(rkValues_ydot) =" << rkValues_ydot
.size();
934 write_to_file(file_rk_bif
, rkValues_x
, rkValues_y
, rkValues_phi
, params
);
935 write_to_file(file_rk_biv
, rkValues_xdot
, rkValues_ydot
, rkValues_phidot
, params
);
936 write_to_file(file_rk_avg
, rkAvgvelo_x
, rkAvgvelo_y
, rkAvgvelo_phi
, params
);
937 write_to_file(file_rk_variance
, rkVariance_x
, rkVariance_y
, rkVariance_phi
,params
);
938 write_to_file(file_rk_distance
, rkDist_x
, rkDist_y
, rkDist_phi
, params
);
939 write_to_file(file_rk_defangle
, rkDefAngle
, NullMap
, NullMap
, params
);
942 qDebug() << "dual bifurcation mode";
943 qDebug() << "bifurcation parameters: " << param1
<<"\t"<<param2
;
944 qDebug() << "Number of samples : " << samples
;
946 QString vx_color
, vy_color
;
947 QString name
= "tmp.dat";
949 QTextStream
out(&file
);
950 file
.open(QIODevice::WriteOnly
);
951 out
<< "x\ty\tvx\tvx_color\tvy\tvy_color\tvphi" << endl
;
952 for(Int it1
=0;(it1
*stepr1
)<=(tor1
-fromr1
);it1
++) {
953 for(Int it2
=0;(it2
*stepr2
)<=(tor2
-fromr2
);it2
++) {
954 stp1
= fromr1
+it1
*stepr1
;
955 stp2
= fromr2
+it2
*stepr2
;
956 qDebug() << stp1
<< "("<<tor1
<<")" << stp2
<< "("<<tor2
<<")";
957 for (Int z
=0;z
<samples
;z
++) {
959 x0
= randpi(ran
), xdot0
= randpi(ran
), y0
= randpi(ran
), ydot0
= randpi(ran
), phi0
= randpi(ran
);
960 IC_setup(y
,x0
,xdot0
,y0
,ydot0
,phi0
,params
);
961 bifparam(v
,param1
,stp1
,params
);
962 bifparam(v
,param2
,stp2
,params
);
965 for (Int i=0;i<10;i++)
966 out << "params["<<i<<"] = " << params[i] << " ";
969 // inner for: iterate over runge-kutta
972 tau
= 2*PI
/params
[4];
974 //qDebug() << "tau: " << tau << "\tL: " << L;
976 xtest
= x
+h
; // test next x increment
977 //if (xtest < k*tau) { qDebug() << "["<<k<<"]" << xtest << "<" << k*tau << "..."; }
978 if (xtest
>= k
*tau
) {
979 //qDebug() << "["<<k<<"]" << xtest << ">" << k*tau << "!";
980 //qDebug() << "new h is" << k << "*" << tau << "-" << x << "=" << hnew;
982 //qDebug() << "making rk4() with stepsize"<<hnew<<"at"<<r;
983 derivs(x
,y
,dydx
,params
);
984 rk4(y
,dydx
,x
,hnew
,yout
,params
);
987 derivs(x
,y
,dydx
,params
);
988 rk4(y
,dydx
,x
,h
,yout
,params
); // xold
989 for (Int j
=0;j
<n
;j
++)
990 y
[j
] = yout
[j
]; // y[x+h] !!!!!!!
991 x
+= h
; // do it for real
994 m_x
= yout
[0]/L
; m_y
= yout
[1]/L
; m_phi
= yout
[2]/L
;
995 avg
[0] = (Doub
) m_x
/k
; avg
[1] = (Doub
) m_y
/k
;
996 avg
[2] = (Doub
) m_phi
/k
;
997 set_color(avg
[0], vx_color
);
998 set_color(avg
[1], vy_color
);
999 out
<< stp1
<< "\t" << stp2
<< "\t"
1000 << avg
[0] << "\t" << vx_color
<< "\t" << avg
[1]
1001 << "\t" << vy_color
<< "\t" << avg
[2] << endl
;
1003 } // end 2. outer for
1004 } // end 1. outer for
1006 qDebug() << "moving" << name
<< "to safety";
1007 file
.copy(name
, file_rk_dualbif
);
1015 qDebug() << "(euler) standard mode";
1016 qDebug() << "stepsize:" << h
;
1017 qDebug() << "number of steps:" << s
;
1019 IC_setup(y
,x0
,xdot0
,y0
,ydot0
,phi0
,params
);
1023 tau
= 2*PI
/params
[4];
1025 //qDebug() << k << "<" << s;
1026 //qDebug() << "x is now" << x;
1027 //qDebug() << "deriving values at" << x;
1028 //qDebug() << x0, y0, phi0;
1029 derivs(x
,y
,dydx
,params
); // sets first dydx[] for rk4()
1030 derivw(x
,y
,dW
,params
,gauss
);
1031 euler(y
,dydx
,dW
,x
,h
,yout
);
1032 //for (Int i=0;i<=18;i++)
1033 //qDebug() << "params["<<i<<"]" << params[i];
1035 //qDebug() << x <<"=="<< hit*0.1;
1036 //qDebug() << "writing2 to map";
1038 //qDebug() << "next value to write out" << hit*0.1;
1042 euValues_x
.insert(x
,yout
[0]);
1045 //xpi = ABS(fmod(yout[0],(2*PI)));
1046 //ypi = ABS(fmod(yout[1],(2*PI)));
1047 euValues_x
.insert(x
,yout
[0]);
1048 euValues_y
.insert(x
,yout
[1]);
1049 //rkValues_x.insert(x,xpi);
1050 //rkValues_y.insert(x,ypi);
1051 euValues_phi
.insert(x
,yout
[2]);
1052 x1
= yout
[0] + params
[7]*cos(yout
[2]);
1053 y1
= yout
[1] + params
[7]*sin(yout
[2]);
1054 x2
= yout
[0] - params
[8]*cos(yout
[2]);
1055 y2
= yout
[1] - params
[8]*sin(yout
[2]);
1056 euValues_p1x
.insert(x
,x1
);
1057 euValues_p1y
.insert(x
,y1
);
1058 euValues_p2x
.insert(x
,x2
);
1059 euValues_p2y
.insert(x
,y2
);
1060 euValues_vx
.insert(x
,dydx
[0]);
1061 euValues_vy
.insert(x
,dydx
[1]);
1062 euValues_vphi
.insert(x
,dydx
[2]);
1064 } // end fromt switch
1067 //qDebug() << "making step of size" << h;
1068 for (Int j
=0;j
<n
;j
++)
1071 //qDebug() << "new x is now" << x;
1073 //qDebug() << x << ">=" << k*tau;
1074 //qDebug() << "incrementing k";
1076 //qDebug() << "new value of x needed is" << k*tau;
1079 qDebug() << "sizeof(euValues_x) =" << euValues_x
.size();
1080 qDebug() << "sizeof(euValues_y) =" << euValues_y
.size();
1081 qDebug() << "sizeof(euValues_phi) =" << euValues_phi
.size();
1082 write_to_file(file_eu_out
, euValues_x
, euValues_y
, euValues_phi
, params
);
1083 write_to_file(file_eu_pt1
, euValues_p1x
, euValues_p1y
, euValues_phi
, params
);
1084 write_to_file(file_eu_pt2
, euValues_p2x
, euValues_p2y
, euValues_phi
, params
);
1085 write_to_file(file_eu_vel
, euValues_vx
, euValues_vy
, euValues_vphi
, params
);
1088 qDebug() << "bifurcation mode";
1089 qDebug() << "bifurcation parameter: " << param1
;
1090 qDebug() << "Number of samples : " << samples
;
1092 for (Int j
=0;(j
*stepr1
)<=(tor1
-fromr1
);j
++) {
1093 r
= fromr1
+j
*stepr1
;
1094 qDebug() << "at step" << j
<< "of" << (tor1
-fromr1
)/stepr1
;
1095 for (Int z
=0;z
<samples
;z
++) {
1097 x0
= randpi(ran
), xdot0
= randpi(ran
), y0
= randpi(ran
), ydot0
= randpi(ran
), phi0
= randpi(ran
);
1098 //qDebug() << "sample" << z << "using" << x0 << xdot0 << y0 << ydot0 << phi0;
1099 IC_setup(y
,x0
,xdot0
,y0
,ydot0
,phi0
,params
);
1100 bifparam(v
,param1
,r
,params
);
1101 // inner for: iterate over runge-kutta
1104 tau
= 2*PI
/params
[4];
1106 //qDebug() << "tau: " << tau << "\tL: " << L;
1108 xtest
= x
+h
; // test next x increment
1109 //if (xtest < k*tau) { qDebug() << "["<<k<<"]" << xtest << "<" << k*tau << "..."; }
1110 if (xtest
>= k
*tau
) {
1111 //qDebug() << "["<<k<<"]" << xtest << ">" << k*tau << "!";
1112 //qDebug() << "new h is" << k << "*" << tau << "-" << x << "=" << hnew;
1114 //qDebug() << "making euler() with stepsize"<<hnew<<"at"<<r;
1115 derivs(x
,y
,dydx
,params
);
1116 derivw(x
,y
, dW
, params
,gauss
);
1117 euler(y
,dydx
,dW
,x
,hnew
,yout
);
1120 xpi
[z
][k
] = yout
[0];
1122 euValues_x
.insert(r
,ABS(fmod(xpi
[z
][k
],L
)));
1123 euValues_xdot
.insert(r
,dydx
[0]);
1127 xpi
[z
][k
] = yout
[0];
1128 //qDebug() << "xpi["<<z<<"]["<<k<<"]:" << xpi[z][k];
1129 ypi
[z
][k
] = yout
[1];
1130 phipi
[z
][k
] = yout
[2];
1131 euDist_x
.insert(r
,SQR(yout
[0]-x0
));
1132 euDist_y
.insert(r
,SQR(yout
[1]-y0
));
1133 euDist_phi
.insert(r
,SQR(yout
[2]-phi0
));
1135 euValues_x
.insert(r
,ABS(fmod(xpi
[z
][k
],L
)));
1136 euValues_y
.insert(r
,ABS(fmod(ypi
[z
][k
],L
)));
1137 euValues_phi
.insert(r
,ABS(fmod(phipi
[z
][k
],L
)));
1138 euValues_xdot
.insert(r
,dydx
[0]);
1139 euValues_ydot
.insert(r
,dydx
[1]);
1140 euValues_phidot
.insert(r
,dydx
[2]);
1146 derivs(x
,y
,dydx
,params
);
1147 derivw(x
,y
,dW
, params
,gauss
);
1148 euler(y
,dydx
,dW
,x
,h
,yout
); // xold
1149 for (Int j
=0;j
<n
;j
++)
1150 y
[j
] = yout
[j
]; // y[x+h] !!!!!!!
1151 x
+= h
; // do it for real
1153 //qDebug() << "at" << x << "in time for k = " << k;
1155 Int m_x
, m_y
, m_phi
;
1158 avg
[0] = (Doub
) m_x
/k
;
1159 euAvgvelo_x
.insert(r
,avg
[0]);
1162 m_x
= yout
[0]/L
; m_y
= yout
[1]/L
; m_phi
= yout
[2]/L
;
1163 avg
[0] = (Doub
) m_x
/k
; avg
[1] = (Doub
) m_y
/k
; avg
[2] = (Doub
) m_phi
/k
;
1164 trajectory_length
= sqrt(SQR(yout
[0]-x0
)+SQR(yout
[1])-y0
);
1165 if (abs(yout
[0]-x0
) > trajectory_length
) {
1166 velocity_angle
= PI
;
1168 velocity_angle
= (acos((yout
[0]-x0
)/trajectory_length
));
1170 bias_angle
= params
[10];
1171 deflection
= (180/PI
)*ABS(velocity_angle
- bias_angle
);
1172 euAvgvelo_x
.insert(r
,avg
[0]);
1173 euAvgvelo_y
.insert(r
,avg
[1]);
1174 euAvgvelo_phi
.insert(r
,avg
[2]);
1175 euDefAngle
.insert(r
,deflection
);
1179 VecDoub
msd_x(samples
,0.0);
1180 VecDoub
msd_y(samples
,0.0);
1181 VecDoub
msd_phi(samples
,0.0);
1184 Doub sigma_phi
[s
-1];
1185 //qDebug() << "samples:" << samples << "steps:" << s;
1186 for(Int i
=0;i
<s
;i
++) {
1187 //qDebug() << "["<<i<<"]:---------------------------------";
1188 for(Int j
=0;j
<samples
;j
++) {
1189 //qDebug() << "xpi["<<j<<"]["<<i<<"]:" << xpi[j][i];
1190 msd_x
[j
] = xpi
[j
][i
];
1191 //qDebug() << "["<<j<<"]:" << sper_x[j];
1192 msd_y
[j
] = ypi
[j
][i
];
1193 msd_phi
[j
] = phipi
[j
][i
];
1195 diffusion(msd_x
, samples
, sigma
);
1197 diffusion(msd_y
, samples
, sigma
);
1199 diffusion(msd_phi
, samples
, sigma
);
1200 sigma_phi
[i
] = sigma
;
1201 //qDebug() << "sigma_x["<<i<<"]:" << sigma_x[i];
1203 // the lists of keys in QMultiMap are read out backwards...
1204 for(Int k
=(s
-1);k
>=0;k
--) {
1205 euVariance_x
.insert(r
,sigma_x
[k
]);
1206 euVariance_y
.insert(r
,sigma_y
[k
]);
1207 euVariance_phi
.insert(r
,sigma_phi
[k
]);
1209 //qDebug() << euVariance_x;
1212 * we need to do something about this
1214 qDebug() << "sizeof(euValues_x) =" << euValues_x
.size();
1215 qDebug() << "sizeof(euValues_y) =" << euValues_y
.size();
1216 qDebug() << "sizeof(euValues_xdot) =" << euValues_xdot
.size();
1217 qDebug() << "sizeof(euValues_ydot) =" << euValues_ydot
.size();
1218 write_to_file(file_eu_bif
, euValues_x
, euValues_y
, euValues_phi
, params
);
1219 write_to_file(file_eu_biv
, euValues_xdot
, euValues_ydot
, euValues_phidot
, params
);
1220 write_to_file(file_eu_avg
, euAvgvelo_x
, euAvgvelo_y
, euAvgvelo_phi
, params
);
1221 write_to_file(file_eu_variance
, euVariance_x
, euVariance_y
, euVariance_phi
,params
);
1222 write_to_file(file_eu_distance
, euDist_x
, euDist_y
, euDist_phi
, params
);
1223 write_to_file(file_eu_defangle
, euDefAngle
, NullMap
, NullMap
, params
);
1226 qDebug() << "dual bifurcation mode";
1227 qDebug() << "bifurcation parameters: " << param1
<<"\t"<<param2
;
1228 qDebug() << "Number of samples : " << samples
;
1230 QString vx_color
, vy_color
;
1231 QString name
= "tmp.dat";
1233 QTextStream
out(&file
);
1234 file
.open(QIODevice::WriteOnly
);
1235 out
<< "x\ty\tvx\tvx_color\tvy\tvy_color\tvphi" << endl
;
1236 for (Int it1
=0;(it1
*stepr1
)<=(tor1
-fromr1
);it1
++) {
1237 for (Int it2
=0;(it2
*stepr2
)<=(tor2
-fromr2
);it2
++) {
1238 stp1
= fromr1
+it1
*stepr1
;
1239 stp2
= fromr2
+it2
*stepr2
;
1240 qDebug() << stp1
<< "("<<tor1
<<")" << stp2
<< "("<<tor2
<<")";
1241 for (Int z
=0;z
<samples
;z
++) {
1243 x0
= randpi(ran
), xdot0
= randpi(ran
), y0
= randpi(ran
), ydot0
= randpi(ran
), phi0
= randpi(ran
);
1244 IC_setup(y
,x0
,xdot0
,y0
,ydot0
,phi0
,params
);
1245 bifparam(v
,param1
,stp1
,params
);
1246 bifparam(v
,param2
,stp2
,params
);
1247 // inner for: iterate over runge-kutta
1250 tau
= 2*PI
/params
[4];
1252 //qDebug() << "tau: " << tau << "\tL: " << L;
1254 xtest
= x
+h
; // test next x increment
1255 //if (xtest < k*tau) { qDebug() << "["<<k<<"]" << xtest << "<" << k*tau << "..."; }
1256 if (xtest
>= k
*tau
) {
1257 //qDebug() << "["<<k<<"]" << xtest << ">" << k*tau << "!";
1258 //qDebug() << "new h is" << k << "*" << tau << "-" << x << "=" << hnew;
1260 //qDebug() << "making euler() with stepsize"<<hnew<<"at"<<r;
1261 derivs(x
,y
,dydx
,params
);
1262 derivw(x
,y
, dW
,params
,gauss
);
1263 euler(y
,dydx
,dW
,x
,hnew
,yout
);
1266 derivs(x
,y
,dydx
,params
);
1267 derivw(x
,y
, dW
,params
,gauss
);
1268 euler(y
,dydx
,dW
,x
,h
,yout
); // xold
1269 for (Int j
=0;j
<n
;j
++)
1270 y
[j
] = yout
[j
]; // y[x+h] !!!!!!!
1271 x
+= h
; // do it for real
1273 Int m_x
, m_y
, m_phi
;
1274 m_x
= yout
[0]/L
; m_y
= yout
[1]/L
; m_phi
= yout
[2]/L
;
1275 avg
[0] = (Doub
) m_x
/k
; avg
[1] = (Doub
) m_y
/k
;
1276 avg
[2] = (Doub
) m_phi
/k
;
1277 set_color(avg
[0], vx_color
);
1278 set_color(avg
[1], vy_color
);
1279 out
<< stp1
<< "\t" << stp2
<< "\t"
1280 << avg
[0] << "\t" << vx_color
<< "\t" << avg
[1]
1281 << "\t" << vy_color
<< "\t" << avg
[2] << endl
;
1284 } // end 2. outer for
1285 } // end 1. outer for
1287 qDebug() << "moving" << name
<< "to safety";
1288 file
.copy(name
, file_rk_dualbif
);
1294 throw("No method specified!");
1297 rkValues_xdot
.clear();
1299 rkValues_ydot
.clear();
1300 rkValues_phi
.clear();
1301 rkValues_phidot
.clear();
1302 rkAvgvelo_x
.clear();
1303 rkAvgvelo_y
.clear();
1304 rkAvgvelo_phi
.clear();
1307 euValues_xdot
.clear();
1309 euValues_ydot
.clear();
1310 euValues_phi
.clear();
1311 euValues_phidot
.clear();
1312 euAvgvelo_x
.clear();
1313 euAvgvelo_y
.clear();
1314 euAvgvelo_phi
.clear();
1318 //=============================================================================