wsphillips / Conductor.jl

Choo-choo
MIT License
61 stars 12 forks source link

Simulation timescale factor x1000 different than expected #42

Closed rpgowers closed 2 years ago

rpgowers commented 2 years ago

Using the version of Conductor.jl installed from the REPL (0.0.4, Julia 1.7.3), the voltage step response generated by the Simulation function is a factor 1000x faster than expected after generating the neuron model via the CompartmentSystem constructor. This situation can also be generated in the most recent hodgkinhuxley.jl demo script by removing the active channels. Minimal example notebook showing this below:

https://gist.github.com/rpgowers/b1fff319f8832736287e8788aedb9e11

wsphillips commented 2 years ago

Thanks! Ought to be fixed by https://github.com/wsphillips/Conductor.jl/commit/c4844000e4da7f390ea79b9b764437be9549a0a5 now on main branch.

using Conductor, Unitful, ModelingToolkit, Plots, OrdinaryDiffEq
import Unitful: mV, mS, cm, μm, ms, μs, mF, μF

@named leak = IonChannel(Leak, max_g = 2.0mS/cm^2); # create leak channel
channels = [leak];
reversals = Equilibria([Leak => -60.0mV]);
Vm = MembranePotential(-30.0mV); # start simulation away from equilibrium
dynamics = HodgkinHuxley(Vm, channels, reversals; capacitance = 20.0μF/cm^2, geometry=Point())

@named neuron = CompartmentSystem(dynamics)
sim = Simulation(neuron, time = 100.0ms)
solution = solve(sim, Tsit5());
plot(solution)

timeconstant