/*
 * This code is generated by BioUML FrameWork 
 * for BIOMD0000000099.xml diagram  at 2008.03.20 15:08:35
 */
import biouml.plugins.simulation.ae.NewtonSolver;
import biouml.plugins.simulation.java.JavaBaseModel;
import ru.biosoft.math.MathRoutines;

public class BIOMD0000000099 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_compartment_1_*parameter_0*x[5];
        rate_reaction_1 = _compartment_0_compartment_1_*parameter_1*x[3];
        rate_reaction_10 = compartment_0*parameter_10*x[3];
        rate_reaction_11 = compartment_0*parameter_11*x[6];
        rate_reaction_12 = _compartment_0_compartment_1_*parameter_12*x[6];
        rate_reaction_13 = _compartment_0_compartment_1_*parameter_13*x[4]*x[1];
        rate_reaction_2 = _compartment_0_compartment_1_*parameter_2*x[0];
        rate_reaction_3 = _compartment_0_compartment_1_*parameter_3*x[1];
        rate_reaction_4 = _compartment_0_compartment_1_*parameter_4*x[4];
        rate_reaction_5 = _compartment_0_compartment_1_*parameter_5*x[5]*x[1];
        rate_reaction_6 = _compartment_0_compartment_1_*parameter_6;
        rate_reaction_7 = _compartment_0_compartment_1_*parameter_7*x[2]*x[5];
        rate_reaction_8 = _compartment_0_compartment_1_*parameter_8*x[3];
        rate_reaction_9 = _compartment_0_compartment_1_*parameter_9*x[0]*x[2];
    }

    public void Init()
    {
        initialValues = getInitialValues();
/*
 * Initialize variables
 */
        _compartment_0_compartment_1_ = 1.0; // initial value of $"compartment_0.compartment_1"
        compartment_0 = 1.0; // initial value of $compartment_0
        parameter_0 = 1.4; // initial value of parameter_0
        parameter_1 = 0.9; // initial value of parameter_1
        parameter_10 = 0.6; // initial value of parameter_10
        parameter_11 = 3.1; // initial value of parameter_11
        parameter_12 = 33.0; // initial value of parameter_12
        parameter_13 = 4.5; // initial value of parameter_13
        parameter_2 = 2.5; // initial value of parameter_2
        parameter_3 = 1.5; // initial value of parameter_3
        parameter_4 = 0.6; // initial value of parameter_4
        parameter_5 = 0.8; // initial value of parameter_5
        parameter_6 = 2.0; // initial value of parameter_6
        parameter_7 = 1.3; // initial value of parameter_7
        parameter_8 = 0.29; // initial value of parameter_8
        parameter_9 = 1.0; // initial value of parameter_9
    }

    /*
     * Model variables initial values
     */
    protected double _compartment_0_compartment_1_;
    protected double rate_reaction_0;
    protected double rate_reaction_1;
    protected double rate_reaction_10;
    protected double rate_reaction_11;
    protected double rate_reaction_12;
    protected double rate_reaction_13;
    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_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[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] = 1.0; // - $"compartment_0.compartment_1.species_1"
        x[1] = 1.0; // - $"compartment_0.compartment_1.species_2"
        x[2] = 2.5; // - $"compartment_0.compartment_1.species_3"
        x[3] = 1.4; // - $"compartment_0.compartment_1.species_4"
        x[4] = 1.5; // - $"compartment_0.compartment_1.species_5"
        x[5] = 1.6; // - $"compartment_0.compartment_1.species_6"
        x[6] = 0.0; // - $"compartment_0.species_0"

        __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 'BIOMD0000000099.xml' model
         */
    public void __internalDyDt_0(double time, double [] x, double[] result)
    {
        result[0] = +rate_reaction_8-rate_reaction_9;
        result[1] = +rate_reaction_2-rate_reaction_3;
        result[2] = +rate_reaction_6-rate_reaction_7;
        result[3] = +rate_reaction_0-rate_reaction_1;
        result[4] = +rate_reaction_12-rate_reaction_13;
        result[5] = +rate_reaction_4-rate_reaction_5;
        result[6] = +rate_reaction_10-rate_reaction_11;
    }
    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 ...