/*
 * This code is generated by BioUML FrameWork 
 * for BIOMD0000000028.xml diagram  at 2008.03.20 15:04:05
 */
import biouml.plugins.simulation.ae.NewtonSolver;
import biouml.plugins.simulation.java.JavaBaseModel;
import ru.biosoft.math.MathRoutines;

public class BIOMD0000000028 extends JavaBaseModel
{

/*
 * Write rules to calculate equation parameters
 */


/*
 * Write rules to calculate equation parameters excluding internal variables.
 */
    public void __internalRateVarInitFunc_0(double time, double[] x)
    {
        rate_reaction_0000001 = cell*(k1*x[0]*x[1] - k_1*x[4]);
        rate_reaction_0000002 = cell*k2*x[4];
        rate_reaction_0000003 = cell*(k3*x[11]*x[1] - k_3*x[12]);
        rate_reaction_0000004 = cell*k4*x[12];
        rate_reaction_0000005 = cell*(k5*x[0]*x[1] - k_5*x[3]);
        rate_reaction_0000006 = cell*k6*x[3];
        rate_reaction_0000007 = cell*(k7*x[7]*x[1] - k_7*x[8]);
        rate_reaction_0000008 = cell*k8*x[8];
        rate_reaction_0000009 = cell*(h1*x[14]*x[2] - h_1*x[15]);
        rate_reaction_0000010 = cell*h2*x[15];
        rate_reaction_0000011 = cell*(h3*x[10] - h_3*x[7]*x[2]);
        rate_reaction_0000012 = cell*h5*x[9];
        rate_reaction_0000013 = cell*(h4*x[7]*x[2] - h_4*x[9]);
        rate_reaction_0000014 = cell*h8*x[13];
        rate_reaction_0000015 = cell*(h6*x[5] - h_6*x[0]*x[2]);
        rate_reaction_0000017 = cell*(h7*x[11]*x[2] - h_7*x[13]);
        rate_reaction_0000019 = cell*(h9*x[6] - h_9*x[0]*x[2]);
    }

    public void Init()
    {
        initialValues = getInitialValues();
/*
 * Initialize variables
 */
        cell = 1.0; // initial value of $cell
        h1 = 0.045; // initial value of h1
        h2 = 0.092; // initial value of h2
        h3 = 1.0; // initial value of h3
        h4 = 0.01; // initial value of h4
        h5 = 0.5; // initial value of h5
        h6 = 0.086; // initial value of h6
        h7 = 0.01; // initial value of h7
        h8 = 0.47; // initial value of h8
        h9 = 0.14; // initial value of h9
        h_1 = 1.0; // initial value of h_1
        h_3 = 0.01; // initial value of h_3
        h_4 = 1.0; // initial value of h_4
        h_6 = 0.0011; // initial value of h_6
        h_7 = 1.0; // initial value of h_7
        h_9 = 0.0018; // initial value of h_9
        k1 = 0.0050; // initial value of k1
        k2 = 1.08; // initial value of k2
        k3 = 0.025; // initial value of k3
        k4 = 0.0070; // initial value of k4
        k5 = 0.05; // initial value of k5
        k6 = 0.0080; // initial value of k6
        k7 = 0.0050; // initial value of k7
        k8 = 0.45; // initial value of k8
        k_1 = 1.0; // initial value of k_1
        k_3 = 1.0; // initial value of k_3
        k_5 = 1.0; // initial value of k_5
        k_7 = 1.0; // initial value of k_7
    }

    /*
     * Model variables initial values
     */
    protected double rate_reaction_0000001;
    protected double rate_reaction_0000002;
    protected double rate_reaction_0000003;
    protected double rate_reaction_0000004;
    protected double rate_reaction_0000005;
    protected double rate_reaction_0000006;
    protected double rate_reaction_0000007;
    protected double rate_reaction_0000008;
    protected double rate_reaction_0000009;
    protected double rate_reaction_0000010;
    protected double rate_reaction_0000011;
    protected double rate_reaction_0000012;
    protected double rate_reaction_0000013;
    protected double rate_reaction_0000014;
    protected double rate_reaction_0000015;
    protected double rate_reaction_0000017;
    protected double rate_reaction_0000019;
    protected double cell;
    protected double h1;
    protected double h2;
    protected double h3;
    protected double h4;
    protected double h5;
    protected double h6;
    protected double h7;
    protected double h8;
    protected double h9;
    protected double h_1;
    protected double h_3;
    protected double h_4;
    protected double h_6;
    protected double h_7;
    protected double h_9;
    protected double k1;
    protected double k2;
    protected double k3;
    protected double k4;
    protected double k5;
    protected double k6;
    protected double k7;
    protected double k8;
    protected double k_1;
    protected double k_3;
    protected double k_5;
    protected double k_7;

    public double[] extendResult(double time,double [] x)
    {
        this.time = time;


        double[] y = new double[16];
        y[0] = x[0];
        y[1] = x[1];
        y[2] = x[2];
        y[3] = x[3];
        y[4] = x[4];
        y[5] = x[5];
        y[6] = x[6];
        y[7] = x[7];
        y[8] = x[8];
        y[9] = x[9];
        y[10] = x[10];
        y[11] = x[11];
        y[12] = x[12];
        y[13] = x[13];
        y[14] = x[14];
        y[15] = x[15];
        return y;
    }
    public double[] getInitialValues()
    {
        double [] x = new double[16];
        this.time = 0.0;
        x[0] = 800.0; // - $"cell.M"
        x[1] = 180.0; // - $"cell.MEK"
        x[2] = 100.0; // - $"cell.MKP3"
        x[3] = 0.0; // - $"cell.M_MEK_T"
        x[4] = 0.0; // - $"cell.M_MEK_Y"
        x[5] = 0.0; // - $"cell.M_MKP3_T"
        x[6] = 0.0; // - $"cell.M_MKP3_Y"
        x[7] = 0.0; // - $"cell.MpT"
        x[8] = 0.0; // - $"cell.MpT_MEK"
        x[9] = 0.0; // - $"cell.MpT_MKP3_T"
        x[10] = 0.0; // - $"cell.MpT_MKP3_Y"
        x[11] = 0.0; // - $"cell.MpY"
        x[12] = 0.0; // - $"cell.MpY_MEK"
        x[13] = 0.0; // - $"cell.MpY_MKP3"
        x[14] = 0.0; // - $"cell.Mpp"
        x[15] = 0.0; // - $"cell.Mpp_MKP3"

        __internalRateVarInitFunc_0(time, x);

        return x;
    }

/*
 * code for algebraic rules calculations
 */

/*
 * end of code for algebraic rules calculations
 */

    protected void calculateRates(double time, double[] x)
    {

        __internalRateVarInitFunc_0(time, x);

    }

        /*
         * calculate dy/dt for 'BIOMD0000000028.xml' model
         */
    public void __internalDyDt_0(double time, double [] x, double[] result)
    {
        result[0] = -rate_reaction_0000001-rate_reaction_0000005+rate_reaction_0000015+rate_reaction_0000019;
        result[1] = -rate_reaction_0000001+rate_reaction_0000002-rate_reaction_0000003+rate_reaction_0000004-rate_reaction_0000005+rate_reaction_0000006-rate_reaction_0000007+rate_reaction_0000008;
        result[2] = -rate_reaction_0000009+rate_reaction_0000011-rate_reaction_0000013+rate_reaction_0000015-rate_reaction_0000017+rate_reaction_0000019;
        result[3] = +rate_reaction_0000005-rate_reaction_0000006;
        result[4] = +rate_reaction_0000001-rate_reaction_0000002;
        result[5] = +rate_reaction_0000012-rate_reaction_0000015;
        result[6] = +rate_reaction_0000014-rate_reaction_0000019;
        result[7] = +rate_reaction_0000006-rate_reaction_0000007+rate_reaction_0000011-rate_reaction_0000013;
        result[8] = +rate_reaction_0000007-rate_reaction_0000008;
        result[9] = -rate_reaction_0000012+rate_reaction_0000013;
        result[10] = +rate_reaction_0000010-rate_reaction_0000011;
        result[11] = +rate_reaction_0000002-rate_reaction_0000003-rate_reaction_0000017;
        result[12] = +rate_reaction_0000003-rate_reaction_0000004;
        result[13] = -rate_reaction_0000014+rate_reaction_0000017;
        result[14] = +rate_reaction_0000004+rate_reaction_0000008-rate_reaction_0000009;
        result[15] = +rate_reaction_0000009-rate_reaction_0000010;
    }
    protected double [] calculateResult(double time, double[] x)
    {
        double[] result = new double[16];
        __internalDyDt_0(time, x, result);
        return result;
    }
    public double[] dy_dt(double time, double[] x)
    {
        this.time = time;
        calculateRates( time,x );

        return calculateResult( time,x );
    }

} // class ...