/*
 * This code is generated by BioUML FrameWork 
 * for BIOMD0000000068.xml diagram  at 2008.03.20 15:04:55
 */
import biouml.plugins.simulation.ae.NewtonSolver;
import biouml.plugins.simulation.java.JavaBaseModel;
import ru.biosoft.math.MathRoutines;

public class BIOMD0000000068 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 = compartment*v1_V0;
        rate_vCys = vCys_CGS*(vCys_kcat2/(1 + vCys_KmCYS/_compartment_Cys_))*x[0]/(x[0] + vCys_KmPHSER*(1 + _compartment_Phi_/vCys_Ki2)/(1 + vCys_KmCYS/_compartment_Cys_));
        rate_vThr = vThr_TS*(5.9E-4 + 0.062*Math.pow(vThr_AdoMet, 2.9)/(23170.47500592078 + Math.pow(vThr_AdoMet, 2.9)))*x[0]/(1 + _compartment_Phi_/vThr_Ki3);
    }

    public void Init()
    {
        initialValues = getInitialValues();
/*
 * Initialize variables
 */
        _compartment_Cys_ = 15.0; // initial value of $"compartment.Cys"
        _compartment_Phi_ = 10000.0; // initial value of $"compartment.Phi"
        compartment = 1.0; // initial value of $compartment
        v1_V0 = 1.0; // initial value of v1_V0
        vCys_CGS = 0.7; // initial value of vCys_CGS
        vCys_Ki2 = 2000.0; // initial value of vCys_Ki2
        vCys_KmCYS = 460.0; // initial value of vCys_KmCYS
        vCys_KmPHSER = 2500.0; // initial value of vCys_KmPHSER
        vCys_kcat2 = 30.0; // initial value of vCys_kcat2
        vThr_AdoMet = 20.0; // initial value of vThr_AdoMet
        vThr_Ki3 = 1000.0; // initial value of vThr_Ki3
        vThr_TS = 5.0; // initial value of vThr_TS
    }

    /*
     * Model variables initial values
     */
    protected double _compartment_Cys_;
    protected double _compartment_Cystathionine_;
    protected double _compartment_Hser_;
    protected double _compartment_Phi_;
    protected double _compartment_Thr_;
    protected double rate_v1;
    protected double rate_vCys;
    protected double rate_vThr;
    protected double compartment;
    protected double v1_V0;
    protected double vCys_CGS;
    protected double vCys_Ki2;
    protected double vCys_KmCYS;
    protected double vCys_KmPHSER;
    protected double vCys_kcat2;
    protected double vThr_AdoMet;
    protected double vThr_Ki3;
    protected double vThr_TS;

    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.Phser"

        __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 'BIOMD0000000068.xml' model
         */
    public void __internalDyDt_0(double time, double [] x, double[] result)
    {
        result[0] = +rate_v1-rate_vCys-rate_vThr;
    }
    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 ...