% Software implementation of the Simone_Trancuccio2025 model of the action potential 
% of human induced pluripotent stem cell-derived cardiomyocytes.
%
% This software is provided for NON-COMMERCIAL USE ONLY
%
% The Simone_Trancuccio2025 model is described in the article 
% "A Novel Computational Model of Human iPSC-Derived Ventricular Myocytes with
% Improved L-Type Calcium Current for Application to Timothy Syndrome"
% Francesca Simone, Alessandro Trancuccio, Jaroslaw Karol Sochacki, Celia
% Martinez Prieto, Silvia G. Priori, Luca F. Pavarino, and Demetrio J.
% Santiago.
%
% Please cite the above paper when using this model.
% 
% Email: francesca.simone01@universitadipavia.it / alessandro.trancuccio@gmail.com 

clc, clear, close all

options = odeset('RelTol',1e-10,'AbsTol',1e-11,'MaxStep',0.5);  % options for ode solver

% initial conditions of WT cell at steady state when cell beating spontaneously
X0=[-0.065642985879806437 0.17821569653138702 1.4566184771254109E-5 ...
       0 6.5556281932222E-5 0.33074339319138579 0.059425007489853521 0.18877505885888735 ...
       0.07627448447095 0.048944005104246784 0.29570305672505981 0.016554168834145525 ...
       0.73968455226231711 0.10417660664174874 0.39033861625171062 0.053215701505770076 ...
       0.47649348170842903 0.53768731112443835 0.0847876177017315 0.11061207101147875 ...
       0.73593493640461527 0.00903869987310981 6.2114113476440238 0.012992457261204014 ...
       0.071763383765060126 0.030804685840789266 0.00018558188518140575 ...
       0.84248226973593832 3.0559890049318125E-5 0.1057093597332886 0.044502875515751814 ...
       0.428766220682904 0.075361563406389512 0.04064523191526985 0.30491525263163954 ...
       0.016554168834145525 0.73968455226231711];
% simulation duration
T=100;
% stimFalg = 0 => spontaneous activity
% stimFalg = 1 => spontaneous activity
stimFlag = 0;
i_stim_frequency = 0; 
model=@Simone_Trancuccio2025;
% Percentage of channels affected by the mutation
% fractional_TS = 0 => Wild-type model
% fractional_TS = 0.22 => Timothy Syndrome model
fractional_TS=0;
[time, Y]=ode15s(model,[0 T],X0,options, stimFlag, 1,i_stim_frequency,fractional_TS);
V=Y(:,1)*1000; 

figure(1)
plot(time*1000,V)
xlabel('time [ms]')
ylabel('V_m [mV]')