Skip to content

Commit

Permalink
Pulses (#19)
Browse files Browse the repository at this point in the history
* pkg

* ProgressLogging

* shorter istirm func

* dont use fractions

* no fractions

* test code

* Rodas5P wins

* pkg upd

* fix unit error in ISO module

* Dca

* typo

* test code

* pkg

* CI

* simplify

* comment

* fix bugs

* fix

* test code

* fix ca flux

* record KmRyR

* test code

* upd

* wip

* pkg

* test code

* Pkg

* using DifferentialEquations

* pkg

* PDE and jup unstable

* pkg

* wip

* pkg

* compartment vglumes

* cell geometry

* test code

* JULIA_CONDAPKG_BACKEND

* minimal deps

* fix
  • Loading branch information
sosiristseng authored Sep 19, 2024
1 parent 9746510 commit 3d8865f
Show file tree
Hide file tree
Showing 20 changed files with 259 additions and 231 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ concurrency:

env:
NBCONVERT_JOBS: '2'
LITERATE_PROC: '4'
LITERATE_PROC: '2'
JULIA_NUM_THREADS: '2'
ALLOWERRORS: 'false'
CACHE_NUM: '1'
JULIA_CONDAPKG_BACKEND: 'Null'
JULIA_CI: 'true'
NBCACHE: '.cache'
UV_SYSTEM_PYTHON: 1

jobs:
CI:
runs-on: self-hosted
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -32,8 +32,10 @@ jobs:
id: setup-python
with:
python-version: '3.x'
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Install Python dependencies
run: pip install -r requirements.txt
run: uv pip install -r requirements.txt
- name: Read Julia version
uses: SebRollen/[email protected]
id: read_toml
Expand All @@ -44,7 +46,7 @@ jobs:
id: hash
run: |
echo "value=${{ hashFiles('Project.toml', 'Manifest.toml', 'src/**') }}" >> "$GITHUB_OUTPUT"
echo "ver=${{ runner.os }}-julia-${{ env.CACHE_NUM }}-${{ steps.read_toml.outputs.value }}" >> "$GITHUB_OUTPUT"
echo "ver=${{ runner.os }}-julia-${{ steps.read_toml.outputs.value }}" >> "$GITHUB_OUTPUT"
- name: Cache executed notebooks
uses: actions/cache@v4
id: cache-nb
Expand All @@ -59,7 +61,7 @@ jobs:
version: ${{ steps.read_toml.outputs.value }}
- name: Restore Julia packages
uses: actions/cache/restore@v4
if: ${{ runner.environment == 'github-hosted' }}
if: ${{ runner.environment == 'github-hosted'}}
id: cache-julia
with:
path: ~/.julia
Expand All @@ -70,7 +72,7 @@ jobs:
if: ${{ runner.environment == 'self-hosted' || steps.cache-julia.outputs.cache-hit != 'true' }}
shell: julia --color=yes {0}
run: |
using Pkg, Dates
using Pkg
Pkg.add(["IJulia", "Literate", "PrettyTables", "JSON"])
Pkg.activate(".")
Pkg.instantiate()
Expand All @@ -83,7 +85,7 @@ jobs:
key: ${{ steps.cache-julia.outputs.cache-primary-key }}
- name: Run notebooks
if: ${{ steps.cache-nb.outputs.cache-hit != 'true' }}
run: julia --color=yes -p ${{ env.LITERATE_PROC }} --heap-size-hint=3G run.jl
run: julia --project=@. --color=yes -p ${{ env.LITERATE_PROC }} run.jl
- name: Copy back built notebooks
run: cp --verbose -rf ${{ env.NBCACHE }}/docs/* docs/
- name: Build website
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/clear-main-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Clear main caches
on:
workflow_dispatch:

jobs:
cleanup:
permissions:
actions: write
runs-on: ubuntu-latest
steps:
- name: Cleanup
run: |
gh extension install actions/gh-actions-cache
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
BRANCH: ${{ github.event.repository.default_branch }}
File renamed without changes.
74 changes: 42 additions & 32 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

julia_version = "1.10.5"
manifest_format = "2.0"
project_hash = "c31fe08d86ec107a97ce2f38a0768055cf0cb993"
project_hash = "dc71554e00e1c1774b67892932418d9d6263c240"

[[deps.ADTypes]]
git-tree-sha1 = "99a6f5d0ce1c7c6afdb759daa30226f71c54f6b0"
git-tree-sha1 = "5a5eafb8344b81b8c2237f8a6f6b3602b3f6180e"
uuid = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
version = "1.7.1"
version = "1.8.1"
weakdeps = ["ChainRulesCore", "EnzymeCore"]

[deps.ADTypes.extensions]
Expand All @@ -20,24 +20,28 @@ uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
version = "0.4.5"

[[deps.Accessors]]
deps = ["CompositionsBase", "ConstructionBase", "Dates", "InverseFunctions", "LinearAlgebra", "MacroTools", "Markdown", "Test"]
git-tree-sha1 = "f61b15be1d76846c0ce31d3fcfac5380ae53db6a"
deps = ["CompositionsBase", "ConstructionBase", "InverseFunctions", "LinearAlgebra", "MacroTools", "Markdown"]
git-tree-sha1 = "b392ede862e506d451fc1616e79aa6f4c673dab8"
uuid = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
version = "0.1.37"
version = "0.1.38"

[deps.Accessors.extensions]
AccessorsAxisKeysExt = "AxisKeys"
AccessorsDatesExt = "Dates"
AccessorsIntervalSetsExt = "IntervalSets"
AccessorsStaticArraysExt = "StaticArrays"
AccessorsStructArraysExt = "StructArrays"
AccessorsTestExt = "Test"
AccessorsUnitfulExt = "Unitful"

[deps.Accessors.weakdeps]
AxisKeys = "94b1ba4f-4ee9-5380-92f1-94cde586c3c5"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[[deps.Adapt]]
Expand Down Expand Up @@ -130,9 +134,9 @@ version = "0.1.6"

[[deps.BlockArrays]]
deps = ["ArrayLayouts", "FillArrays", "LinearAlgebra"]
git-tree-sha1 = "5c0ffe1dff8cb7112de075f1b1cb32191675fcba"
git-tree-sha1 = "d434647f798823bcae510aee0bc0401927f64391"
uuid = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
version = "1.1.0"
version = "1.1.1"

[deps.BlockArrays.extensions]
BlockArraysBandedMatricesExt = "BandedMatrices"
Expand Down Expand Up @@ -166,9 +170,9 @@ version = "1.18.0+2"

[[deps.ChainRulesCore]]
deps = ["Compat", "LinearAlgebra"]
git-tree-sha1 = "71acdbf594aab5bbb2cec89b208c41b4c411e49f"
git-tree-sha1 = "3e4b134270b372f2ed4d4d0e936aabaefc1802bc"
uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
version = "1.24.0"
version = "1.25.0"
weakdeps = ["SparseArrays"]

[deps.ChainRulesCore.extensions]
Expand Down Expand Up @@ -342,9 +346,9 @@ version = "1.9.1"

[[deps.DiffEqBase]]
deps = ["ArrayInterface", "ConcreteStructs", "DataStructures", "DocStringExtensions", "EnumX", "EnzymeCore", "FastBroadcast", "FastClosures", "ForwardDiff", "FunctionWrappers", "FunctionWrappersWrappers", "LinearAlgebra", "Logging", "Markdown", "MuladdMacro", "Parameters", "PreallocationTools", "PrecompileTools", "Printf", "RecursiveArrayTools", "Reexport", "SciMLBase", "SciMLOperators", "SciMLStructures", "Setfield", "Static", "StaticArraysCore", "Statistics", "Tricks", "TruncatedStacktraces"]
git-tree-sha1 = "d7d43a1cc11dc4e4e5378816ae720fccd75a77c8"
git-tree-sha1 = "fa7d580038451a8df4434ef5b079ac9b2d486194"
uuid = "2b5f629d-d688-5b77-993f-72d75c75574e"
version = "6.155.0"
version = "6.155.1"

[deps.DiffEqBase.extensions]
DiffEqBaseCUDAExt = "CUDA"
Expand Down Expand Up @@ -904,9 +908,9 @@ version = "3.0.0+1"

[[deps.LLVMOpenMP_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "e16271d212accd09d52ee0ae98956b8a05c4b626"
git-tree-sha1 = "78211fb6cbc872f77cad3fc0b6cf647d923f4929"
uuid = "1d63c593-3942-5779-bab2-d838dc0a180e"
version = "17.0.6+0"
version = "18.1.7+0"

[[deps.LZO_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
Expand Down Expand Up @@ -1189,9 +1193,9 @@ uuid = "a63ad114-7e13-5084-954f-fe012c677804"

[[deps.ModelingToolkit]]
deps = ["AbstractTrees", "ArrayInterface", "BlockArrays", "Combinatorics", "Compat", "ConstructionBase", "DataStructures", "DiffEqBase", "DiffEqCallbacks", "DiffEqNoiseProcess", "DiffRules", "Distributed", "Distributions", "DocStringExtensions", "DomainSets", "DynamicQuantities", "ExprTools", "Expronicon", "FindFirstFunctions", "ForwardDiff", "FunctionWrappersWrappers", "Graphs", "InteractiveUtils", "JuliaFormatter", "JumpProcesses", "Latexify", "Libdl", "LinearAlgebra", "MLStyle", "NaNMath", "NonlinearSolve", "OrderedCollections", "PrecompileTools", "RecursiveArrayTools", "Reexport", "RuntimeGeneratedFunctions", "SciMLBase", "SciMLStructures", "Serialization", "Setfield", "SimpleNonlinearSolve", "SparseArrays", "SpecialFunctions", "StaticArrays", "SymbolicIndexingInterface", "SymbolicUtils", "Symbolics", "URIs", "UnPack", "Unitful"]
git-tree-sha1 = "bc5164aa274590945239c84b198fd5ce475a4772"
git-tree-sha1 = "1f63c7127bbabf22c58edc85dac72afa28fce375"
uuid = "961ee093-0014-501f-94e3-6117800e7a78"
version = "9.39.1"
version = "9.40.0"

[deps.ModelingToolkit.extensions]
MTKBifurcationKitExt = "BifurcationKit"
Expand Down Expand Up @@ -1671,6 +1675,12 @@ version = "0.5.6"
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[[deps.ProgressLogging]]
deps = ["Logging", "SHA", "UUIDs"]
git-tree-sha1 = "80d919dee55b9c50e8d9e2da5eeafff3fe58b539"
uuid = "33c8b6b6-d38a-422a-b730-caa89a2f386c"
version = "0.1.4"

[[deps.PtrArrays]]
git-tree-sha1 = "77a42d78b6a92df47ab37e177b2deac405e1c88f"
uuid = "43287f4e-b6f4-7ad1-bb20-aadabca52c3d"
Expand Down Expand Up @@ -1702,9 +1712,9 @@ version = "6.7.1+1"

[[deps.QuadGK]]
deps = ["DataStructures", "LinearAlgebra"]
git-tree-sha1 = "1d587203cf851a51bf1ea31ad7ff89eff8d625ea"
git-tree-sha1 = "cda3b045cf9ef07a08ad46731f5a3165e56cf3da"
uuid = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
version = "2.11.0"
version = "2.11.1"

[deps.QuadGK.extensions]
QuadGKEnzymeExt = "Enzyme"
Expand Down Expand Up @@ -1801,15 +1811,15 @@ version = "1.1.1"

[[deps.Rmath]]
deps = ["Random", "Rmath_jll"]
git-tree-sha1 = "f65dcb5fa46aee0cf9ed6274ccbd597adc49aa7b"
git-tree-sha1 = "852bd0f55565a9e973fcfee83a84413270224dc4"
uuid = "79098fc4-a85e-5d69-aa6a-4863f24498fa"
version = "0.7.1"
version = "0.8.0"

[[deps.Rmath_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "e60724fd3beea548353984dc61c943ecddb0e29a"
git-tree-sha1 = "58cdd8fb2201a6267e1db87ff148dd6c1dbd8ad8"
uuid = "f50d1b31-88e8-58de-be2c-1cc44531875f"
version = "0.4.3+0"
version = "0.5.1+0"

[[deps.RuntimeGeneratedFunctions]]
deps = ["ExprTools", "SHA", "Serialization"]
Expand All @@ -1834,9 +1844,9 @@ version = "0.6.43"

[[deps.SciMLBase]]
deps = ["ADTypes", "Accessors", "ArrayInterface", "CommonSolve", "ConstructionBase", "Distributed", "DocStringExtensions", "EnumX", "Expronicon", "FunctionWrappersWrappers", "IteratorInterfaceExtensions", "LinearAlgebra", "Logging", "Markdown", "PrecompileTools", "Preferences", "Printf", "RecipesBase", "RecursiveArrayTools", "Reexport", "RuntimeGeneratedFunctions", "SciMLOperators", "SciMLStructures", "StaticArraysCore", "Statistics", "SymbolicIndexingInterface", "Tables"]
git-tree-sha1 = "952e09c65264fe2a8155dd6aad60c188a0b83f69"
git-tree-sha1 = "c96f81c3e98d5e2f0848fb42aba4383d772c3bb7"
uuid = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
version = "2.53.0"
version = "2.53.1"

[deps.SciMLBase.extensions]
SciMLBaseChainRulesCoreExt = "ChainRulesCore"
Expand Down Expand Up @@ -1906,9 +1916,9 @@ version = "1.1.0"

[[deps.SimpleNonlinearSolve]]
deps = ["ADTypes", "ArrayInterface", "ConcreteStructs", "DiffEqBase", "DiffResults", "DifferentiationInterface", "FastClosures", "FiniteDiff", "ForwardDiff", "LinearAlgebra", "MaybeInplace", "PrecompileTools", "Reexport", "SciMLBase", "Setfield", "StaticArraysCore"]
git-tree-sha1 = "4d7a7c177bcb4c6dc465f09db91bfdb28c578919"
git-tree-sha1 = "536c0ee0b4b766ddee24220c6bb60932df4e2c39"
uuid = "727e6d20-b764-4bd8-a329-72de5adea6c7"
version = "1.12.0"
version = "1.12.1"

[deps.SimpleNonlinearSolve.extensions]
SimpleNonlinearSolveChainRulesCoreExt = "ChainRulesCore"
Expand Down Expand Up @@ -2041,9 +2051,9 @@ version = "0.34.3"

[[deps.StatsFuns]]
deps = ["HypergeometricFunctions", "IrrationalConstants", "LogExpFunctions", "Reexport", "Rmath", "SpecialFunctions"]
git-tree-sha1 = "cef0472124fab0695b58ca35a77c6fb942fdab8a"
git-tree-sha1 = "b423576adc27097764a90e163157bcfc9acf0f46"
uuid = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
version = "1.3.1"
version = "1.3.2"
weakdeps = ["ChainRulesCore", "InverseFunctions"]

[deps.StatsFuns.extensions]
Expand Down Expand Up @@ -2079,9 +2089,9 @@ version = "0.2.2"

[[deps.SymbolicUtils]]
deps = ["AbstractTrees", "ArrayInterface", "Bijections", "ChainRulesCore", "Combinatorics", "ConstructionBase", "DataStructures", "DocStringExtensions", "DynamicPolynomials", "IfElse", "LinearAlgebra", "MultivariatePolynomials", "NaNMath", "Setfield", "SparseArrays", "SpecialFunctions", "StaticArrays", "SymbolicIndexingInterface", "TermInterface", "TimerOutputs", "Unityper"]
git-tree-sha1 = "9d983078d9e99421fcca44c373e4304b8421fdde"
git-tree-sha1 = "3927e02dc7648a45ec6aa592bcd8374094a44740"
uuid = "d1185830-fcd6-423d-90d6-eec64667417b"
version = "3.6.0"
version = "3.7.1"

[deps.SymbolicUtils.extensions]
SymbolicUtilsLabelledArraysExt = "LabelledArrays"
Expand All @@ -2093,9 +2103,9 @@ version = "3.6.0"

[[deps.Symbolics]]
deps = ["ADTypes", "ArrayInterface", "Bijections", "CommonWorldInvalidations", "ConstructionBase", "DataStructures", "DiffRules", "Distributions", "DocStringExtensions", "DomainSets", "DynamicPolynomials", "IfElse", "LaTeXStrings", "LambertW", "Latexify", "Libdl", "LinearAlgebra", "LogExpFunctions", "MacroTools", "Markdown", "NaNMath", "PrecompileTools", "Primes", "RecipesBase", "Reexport", "RuntimeGeneratedFunctions", "SciMLBase", "Setfield", "SparseArrays", "SpecialFunctions", "StaticArraysCore", "SymbolicIndexingInterface", "SymbolicLimits", "SymbolicUtils", "TermInterface"]
git-tree-sha1 = "2226d810512c678d2ec9c2a9b2e227c2ebc43573"
git-tree-sha1 = "8b48697e7fec6d4b7c4a9fe892857a5ed2bae7e8"
uuid = "0c5d862f-8b57-4792-8d23-62f2024744c7"
version = "6.11.0"
version = "6.12.0"

[deps.Symbolics.extensions]
SymbolicsForwardDiffExt = "ForwardDiff"
Expand Down
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name = "CaMKIIModel"
uuid = "268d5184-1524-48b5-bbe3-a3af95dac460"
authors = ["Wen-Wei Tseng <[email protected]>"]
version = "0.2.0"
version = "0.3.0"

[deps]
DiffEqCallbacks = "459566f4-90b8-5000-8ac3-15dfb0a30def"
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
ProgressLogging = "33c8b6b6-d38a-422a-b730-caa89a2f386c"
2 changes: 1 addition & 1 deletion docs/camkii_calwave.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using CaMKIIModel: get_camkii_sys, μM, nM, second
@parameters ROS=0μM period=1/3 ca_r=100nM ca_rise=550nM tstart=200.0second tend=300.0second
@independent_variables t
@variables Ca(t)
sys = get_camkii_sys(;Ca, ROS)
sys = get_camkii_sys(Ca;ROS)

# Periodic assymetric calcium pulses
function ca_wave(t;
Expand Down
2 changes: 1 addition & 1 deletion docs/camkii_ros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ end
@independent_variables t
@variables Ca(t)
casys = ca_decay_sys()
sys = get_camkii_sys(;Ca, ROS)
sys = get_camkii_sys(Ca; ROS)
sys = extend(casys, sys)
sys = structural_simplify(sys)
unknowns(sys)
Expand Down
5 changes: 1 addition & 4 deletions run.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ using IJulia
@everywhere begin
ENV["GKSwstype"] = "100"
using Literate, Pkg, JSON
Pkg.activate(Base.current_project())
end

# Strip SVG output from a Jupyter notebook
Expand Down Expand Up @@ -100,9 +99,7 @@ function main(;
ts_lit = pmap(litnbs; on_error=ex -> NaN) do nb
@elapsed run_literate(nb, cachedir; rmsvg)
end

# Remove worker processes to release some memory
rmprocs(workers())
rmprocs(workers()) # Remove worker processes to release some memory

# Debug notebooks one by one if there are errors
for (nb, t) in zip(litnbs, ts_lit)
Expand Down
4 changes: 3 additions & 1 deletion src/CaMKIIModel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ module CaMKIIModel
using ModelingToolkit
using ModelingToolkit: t_nounits as t, D_nounits as D
using NaNMath
using OrdinaryDiffEq
using DiffEqCallbacks

export get_camkii_sys, get_bar_sys, build_neonatal_ecc_sys
export get_camkii_sys, get_bar_sys, build_neonatal_ecc_sys, build_stim_callbacks

include("utils.jl")
include("camkii_ros.jl")
Expand Down
5 changes: 2 additions & 3 deletions src/camkii_ros.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CaMKII system with ROS activation
function get_camkii_sys(;
Ca=0μM, ROS=0μM,
function get_camkii_sys(Ca=0μM;
ROS=0μM,
binding_To_PCaMK=0.1,
decay_CaM=3,
phospho_rate=1Hz,
Expand Down Expand Up @@ -92,7 +92,6 @@ function get_camkii_sys(;
CAM_T ~ CaM0 + Ca2CaM_C + Ca2CaM_N + Ca4CaM + CaM0_CaMK + Ca2CaM_C_CaMK + Ca2CaM_N_CaMK + Ca4CaM_CaMK + CaM0_CaMKP + Ca2CaM_C_CaMKP + Ca2CaM_N_CaMKP + Ca4CaM_CaMKP + Ca4CaM_CaMKOX + Ca4CaM_CaMKPOX,
]

Num(0)
rates = merge(Dict(sts .=> Num(0)), Dict(conservedvars .=> Num(0)))

# Observables
Expand Down
Loading

0 comments on commit 3d8865f

Please sign in to comment.