Search in sources :

Example 51 with MathException

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

the class XmlReader method getKinetics.

/**
 * This method returns a Kinetics object from a XML Element based on the value of the kinetics type attribute.
 * Creation date: (3/19/2001 4:42:04 PM)
 * @return cbit.vcell.model.Kinetics
 * @param param org.jdom.Element
 */
private Kinetics getKinetics(Element param, ReactionStep reaction, Model model) throws XmlParseException {
    VariableHash varHash = new VariableHash();
    addResevedSymbols(varHash, model);
    String type = param.getAttributeValue(XMLTags.KineticsTypeAttrTag);
    Kinetics newKinetics = null;
    try {
        if (type.equalsIgnoreCase(XMLTags.KineticsTypeGeneralKinetics)) {
            // create a general kinetics
            newKinetics = new GeneralKinetics(reaction);
        } else if (type.equalsIgnoreCase(XMLTags.KineticsTypeGeneralCurrentKinetics)) {
            // Create GeneralCurrentKinetics
            newKinetics = new GeneralCurrentKinetics(reaction);
        } else if (type.equalsIgnoreCase(XMLTags.KineticsTypeMassAction) && reaction instanceof SimpleReaction) {
            // create a Mass Action kinetics
            newKinetics = new MassActionKinetics((SimpleReaction) reaction);
        } else if (type.equalsIgnoreCase(XMLTags.KineticsTypeNernst) && reaction instanceof FluxReaction) {
            // create NernstKinetics
            newKinetics = new NernstKinetics((FluxReaction) reaction);
        } else if (type.equalsIgnoreCase(XMLTags.KineticsTypeGHK) && reaction instanceof FluxReaction) {
            // create GHKKinetics
            newKinetics = new GHKKinetics((FluxReaction) reaction);
        } else if (type.equalsIgnoreCase(XMLTags.KineticsTypeHMM_Irr) && reaction instanceof SimpleReaction) {
            // create HMM_IrrKinetics
            newKinetics = new HMM_IRRKinetics((SimpleReaction) reaction);
        } else if (type.equalsIgnoreCase(XMLTags.KineticsTypeHMM_Rev) && reaction instanceof SimpleReaction) {
            // create HMM_RevKinetics
            newKinetics = new HMM_REVKinetics((SimpleReaction) reaction);
        } else if (type.equalsIgnoreCase(XMLTags.KineticsTypeGeneralTotal_oldname)) {
            // create GeneralTotalKinetics
            newKinetics = new GeneralLumpedKinetics(reaction);
        } else if (type.equalsIgnoreCase(XMLTags.KineticsTypeGeneralLumped)) {
            // create GeneralLumpedKinetics
            newKinetics = new GeneralLumpedKinetics(reaction);
        } else if (type.equalsIgnoreCase(XMLTags.KineticsTypeGeneralCurrentLumped)) {
            // create GeneralCurrentLumpedKinetics
            newKinetics = new GeneralCurrentLumpedKinetics(reaction);
        } else if (type.equalsIgnoreCase(XMLTags.KineticsTypeGeneralPermeability) && reaction instanceof FluxReaction) {
            // create GeneralPermeabilityKinetics
            newKinetics = new GeneralPermeabilityKinetics((FluxReaction) reaction);
        } else if (type.equalsIgnoreCase(XMLTags.KineticsTypeMacroscopic_Irr) && reaction instanceof SimpleReaction) {
            // create Macroscopic_IRRKinetics
            newKinetics = new Macroscopic_IRRKinetics((SimpleReaction) reaction);
        } else if (type.equalsIgnoreCase(XMLTags.KineticsTypeMicroscopic_Irr) && reaction instanceof SimpleReaction) {
            // create Microscopic_IRRKinetics
            newKinetics = new Microscopic_IRRKinetics((SimpleReaction) reaction);
        } else {
            throw new XmlParseException("Unknown kinetics type: " + type);
        }
    } catch (ExpressionException e) {
        e.printStackTrace();
        throw new XmlParseException("Error creating the kinetics for reaction: " + reaction.getName(), e);
    }
    try {
        // transaction begin flag ... yeah, this is a hack
        newKinetics.reading(true);
        // Read all of the parameters
        List<Element> list = param.getChildren(XMLTags.ParameterTag, vcNamespace);
        // add constants that may be used in kinetics.
        // VariableHash varHash = getVariablesHash();
        ArrayList<String> reserved = new ArrayList<String>();
        ReservedSymbol[] reservedSymbols = reaction.getModel().getReservedSymbols();
        for (ReservedSymbol rs : reservedSymbols) {
            reserved.add(rs.getName());
        }
        try {
            if (reaction.getStructure() instanceof Membrane) {
                Membrane membrane = (Membrane) reaction.getStructure();
                varHash.addVariable(new Constant(membrane.getMembraneVoltage().getName(), new Expression(0.0)));
                reserved.add(membrane.getMembraneVoltage().getName());
            }
            // 
            // add Reactants, Products, and Catalysts (ReactionParticipants)
            // 
            ReactionParticipant[] rp = reaction.getReactionParticipants();
            for (int i = 0; i < rp.length; i++) {
                varHash.addVariable(new Constant(rp[i].getName(), new Expression(0.0)));
            }
        } catch (MathException e) {
            e.printStackTrace(System.out);
            throw new XmlParseException("error reordering parameters according to dependencies: ", e);
        }
        // 
        for (Element xmlParam : list) {
            String paramName = unMangle(xmlParam.getAttributeValue(XMLTags.NameAttrTag));
            String role = xmlParam.getAttributeValue(XMLTags.ParamRoleAttrTag);
            String paramExpStr = xmlParam.getText();
            Expression paramExp = unMangleExpression(paramExpStr);
            try {
                if (varHash.getVariable(paramName) == null) {
                    varHash.addVariable(new Function(paramName, paramExp, null));
                } else {
                    if (reserved.contains(paramName)) {
                        varHash.removeVariable(paramName);
                        varHash.addVariable(new Function(paramName, paramExp, null));
                    }
                }
            } catch (MathException e) {
                e.printStackTrace(System.out);
                throw new XmlParseException("error reordering parameters according to dependencies: ", e);
            }
            Kinetics.KineticsParameter tempParam = null;
            if (!role.equals(XMLTags.ParamRoleUserDefinedTag)) {
                tempParam = newKinetics.getKineticsParameterFromRole(Kinetics.getParamRoleFromDefaultDesc(role));
            } else {
                continue;
            }
            // hack for bringing in General Total kinetics without breaking.
            if (tempParam == null && newKinetics instanceof GeneralLumpedKinetics) {
                if (role.equals(Kinetics.GTK_AssumedCompartmentSize_oldname) || role.equals(Kinetics.GTK_ReactionRate_oldname) || role.equals(Kinetics.GTK_CurrentDensity_oldname)) {
                    continue;
                } else if (role.equals(VCMODL.TotalRate_oldname)) {
                    tempParam = newKinetics.getKineticsParameterFromRole(Kinetics.ROLE_LumpedReactionRate);
                }
            }
            // hack from bringing in chargeValence parameters without breaking
            if (tempParam == null && Kinetics.getParamRoleFromDefaultDesc(role) == Kinetics.ROLE_ChargeValence) {
                tempParam = newKinetics.getChargeValenceParameter();
            }
            if (tempParam == null) {
                throw new XmlParseException("parameter with role '" + role + "' not found in kinetics type '" + type + "'");
            }
            // 
            if (!tempParam.getName().equals(paramName)) {
                Kinetics.KineticsParameter multNameParam = newKinetics.getKineticsParameter(paramName);
                int n = 0;
                while (multNameParam != null) {
                    String tempName = paramName + "_" + n++;
                    newKinetics.renameParameter(paramName, tempName);
                    multNameParam = newKinetics.getKineticsParameter(tempName);
                }
                newKinetics.renameParameter(tempParam.getName(), paramName);
            }
        }
        // 
        // create unresolved parameters for all unresolved symbols
        // 
        String unresolvedSymbol = varHash.getFirstUnresolvedSymbol();
        while (unresolvedSymbol != null) {
            try {
                // will turn into an UnresolvedParameter.
                varHash.addVariable(new Function(unresolvedSymbol, new Expression(0.0), null));
            } catch (MathException e) {
                e.printStackTrace(System.out);
                throw new XmlParseException(e);
            }
            newKinetics.addUnresolvedParameter(unresolvedSymbol);
            unresolvedSymbol = varHash.getFirstUnresolvedSymbol();
        }
        Variable[] sortedVariables = varHash.getTopologicallyReorderedVariables();
        ModelUnitSystem modelUnitSystem = reaction.getModel().getUnitSystem();
        for (int i = sortedVariables.length - 1; i >= 0; i--) {
            if (sortedVariables[i] instanceof Function) {
                Function paramFunction = (Function) sortedVariables[i];
                Element xmlParam = null;
                for (int j = 0; j < list.size(); j++) {
                    Element tempParam = (Element) list.get(j);
                    if (paramFunction.getName().equals(unMangle(tempParam.getAttributeValue(XMLTags.NameAttrTag)))) {
                        xmlParam = tempParam;
                        break;
                    }
                }
                if (xmlParam == null) {
                    // must have been an unresolved parameter
                    continue;
                }
                String symbol = xmlParam.getAttributeValue(XMLTags.VCUnitDefinitionAttrTag);
                VCUnitDefinition unit = null;
                if (symbol != null) {
                    unit = modelUnitSystem.getInstance(symbol);
                }
                Kinetics.KineticsParameter tempParam = newKinetics.getKineticsParameter(paramFunction.getName());
                if (tempParam == null) {
                    newKinetics.addUserDefinedKineticsParameter(paramFunction.getName(), paramFunction.getExpression(), unit);
                } else {
                    newKinetics.setParameterValue(tempParam, paramFunction.getExpression());
                    tempParam.setUnitDefinition(unit);
                }
            }
        }
    } catch (java.beans.PropertyVetoException e) {
        e.printStackTrace(System.out);
        throw new XmlParseException("Exception while setting parameters for Reaction : " + reaction.getName(), e);
    } catch (ExpressionException e) {
        e.printStackTrace(System.out);
        throw new XmlParseException("Exception while settings parameters for Reaction : " + reaction.getName(), e);
    } finally {
        newKinetics.reading(false);
    }
    return newKinetics;
}
Also used : FilamentVariable(cbit.vcell.math.FilamentVariable) OutsideVariable(cbit.vcell.math.OutsideVariable) StochVolVariable(cbit.vcell.math.StochVolVariable) RandomVariable(cbit.vcell.math.RandomVariable) VolumeRandomVariable(cbit.vcell.math.VolumeRandomVariable) VolumeParticleVariable(cbit.vcell.math.VolumeParticleVariable) VolumeRegionVariable(cbit.vcell.math.VolumeRegionVariable) InsideVariable(cbit.vcell.math.InsideVariable) VolVariable(cbit.vcell.math.VolVariable) MembraneRegionVariable(cbit.vcell.math.MembraneRegionVariable) PointVariable(cbit.vcell.math.PointVariable) MembraneRandomVariable(cbit.vcell.math.MembraneRandomVariable) MembraneParticleVariable(cbit.vcell.math.MembraneParticleVariable) ParticleVariable(cbit.vcell.math.ParticleVariable) MemVariable(cbit.vcell.math.MemVariable) FilamentRegionVariable(cbit.vcell.math.FilamentRegionVariable) Variable(cbit.vcell.math.Variable) KineticsParameter(cbit.vcell.model.Kinetics.KineticsParameter) VariableHash(cbit.vcell.math.VariableHash) HMM_IRRKinetics(cbit.vcell.model.HMM_IRRKinetics) MacroscopicRateConstant(cbit.vcell.math.MacroscopicRateConstant) Constant(cbit.vcell.math.Constant) Element(org.jdom.Element) ReservedSymbol(cbit.vcell.model.Model.ReservedSymbol) NernstKinetics(cbit.vcell.model.NernstKinetics) ArrayList(java.util.ArrayList) FluxReaction(cbit.vcell.model.FluxReaction) GeneralKinetics(cbit.vcell.model.GeneralKinetics) GeneralLumpedKinetics(cbit.vcell.model.GeneralLumpedKinetics) ExpressionException(cbit.vcell.parser.ExpressionException) PropertyVetoException(java.beans.PropertyVetoException) GeneralCurrentKinetics(cbit.vcell.model.GeneralCurrentKinetics) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction) Function(cbit.vcell.math.Function) GeneralCurrentLumpedKinetics(cbit.vcell.model.GeneralCurrentLumpedKinetics) Membrane(cbit.vcell.model.Membrane) Macroscopic_IRRKinetics(cbit.vcell.model.Macroscopic_IRRKinetics) GeneralPermeabilityKinetics(cbit.vcell.model.GeneralPermeabilityKinetics) ModelUnitSystem(cbit.vcell.model.ModelUnitSystem) SimpleReaction(cbit.vcell.model.SimpleReaction) GHKKinetics(cbit.vcell.model.GHKKinetics) HMM_REVKinetics(cbit.vcell.model.HMM_REVKinetics) VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) Expression(cbit.vcell.parser.Expression) MathException(cbit.vcell.math.MathException) MassActionKinetics(cbit.vcell.model.MassActionKinetics) Macroscopic_IRRKinetics(cbit.vcell.model.Macroscopic_IRRKinetics) Kinetics(cbit.vcell.model.Kinetics) NernstKinetics(cbit.vcell.model.NernstKinetics) GeneralKinetics(cbit.vcell.model.GeneralKinetics) GeneralLumpedKinetics(cbit.vcell.model.GeneralLumpedKinetics) GeneralPermeabilityKinetics(cbit.vcell.model.GeneralPermeabilityKinetics) GHKKinetics(cbit.vcell.model.GHKKinetics) MassActionKinetics(cbit.vcell.model.MassActionKinetics) Microscopic_IRRKinetics(cbit.vcell.model.Microscopic_IRRKinetics) GeneralCurrentKinetics(cbit.vcell.model.GeneralCurrentKinetics) HMM_REVKinetics(cbit.vcell.model.HMM_REVKinetics) HMM_IRRKinetics(cbit.vcell.model.HMM_IRRKinetics) GeneralCurrentLumpedKinetics(cbit.vcell.model.GeneralCurrentLumpedKinetics) Microscopic_IRRKinetics(cbit.vcell.model.Microscopic_IRRKinetics) ReactionParticipant(cbit.vcell.model.ReactionParticipant)

Example 52 with MathException

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

the class XmlReader method getJumpProcess.

/**
 * The method returns a JumpProcess object from a XML element.
 * Creation date: (7/24/2006 6:28:42 PM)
 * @return cbit.vcell.math.JumpProcess
 * @param param org.jdom.Element
 * @param md cbit.vcell.math.MathDescription
 * @exception cbit.vcell.xml.XmlParseException The exception description.
 */
private JumpProcess getJumpProcess(Element param, MathDescription md) throws XmlParseException {
    // name
    String name = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
    // probability rate
    Element pb = param.getChild(XMLTags.ProbabilityRateTag, vcNamespace);
    Expression exp = unMangleExpression(pb.getText());
    JumpProcess jump = new JumpProcess(name, exp);
    // add actions
    Iterator<Element> iterator = param.getChildren(XMLTags.ActionTag, vcNamespace).iterator();
    while (iterator.hasNext()) {
        Element tempelement = (Element) iterator.next();
        try {
            jump.addAction(getAction(tempelement, md));
        } catch (MathException e) {
            e.printStackTrace();
            throw new XmlParseException("A MathException was fired when adding a new Action to the JumpProcess " + name, e);
        } catch (ExpressionException e) {
            e.printStackTrace();
        }
    }
    return jump;
}
Also used : Expression(cbit.vcell.parser.Expression) MathException(cbit.vcell.math.MathException) Element(org.jdom.Element) JumpProcess(cbit.vcell.math.JumpProcess) ParticleJumpProcess(cbit.vcell.math.ParticleJumpProcess) ExpressionException(cbit.vcell.parser.ExpressionException)

Example 53 with MathException

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

the class XmlReader method getCompartmentSubDomain.

/**
 * This method returns a CompartmentSubDomain objecy from a XML element.
 * Creation date: (5/17/2001 11:59:45 AM)
 * @return cbit.vcell.math.CompartmentSubDomain
 * @param param org.jdom.Element
 * @exception cbit.vcell.xml.XmlParseException The exception description.
 */
private CompartmentSubDomain getCompartmentSubDomain(Element param, MathDescription mathDesc) throws XmlParseException {
    // get attributes
    String name = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
    int priority = -1;
    String temp = param.getAttributeValue(XMLTags.PriorityAttrTag);
    if (temp != null) {
        priority = Integer.parseInt(temp);
    }
    // --- create new CompartmentSubDomain ---
    CompartmentSubDomain subDomain = new CompartmentSubDomain(name, priority);
    transcribeComments(param, subDomain);
    // Process BoundaryConditions
    Iterator<Element> iterator = param.getChildren(XMLTags.BoundaryTypeTag, vcNamespace).iterator();
    while (iterator.hasNext()) {
        Element tempelement = (Element) iterator.next();
        // create BoundaryConditionType
        temp = tempelement.getAttributeValue(XMLTags.BoundaryTypeAttrTag);
        BoundaryConditionType bType = new BoundaryConditionType(temp);
        // Process Xm
        if (tempelement.getAttributeValue(XMLTags.BoundaryAttrTag).equalsIgnoreCase(XMLTags.BoundaryAttrValueXm)) {
            subDomain.setBoundaryConditionXm(bType);
        } else if (tempelement.getAttributeValue(XMLTags.BoundaryAttrTag).equalsIgnoreCase(XMLTags.BoundaryAttrValueXp)) {
            // Process Xp
            subDomain.setBoundaryConditionXp(bType);
        } else if (tempelement.getAttributeValue(XMLTags.BoundaryAttrTag).equalsIgnoreCase(XMLTags.BoundaryAttrValueYm)) {
            // Process Ym
            subDomain.setBoundaryConditionYm(bType);
        } else if (tempelement.getAttributeValue(XMLTags.BoundaryAttrTag).equalsIgnoreCase(XMLTags.BoundaryAttrValueYp)) {
            // Process Yp
            subDomain.setBoundaryConditionYp(bType);
        } else if (tempelement.getAttributeValue(XMLTags.BoundaryAttrTag).equalsIgnoreCase(XMLTags.BoundaryAttrValueZm)) {
            // Process Zm
            subDomain.setBoundaryConditionZm(bType);
        } else if (tempelement.getAttributeValue(XMLTags.BoundaryAttrTag).equalsIgnoreCase(XMLTags.BoundaryAttrValueZp)) {
            // Process Zp
            subDomain.setBoundaryConditionZp(bType);
        } else {
            // If not indentified throw an exception!!
            throw new XmlParseException("Unknown BoundaryConditionType: " + tempelement.getAttributeValue(XMLTags.BoundaryAttrTag));
        }
    }
    // process BoundaryConditionSpecs
    iterator = param.getChildren(XMLTags.BoundaryConditionSpecTag, vcNamespace).iterator();
    if (iterator != null) {
        while (iterator.hasNext()) {
            Element tempelement = (Element) iterator.next();
            try {
                subDomain.addBoundaryConditionSpec(getBoundaryConditionSpec(tempelement));
            } catch (MathException e) {
                e.printStackTrace();
                throw new XmlParseException("A MathException was fired when adding a BoundaryConditionSpec to the compartmentSubDomain " + name, e);
            }
        }
    }
    // process OdeEquations
    iterator = param.getChildren(XMLTags.OdeEquationTag, vcNamespace).iterator();
    while (iterator.hasNext()) {
        Element tempelement = (Element) iterator.next();
        try {
            subDomain.addEquation(getOdeEquation(tempelement, mathDesc));
        } catch (MathException e) {
            e.printStackTrace();
            throw new XmlParseException("A MathException was fired when adding an OdeEquation to the compartmentSubDomain " + name, e);
        }
    }
    // process PdeEquations
    iterator = param.getChildren(XMLTags.PdeEquationTag, vcNamespace).iterator();
    while (iterator.hasNext()) {
        Element tempelement = (Element) iterator.next();
        try {
            subDomain.addEquation(getPdeEquation(tempelement, mathDesc));
        } catch (MathException e) {
            e.printStackTrace();
            throw new XmlParseException("A MathException was fired when adding an PdeEquation to the compartmentSubDomain " + name, e);
        }
    }
    // Process VolumeRegionEquation
    iterator = param.getChildren(XMLTags.VolumeRegionEquationTag, vcNamespace).iterator();
    while (iterator.hasNext()) {
        Element tempelement = (Element) iterator.next();
        try {
            subDomain.addEquation(getVolumeRegionEquation(tempelement, mathDesc));
        } catch (MathException e) {
            e.printStackTrace();
            throw new XmlParseException("A MathException was fired when adding a VolumeRegionEquation to the compartmentSubDomain " + name, e);
        }
    }
    // Process Variable initial conditions (added for stochastic algos)
    iterator = param.getChildren(XMLTags.VarIniCount_OldTag, vcNamespace).iterator();
    if (iterator != null) {
        while (iterator.hasNext()) {
            Element tempelement = (Element) iterator.next();
            try {
                subDomain.addVarIniCondition(getVarIniCount(tempelement, mathDesc));
            } catch (MathException e) {
                e.printStackTrace();
                throw new XmlParseException("A MathException was fired when adding a variable initial condition to the compartmentSubDomain " + name, e);
            } catch (ExpressionException e) {
                e.printStackTrace();
            }
        }
    }
    iterator = param.getChildren(XMLTags.VarIniCountTag, vcNamespace).iterator();
    if (iterator != null) {
        while (iterator.hasNext()) {
            Element tempelement = (Element) iterator.next();
            try {
                subDomain.addVarIniCondition(getVarIniCount(tempelement, mathDesc));
            } catch (MathException e) {
                e.printStackTrace();
                throw new XmlParseException("A MathException was fired when adding a variable initial condition to the compartmentSubDomain " + name, e);
            } catch (ExpressionException e) {
                e.printStackTrace();
            }
        }
    }
    iterator = param.getChildren(XMLTags.VarIniPoissonExpectedCountTag, vcNamespace).iterator();
    if (iterator != null) {
        while (iterator.hasNext()) {
            Element tempelement = (Element) iterator.next();
            try {
                subDomain.addVarIniCondition(getVarIniPoissonExpectedCount(tempelement, mathDesc));
            } catch (MathException e) {
                e.printStackTrace();
                throw new XmlParseException("A MathException was fired when adding a variable initial condition to the compartmentSubDomain " + name, e);
            } catch (ExpressionException e) {
                e.printStackTrace();
            }
        }
    }
    // 
    // Process JumpProcesses (added for stochastic algos)
    iterator = param.getChildren(XMLTags.JumpProcessTag, vcNamespace).iterator();
    while (iterator.hasNext()) {
        Element tempelement = (Element) iterator.next();
        try {
            subDomain.addJumpProcess(getJumpProcess(tempelement, mathDesc));
        } catch (MathException e) {
            e.printStackTrace();
            throw new XmlParseException("A MathException was fired when adding a jump process to the compartmentSubDomain " + name, e);
        }
    }
    iterator = param.getChildren(XMLTags.ParticleJumpProcessTag, vcNamespace).iterator();
    while (iterator.hasNext()) {
        Element tempelement = (Element) iterator.next();
        try {
            subDomain.addParticleJumpProcess(getParticleJumpProcess(tempelement, mathDesc));
        } catch (MathException e) {
            e.printStackTrace();
            throw new XmlParseException("A MathException was fired when adding a jump process to the compartmentSubDomain " + name, e);
        }
    }
    iterator = param.getChildren(XMLTags.ParticlePropertiesTag, vcNamespace).iterator();
    while (iterator.hasNext()) {
        Element tempelement = (Element) iterator.next();
        try {
            subDomain.addParticleProperties(getParticleProperties(tempelement, mathDesc));
        } catch (MathException e) {
            e.printStackTrace();
            throw new XmlParseException("A MathException was fired when adding a jump process to the compartmentSubDomain " + name, e);
        }
    }
    // process ComputeCentroid "equations"
    iterator = param.getChildren(XMLTags.ComputeCentroidTag, vcNamespace).iterator();
    while (iterator.hasNext()) {
        Element tempelement = (Element) iterator.next();
        try {
            subDomain.addEquation(getComputeCentroid(tempelement, mathDesc));
        } catch (MathException e) {
            e.printStackTrace();
            throw new XmlParseException("A MathException was fired when adding an ComputeCentroid 'equation' to the compartmentSubDomain " + name, e);
        }
    }
    // process ComputeMembraneMetric "equations"
    iterator = param.getChildren(XMLTags.ComputeMembraneMetricTag, vcNamespace).iterator();
    while (iterator.hasNext()) {
        Element tempelement = (Element) iterator.next();
        try {
            subDomain.addEquation(getComputeMembraneMetric(tempelement, mathDesc));
        } catch (MathException e) {
            e.printStackTrace();
            throw new XmlParseException("A MathException was fired when adding an ComputeMembraneMetric 'equation' to the compartmentSubDomain " + name, e);
        }
    }
    // Process the FastSystem (if thre is)
    Element tempelement = param.getChild(XMLTags.FastSystemTag, vcNamespace);
    if (tempelement != null) {
        subDomain.setFastSystem(getFastSystem(tempelement, mathDesc));
    }
    return subDomain;
}
Also used : CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) MathException(cbit.vcell.math.MathException) Element(org.jdom.Element) BoundaryConditionType(cbit.vcell.math.BoundaryConditionType) ExpressionException(cbit.vcell.parser.ExpressionException)

Example 54 with MathException

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

the class XmlReader method getFilamentSubDomain.

/**
 * This method returns a FilamentSubDomain object from a XMl element.
 * Creation date: (5/18/2001 4:27:22 PM)
 * @return cbit.vcell.math.FilamentSubDomain
 * @param param org.jdom.Element
 * @exception cbit.vcell.xml.XmlParseException The exception description.
 */
private FilamentSubDomain getFilamentSubDomain(Element param, MathDescription mathDesc) throws XmlParseException {
    // get name
    String name = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
    // get outside Compartment ref
    String outsideName = unMangle(param.getAttributeValue(XMLTags.OutsideCompartmentTag));
    CompartmentSubDomain outsideRef = (CompartmentSubDomain) mathDesc.getCompartmentSubDomain(outsideName);
    if (outsideRef == null) {
        throw new XmlParseException("The reference to the CompartmentSubDomain " + outsideName + ", could not be resolved!");
    }
    // *** create new filamentSubDomain object ***
    FilamentSubDomain filDomain = new FilamentSubDomain(name, outsideRef);
    // add OdeEquations
    Iterator<Element> iterator = param.getChildren(XMLTags.OdeEquationTag, vcNamespace).iterator();
    while (iterator.hasNext()) {
        Element tempElement = (Element) iterator.next();
        try {
            filDomain.addEquation(getOdeEquation(tempElement, mathDesc));
        } catch (MathException e) {
            e.printStackTrace(System.out);
            throw new XmlParseException("A MathException was fired when adding an OdeEquation to the FilamentSubDomain " + name, e);
        }
    }
    // Add the FastSytem
    filDomain.setFastSystem(getFastSystem(param.getChild(XMLTags.FastSystemTag, vcNamespace), mathDesc));
    return filDomain;
}
Also used : CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) MathException(cbit.vcell.math.MathException) Element(org.jdom.Element) FilamentSubDomain(cbit.vcell.math.FilamentSubDomain)

Example 55 with MathException

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

the class XmlReader method getPostProcessingBlock.

private void getPostProcessingBlock(MathDescription mathDesc, Element element) throws XmlParseException {
    Iterator<Element> iterator = element.getChildren(XMLTags.ExplicitDataGenerator, vcNamespace).iterator();
    while (iterator.hasNext()) {
        Element tempelement = (Element) iterator.next();
        ExplicitDataGenerator explicitDataGenerator = getExplicitDataGenerator(tempelement);
        try {
            mathDesc.getPostProcessingBlock().addDataGenerator(explicitDataGenerator);
        } catch (MathException e) {
            throw new XmlParseException(e);
        }
    }
    iterator = element.getChildren(XMLTags.ProjectionDataGenerator, vcNamespace).iterator();
    while (iterator.hasNext()) {
        Element tempelement = (Element) iterator.next();
        ProjectionDataGenerator projectionDataGenerator = getProjectionDataGenerator(tempelement);
        try {
            mathDesc.getPostProcessingBlock().addDataGenerator(projectionDataGenerator);
        } catch (MathException e) {
            throw new XmlParseException(e);
        }
    }
    iterator = element.getChildren(XMLTags.ConvolutionDataGenerator, vcNamespace).iterator();
    while (iterator.hasNext()) {
        Element tempelement = (Element) iterator.next();
        ConvolutionDataGenerator convolutionDataGenerator = getConvolutionDataGenerator(tempelement);
        try {
            mathDesc.getPostProcessingBlock().addDataGenerator(convolutionDataGenerator);
        } catch (MathException e) {
            throw new XmlParseException(e);
        }
    }
}
Also used : MathException(cbit.vcell.math.MathException) Element(org.jdom.Element) ConvolutionDataGenerator(cbit.vcell.math.ConvolutionDataGenerator) ProjectionDataGenerator(cbit.vcell.math.ProjectionDataGenerator) ExplicitDataGenerator(cbit.vcell.math.ExplicitDataGenerator)

Aggregations

MathException (cbit.vcell.math.MathException)78 ExpressionException (cbit.vcell.parser.ExpressionException)46 Expression (cbit.vcell.parser.Expression)38 Variable (cbit.vcell.math.Variable)33 VolVariable (cbit.vcell.math.VolVariable)26 CompartmentSubDomain (cbit.vcell.math.CompartmentSubDomain)18 MemVariable (cbit.vcell.math.MemVariable)18 PropertyVetoException (java.beans.PropertyVetoException)18 DataAccessException (org.vcell.util.DataAccessException)16 MathDescription (cbit.vcell.math.MathDescription)15 Vector (java.util.Vector)15 Element (org.jdom.Element)15 IOException (java.io.IOException)14 Function (cbit.vcell.math.Function)13 SimulationSymbolTable (cbit.vcell.solver.SimulationSymbolTable)13 MembraneParticleVariable (cbit.vcell.math.MembraneParticleVariable)12 ParticleVariable (cbit.vcell.math.ParticleVariable)12 VolumeParticleVariable (cbit.vcell.math.VolumeParticleVariable)12 ArrayList (java.util.ArrayList)12 MappingException (cbit.vcell.mapping.MappingException)11