Skip to content
Snippets Groups Projects
Commit c822f8b9 authored by Sam Yates's avatar Sam Yates Committed by Benjamin Cumming
Browse files

Patch up Julia scripts for Julia 1.0 (#629)

* Use `Unitful.uconvert` for scalar conversions (Float64 cast apparently does not work at the moment).
* Use .+ for scalar/array addition.
* Replace `immutable` with `struct`.
* Qualify included modules with `Main.` for using statements.
* Add informational note to FindJulia as component identification can take a long time as Julia may compile them from source.
parent 7bd98a2a
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,9 @@ include(FindPackageHandleStandardArgs)
if(NOT Julia_FOUND)
find_program(Julia_EXECUTABLE julia)
if(Julia_EXECUTABLE)
if(Julia_FIND_COMPONENTS)
message(STATUS "Checking for Julia components: ${Julia_FIND_COMPONENTS}")
endif()
foreach(component ${Julia_FIND_COMPONENTS})
set(_found_var "Julia_${component}_FOUND")
if(NOT ${_found_var})
......
......@@ -6,7 +6,7 @@ using Sundials
using Unitful
using Unitful.DefaultSymbols
immutable HHParam
struct HHParam
c_m # membrane spacific capacitance
gnabar # Na channel cross-membrane conductivity
gkbar # K channel cross-membrane conductivity
......@@ -47,7 +47,7 @@ immutable HHParam
end
immutable Stim
struct Stim
t0 # start time of stimulus
t1 # stop time of stimulus
i_e # stimulus current density
......@@ -144,7 +144,6 @@ function run_hh(t_end; v0=-65mV, stim=Stim(), param=HHParam(), sample_dt=0.01ms)
ydot[1], ydot[2], ydot[3], ydot[4] =
vdot*t_scale/v_scale, mdot*t_scale, hdot*t_scale, ndot*t_scale
# Float64(vdot*t_scale/v_scale), Float64(mdot*t_scale), Float64(hdot*t_scale), Float64(ndot*t_scale)
return Sundials.CV_SUCCESS
end
......
......@@ -6,7 +6,7 @@ using Sundials
using Unitful
using Unitful.DefaultSymbols
immutable LVAParam
struct LVAParam
c_m # membrane spacific capacitance
gbar # Ca channel cross-membrane conductivity
eca # Ca channel reversal potential
......@@ -32,7 +32,7 @@ immutable LVAParam
end
immutable Stim
struct Stim
t0 # start time of stimulus
t1 # stop time of stimulus
i_e # stimulus current density
......
module PassiveCable
using Unitful: uconvert, NoUnits
export cable_normalize, cable, rallpack1
# Compute solution g(x, t) to
......@@ -94,7 +96,7 @@ function cable(x, t, L, lambda, tau, r, V, I; tol=1e-8)
return V
else
tol_n = abs(tol/scale)
return scale*cable_normalized(Float64(x/lambda), Float64(t/tau), Float64(L/lambda), tol=tol_n) + V
return scale*cable_normalized(uconvert(NoUnits, x/lambda), uconvert(NoUnits, t/tau), uconvert(NoUnits, L/lambda), tol=tol_n) + V
end
end
......
......@@ -19,7 +19,7 @@ c = 0.01mA/cm^2
tau = 10ms
ts = collect(0s: sample_dt: t_end)
is = area*(1/3*c + (a0-1/3*c)*exp.(-ts/tau))
is = area*(1/3*c .+ (a0-1/3*c)*exp.(-ts/tau))
trace = Dict(
:name => "membrane current",
......
......@@ -5,7 +5,7 @@ include("LVAChannels.jl")
using JSON
using Unitful
using Unitful.DefaultSymbols
using LVAChannels
using Main.LVAChannels
scale(quantity, unit) = uconvert(NoUnits, quantity/unit)
......
......@@ -5,7 +5,7 @@ include("PassiveCable.jl")
using JSON
using Unitful
using Unitful.DefaultSymbols
using PassiveCable
using Main.PassiveCable
scale(quantity, unit) = uconvert(NoUnits, quantity/unit)
......
......@@ -5,7 +5,7 @@ include("HHChannels.jl")
using JSON
using Unitful
using Unitful.DefaultSymbols
using HHChannels
using Main.HHChannels
scale(quantity, unit) = uconvert(NoUnits, quantity/unit)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment