NB. Sample script for A Cellular Model for Spatial Population Dynamics NB. by Chu Yue (Stella) Dong, James T. Long, Clifford A. Reiter, Corey Staten, Rytis Umbrasas NB. Summer 2008 NB. Requires Jsoftware (it is free: download from www.jsoftware.com) NB. and the following addons (also availble from Jsoftware: NB. media/image3 NB. graphics/fvj3 NB. math/lapack NB. NB. load addon and system scripts require '~addons/graphics/fvj3/automata.ijs' require 'plot misc' require '~addons/math/lapack/lapack.ijs' NB. for eigenvalues require '~addons/math/lapack/dgeev.ijs' NB. for eigenvalues NB. window size VRAWH=:800 800 NB. clamp function cp01=: 0>.(<:256^2)<.] NB. finds fixed for these iterations fxpt=: 3 :'(1-{."1 y) %. }."1 y' NB. finds eigenvalues eigval=: >@(1&{)@dgeev_jlapack_ NB. magnatude of eigenvalues for these iteration at FP fpev=:3 : '|eigval (* y +/ . * 1,])D. 1 fxpt y' NB. global rule from local r=:[: (,"2) 3 3&(lr;._3)@perext2 NB. periodic extension perext2=:perext"_1@:perext NB. [max_iter delay] show_auto_rgb X0 'filename' show_auto_rgb=:2 : 0 100 0.5 u show_auto_rgb n y : maxit=.x m0=.<.<./VRAWH%|.2{.$ n VRAWH=:m0*|.2{.$ n vwin 'auto' wd 'pmovex 100 0 ',":VRAWH n=.|.n sa_ha=:,:n sa_h0=:,:(<0 0){n fns=:nx_fn&.>^:(i.maxit+1) <fn=:(path_nm y),'sa_temp0000.png' vfshow_rgb ti=.3 {."1 m0 spix 0>.255<.<.255%~n max=.2*fxpt C0 for. i. maxit do. n=.u n vfshow_rgb ti=.m0 spix 0>.255<.<.n(*"1) 255.99%max sa_h0=:sa_h0,(<0 0){n sa_ha=:sa_ha,n smoutput avg ,/n wd 'msgs' end. max=.>./,/,/sa_ha smoutput 'creating frames...' wd 'msgs' for_k0. i. maxit+1 do. ti=.3 {."1 m0 spix 0>.255<.<.(k0{sa_ha) (*"1) 255.99%max ti write_image >k0{fns end. smoutput 'creating movie from frames...' wd 'msgs' NB. sa_z=:n 10 fseq_to_png_mov fns;y ferase fns (scriptform 'M0 C0 cp01 lr sa_h0') fwrite '.ijs',~_4}.y ) vfshow_rgb=:3 : 0 wd 'psel ',WIN_nam,';' glpixels (0 0,VRAWH),,256 256 256#.3{."1 y glpaint '' ) NB. C0 PND M0 -- constructs the main function NB. C0 matrix of update coef NB. M0 migration coef PND=:2 : 0 cp01@:(* m +/ . * 1 , ] )@:(n locX) f. ) NB. loc averaging locX=:1 : '[:+/((-.,:])m)*((4&{,:avg)@(,/))' NB. fig 07 NB. set the matrix of coefficients (fxpt,:fpev) C0=:".;._2] 0 : 0 1.53 _0.0980392 _0.980392 _1.02 1.02 0.980392 _0.0980392 _1.02 0.490196 0.980392 0.980392 _0.0980392 ) NB. set migration rates M0=:0.5 0.5 1 lr=:C0 PND M0 X3=:(2*fxpt C0)*"1 ?(200 200,$M0)$0 lr=:C0 PND M0 NB. create the movie with shown name 200 (r f.) show_auto_rgb X3 'c:\temp\fig07.mov'