<?xml version='1.0' encoding='UTF-8'?>
<!-- TODO read mahajan paper and find out which one this is.-->
<model name="kr_channel" xmlns="http://www.cellml.org/cellml/1.1#" xmlns:cellml="http://www.cellml.org/cellml/1.1#" xmlns:xlink="http://www.w3.org/1999/xlink">
    <import xlink:href="../../units.cellml">
        <units name="ms" units_ref="ms"/>
        <units name="per_ms" units_ref="per_ms"/>
        <units name="mV" units_ref="mV"/>
        <units name="per_mV" units_ref="per_mV"/>
        <units name="uS_per_nF" units_ref="uS_per_nF"/>
        <units name="nA_per_nF" units_ref="nA_per_nF"/>
    </import>
    <component name="IKr">
        <variable name="V" public_interface="in" units="mV"/>
        <variable name="ek" public_interface="in" units="mV"/>
        <variable name="time" public_interface="in" units="ms"/>
        <variable name="K_o" public_interface="in" units="mM"/>
        <variable initial_value="0.007074239331" name="xr" units="dimensionless"/>
        <variable initial_value="0.0125" name="gkr" units="uS_per_nF"/>
        <variable name="xkrv1" units="per_ms"/>
        <variable name="xkrv2" units="per_ms"/>
        <variable name="taukr" units="ms"/>
        <variable name="xkrinf" units="dimensionless"/>
        <variable name="rg" units="dimensionless"/>
        <variable name="xikr" public_interface="out" units="nA_per_nF"/>
        <math xmlns="http://www.w3.org/1998/Math/MathML">
            <apply>
                <eq/>
                <ci>xkrv1</ci>
                <piecewise>
                    <piece>
                        <apply>
                            <divide/>
                            <apply>
                                <times/>
                                <cn cellml:units="per_ms">0.00138</cn>
                                <cn cellml:units="per_mV">1</cn>
                                <apply>
                                    <plus/>
                                    <ci>V</ci>
                                    <cn cellml:units="mV">7</cn>
                                </apply>
                            </apply>
                            <apply>
                                <minus/>
                                <cn cellml:units="dimensionless">1</cn>
                                <apply>
                                    <exp/>
                                    <apply>
                                        <times/>
                                        <apply>
                                            <minus/>
                                            <cn cellml:units="per_mV">0.123</cn>
                                        </apply>
                                        <apply>
                                            <plus/>
                                            <ci>V</ci>
                                            <cn cellml:units="mV">7</cn>
                                        </apply>
                                    </apply>
                                </apply>
                            </apply>
                        </apply>
                        <apply>
                            <gt/>
                            <apply>
                                <abs/>
                                <apply>
                                    <plus/>
                                    <ci>V</ci>
                                    <cn cellml:units="mV">7</cn>
                                </apply>
                            </apply>
                            <cn cellml:units="mV">0.001</cn>
                        </apply>
                    </piece>
                    <otherwise>
                        <apply>
                            <divide/>
                            <cn cellml:units="per_ms">0.00138</cn>
                            <cn cellml:units="dimensionless">0.123</cn>
                        </apply>
                    </otherwise>
                </piecewise>
            </apply>
            <apply>
                <eq/>
                <ci>xkrv2</ci>
                <piecewise>
                    <piece>
                        <apply>
                            <divide/>
                            <apply>
                                <times/>
                                <cn cellml:units="per_ms">0.00061</cn>
                                <cn cellml:units="per_mV">1</cn>
                                <apply>
                                    <plus/>
                                    <ci>V</ci>
                                    <cn cellml:units="mV">10</cn>
                                </apply>
                            </apply>
                            <apply>
                                <minus/>
                                <apply>
                                    <exp/>
                                    <apply>
                                        <times/>
                                        <cn cellml:units="per_mV">0.145</cn>
                                        <apply>
                                            <plus/>
                                            <ci>V</ci>
                                            <cn cellml:units="mV">10</cn>
                                        </apply>
                                    </apply>
                                </apply>
                                <cn cellml:units="dimensionless">1</cn>
                            </apply>
                        </apply>
                        <apply>
                            <gt/>
                            <apply>
                                <abs/>
                                <apply>
                                    <plus/>
                                    <ci>V</ci>
                                    <cn cellml:units="mV">10</cn>
                                </apply>
                            </apply>
                            <cn cellml:units="mV">0.001</cn>
                        </apply>
                    </piece>
                    <otherwise>
                        <apply>
                            <divide/>
                            <cn cellml:units="per_ms">0.00061</cn>
                            <cn cellml:units="dimensionless">0.145</cn>
                        </apply>
                    </otherwise>
                </piecewise>
            </apply>
            <apply>
                <eq/>
                <ci>taukr</ci>
                <apply>
                    <divide/>
                    <cn cellml:units="dimensionless">1</cn>
                    <apply>
                        <plus/>
                        <ci>xkrv1</ci>
                        <ci>xkrv2</ci>
                    </apply>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>xkrinf</ci>
                <apply>
                    <divide/>
                    <cn cellml:units="dimensionless">1</cn>
                    <apply>
                        <plus/>
                        <cn cellml:units="dimensionless">1</cn>
                        <apply>
                            <exp/>
                            <apply>
                                <divide/>
                                <apply>
                                    <minus/>
                                    <apply>
                                        <plus/>
                                        <ci>V</ci>
                                        <cn cellml:units="mV">50</cn>
                                    </apply>
                                </apply>
                                <cn cellml:units="mV">7.5</cn>
                            </apply>
                        </apply>
                    </apply>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>rg</ci>
                <apply>
                    <divide/>
                    <cn cellml:units="dimensionless">1</cn>
                    <apply>
                        <plus/>
                        <cn cellml:units="dimensionless">1</cn>
                        <apply>
                            <exp/>
                            <apply>
                                <divide/>
                                <apply>
                                    <plus/>
                                    <ci>V</ci>
                                    <cn cellml:units="mV">33</cn>
                                </apply>
                                <cn cellml:units="mV">22.4</cn>
                            </apply>
                        </apply>
                    </apply>
                </apply>
            </apply>
            <apply>
                <eq/>
                <ci>xikr</ci>
                <apply>
                    <times/>
                    <ci>gkr</ci>
                    <apply>
                        <root/>
                        <apply>
                            <divide/>
                            <ci>K_o</ci>
                            <cn cellml:units="mM">5.4</cn>
                        </apply>
                    </apply>
                    <ci>xr</ci>
                    <ci>rg</ci>
                    <apply>
                        <minus/>
                        <ci>V</ci>
                        <ci>ek</ci>
                    </apply>
                </apply>
            </apply>
            <apply>
                <eq/>
                <apply>
                    <diff/>
                    <bvar>
                        <ci>time</ci>
                    </bvar>
                    <ci>xr</ci>
                </apply>
                <apply>
                    <divide/>
                    <apply>
                        <minus/>
                        <ci>xkrinf</ci>
                        <ci>xr</ci>
                    </apply>
                    <ci>taukr</ci>
                </apply>
            </apply>
        </math>
    </component>
</model>
