Initial conditions#
1Hz pacing for 1000 seconds
using ProgressLogging
using OrdinaryDiffEq
using ModelingToolkit
using ECMEDox
using ECMEDox: second, mM, Hz, μM, build_stim_callbacks
using Plots
using DisplayAs: PNG
tend = 1000.0second
bcl = 1.0second
@named sys = build_model(; tend, bcl)
u0 = build_u0(sys)
sts = unknowns(sys)
alg = KenCarp47()
prob = ODEProblem(sys, [u0; sys.KCAT_IDH => 43Hz], tend)
@time sol = solve(prob, alg; reltol=1e-6, abstol=1e-6, progress=true)
for i in sts
istr = replace(string(i), "(t)" => "")
println("sys.", istr, " => ", sol[i][end], ",")
end
┌ Warning: Did not converge after `maxiters = 0` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics ~/.julia/packages/Symbolics/sc64L/src/variable.jl:587
┌ Warning: Did not converge after `maxiters = 0` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics ~/.julia/packages/Symbolics/sc64L/src/variable.jl:587
┌ Warning: Did not converge after `maxiters = 0` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics ~/.julia/packages/Symbolics/sc64L/src/variable.jl:587
┌ Warning: Did not converge after `maxiters = 0` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics ~/.julia/packages/Symbolics/sc64L/src/variable.jl:587
┌ Warning: Did not converge after `maxiters = 0` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics ~/.julia/packages/Symbolics/sc64L/src/variable.jl:587
┌ Warning: Did not converge after `maxiters = 0` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics ~/.julia/packages/Symbolics/sc64L/src/variable.jl:587
┌ Warning: Did not converge after `maxiters = 0` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics ~/.julia/packages/Symbolics/sc64L/src/variable.jl:587
┌ Warning: Did not converge after `maxiters = 0` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics ~/.julia/packages/Symbolics/sc64L/src/variable.jl:587
┌ Warning: Did not converge after `maxiters = 0` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics ~/.julia/packages/Symbolics/sc64L/src/variable.jl:587
┌ Warning: Did not converge after `maxiters = 0` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics ~/.julia/packages/Symbolics/sc64L/src/variable.jl:587
┌ Warning: Did not converge after `maxiters = 0` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics ~/.julia/packages/Symbolics/sc64L/src/variable.jl:587
┌ Warning: Did not converge after `maxiters = 0` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics ~/.julia/packages/Symbolics/sc64L/src/variable.jl:587
┌ Warning: Did not converge after `maxiters = 0` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics ~/.julia/packages/Symbolics/sc64L/src/variable.jl:587
┌ Warning: Did not converge after `maxiters = 0` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics ~/.julia/packages/Symbolics/sc64L/src/variable.jl:587
┌ Warning: Did not converge after `maxiters = 0` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics ~/.julia/packages/Symbolics/sc64L/src/variable.jl:587
┌ Warning: Did not converge after `maxiters = 0` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics ~/.julia/packages/Symbolics/sc64L/src/variable.jl:587
┌ Warning: Did not converge after `maxiters = 0` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics ~/.julia/packages/Symbolics/sc64L/src/variable.jl:587
┌ Warning: Did not converge after `maxiters = 0` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics ~/.julia/packages/Symbolics/sc64L/src/variable.jl:587
┌ Warning: Did not converge after `maxiters = 0` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics ~/.julia/packages/Symbolics/sc64L/src/variable.jl:587
┌ Warning: Did not converge after `maxiters = 0` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics ~/.julia/packages/Symbolics/sc64L/src/variable.jl:587
┌ Warning: Did not converge after `maxiters = 0` substitutions. Either there is a cycle in the rules or `maxiters` needs to be higher.
└ @ Symbolics ~/.julia/packages/Symbolics/sc64L/src/variable.jl:587
14.034833 seconds (20.24 M allocations: 1.107 GiB, 5.06% gc time, 35.12% compilation time)
sys.sox_m => 0.20355755363044453,
sys.dpsi => 162.56305404504826,
sys.nadh_m => 532.1928067833522,
sys.adp_m => 14.943652392910426,
sys.adp_i => 48.6998256190487,
sys.ca_m => 0.9117105630247363,
sys.ca_ss => 0.19408623125273616,
sys.ca_jsr => 1205.7959761526802,
sys.ca_nsr => 1209.9542624577405,
sys.k_i => 144752.08210462655,
sys.na_i => 10193.328860476286,
sys.vm => -85.41068250996697,
sys.x_yca => 0.7248868636478797,
sys.cca4_lcc => 9.345018323619454e-23,
sys.cca3_lcc => 2.995623531784777e-17,
sys.cca2_lcc => 3.601012566483363e-12,
sys.cca1_lcc => 1.9238806071896132e-7,
sys.cca0_lcc => 0.003854435112576801,
sys.o_lcc => 1.4153497837372835e-23,
sys.c4_lcc => 9.433419465001388e-23,
sys.c3_lcc => 1.20959896982097e-16,
sys.c2_lcc => 5.8162706242895474e-11,
sys.c1_lcc => 1.2429833521802319e-5,
sys.pc2_ryr => 0.13850672774872572,
sys.po2_ryr => 2.830676684859129e-9,
sys.po1_ryr => 0.00018442172581905738,
sys.crp_ic => 15105.79590379376,
sys.crp_i => 15178.107140627673,
sys.adp_ic => 49.47175226072855,
sys.x_n1 => 0.019199148280446877,
sys.x_p3 => 0.009804319685619052,
sys.x_p2 => 0.011234186978347067,
sys.x_p1 => 0.005984308990030096,
sys.x_p0 => 0.0067254103820972525,
sys.htr_ca => 137.63560961407194,
sys.ltr_ca => 23.20757022562701,
sys.ca_i => 0.1912378746691127,
sys.x_k => 0.002799279560339928,
sys.j_na => 0.9787481698634661,
sys.h_na => 0.9703497710936465,
sys.m_na => 0.001443205971646537,
sys.oaa => 0.003531073557490484,
sys.mal => 0.16878764215695258,
sys.fum => 13.22862264167596,
sys.suc => 0.796659981313434,
sys.scoa => 0.03936949482006476,
sys.akg => 0.4599996987252416,
sys.isoc => 880.1625905026108,
sys.cytc_ox => 217.65546476857884,
sys.cytc1_ox => 262.9324873517679,
sys.fes_ox => 165.7817431289021,
sys.blo_bhr => 48.994554850646665,
sys.blr_bho => 108.71979566199869,
sys.blo_bho => 163.9764550009693,
sys.QH2_p => 98.3409760135494,
sys.QH2_n => 98.37893647407714,
sys.Q_n => 1834.4356284534251,
sys.SQn => 133.64760812380877,
sys.SQp => 0.723258062293628,
sys.N2r_C1 => 16.995735334707863,
sys.gssg_i => 0.8261756753437012,
sys.h2o2_i => 0.00028910008349311686,
sys.sox_i => 0.00037911856753194793,
plot(sol, idxs=sys.vm, legend=:right, tspan=(900second, 901second)) |> PNG

Citric acid cycle metabolites Dominated by citrate and isocitrate
@unpack cit, isoc, oaa, akg, scoa, suc, fum, mal = sys
plot(sol, idxs=[cit, isoc, oaa, akg, scoa, suc, fum, mal], legend=:right, title="CAC metabolites") |> PNG

Q cycle
@unpack Q_n, SQn, QH2_n, QH2_p, Q_p, SQp, fes_ox, fes_rd, cytc_ox, cytc_rd = sys
pl_q = plot(sol, idxs=[Q_n + Q_p, SQn, QH2_n + QH2_p, SQp], title="Q cycle", legend=:left, xlabel="Time (ms)", ylabel="Conc. (μM)") |> PNG

pl_q = plot(sol, idxs=[fes_ox, fes_rd, cytc_ox, cytc_rd], title="Q cycle (downstream)", legend=:left, xlabel="Time (ms)", ylabel="Conc. (μM)") |> PNG

plot(sol, idxs = [sys.vHresC1, sys.vHresC3, sys.vHresC4], ylims=(0, 3))

plot(sol, idxs = [sys.sox_i, sys.sox_m], tspan=(900e3, 910e3))

ROS
plot(sol, idxs = [sys.vROSIf, sys.vROSIq, sys.vROSC1, sys.vROSC3], tspan=(900e3, 910e3))

O2 Shunt
plot(sol, idxs=100 * sys.vROS / (sys.vO2 + sys.vROS), title="O2 Shunt", tspan=(900e3, 910e3))

plot(sol, idxs = [sys.dpsi], tspan=(900e3, 910e3))

plot(sol, idxs = [sys.vC5], tspan=(900e3, 910e3))

This notebook was generated using Literate.jl.