/*
 * This code is generated by BioUML FrameWork 
 * for BIOMD0000000072.xml diagram  at 2008.03.20 15:07:53
 */
import biouml.plugins.simulation.ae.NewtonSolver;
import biouml.plugins.simulation.java.JavaBaseModel;
import ru.biosoft.math.MathRoutines;

public class BIOMD0000000072 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_0 = cell*(reaction_0_k1*x[2]*x[3] - reaction_0_k2*x[6]);
        rate_reaction_1 = cell*reaction_1_v;
        rate_reaction_2 = cell*reaction_2_k1*x[3];
        rate_reaction_3 = cell*reaction_3_k1*x[5]*x[1];
        rate_reaction_4 = cell*reaction_4_k1*x[6]*x[0];
        rate_reaction_5 = cell*reaction_5_k1*x[6];
        rate_reaction_6 = cell*reaction_6_k1*x[4];
    }

    public void Init()
    {
        initialValues = getInitialValues();
/*
 * Initialize variables
 */
        cell = 1.0; // initial value of $cell
        reaction_0_k1 = 3.32E-18; // initial value of reaction_0_k1
        reaction_0_k2 = 0.01; // initial value of reaction_0_k2
        reaction_1_v = 4.0; // initial value of reaction_1_v
        reaction_2_k1 = 4.0E-4; // initial value of reaction_2_k1
        reaction_3_k1 = 1.0; // initial value of reaction_3_k1
        reaction_4_k1 = 1.0E-5; // initial value of reaction_4_k1
        reaction_5_k1 = 0.0040; // initial value of reaction_5_k1
        reaction_6_k1 = 0.11; // initial value of reaction_6_k1
    }

    /*
     * Model variables initial values
     */
    protected double rate_reaction_0;
    protected double rate_reaction_1;
    protected double rate_reaction_2;
    protected double rate_reaction_3;
    protected double rate_reaction_4;
    protected double rate_reaction_5;
    protected double rate_reaction_6;
    protected double cell;
    protected double reaction_0_k1;
    protected double reaction_0_k2;
    protected double reaction_1_v;
    protected double reaction_2_k1;
    protected double reaction_3_k1;
    protected double reaction_4_k1;
    protected double reaction_5_k1;
    protected double reaction_6_k1;

    public double[] extendResult(double time,double [] x)
    {
        this.time = time;


        double[] y = new double[7];
        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];
        return y;
    }
    public double[] getInitialValues()
    {
        double [] x = new double[7];
        this.time = 0.0;
        x[0] = 7000.0; // - $"cell.G"
        x[1] = 3000.0; // - $"cell.Gbg"
        x[2] = 6.02E17; // - $"cell.L"
        x[3] = 10000.0; // - $"cell.R"
        x[4] = 0.0; // - $cell.Ga
        x[5] = 3000.0; // - $cell.Gd
        x[6] = 0.0; // - $cell.RL

        __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 'BIOMD0000000072.xml' model
         */
    public void __internalDyDt_0(double time, double [] x, double[] result)
    {
        result[0] = +rate_reaction_3-rate_reaction_4;
        result[1] = -rate_reaction_3+rate_reaction_4;
        result[2] = -rate_reaction_0;
        result[3] = -rate_reaction_0+rate_reaction_1-rate_reaction_2;
        result[4] = +rate_reaction_4-rate_reaction_6;
        result[5] = -rate_reaction_3+rate_reaction_6;
        result[6] = +rate_reaction_0-rate_reaction_5;
    }
    protected double [] calculateResult(double time, double[] x)
    {
        double[] result = new double[7];
        __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 ...