/*
 * This code is generated by BioUML FrameWork 
 * for BIOMD0000000031.xml diagram  at 2008.03.20 15:04:08
 */
import biouml.plugins.simulation.ae.NewtonSolver;
import biouml.plugins.simulation.java.JavaBaseModel;
import ru.biosoft.math.MathRoutines;

public class BIOMD0000000031 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_v1 = uVol*(k1cat*_uVol_MAPKK1_*x[0]/Km1/(1 + x[0]/Km1));
        rate_v2 = uVol*(k2cat*_uVol_MAPKK2_*x[2]/Km2/(1 + x[2]/Km2));
        rate_v3 = uVol*(k3cat*_uVol_MKP3_*x[1]/Km3/(1 + x[1]/Km3 + x[2]/Km4 + x[0]/Km5));
        rate_v4 = uVol*(k4cat*_uVol_MKP3_*x[2]/Km4/(1 + x[1]/Km3 + x[2]/Km4 + x[0]/Km5));
    }

    public void Init()
    {
        initialValues = getInitialValues();
/*
 * Initialize variables
 */
        _uVol_MAPKK1_ = 100.0; // initial value of $"uVol.MAPKK1"
        _uVol_MAPKK2_ = 1.0; // initial value of $"uVol.MAPKK2"
        _uVol_MKP3_ = 100.0; // initial value of $"uVol.MKP3"
        uVol = 1.0; // initial value of $uVol
        Km1 = 50.0; // initial value of Km1
        Km2 = 500.0; // initial value of Km2
        Km3 = 5.0; // initial value of Km3
        Km4 = 18.0; // initial value of Km4
        Km5 = 78.0; // initial value of Km5
        k1cat = 0.01; // initial value of k1cat
        k2cat = 15.0; // initial value of k2cat
        k3cat = 0.084; // initial value of k3cat
        k4cat = 0.06; // initial value of k4cat
    }

    /*
     * Model variables initial values
     */
    protected double _uVol_MAPKK1_;
    protected double _uVol_MAPKK2_;
    protected double _uVol_MKP3_;
    protected double rate_v1;
    protected double rate_v2;
    protected double rate_v3;
    protected double rate_v4;
    protected double uVol;
    protected double Km1;
    protected double Km2;
    protected double Km3;
    protected double Km4;
    protected double Km5;
    protected double k1cat;
    protected double k2cat;
    protected double k3cat;
    protected double k4cat;

    public double[] extendResult(double time,double [] x)
    {
        this.time = time;


        double[] y = new double[3];
        y[0] = x[0];
        y[1] = x[1];
        y[2] = x[2];
        return y;
    }
    public double[] getInitialValues()
    {
        double [] x = new double[3];
        this.time = 0.0;
        x[0] = 500.0; // - $"uVol.M"
        x[1] = 0.0; // - $"uVol.Mpp"
        x[2] = 0.0; // - $uVol.Mp

        __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 'BIOMD0000000031.xml' model
         */
    public void __internalDyDt_0(double time, double [] x, double[] result)
    {
        result[0] = -rate_v1+rate_v4;
        result[1] = +rate_v2-rate_v3;
        result[2] = +rate_v1-rate_v2+rate_v3-rate_v4;
    }
    protected double [] calculateResult(double time, double[] x)
    {
        double[] result = new double[3];
        __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 ...