%     Cardiac model ToR-ORd
%     Copyright (C) 2019 Jakub Tomek. Contact: jakub.tomek.mff@gmail.com
% 
%     This program is free software: you can redistribute it and/or modify
%     it under the terms of the GNU General Public License as published by
%     the Free Software Foundation, either version 3 of the License, or
%     (at your option) any later version.
% 
%     This program is distributed in the hope that it will be useful,
%     but WITHOUT ANY WARRANTY; without even the implied warranty of
%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%     GNU General Public License for more details.
% 
%     You should have received a copy of the GNU General Public License
%     along with this program.  If not, see <https://www.gnu.org/licenses/>.


function X0 = getStartingState(modelCode)
% A function returning initial state for various models. Currently only 3
% variants are present, for endo/epi/midmyocardial ToR-ORd, but futher ones
% may be added

%% Baseline ToR-ORd
if (strcmp(modelCode, 'Torord_endo'))
    X0=[-88.8691566357934,12.0996647655188,12.1000028563765,142.412524737626,142.412481425842,7.45541572746214e-05,6.50418928341426e-05,1.53037019085812,1.52803094224238,0.000787657400526199,0.674096901201792,0.830658198588696,0.830466744399495,0.830093612199637,0.000159670117055769,0.528261721740178,0.288775833197764,0.000944249645410894,0.999616956857814,0.593680589620082,0.000481107253796778,0.999616964658062,0.654092074678260,8.86091322819384e-29,0.999999992783113,0.938965241412012,0.999999992783179,0.999900458262832,0.999977476316330,0.000492094765239740,0.000833711885764158,0.999999992566681,0.999999992766279,0.247156543918935,0.000175017075236424,3.90843796133124e-24,0.0110752904836162,0.998073652444028,0.000844745297078649,0.000698171876592920,0.000370404872169913,1.30239063420973e-05,-1.88428892080206e-22];
end

if (strcmp(modelCode, 'Torord_epi'))
    X0=[-89.0154768721342,12.8382605269815,12.8386296068886,142.460122044002,142.460073757800,7.44971662963012e-05,6.38115248479545e-05,1.83376662673169,1.83451041520486,0.000763228908104755,0.678841695234194,0.833544909403616,0.833497781389367,0.833311768661844,0.000155293652653466,0.536468471494865,0.300980562176301,0.000934977025106033,0.999626696605431,0.999623652971323,0.000476380566651530,0.999626696659922,0.999626199062997,3.44090020293841e-37,0.999999993064605,0.948443428743038,0.999999993064610,0.999933400688481,0.999981769973542,0.000456804180120420,0.000830893014440888,0.999999993064818,0.999999993064276,0.232708882444918,0.000172120093619941,4.14953854790051e-24,0.0129726050063671,0.998185994327463,0.000836058850210933,0.000685608512717355,0.000282493081467249,9.84492151787658e-06,1.70514183624061e-22]';
end
if (strcmp(modelCode, 'Torord_mid'))
    X0=[-88.9590090659588,14.9968170642505,14.9974341914714,142.625375608671,142.625316420398,9.17163015407947e-05,7.25139659488411e-05,1.94322774406231,1.95039622434061,0.000772566809118471,0.677013343047248,0.832434326858963,0.832290316009961,0.831808572855801,0.000156968260425169,0.527174936474434,0.280556044033432,0.000938545400571819,0.999622955471138,0.568989935607894,0.000478199529001736,0.999622960224351,0.627685396742549,5.59921706285619e-28,0.999999992950244,0.921126200688429,0.999999992957103,0.999799367958552,0.999967255695472,0.000748915074620697,0.00184513039130798,0.999999992835124,0.999999992956490,0.264964501338528,0.000173243302385262,2.12311882737393e-20,0.0187898657397651,0.997900476271853,0.000839251201866205,0.000704846358850060,0.000536619999494324,1.88036392748250e-05,9.41901389088170e-19]';
end

%% steady-state dynamic Cl
if (strcmp(modelCode, 'Torord_endo_dynCl'))
    X0=[-89.7480828168753	12.3973564703237	12.3976953330256	147.711474407329	147.711433360862	7.45348093580908e-05	6.49734059262396e-05	1.52800059077496	1.52569253436820	0.000651715361520436	0.701845427662345	0.847326693399099	0.847165668535608	0.846901438940383	0.000135120261194560	0.556601650459093	0.311549070692613	0.000889925901945137	0.999671576537361	0.598890849399207	0.000453416519958675	0.999671583620741	0.662069197871101	1.58884121071311e-31	0.999999994310640	0.940179072110115	0.999999994310551	0.999901376748386	0.999984619576572	0.000489937844976504	0.000832600925714172	0.999999994343118	0.999999994312043	0.243959016060676	0.000158616694622612	1.80824774078763e-22	0.0109502564192484	0.998251134783098	0.000793602046257213	0.000653214338491609	0.000292244895058368	9.80408293117642e-06	4.35860784390795e-21	29.2069793887423	29.2069557375901];
end

if (strcmp(modelCode, 'Torord_epi_dynCl'))
    X0=[-90.7456332496277	13.4006197127101	13.4009366375605	152.363889991411	152.363844281265	6.62181569329109e-05	5.74992101186664e-05	1.80679354108253	1.80504703846161	0.000525323142244124	0.731365613931879	0.864514804478946	0.864457115015362	0.864352715733040	0.000111796946200753	0.591653600903076	0.347681236790268	0.000832040787904695	0.999724237643709	0.999723490323258	0.000423912054921203	0.999724237767365	0.999724054768924	-2.48652723154831e-36	0.999999995656968	0.951060213798798	0.999999995656976	0.999937692440505	0.999988620215189	0.000304952292598877	0.000527266836293694	0.999999995656685	0.999999995656399	0.223358448594285	0.000141824743798310	6.77882673136480e-25	0.0127354136594547	0.998473340797544	0.000739304520671507	0.000602907876760312	0.000178778329437106	5.67825481839631e-06	-1.58194108230975e-23	34.3172099045416	34.3171879616709];
end


if (strcmp(modelCode, 'Torord_mid_dynCl'))
    X0=[-91.3391803967798	15.9486733631902	15.9492201219199	156.713067183465	156.713012917889	8.29757614119249e-05	6.64218738239930e-05	2.01222465016069	2.01641461550468	0.000461956534829239	0.747897241513971	0.873907657623256	0.873784149746068	0.873537507470071	9.98770874860868e-05	0.598611759466370	0.333989914508018	0.000799404188333773	0.999751418648699	0.570253781914665	0.000407277681198651	0.999751424044492	0.635192659820007	-8.33460419955820e-30	0.999999996299523	0.918358695116332	0.999999996300839	0.999754043234341	0.999974289100453	0.000533651965198686	0.00125786136830066	0.999999996207845	0.999999996298728	0.264229298875232	0.000132734770983313	-1.30048587380675e-21	0.0201882046405105	0.998345129712001	0.000708645966770289	0.000591004733696651	0.000344573276330018	1.06423014130810e-05	-7.61071425848620e-20	48.9127681450109	48.9127355777872];
end

end