How come julia won't run this code? -


i in process of trying learn little using julia translating old example code solves time dependent schrodinger equation. here have far:

require("setparams.jl") require("v.jl") require("initialrim.jl") #require("expevolve.jl")   function doit()      nspace, r, im, x0, width, k0, xmax, xmin, v0, a, dx, dx2, n, dt = setparams()    r, im = initialrim(width,n,k0,dt,xmin) probden = zeros(nspace) probden = r.*r + im.*im plot(probden) #imold = im; t=0.0 #t, r =evolve!(r,im,t,v0,width,a,dx,dx2,dt,xmin,n)  println("done")  end 

after requiring above code, using winston. attempt run code typing doit(). nothing appears.

can please let me know doing wrong? can provide innards of setuparame() if needed, initialrim() thought @ first i'd ask whether expectations should happen in fault. note if run setuparams() , initialrim() in terminal session, plot(probden), correct graph appears.

thanks help.

update:

i have restarted julia, have done using winston, , have done doit() wit:

julia> using winston

julia> require("drivesch.jl")

julia> doit() error: dx not defined in initialrim @ /users/comerduncan/juliaexamples/tdsch/initialrim.jl:8 in doit @ /users/comerduncan/juliaexamples/tdsch/drivesch.jl:11

however, call setparams() sets dx along other things. see when run setparams() interactively. not understanding problem...

it seems use dx in initialrim, dx not 1 of arguments pass it. if access variable not parameter nor assigned inside julia function, julia variable same name in surrounding scopes. when run

nspace, r, im, x0, width, k0, xmax, xmin, v0, a, dx, dx2, n, dt = setparams() 

in global scope, , create global variable dx initialrim access. when wrap calls function, create local variable dx can not accessed initialrim.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -