/*
 * This code is generated by BioUML FrameWork 
 * for BIOMD0000000076.xml diagram  at 2008.03.20 15:07:57
 */
import biouml.plugins.simulation.ae.NewtonSolver;
import biouml.plugins.simulation.java.JavaBaseModel;
import ru.biosoft.math.MathRoutines;

public class BIOMD0000000076 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_Gpd_p = compartment*Gpd_p_Vf1/(Gpd_p_K1nadh*Gpd_p_K1dhap)*(Gpd_p_NADH*_compartment_DHAP_ - Gpd_p_NAD*x[0]/Gpd_p_Keq1)/((1 + Gpd_p_F16BP/Gpd_p_K1f16bp + Gpd_p_ATP/Gpd_p_K1atp + Gpd_p_ADP/Gpd_p_K1adp)*(1 + Gpd_p_NADH/Gpd_p_K1nadh + Gpd_p_NAD/Gpd_p_K1nad)*(1 + _compartment_DHAP_/Gpd_p_K1dhap + x[0]/Gpd_p_K1g3p));
        rate_Gpp_p = compartment*Gpp_p_V2*x[0]/Gpp_p_K2g3p/((1 + x[0]/Gpp_p_K2g3p)*(1 + Gpp_p_Phi/Gpp_p_K2phi));
    }

    public void Init()
    {
        initialValues = getInitialValues();
/*
 * Initialize variables
 */
        _compartment_DHAP_ = 0.59; // initial value of $"compartment.DHAP"
        _compartment_Gly_ = 15.1; // initial value of $"compartment.Gly"
        compartment = 1.0; // initial value of $compartment
        Gpd_p_ADP = 2.17; // initial value of Gpd_p_ADP
        Gpd_p_ATP = 2.37; // initial value of Gpd_p_ATP
        Gpd_p_F16BP = 6.01; // initial value of Gpd_p_F16BP
        Gpd_p_K1adp = 2.0; // initial value of Gpd_p_K1adp
        Gpd_p_K1atp = 0.73; // initial value of Gpd_p_K1atp
        Gpd_p_K1dhap = 0.54; // initial value of Gpd_p_K1dhap
        Gpd_p_K1f16bp = 4.8; // initial value of Gpd_p_K1f16bp
        Gpd_p_K1g3p = 1.2; // initial value of Gpd_p_K1g3p
        Gpd_p_K1nad = 0.93; // initial value of Gpd_p_K1nad
        Gpd_p_K1nadh = 0.023; // initial value of Gpd_p_K1nadh
        Gpd_p_Keq1 = 10000.0; // initial value of Gpd_p_Keq1
        Gpd_p_NAD = 1.45; // initial value of Gpd_p_NAD
        Gpd_p_NADH = 1.87; // initial value of Gpd_p_NADH
        Gpd_p_Vf1 = 47.0; // initial value of Gpd_p_Vf1
        Gpp_p_K2g3p = 3.5; // initial value of Gpp_p_K2g3p
        Gpp_p_K2phi = 1.0; // initial value of Gpp_p_K2phi
        Gpp_p_Phi = 1.0; // initial value of Gpp_p_Phi
        Gpp_p_V2 = 53.0; // initial value of Gpp_p_V2
    }

    /*
     * Model variables initial values
     */
    protected double _compartment_DHAP_;
    protected double _compartment_Gly_;
    protected double rate_Gpd_p;
    protected double rate_Gpp_p;
    protected double compartment;
    protected double Gpd_p_ADP;
    protected double Gpd_p_ATP;
    protected double Gpd_p_F16BP;
    protected double Gpd_p_K1adp;
    protected double Gpd_p_K1atp;
    protected double Gpd_p_K1dhap;
    protected double Gpd_p_K1f16bp;
    protected double Gpd_p_K1g3p;
    protected double Gpd_p_K1nad;
    protected double Gpd_p_K1nadh;
    protected double Gpd_p_Keq1;
    protected double Gpd_p_NAD;
    protected double Gpd_p_NADH;
    protected double Gpd_p_Vf1;
    protected double Gpp_p_K2g3p;
    protected double Gpp_p_K2phi;
    protected double Gpp_p_Phi;
    protected double Gpp_p_V2;

    public double[] extendResult(double time,double [] x)
    {
        this.time = time;


        double[] y = new double[1];
        y[0] = x[0];
        return y;
    }
    public double[] getInitialValues()
    {
        double [] x = new double[1];
        this.time = 0.0;
        x[0] = 0.0; // - $"compartment.G3P"

        __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 'BIOMD0000000076.xml' model
         */
    public void __internalDyDt_0(double time, double [] x, double[] result)
    {
        result[0] = +rate_Gpd_p-rate_Gpp_p;
    }
    protected double [] calculateResult(double time, double[] x)
    {
        double[] result = new double[1];
        __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 ...