/*
 * This code is generated by BioUML FrameWork 
 * for BIOMD0000000116.xml diagram  at 2008.03.20 15:08:53
 */
import biouml.plugins.simulation.ae.NewtonSolver;
import biouml.plugins.simulation.java.JavaBaseModel;
import ru.biosoft.math.MathRoutines;

public class BIOMD0000000116 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 = compartment_0*parameter_9*x[0]*(parameter_1 - x[1]);
        rate_reaction_1 = compartment_0*parameter_6*parameter_7/(1 + parameter_7/parameter_8)*(parameter_0 - x[0]);
        rate_reaction_2 = compartment_0*parameter_10*x[1]*(parameter_2 - x[2]);
        rate_reaction_3 = compartment_0*parameter_15*parameter_14/(1 + parameter_14/parameter_16)*(parameter_3 - x[3]);
        rate_reaction_4 = compartment_0*parameter_17*x[3]*(parameter_4 - x[4]);
        rate_reaction_5 = compartment_0*parameter_18*x[4]*(parameter_5 - x[5]);
        rate_reaction_6 = compartment_0*parameter_12*x[0]*(parameter_4 - x[4]);
        rate_reaction_7 = compartment_0*parameter_12*x[3]*(parameter_1 - x[1]);
        rate_reaction_8 = compartment_0*parameter_11*x[5]*x[2]/(1 + x[2]/parameter_13);
        rate_reaction_9 = compartment_0*parameter_11*x[5]*x[2]/(1 + x[5]/parameter_19);
    }

    public void Init()
    {
        initialValues = getInitialValues();
/*
 * Initialize variables
 */
        compartment_0 = 1.0; // initial value of $compartment_0
        parameter_0 = 10.0; // initial value of parameter_0
        parameter_1 = 10.0; // initial value of parameter_1
        parameter_10 = 1.0; // initial value of parameter_10
        parameter_11 = 1.0; // initial value of parameter_11
        parameter_13 = 1.0; // initial value of parameter_13
        parameter_14 = 5.0; // initial value of parameter_14
        parameter_15 = 1.0; // initial value of parameter_15
        parameter_16 = 1.0; // initial value of parameter_16
        parameter_17 = 1.0; // initial value of parameter_17
        parameter_18 = 1.0; // initial value of parameter_18
        parameter_19 = 1.0; // initial value of parameter_19
        parameter_2 = 10.0; // initial value of parameter_2
        parameter_3 = 10.0; // initial value of parameter_3
        parameter_4 = 10.0; // initial value of parameter_4
        parameter_5 = 10.0; // initial value of parameter_5
        parameter_6 = 1.0; // initial value of parameter_6
        parameter_7 = 8.5; // initial value of parameter_7
        parameter_8 = 1.0; // initial value of parameter_8
        parameter_9 = 1.0; // initial value of parameter_9
    }

    /*
     * 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 rate_reaction_7;
    protected double rate_reaction_8;
    protected double rate_reaction_9;
    protected double compartment_0;
    protected double parameter_0;
    protected double parameter_1;
    protected double parameter_10;
    protected double parameter_11;
    protected double parameter_12;
    protected double parameter_13;
    protected double parameter_14;
    protected double parameter_15;
    protected double parameter_16;
    protected double parameter_17;
    protected double parameter_18;
    protected double parameter_19;
    protected double parameter_2;
    protected double parameter_3;
    protected double parameter_4;
    protected double parameter_5;
    protected double parameter_6;
    protected double parameter_7;
    protected double parameter_8;
    protected double parameter_9;

    public double[] extendResult(double time,double [] x)
    {
        this.time = time;


        double[] y = new double[6];
        y[0] = x[0];
        y[1] = x[1];
        y[2] = x[2];
        y[3] = x[3];
        y[4] = x[4];
        y[5] = x[5];
        return y;
    }
    public double[] getInitialValues()
    {
        double [] x = new double[6];
        this.time = 0.0;
        x[0] = 1.023667; // - $"compartment_0.species_0"
        x[1] = 2.154231; // - $"compartment_0.species_1"
        x[2] = 6.271793; // - $"compartment_0.species_2"
        x[3] = 3.203692; // - $"compartment_0.species_3"
        x[4] = 8.232192; // - $"compartment_0.species_4"
        x[5] = 9.312021; // - $"compartment_0.species_5"

        __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 'BIOMD0000000116.xml' model
         */
    public void __internalDyDt_0(double time, double [] x, double[] result)
    {
        result[0] = -rate_reaction_0+rate_reaction_1-rate_reaction_6;
        result[1] = +rate_reaction_0-rate_reaction_2+rate_reaction_7;
        result[2] = +rate_reaction_2-rate_reaction_8;
        result[3] = +rate_reaction_3-rate_reaction_4-rate_reaction_7;
        result[4] = +rate_reaction_4-rate_reaction_5+rate_reaction_6;
        result[5] = +rate_reaction_5-rate_reaction_9;
    }
    protected double [] calculateResult(double time, double[] x)
    {
        double[] result = new double[6];
        __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 ...