/*
 * This code is generated by BioUML FrameWork 
 * for BIOMD0000000050.xml diagram  at 2008.03.20 15:04:29
 */
import biouml.plugins.simulation.ae.NewtonSolver;
import biouml.plugins.simulation.java.JavaBaseModel;
import ru.biosoft.math.MathRoutines;

public class BIOMD0000000050 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 = v1_k1*x[0];
        rate_v10 = v10_k10*x[10];
        rate_v11 = v11_k11*x[10];
        rate_v12 = v12_k12*x[4];
        rate_v13 = v13_k13*x[2];
        rate_v14 = v14_k14*x[9]*x[3];
        rate_v15 = v15_k15*x[9];
        rate_v16 = v16_k16*x[11];
        rate_v2 = v2_k2*x[0];
        rate_v3 = v3_k3*x[0];
        rate_v4 = v4_k4*x[10];
        rate_v5 = v5_k5*x[7];
        rate_v6 = v6_k6*x[7];
        rate_v7 = v7_k7*x[11];
        rate_v8 = v8_k8*x[6];
        rate_v9 = v9_k9*x[6];
    }

    public void Init()
    {
        initialValues = getInitialValues();
/*
 * Initialize variables
 */
        v10_k10 = 0.0707; // initial value of v10_k10
        v11_k11 = 0.1131; // initial value of v11_k11
        v12_k12 = 8.0E-4; // initial value of v12_k12
        v13_k13 = 0.0022; // initial value of v13_k13
        v14_k14 = 0.0034; // initial value of v14_k14
        v15_k15 = 0.0159; // initial value of v15_k15
        v16_k16 = 0.0134; // initial value of v16_k16
        v1_k1 = 0.0057; // initial value of v1_k1
        v2_k2 = 0.0156; // initial value of v2_k2
        v3_k3 = 0.0155; // initial value of v3_k3
        v4_k4 = 0.0794; // initial value of v4_k4
        v5_k5 = 0.0907; // initial value of v5_k5
        v6_k6 = 0.0274; // initial value of v6_k6
        v7_k7 = 0.2125; // initial value of v7_k7
        v9_k9 = 1.9085; // initial value of v9_k9
    }

    /*
     * Model variables initial values
     */
    protected double rate_v1;
    protected double rate_v10;
    protected double rate_v11;
    protected double rate_v12;
    protected double rate_v13;
    protected double rate_v14;
    protected double rate_v15;
    protected double rate_v16;
    protected double rate_v2;
    protected double rate_v3;
    protected double rate_v4;
    protected double rate_v5;
    protected double rate_v6;
    protected double rate_v7;
    protected double rate_v8;
    protected double rate_v9;
    protected double v10_k10;
    protected double v11_k11;
    protected double v12_k12;
    protected double v13_k13;
    protected double v14_k14;
    protected double v15_k15;
    protected double v16_k16;
    protected double v1_k1;
    protected double v2_k2;
    protected double v3_k3;
    protected double v4_k4;
    protected double v5_k5;
    protected double v6_k6;
    protected double v7_k7;
    protected double v8_k8;
    protected double v9_k9;

    public double[] extendResult(double time,double [] x)
    {
        this.time = time;


        double[] y = new double[14];
        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];
        return y;
    }
    public double[] getInitialValues()
    {
        double [] x = new double[14];
        this.time = 0.0;
        x[0] = 9.0; // - $"compartment.DFG"
        x[1] = 0.0; // - $"compartment.Fru"
        x[2] = 0.0; // - $"compartment.Glu"
        x[3] = 0.0; // - $"compartment.Gly"
        x[4] = 0.0; // - $"compartment.Man"
        x[5] = 0.0; // - $"compartment.Mel"
        x[6] = 0.0; // - $"compartment._1DG"
        x[7] = 0.0; // - $"compartment._3DG"
        x[8] = 0.0; // - $compartment.AA
        x[9] = 0.0; // - $compartment.Cn
        x[10] = 0.0; // - $compartment.E1
        x[11] = 0.0; // - $compartment.E2
        x[12] = 0.0; // - $compartment.FA
        x[13] = 0.0; // - $compartment.MG

        __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 'BIOMD0000000050.xml' model
         */
    public void __internalDyDt_0(double time, double [] x, double[] result)
    {
        result[0] = -rate_v1-rate_v2-rate_v3;
        result[1] = +rate_v16;
        result[2] = +rate_v11+rate_v12-rate_v13;
        result[3] = +rate_v10+rate_v11-rate_v14+rate_v16+rate_v3+rate_v4+rate_v7;
        result[4] = +rate_v10-rate_v12;
        result[5] = +rate_v14;
        result[6] = +rate_v7-rate_v8-rate_v9;
        result[7] = +rate_v13+rate_v4-rate_v5-rate_v6;
        result[8] = +rate_v15+rate_v9;
        result[9] = -rate_v14-rate_v15+rate_v3+rate_v5+rate_v8;
        result[10] = -rate_v10-rate_v11+rate_v1-rate_v4;
        result[11] = -rate_v16+rate_v2-rate_v7;
        result[12] = +rate_v15+rate_v6;
        result[13] = +rate_v15;
    }
    protected double [] calculateResult(double time, double[] x)
    {
        double[] result = new double[14];
        __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 ...