Search in sources :

Example 11 with BoundaryConditionType

use of cbit.vcell.math.BoundaryConditionType 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 12 with BoundaryConditionType

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

the class XmlReader method getBoundaryConditionSpec.

private BoundaryConditionSpec getBoundaryConditionSpec(Element param) throws XmlParseException, MathException {
    // retrieve values
    String boundarySubdomainName = unMangle(param.getAttributeValue(XMLTags.BoundarySubdomainNameTag));
    String boundarySubdomainType = unMangle(param.getAttributeValue(XMLTags.BoundaryTypeTag));
    if (boundarySubdomainName != null && boundarySubdomainType != null) {
        BoundaryConditionSpec bcs = new BoundaryConditionSpec(boundarySubdomainName, new BoundaryConditionType(boundarySubdomainType));
        return bcs;
    }
    return null;
}
Also used : BoundaryConditionType(cbit.vcell.math.BoundaryConditionType) BoundaryConditionSpec(cbit.vcell.math.SubDomain.BoundaryConditionSpec)

Example 13 with BoundaryConditionType

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

the class XmlReader method getFeatureMapping.

/**
 * This method retuns a FeatureMapping object from a XML representation.
 * Creation date: (5/7/2001 4:12:03 PM)
 * @return cbit.vcell.mapping.FeatureMapping
 * @param param org.jdom.Element
 */
private FeatureMapping getFeatureMapping(Element param, SimulationContext simulationContext) throws XmlParseException {
    // Retrieve attributes
    String featurename = unMangle(param.getAttributeValue(XMLTags.FeatureAttrTag));
    String geometryClassName = param.getAttributeValue(XMLTags.SubVolumeAttrTag);
    if (geometryClassName != null) {
        geometryClassName = unMangle(geometryClassName);
    } else {
        geometryClassName = param.getAttributeValue(XMLTags.GeometryClassAttrTag);
        if (geometryClassName != null) {
            geometryClassName = unMangle(geometryClassName);
        }
    }
    Feature featureref = (Feature) simulationContext.getModel().getStructure(featurename);
    if (featureref == null) {
        throw new XmlParseException("The Feature " + featurename + " could not be resolved!");
    }
    // *** Create new Feature Mapping ****
    FeatureMapping feamap = new FeatureMapping(featureref, simulationContext, simulationContext.getModel().getUnitSystem());
    // Set Size
    if (param.getAttributeValue(XMLTags.SizeTag) != null) {
        String size = unMangle(param.getAttributeValue(XMLTags.SizeTag));
        try {
            feamap.getSizeParameter().setExpression(unMangleExpression(size));
        } catch (ExpressionException e) {
            e.printStackTrace(System.out);
            throw new XmlParseException("An expressionException was fired when setting the size Expression " + size + " to a featureMapping!", e);
        }
    } else {
        try {
            feamap.getSizeParameter().setExpression(null);
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("unexpected exception while setting structure size: " + e.getMessage());
        }
    }
    // Set Volume/unit_area if it exists
    if (param.getAttributeValue(XMLTags.VolumePerUnitAreaTag) != null) {
        String volPerUnitArea = unMangle(param.getAttributeValue(XMLTags.VolumePerUnitAreaTag));
        try {
            feamap.getVolumePerUnitAreaParameter().setExpression(unMangleExpression(volPerUnitArea));
        } catch (ExpressionException e) {
            e.printStackTrace(System.out);
            throw new XmlParseException("An expressionException was fired when setting the VolumePerUnitArea Expression " + volPerUnitArea + " to a featureMapping!", e);
        }
    }
    // Set Volume/unitVol if it exists
    if (param.getAttributeValue(XMLTags.VolumePerUnitVolumeTag) != null) {
        String volPerUnitVol = unMangle(param.getAttributeValue(XMLTags.VolumePerUnitVolumeTag));
        try {
            feamap.getVolumePerUnitVolumeParameter().setExpression(unMangleExpression(volPerUnitVol));
        } catch (ExpressionException e) {
            e.printStackTrace(System.out);
            throw new XmlParseException("An expressionException was fired when setting the size Expression " + volPerUnitVol + " to a featureMapping!", e);
        }
    }
    if (geometryClassName != null) {
        GeometryClass[] geometryClasses = simulationContext.getGeometry().getGeometryClasses();
        for (int i = 0; i < geometryClasses.length; i++) {
            if (geometryClasses[i].getName().equals(geometryClassName)) {
                try {
                    feamap.setGeometryClass(geometryClasses[i]);
                } catch (PropertyVetoException e) {
                    e.printStackTrace(System.out);
                    throw new XmlParseException("A propertyVetoException was fired when trying to set the subvolume or surface " + geometryClassName + " to a MembraneMapping!", e);
                }
            }
        }
    }
    // Set Boundary conditions
    Element tempElement = param.getChild(XMLTags.BoundariesTypesTag, vcNamespace);
    // Xm
    String temp = tempElement.getAttributeValue(XMLTags.BoundaryAttrValueXm);
    BoundaryConditionType bct = new BoundaryConditionType(temp);
    feamap.setBoundaryConditionTypeXm(bct);
    // Xp
    temp = tempElement.getAttributeValue(XMLTags.BoundaryAttrValueXp);
    bct = new BoundaryConditionType(temp);
    feamap.setBoundaryConditionTypeXp(bct);
    // Ym
    temp = tempElement.getAttributeValue(XMLTags.BoundaryAttrValueYm);
    bct = new BoundaryConditionType(temp);
    feamap.setBoundaryConditionTypeYm(bct);
    // Yp
    temp = tempElement.getAttributeValue(XMLTags.BoundaryAttrValueYp);
    bct = new BoundaryConditionType(temp);
    feamap.setBoundaryConditionTypeYp(bct);
    // Zm
    temp = tempElement.getAttributeValue(XMLTags.BoundaryAttrValueZm);
    bct = new BoundaryConditionType(temp);
    feamap.setBoundaryConditionTypeZm(bct);
    // Zp
    temp = tempElement.getAttributeValue(XMLTags.BoundaryAttrValueZp);
    bct = new BoundaryConditionType(temp);
    feamap.setBoundaryConditionTypeZp(bct);
    return feamap;
}
Also used : GeometryClass(cbit.vcell.geometry.GeometryClass) Element(org.jdom.Element) BoundaryConditionType(cbit.vcell.math.BoundaryConditionType) Feature(cbit.vcell.model.Feature) ExpressionException(cbit.vcell.parser.ExpressionException) GeometryException(cbit.vcell.geometry.GeometryException) MathFormatException(cbit.vcell.math.MathFormatException) MappingException(cbit.vcell.mapping.MappingException) PropertyVetoException(java.beans.PropertyVetoException) ImageException(cbit.image.ImageException) ExpressionBindingException(cbit.vcell.parser.ExpressionBindingException) ModelException(cbit.vcell.model.ModelException) DataConversionException(org.jdom.DataConversionException) ExpressionException(cbit.vcell.parser.ExpressionException) MathException(cbit.vcell.math.MathException) PropertyVetoException(java.beans.PropertyVetoException) FeatureMapping(cbit.vcell.mapping.FeatureMapping)

Example 14 with BoundaryConditionType

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

the class XmlReader method getMembraneSubDomain.

/**
 * This method returns a MembraneSubDomain object from a XML Element.
 * Creation date: (5/18/2001 4:23:30 PM)
 * @return cbit.vcell.math.MembraneSubDomain
 * @param param org.jdom.Element
 * @exception cbit.vcell.xml.XmlParseException The exception description.
 */
@SuppressWarnings("unchecked")
private MembraneSubDomain getMembraneSubDomain(Element param, MathDescription mathDesc) throws XmlParseException {
    // no need to do anything with the 'Name' attribute : constructor of MembraneSubDomain creates name from inside/outside compartmentSubDomains.
    // String msdName = unMangle( param.getAttributeValue(XMLTags.NameAttrTag) );
    // if ( msdName != null) {
    // }
    // get compartmentSubDomain references
    // inside
    String name = unMangle(param.getAttributeValue(XMLTags.InsideCompartmentTag));
    CompartmentSubDomain insideRef = (CompartmentSubDomain) mathDesc.getCompartmentSubDomain(name);
    if (insideRef == null) {
        throw new XmlParseException("The reference to the inside CompartmentSubDomain " + name + ", could not be resolved!");
    }
    // outside
    name = unMangle(param.getAttributeValue(XMLTags.OutsideCompartmentTag));
    CompartmentSubDomain outsideRef = (CompartmentSubDomain) mathDesc.getCompartmentSubDomain(name);
    if (outsideRef == null) {
        throw new XmlParseException("The reference to the outside CompartmentSubDomain " + name + ", could not be resolved!");
    }
    // *** create new Membrane SubDomain ***
    SubVolume insideSubVolume = mathDesc.getGeometry().getGeometrySpec().getSubVolume(insideRef.getName());
    SubVolume outsideSubVolume = mathDesc.getGeometry().getGeometrySpec().getSubVolume(outsideRef.getName());
    SurfaceClass surfaceClass = mathDesc.getGeometry().getGeometrySurfaceDescription().getSurfaceClass(insideSubVolume, outsideSubVolume);
    MembraneSubDomain subDomain = new MembraneSubDomain(insideRef, outsideRef, surfaceClass.getName());
    transcribeComments(param, subDomain);
    // Process BoundaryConditions
    Iterator<Element> iterator = param.getChildren(XMLTags.BoundaryTypeTag, vcNamespace).iterator();
    while (iterator.hasNext()) {
        Element tempelement = (Element) iterator.next();
        // create BoundaryConditionType
        String 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));
        }
    }
    // Add OdeEquations
    iterator = param.getChildren(XMLTags.OdeEquationTag, vcNamespace).iterator();
    while (iterator.hasNext()) {
        Element tempElement = (Element) iterator.next();
        OdeEquation odeEquation = getOdeEquation(tempElement, mathDesc);
        try {
            subDomain.addEquation(odeEquation);
        } catch (MathException e) {
            e.printStackTrace();
            throw new XmlParseException("A MathException was fired when adding an OdeEquation to a MembraneSubDomain!", 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 MembraneSubDomain " + name, e);
        }
    }
    // Add JumpConditions
    iterator = param.getChildren(XMLTags.JumpConditionTag, vcNamespace).iterator();
    while (iterator.hasNext()) {
        Element tempElement = (Element) iterator.next();
        try {
            subDomain.addJumpCondition(getJumpCondition(tempElement, mathDesc));
        } catch (MathException e) {
            e.printStackTrace();
            throw new XmlParseException("A MathException was fired when adding a JumpCondition to a MembraneSubDomain!", e);
        }
    }
    // Add the FastSystem (if any)
    Element tempElement = param.getChild(XMLTags.FastSystemTag, vcNamespace);
    if (tempElement != null) {
        subDomain.setFastSystem(getFastSystem(tempElement, mathDesc));
    }
    // add MembraneRegionEquation
    iterator = param.getChildren(XMLTags.MembraneRegionEquationTag, vcNamespace).iterator();
    while (iterator.hasNext()) {
        tempElement = (Element) iterator.next();
        try {
            subDomain.addEquation(getMembraneRegionEquation(tempElement, mathDesc));
        } catch (MathException e) {
            e.printStackTrace();
            throw new XmlParseException("A MathException was fired when adding a MembraneRegionEquation to a MEmbraneSubDomain!", 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 MembraneSubDomain " + 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 MembraneSubDomain " + name, e);
        }
    }
    // process ComputeNormal "equations"
    iterator = param.getChildren(XMLTags.ComputeNormalTag, vcNamespace).iterator();
    while (iterator.hasNext()) {
        Element tempelement = (Element) iterator.next();
        try {
            subDomain.addEquation(getComputeNormal(tempelement, mathDesc));
        } catch (MathException e) {
            e.printStackTrace();
            throw new XmlParseException("A MathException was fired when adding an ComputeNormal 'equation' to the MembraneSubDomain " + name, e);
        }
    }
    Element velElem = param.getChild(XMLTags.VelocityTag, vcNamespace);
    setMembraneSubdomainVelocity(velElem, XMLTags.XAttrTag, subDomain::setVelocityX);
    setMembraneSubdomainVelocity(velElem, XMLTags.YAttrTag, subDomain::setVelocityY);
    return subDomain;
}
Also used : MembraneSubDomain(cbit.vcell.math.MembraneSubDomain) OdeEquation(cbit.vcell.math.OdeEquation) SurfaceClass(cbit.vcell.geometry.SurfaceClass) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) SubVolume(cbit.vcell.geometry.SubVolume) CompartmentSubVolume(cbit.vcell.geometry.CompartmentSubVolume) AnalyticSubVolume(cbit.vcell.geometry.AnalyticSubVolume) ImageSubVolume(cbit.vcell.geometry.ImageSubVolume) MathException(cbit.vcell.math.MathException) Element(org.jdom.Element) BoundaryConditionType(cbit.vcell.math.BoundaryConditionType)

Example 15 with BoundaryConditionType

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

the class FiniteVolumeFileWriter method writeMembrane_VarContext_Equation.

/**
 *EQUATION_BEGIN rf
 *INITIAL 5.0;
 *RATE ( - ((0.02 * ( - rB - rfB + (20.0 * ((x > -3.0) && (x < 3.0) && (y > -5.0) && (y < 5.0))) + _VCell_FieldData_0) * rf) - (0.1 * rfB)) - (50.0 * rf * ((x > -5.0) && (x < 5.0) && (y > -5.0) && (y < 5.0))));
 *DIFFUSION 10.0;
 *BOUNDARY_XM 5.0;
 *BOUNDARY_XP 5.0;
 *BOUNDARY_YM 5.0;
 *BOUNDARY_YP 5.0;
 *EQUATION_END
 * @throws ExpressionException
 * @throws MathException
 */
private void writeMembrane_VarContext_Equation(MembraneSubDomain memSubDomain, Equation equation) throws ExpressionException, MathException {
    printWriter.println("EQUATION_BEGIN " + equation.getVariable().getName());
    printWriter.println("INITIAL " + subsituteExpression(equation.getInitialExpression(), VariableDomain.VARIABLEDOMAIN_MEMBRANE).infix() + ";");
    Expression rateExpression = subsituteExpression(equation.getRateExpression(), VariableDomain.VARIABLEDOMAIN_MEMBRANE);
    printWriter.println("RATE " + replaceVolumeVariable(simTask, memSubDomain, rateExpression) + ";");
    if (bChomboSolver && equation.getExactSolution() != null) {
        printWriter.println(FVInputFileKeyword.EXACT + " " + subsituteExpression(equation.getExactSolution(), VariableDomain.VARIABLEDOMAIN_VOLUME).infix() + ";");
    }
    if (equation instanceof PdeEquation) {
        printWriter.println("DIFFUSION " + subsituteExpression(((PdeEquation) equation).getDiffusionExpression(), VariableDomain.VARIABLEDOMAIN_MEMBRANE).infix() + ";");
        PdeEquation pde = (PdeEquation) equation;
        BoundaryConditionType[] bctypes = new BoundaryConditionType[] { memSubDomain.getInsideCompartment().getBoundaryConditionXm(), memSubDomain.getInsideCompartment().getBoundaryConditionXp(), memSubDomain.getInsideCompartment().getBoundaryConditionYm(), memSubDomain.getInsideCompartment().getBoundaryConditionYp(), memSubDomain.getInsideCompartment().getBoundaryConditionZm(), memSubDomain.getInsideCompartment().getBoundaryConditionZp() };
        writeBoundaryValues(bctypes, pde, VariableDomain.VARIABLEDOMAIN_MEMBRANE);
    }
    // if (simulation.getSolverTaskDescription().getSolverDescription().equals(SolverDescription.SundialsPDE)) {
    // StringBuffer rateDerivativeString = new StringBuffer();
    // Variable[] vars = simulation.getVariables();
    // int count = 0;
    // for (Variable var : vars) {
    // if (var instanceof MemVariable) {
    // Expression exp = rateExpression.differentiate(var.getName());
    // rateDerivativeString.append(exp.flatten().infix() + ";\n");
    // count ++;
    // }
    // }
    // printWriter.println("RATE_DERIVATIVES " + count);
    // printWriter.print(rateDerivativeString);
    // }
    printWriter.println("EQUATION_END");
    printWriter.println();
}
Also used : PdeEquation(cbit.vcell.math.PdeEquation) Expression(cbit.vcell.parser.Expression) BoundaryConditionType(cbit.vcell.math.BoundaryConditionType)

Aggregations

BoundaryConditionType (cbit.vcell.math.BoundaryConditionType)18 Expression (cbit.vcell.parser.Expression)6 ExpressionException (cbit.vcell.parser.ExpressionException)6 GeometryClass (cbit.vcell.geometry.GeometryClass)5 StructureMapping (cbit.vcell.mapping.StructureMapping)5 SubVolume (cbit.vcell.geometry.SubVolume)4 MathException (cbit.vcell.math.MathException)4 PropertyVetoException (java.beans.PropertyVetoException)4 Element (org.jdom.Element)4 SurfaceClass (cbit.vcell.geometry.SurfaceClass)3 FeatureMapping (cbit.vcell.mapping.FeatureMapping)3 MappingException (cbit.vcell.mapping.MappingException)3 CompartmentSubDomain (cbit.vcell.math.CompartmentSubDomain)3 Structure (cbit.vcell.model.Structure)3 ImageException (cbit.image.ImageException)2 BioModel (cbit.vcell.biomodel.BioModel)2 AnalyticSubVolume (cbit.vcell.geometry.AnalyticSubVolume)2 GeometrySpec (cbit.vcell.geometry.GeometrySpec)2 ImageSubVolume (cbit.vcell.geometry.ImageSubVolume)2 RegionInfo (cbit.vcell.geometry.RegionImage.RegionInfo)2