Search in sources :

Example 11 with MathOverrides

use of cbit.vcell.solver.MathOverrides in project vcell by virtualcell.

the class XmlReader method getMathOverrides.

/**
 * This method returns a MathOverrides object from a XML Element.
 * Creation date: (5/21/2001 3:05:17 PM)
 * @return cbit.vcell.solver.MathOverrides
 * @param param org.jdom.Element
 */
private MathOverrides getMathOverrides(Element param, Simulation simulation) throws XmlParseException {
    MathOverrides mathOverrides = null;
    try {
        // Get the constants
        Object[] elements = param.getChildren().toArray();
        Vector<ConstantArraySpec> v1 = new Vector<ConstantArraySpec>();
        Vector<Constant> v2 = new Vector<Constant>();
        for (int i = 0; i < elements.length; i++) {
            Element e = (Element) elements[i];
            Attribute array = e.getAttribute(XMLTags.ConstantArraySpec);
            if (array != null) {
                // collect scan overrides
                String name = e.getAttributeValue(XMLTags.NameAttrTag);
                int type = array.getIntValue();
                v1.add(ConstantArraySpec.createFromString(name, e.getText(), type));
            } else {
                // collect regular overrides
                v2.add(getConstant(e));
            }
        }
        Constant[] constants = (Constant[]) BeanUtils.getArray(v2, Constant.class);
        ConstantArraySpec[] specs = (ConstantArraySpec[]) BeanUtils.getArray(v1, ConstantArraySpec.class);
        // create new MathOverrides object
        mathOverrides = new MathOverrides(simulation, constants, specs);
    } catch (ExpressionException e) {
        e.printStackTrace();
        throw new XmlParseException("A ExpressionException was fired when adding a Constant to the MathOverrides", e);
    } catch (DataConversionException e2) {
        e2.printStackTrace();
        throw new XmlParseException("A DataConversionException occured when reading a ConstantArraySpec type", e2);
    }
    return mathOverrides;
}
Also used : Attribute(org.jdom.Attribute) MacroscopicRateConstant(cbit.vcell.math.MacroscopicRateConstant) Constant(cbit.vcell.math.Constant) Element(org.jdom.Element) ConstantArraySpec(cbit.vcell.solver.ConstantArraySpec) ExpressionException(cbit.vcell.parser.ExpressionException) MathOverrides(cbit.vcell.solver.MathOverrides) VolumeRegionObject(cbit.vcell.mapping.spatial.VolumeRegionObject) PointObject(cbit.vcell.mapping.spatial.PointObject) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) SurfaceRegionObject(cbit.vcell.mapping.spatial.SurfaceRegionObject) CSGObject(cbit.vcell.geometry.CSGObject) DataConversionException(org.jdom.DataConversionException) Vector(java.util.Vector)

Aggregations

MathOverrides (cbit.vcell.solver.MathOverrides)11 Simulation (cbit.vcell.solver.Simulation)5 Constant (cbit.vcell.math.Constant)4 Expression (cbit.vcell.parser.Expression)4 BioModel (cbit.vcell.biomodel.BioModel)3 SimulationContext (cbit.vcell.mapping.SimulationContext)3 ExpressionException (cbit.vcell.parser.ExpressionException)3 SolverTaskDescription (cbit.vcell.solver.SolverTaskDescription)3 MathMapping (cbit.vcell.mapping.MathMapping)2 MathSymbolMapping (cbit.vcell.mapping.MathSymbolMapping)2 ExplicitOutputTimeSpec (cbit.vcell.solver.ExplicitOutputTimeSpec)2 SimulationJob (cbit.vcell.solver.SimulationJob)2 TimeBounds (cbit.vcell.solver.TimeBounds)2 IOException (java.io.IOException)2 Random (java.util.Random)2 SbmlException (org.vcell.sbml.SbmlException)2 KeyValue (org.vcell.util.document.KeyValue)2 QueryHashtable (cbit.sql.QueryHashtable)1 CSGObject (cbit.vcell.geometry.CSGObject)1 Geometry (cbit.vcell.geometry.Geometry)1