/*
 * This code is generated by BioUML FrameWork 
 * for BIOMD0000000010.xml diagram  at 2008.03.20 15:03:25
 */
import biouml.plugins.simulation.ae.NewtonSolver;
import biouml.plugins.simulation.java.JavaBaseModel;
import ru.biosoft.math.MathRoutines;

public class BIOMD0000000010 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_J0 = uVol*J0_V1*x[4]/((1 + Math.pow((x[2]/J0_Ki), J0_n))*(J0_K1 + x[4]));
        rate_J1 = uVol*J1_V2*x[5]/(J1_KK2 + x[5]);
        rate_J2 = uVol*J2_k3*x[5]*x[3]/(J2_KK3 + x[3]);
        rate_J3 = uVol*J3_k4*x[5]*x[6]/(J3_KK4 + x[6]);
        rate_J4 = uVol*J4_V5*x[7]/(J4_KK5 + x[7]);
        rate_J5 = uVol*J5_V6*x[6]/(J5_KK6 + x[6]);
        rate_J6 = uVol*J6_k7*x[7]*x[0]/(J6_KK7 + x[0]);
        rate_J7 = uVol*J7_k8*x[7]*x[1]/(J7_KK8 + x[1]);
        rate_J8 = uVol*J8_V9*x[2]/(J8_KK9 + x[2]);
        rate_J9 = uVol*J9_V10*x[1]/(J9_KK10 + x[1]);
    }

    public void Init()
    {
        initialValues = getInitialValues();
/*
 * Initialize variables
 */
        uVol = 1.0; // initial value of $uVol
        J0_K1 = 10.0; // initial value of J0_K1
        J0_Ki = 9.0; // initial value of J0_Ki
        J0_V1 = 2.5; // initial value of J0_V1
        J0_n = 1.0; // initial value of J0_n
        J1_KK2 = 8.0; // initial value of J1_KK2
        J1_V2 = 0.25; // initial value of J1_V2
        J2_KK3 = 15.0; // initial value of J2_KK3
        J2_k3 = 0.025; // initial value of J2_k3
        J3_KK4 = 15.0; // initial value of J3_KK4
        J3_k4 = 0.025; // initial value of J3_k4
        J4_KK5 = 15.0; // initial value of J4_KK5
        J4_V5 = 0.75; // initial value of J4_V5
        J5_KK6 = 15.0; // initial value of J5_KK6
        J5_V6 = 0.75; // initial value of J5_V6
        J6_KK7 = 15.0; // initial value of J6_KK7
        J6_k7 = 0.025; // initial value of J6_k7
        J7_KK8 = 15.0; // initial value of J7_KK8
        J7_k8 = 0.025; // initial value of J7_k8
        J8_KK9 = 15.0; // initial value of J8_KK9
        J8_V9 = 0.5; // initial value of J8_V9
        J9_KK10 = 15.0; // initial value of J9_KK10
        J9_V10 = 0.5; // initial value of J9_V10
    }

    /*
     * Model variables initial values
     */
    protected double rate_J0;
    protected double rate_J1;
    protected double rate_J2;
    protected double rate_J3;
    protected double rate_J4;
    protected double rate_J5;
    protected double rate_J6;
    protected double rate_J7;
    protected double rate_J8;
    protected double rate_J9;
    protected double uVol;
    protected double J0_K1;
    protected double J0_Ki;
    protected double J0_V1;
    protected double J0_n;
    protected double J1_KK2;
    protected double J1_V2;
    protected double J2_KK3;
    protected double J2_k3;
    protected double J3_KK4;
    protected double J3_k4;
    protected double J4_KK5;
    protected double J4_V5;
    protected double J5_KK6;
    protected double J5_V6;
    protected double J6_KK7;
    protected double J6_k7;
    protected double J7_KK8;
    protected double J7_k8;
    protected double J8_KK9;
    protected double J8_V9;
    protected double J9_KK10;
    protected double J9_V10;

    public double[] extendResult(double time,double [] x)
    {
        this.time = time;


        double[] y = new double[8];
        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];
        return y;
    }
    public double[] getInitialValues()
    {
        double [] x = new double[8];
        this.time = 0.0;
        x[0] = 280.0; // - $"uVol.MAPK"
        x[1] = 10.0; // - $"uVol.MAPK_P"
        x[2] = 10.0; // - $"uVol.MAPK_PP"
        x[3] = 280.0; // - $"uVol.MKK"
        x[4] = 90.0; // - $"uVol.MKKK"
        x[5] = 10.0; // - $"uVol.MKKK_P"
        x[6] = 10.0; // - $"uVol.MKK_P"
        x[7] = 10.0; // - $"uVol.MKK_PP"

        __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 'BIOMD0000000010.xml' model
         */
    public void __internalDyDt_0(double time, double [] x, double[] result)
    {
        result[0] = -rate_J6+rate_J9;
        result[1] = +rate_J6-rate_J7+rate_J8-rate_J9;
        result[2] = +rate_J7-rate_J8;
        result[3] = -rate_J2+rate_J5;
        result[4] = -rate_J0+rate_J1;
        result[5] = +rate_J0-rate_J1;
        result[6] = +rate_J2-rate_J3+rate_J4-rate_J5;
        result[7] = +rate_J3-rate_J4;
    }
    protected double [] calculateResult(double time, double[] x)
    {
        double[] result = new double[8];
        __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 ...