4
4
# For distribution under GNU public License. See COPYING. #
5
5
# #
6
6
# Modified by Jaime E. Villate #
7
- # Time-stamp: "2025-05-27 10:54:55 villate" #
7
+ # Time-stamp: "2025-05-29 21:22:36 villate" #
8
8
# ###########################################################
9
9
10
10
global plotdfOptions
@@ -23,6 +23,7 @@ set plotdfOptions {
23
23
{xcenter 0.0 {(xcenter,ycenter) is the origin of the window}}
24
24
{ycenter 0.0 " see xcenter" }
25
25
{bbox " " " xmin ymin xmax ymax .. overrides the -xcenter etc" }
26
+ {algorithm " adamsMoulton" " can be rungeKutta, rungeKuttaA or adamsMoulton" }
26
27
{tinitial 0.0 " The initial value of variable t" }
27
28
{nsteps 300 " Number of steps to do in one pass" }
28
29
{xfun " " " A semi colon separated list of functions to plot as well" }
@@ -100,22 +101,19 @@ proc doIntegrateScreen { win sx sy } {
100
101
}
101
102
102
103
proc doIntegrate { win x0 y0 } {
103
- makeLocal $win xradius yradius c dxdt dydt tinitial tstep nsteps \
104
+ makeLocal $win xradius yradius c dxdt dydt algorithm tinitial tstep nsteps \
104
105
direction linewidth tinitial versus_t xmin xmax ymin ymax parameters \
105
106
width height
106
107
linkLocal $win didLast trajectoryStarts
107
108
set linewidth [expr {$linewidth *[vectorlength $width $height ]/1000.}]
108
109
set arrowshape [scalarTimesVector $linewidth {3 5 2}]
109
110
110
- # integrator can be rungeKutta, rungeKuttaA or adamsMoulton
111
- set integrator {adamsMoulton}
112
111
oset $win trajectory_at [format " %.10g %.10g" $x0 $y0 ]
113
112
lappend trajectoryStarts [list $x0 $y0 ]
114
113
set didLast {}
115
114
# puts "doing at $trajectory_at"
116
- # Default value for tstep equal to the plot box's diagonal divided by 400
117
115
set steps $nsteps
118
- set h $tstep
116
+ set integrator $algorithm
119
117
120
118
set todo {1}
121
119
switch -- $direction {
@@ -399,6 +397,7 @@ proc plotdf { args } {
399
397
oset $win didLast {}
400
398
# Makes extra vertical space for sliders
401
399
linkLocal $win sliders height tstep xradius yradius
400
+ # Default value for tstep equal to the plot box's diagonal divided by 400
402
401
if { " $tstep " == " " } {
403
402
set tstep [expr {[vectorlength $xradius $yradius ] / 200.0}]
404
403
}
@@ -473,10 +472,21 @@ proc doConfigdf { win } {
473
472
pack $frdydx .dxdt $frdydx .dydt -side bottom -fill x -expand 1
474
473
pack $frdydx .dydxbut $frdydx .dydtbut -side left -fill x -expand 1
475
474
476
- foreach w {narrows parameters xfun linewidth xradius yradius xcenter ycenter tinitial versus_t tstep nsteps direction curves vectors fieldlines } {
475
+ foreach w {narrows parameters xfun linewidth xradius yradius xcenter \
476
+ ycenter tinitial versus_t tstep nsteps direction curves vectors \
477
+ fieldlines} {
477
478
mkentry $wb1 .$w [oloc $win $w ] $w $buttonFont
478
479
pack $wb1 .$w -side bottom -expand 1 -fill x
479
480
}
481
+ radiobutton $wb1 .rk -text " 4th order Runge Kutta" \
482
+ -variable [oloc $win algorithm] -value rungeKutta -anchor w
483
+ radiobutton $wb1 .rka -text " Adaptive-step Runge Kutta" \
484
+ -variable [oloc $win algorithm] -value rungeKuttaA -anchor w
485
+ radiobutton $wb1 .am -text " Adams-Moulton" \
486
+ -variable [oloc $win algorithm] -value adamsMoulton -anchor w
487
+ pack $wb1 .rk -side bottom -expand 1 -fill x
488
+ pack $wb1 .rka -side bottom -expand 1 -fill x
489
+ pack $wb1 .am -side bottom -expand 1 -fill x
480
490
mkentry $wb1 .trajectory_at [oloc $win trajectory_at] \
481
491
" Trajectory at" $buttonFont
482
492
bind $wb1 .trajectory_at.e <KeyPress-Return> \
0 commit comments