Search in sources :

Example 11 with FastRate

use of cbit.vcell.math.FastRate in project vcell by virtualcell.

the class FastSystemAnalyzer method refreshFastVarList.

/**
 * @return java.util.Vector
 */
private void refreshFastVarList() throws MathException, ExpressionException {
    fastVarList.clear();
    // 
    // get list of unique (VolVariables and MemVariables) in fastRate expressions
    // 
    Enumeration<FastRate> fastRatesEnum = fastSystem.getFastRates();
    while (fastRatesEnum.hasMoreElements()) {
        FastRate fr = fastRatesEnum.nextElement();
        Expression exp = fr.getFunction();
        Enumeration<Variable> enum1 = MathUtilities.getRequiredVariables(exp, this);
        while (enum1.hasMoreElements()) {
            Variable var = enum1.nextElement();
            if (var instanceof VolVariable || var instanceof MemVariable) {
                if (!fastVarList.contains(var)) {
                    fastVarList.addElement(var);
                // System.out.println("FastSystemImplicit.refreshFastVarList(), FAST RATE VARIABLE: "+var.getName());
                }
            }
        }
    }
    // 
    // get list of all variables used in invariant expressions that are not used in fast rates
    // 
    Enumeration<FastInvariant> fastInvariantsEnum = fastSystem.getFastInvariants();
    while (fastInvariantsEnum.hasMoreElements()) {
        FastInvariant fi = (FastInvariant) fastInvariantsEnum.nextElement();
        Expression exp = fi.getFunction();
        // System.out.println("FastSystemImplicit.refreshFastVarList(), ORIGINAL FAST INVARIANT: "+exp);
        Enumeration<Variable> enum1 = MathUtilities.getRequiredVariables(exp, this);
        while (enum1.hasMoreElements()) {
            Variable var = enum1.nextElement();
            if (var instanceof VolVariable || var instanceof MemVariable) {
                if (!fastVarList.contains(var)) {
                    fastVarList.addElement(var);
                }
            }
        }
    }
    // 
    // verify that there are N equations (rates+invariants) and N unknowns (fastVariables)
    // 
    int numBoundFunctions = fastSystem.getNumFastInvariants() + fastSystem.getNumFastRates();
    if (fastVarList.size() != numBoundFunctions) {
        throw new MathException("FastSystem.checkDimension(), there are " + fastVarList.size() + " variables and " + numBoundFunctions + " FastInvariant's & FastRates");
    }
}
Also used : ReservedVariable(cbit.vcell.math.ReservedVariable) Variable(cbit.vcell.math.Variable) VolVariable(cbit.vcell.math.VolVariable) MemVariable(cbit.vcell.math.MemVariable) MemVariable(cbit.vcell.math.MemVariable) Expression(cbit.vcell.parser.Expression) VolVariable(cbit.vcell.math.VolVariable) MathException(cbit.vcell.math.MathException) FastRate(cbit.vcell.math.FastRate) FastInvariant(cbit.vcell.math.FastInvariant)

Example 12 with FastRate

use of cbit.vcell.math.FastRate in project vcell by virtualcell.

the class Xmlproducer method getXML.

/**
 * This method returns a XML representation of a FastSystemImplicit object.
 * Creation date: (3/2/2001 4:05:28 PM)
 * @return Element
 * @param param cbit.vcell.math.FastSystemImplicit
 */
private Element getXML(FastSystem param) {
    Element fastsystem = new Element(XMLTags.FastSystemTag);
    // Add Fast Invariant subelements
    Element fastinvariant;
    Enumeration<FastInvariant> enum_fi = param.getFastInvariants();
    while (enum_fi.hasMoreElements()) {
        fastinvariant = new Element(XMLTags.FastInvariantTag);
        FastInvariant fi = enum_fi.nextElement();
        fastinvariant.addContent(mangleExpression(fi.getFunction()));
        fastsystem.addContent(fastinvariant);
    }
    // Add FastRate subelements
    Element fastrate;
    Enumeration<FastRate> enum_fr = param.getFastRates();
    while (enum_fr.hasMoreElements()) {
        FastRate fr = (FastRate) enum_fr.nextElement();
        fastrate = new Element(XMLTags.FastRateTag);
        fastrate.addContent(mangleExpression(fr.getFunction()));
        fastsystem.addContent(fastrate);
    }
    return fastsystem;
}
Also used : Element(org.jdom.Element) FastRate(cbit.vcell.math.FastRate) FastInvariant(cbit.vcell.math.FastInvariant)

Example 13 with FastRate

use of cbit.vcell.math.FastRate in project vcell by virtualcell.

the class ITextWriter method writeFastSystem.

protected void writeFastSystem(Section container, FastSystem fs) throws DocumentException {
    Table eqTable = getTable(2, 100, 1, 2, 2);
    eqTable.addCell(createCell(VCML.FastSystem, getBold(DEF_HEADER_FONT_SIZE), 2, 1, Element.ALIGN_CENTER, true));
    eqTable.endHeaders();
    Enumeration<FastInvariant> enum_fi = fs.getFastInvariants();
    while (enum_fi.hasMoreElements()) {
        FastInvariant fi = enum_fi.nextElement();
        eqTable.addCell(createCell(VCML.FastInvariant, getFont()));
        eqTable.addCell(createCell(fi.getFunction().infix(), getFont()));
    }
    Enumeration<FastRate> enum_fr = fs.getFastRates();
    while (enum_fr.hasMoreElements()) {
        FastRate fr = enum_fr.nextElement();
        eqTable.addCell(createCell(VCML.FastRate, getFont()));
        eqTable.addCell(createCell(fr.getFunction().infix(), getFont()));
    }
    container.add(eqTable);
}
Also used : Table(com.lowagie.text.Table) FastRate(cbit.vcell.math.FastRate) FastInvariant(cbit.vcell.math.FastInvariant)

Aggregations

FastInvariant (cbit.vcell.math.FastInvariant)13 FastRate (cbit.vcell.math.FastRate)13 Variable (cbit.vcell.math.Variable)9 Expression (cbit.vcell.parser.Expression)9 FastSystem (cbit.vcell.math.FastSystem)7 MemVariable (cbit.vcell.math.MemVariable)7 VolVariable (cbit.vcell.math.VolVariable)7 CompartmentSubDomain (cbit.vcell.math.CompartmentSubDomain)5 Constant (cbit.vcell.math.Constant)5 Equation (cbit.vcell.math.Equation)5 MathException (cbit.vcell.math.MathException)5 ReservedVariable (cbit.vcell.math.ReservedVariable)5 SubDomain (cbit.vcell.math.SubDomain)5 Function (cbit.vcell.math.Function)4 JumpCondition (cbit.vcell.math.JumpCondition)4 MembraneSubDomain (cbit.vcell.math.MembraneSubDomain)4 OdeEquation (cbit.vcell.math.OdeEquation)4 PdeEquation (cbit.vcell.math.PdeEquation)4 MathDescription (cbit.vcell.math.MathDescription)3 MembraneRegionEquation (cbit.vcell.math.MembraneRegionEquation)3