Search in sources :

Example 6 with ChomboSolverSpec

use of org.vcell.chombo.ChomboSolverSpec in project vcell by virtualcell.

the class SimulationSummaryPanel method displayMesh.

/**
 * Comment
 */
private void displayMesh() {
    try {
        boolean isSpatial = getSimulation().isSpatial();
        getJLabel11().setVisible(isSpatial);
        getJLabelMesh().setVisible(isSpatial);
        labelMeshRefinementTitle.setVisible(isSpatial);
        getJLabelMeshRefinement().setVisible(isSpatial);
        labelFinestMeshTitle.setVisible(isSpatial);
        labelFinestMesh.setVisible(isSpatial);
        labelRefinementRoiTitle.setVisible(isSpatial);
        labelRefinementRoi.setVisible(isSpatial);
        labelViewLevelMeshTitle.setVisible(isSpatial);
        labelViewLevelMesh.setVisible(isSpatial);
        if (getSimulation() != null && getSimulation().getMeshSpecification() != null) {
            ISize samplingSize = getSimulation().getMeshSpecification().getSamplingSize();
            String labelText = "";
            int dimension = getSimulation().getMeshSpecification().getGeometry().getDimension();
            switch(dimension) {
                case 0:
                    {
                        labelText = "error: no mesh expected";
                        break;
                    }
                default:
                    {
                        labelText = GuiUtils.getMeshSizeText(dimension, samplingSize, true) + " elements";
                        break;
                    }
            }
            getJLabelMesh().setText(labelText);
            ChomboSolverSpec chomboSolverSpec = getSimulation().getSolverTaskDescription().getChomboSolverSpec();
            if (getSimulation().getSolverTaskDescription().getSolverDescription().isChomboSolver()) {
                int numRefinementLevels = chomboSolverSpec.getNumRefinementLevels();
                labelMeshRefinementTitle.setVisible(true);
                getJLabelMeshRefinement().setVisible(true);
                labelFinestMeshTitle.setVisible(true);
                labelFinestMesh.setVisible(true);
                ISize finestISize = chomboSolverSpec.getFinestSamplingSize(samplingSize);
                String text = GuiUtils.getMeshSizeText(dimension, finestISize, true);
                labelFinestMesh.setText(text);
                boolean bHasRefinement = numRefinementLevels > 0;
                if (bHasRefinement) {
                    String refinementText = numRefinementLevels + " level(s)";
                    getJLabelMeshRefinement().setText(refinementText);
                    labelRefinementRoiTitle.setVisible(true);
                    labelRefinementRoi.setVisible(true);
                    String roiText = "Membrane ROI(s): " + chomboSolverSpec.getMembraneRefinementRois().size() + "; Volume ROI(s): " + chomboSolverSpec.getVolumeRefinementRois().size() + ";";
                    labelViewLevelMeshTitle.setVisible(true);
                    labelViewLevelMesh.setVisible(true);
                    labelViewLevelMesh.setText(GuiUtils.getMeshSizeText(dimension, chomboSolverSpec.getViewLevelSamplingSize(samplingSize), true));
                    labelRefinementRoi.setText(roiText);
                } else {
                    labelMeshRefinementTitle.setVisible(false);
                    meshRefinementLabel.setVisible(false);
                    labelFinestMeshTitle.setVisible(false);
                    labelFinestMesh.setVisible(false);
                    labelRefinementRoiTitle.setVisible(false);
                    labelRefinementRoi.setVisible(false);
                    labelViewLevelMeshTitle.setVisible(false);
                    labelViewLevelMesh.setVisible(false);
                }
            } else {
                labelMeshRefinementTitle.setVisible(false);
                getJLabelMeshRefinement().setVisible(false);
                labelFinestMesh.setVisible(false);
                labelFinestMeshTitle.setVisible(false);
                labelRefinementRoiTitle.setVisible(false);
                labelRefinementRoi.setVisible(false);
                labelViewLevelMeshTitle.setVisible(false);
                labelViewLevelMesh.setVisible(false);
            }
        }
    } catch (Exception exc) {
        exc.printStackTrace(System.out);
        getJLabelMesh().setText("");
    }
}
Also used : ISize(org.vcell.util.ISize) ChomboSolverSpec(org.vcell.chombo.ChomboSolverSpec) PropertyVetoException(java.beans.PropertyVetoException)

Example 7 with ChomboSolverSpec

use of org.vcell.chombo.ChomboSolverSpec in project vcell by virtualcell.

the class ChomboSolverSpecPanel method updateViewLevel.

private void updateViewLevel() {
    ChomboSolverSpec chomboSolverSpec = simulation.getSolverTaskDescription().getChomboSolverSpec();
    viewLevelComboBox.removeActionListener(eventHandler);
    viewLevelComboBox.removeAllItems();
    viewLevelComboBox.addItem(new Integer(0));
    int numLevels = chomboSolverSpec.getNumRefinementLevels();
    for (int i = 0; i < numLevels; ++i) {
        viewLevelComboBox.addItem(i + 1);
    }
    if (chomboSolverSpec.isFinestViewLevel()) {
        viewLevelFinestRadioButton.setSelected(chomboSolverSpec.isFinestViewLevel());
        viewLevelComboBox.setEnabled(false);
    } else {
        viewLevelUserSelectRadioButton.setSelected(!chomboSolverSpec.isFinestViewLevel());
        viewLevelComboBox.setEnabled(true);
        int viewLevel = chomboSolverSpec.getViewLevel();
        viewLevelComboBox.setSelectedItem(viewLevel);
    }
    viewLevelComboBox.addActionListener(eventHandler);
}
Also used : ChomboSolverSpec(org.vcell.chombo.ChomboSolverSpec)

Example 8 with ChomboSolverSpec

use of org.vcell.chombo.ChomboSolverSpec in project vcell by virtualcell.

the class XmlReader method getChomboSolverSpec.

private ChomboSolverSpec getChomboSolverSpec(SolverTaskDescription solverTaskDesc, Element element, int dimension) throws XmlParseException {
    int maxBoxSize = parseIntWithDefault(element, XMLTags.MaxBoxSizeTag, ChomboSolverSpec.getDefaultMaxBoxSize(dimension));
    double fillRatio = parseDoubleWithDefault(element, XMLTags.FillRatioTag, ChomboSolverSpec.getDefaultFillRatio());
    boolean bSaveVCellOutput = parseBooleanWithDefault(element, XMLTags.SaveVCellOutput, true);
    boolean bSaveChomboOutput = parseBooleanWithDefault(element, XMLTags.SaveChomboOutput, false);
    Element childElement = element.getChild(XMLTags.RefineRatios, vcNamespace);
    List<Integer> refineRatioList = null;
    if (childElement != null) {
        String text = childElement.getText();
        if (text != null && !text.isEmpty()) {
            StringTokenizer st = new StringTokenizer(text, ",");
            if (st.hasMoreTokens()) {
                refineRatioList = new ArrayList<Integer>();
                while (st.hasMoreElements()) {
                    String token = st.nextToken();
                    if (token != null) {
                        int n = Integer.parseInt(token);
                        refineRatioList.add(n);
                    }
                }
            }
        }
    }
    Integer viewLevel = null;
    try {
        ChomboSolverSpec css = new ChomboSolverSpec(maxBoxSize, fillRatio, viewLevel, bSaveVCellOutput, bSaveChomboOutput, refineRatioList);
        double smallVolfracThreshold = parseDoubleWithDefault(element, XMLTags.SmallVolfracThreshold, 0);
        int blockFactor = parseIntWithDefault(element, XMLTags.BlockFactorTag, ChomboSolverSpec.DEFAULT_BLOCK_FACTOR);
        boolean bActivateFeatureUnderDevelopment = parseBooleanWithDefault(element, XMLTags.ActivateFeatureUnderDevelopment, false);
        css.setSmallVolfracThreshold(smallVolfracThreshold);
        css.setActivateFeatureUnderDevelopment(bActivateFeatureUnderDevelopment);
        css.setBlockFactor(blockFactor);
        int tagsGrow = parseIntWithDefault(element, XMLTags.TagsGrowTag, ChomboSolverSpec.defaultTagsGrow);
        css.setTagsGrow(tagsGrow);
        Element timeBoundsElement = element.getChild(XMLTags.TimeBoundTag, vcNamespace);
        List<Element> timeIntervalElementList = null;
        boolean noTimeBounds = false;
        if (timeBoundsElement == null) {
            noTimeBounds = true;
        } else {
            timeIntervalElementList = timeBoundsElement.getChildren(XMLTags.TimeIntervalTag, vcNamespace);
            if (timeIntervalElementList.size() == 0) {
                noTimeBounds = true;
            }
        }
        if (noTimeBounds) {
            // old format
            double startTime = 0;
            double endTime = solverTaskDesc.getTimeBounds().getEndingTime();
            double timeStep = solverTaskDesc.getTimeStep().getDefaultTimeStep();
            double outputTimeStep = ((UniformOutputTimeSpec) solverTaskDesc.getOutputTimeSpec()).getOutputTimeStep();
            try {
                TimeInterval ti = new TimeInterval(startTime, endTime, timeStep, outputTimeStep);
                css.addTimeInterval(ti);
            } catch (IllegalArgumentException ex) {
                css.addTimeInterval(TimeInterval.getDefaultTimeInterval());
            }
        } else {
            for (Element e : timeIntervalElementList) {
                String s = e.getAttributeValue(XMLTags.StartTimeAttrTag);
                double startTime = Double.valueOf(s);
                s = e.getAttributeValue(XMLTags.EndTimeAttrTag);
                double endTime = Double.valueOf(s);
                s = e.getAttributeValue(XMLTags.TimeStepAttrTag);
                double timeStep = Double.valueOf(s);
                s = e.getAttributeValue(XMLTags.OutputTimeStepAttrTag);
                double outputTimeStep = Double.valueOf(s);
                TimeInterval ti = new TimeInterval(startTime, endTime, timeStep, outputTimeStep);
                css.addTimeInterval(ti);
            }
        }
        Element meshRefineElement = element.getChild(XMLTags.MeshRefinementTag, vcNamespace);
        if (meshRefineElement != null) {
            if (meshRefineElement.getChildren().size() != 0) {
                // in old model, if there is no refinement, set view level to finest
                // only set viewLevel when meshRefinement has children
                Element viewLevelChild = element.getChild(XMLTags.ViewLevelTag, vcNamespace);
                if (viewLevelChild != null) {
                    viewLevel = parseIntWithDefault(element, XMLTags.ViewLevelTag, 0);
                    css.setViewLevel(viewLevel);
                }
            }
            List<Element> levelElementList = meshRefineElement.getChildren(XMLTags.RefinementRoiTag, vcNamespace);
            for (Element levelElement : levelElementList) {
                String levelStr = levelElement.getAttributeValue(XMLTags.RefineRoiLevelAttrTag);
                int level = 1;
                if (levelStr != null) {
                    level = Integer.parseInt(levelStr);
                }
                String type = levelElement.getAttributeValue(XMLTags.RefinementRoiTypeAttrTag);
                RoiType roiType = RoiType.Membrane;
                if (type != null) {
                    try {
                        roiType = RoiType.valueOf(type);
                    } catch (Exception ex) {
                    // ignore
                    }
                }
                Element expElement = levelElement.getChild(XMLTags.ROIExpressionTag, vcNamespace);
                String roiExp = null;
                if (expElement != null) {
                    roiExp = expElement.getText();
                    RefinementRoi roi = new RefinementRoi(roiType, level, roiExp);
                    css.addRefinementRoi(roi);
                }
            }
        }
        return css;
    } catch (ExpressionException e) {
        throw new XmlParseException(e);
    }
}
Also used : UniformOutputTimeSpec(cbit.vcell.solver.UniformOutputTimeSpec) TimeInterval(org.vcell.chombo.TimeInterval) Element(org.jdom.Element) ChomboSolverSpec(org.vcell.chombo.ChomboSolverSpec) 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) ExpressionException(cbit.vcell.parser.ExpressionException) RefinementRoi(org.vcell.chombo.RefinementRoi) StringTokenizer(java.util.StringTokenizer) RoiType(org.vcell.chombo.RefinementRoi.RoiType)

Example 9 with ChomboSolverSpec

use of org.vcell.chombo.ChomboSolverSpec in project vcell by virtualcell.

the class XmlReader method getSolverTaskDescription.

/**
 * This method returns a SolverTaskDescription Object from a XML Element.
 * Creation date: (5/22/2001 10:51:23 AM)
 * @return cbit.vcell.solver.SolverTaskDescription
 * @param param org.jdom.Element
 * @param simulation cbit.vcell.solver.Simulation
 */
private SolverTaskDescription getSolverTaskDescription(Element param, Simulation simulation) throws XmlParseException {
    // *** create new SolverTaskDescription ***
    SolverTaskDescription solverTaskDesc = new SolverTaskDescription(simulation);
    // Added July 22nd, 2007, used as condition for stochSimOptions or stochHybridOprtions
    SolverDescription sd = null;
    // Retrieve attributes
    String taskType = param.getAttributeValue(XMLTags.TaskTypeTag);
    int keepEvery = -1;
    int keepAtMost = -1;
    if (param.getAttributeValue(XMLTags.KeepEveryTag) != null) {
        keepEvery = Integer.parseInt(param.getAttributeValue(XMLTags.KeepEveryTag));
        keepAtMost = Integer.parseInt(param.getAttributeValue(XMLTags.KeepAtMostTag));
    }
    boolean useSymJacob = new Boolean(param.getAttributeValue(XMLTags.UseSymbolicJacobianAttrTag)).booleanValue();
    String solverName = param.getAttributeValue(XMLTags.SolverNameTag);
    // get sentivity parameter
    Element sensparamElement = param.getChild(XMLTags.ConstantTag, vcNamespace);
    Constant sensitivityparam = null;
    if (sensparamElement != null) {
        sensitivityparam = getConstant(sensparamElement);
    }
    // set Attributes
    try {
        // set solver
        sd = SolverDescription.fromDatabaseName(solverName);
        if (sd == null) {
            System.err.println("====================================== couldn't find solver description name ==========================================");
        }
        solverTaskDesc.setSolverDescription(sd);
        if (taskType.equalsIgnoreCase(XMLTags.UnsteadyTag)) {
            solverTaskDesc.setTaskType(SolverTaskDescription.TASK_UNSTEADY);
        } else if (taskType.equalsIgnoreCase(XMLTags.SteadyTag)) {
            solverTaskDesc.setTaskType(SolverTaskDescription.TASK_STEADY);
        } else {
            throw new XmlParseException("Unexpected task type: " + taskType);
        }
    } catch (java.beans.PropertyVetoException e) {
        e.printStackTrace();
        throw new XmlParseException("A PropertyVetoException was fired when setting the taskType: " + taskType, e);
    }
    int numProcessors = parseIntWithDefault(param, XMLTags.NUM_PROCESSORS, 1);
    try {
        solverTaskDesc.setNumProcessors(numProcessors);
        solverTaskDesc.setUseSymbolicJacobian(useSymJacob);
        // get TimeBound
        solverTaskDesc.setTimeBounds(getTimeBounds(param.getChild(XMLTags.TimeBoundTag, vcNamespace)));
        // get TimeStep
        solverTaskDesc.setTimeStep(getTimeStep(param.getChild(XMLTags.TimeStepTag, vcNamespace)));
        // get ErrorTolerance
        solverTaskDesc.setErrorTolerance(getErrorTolerance(param.getChild(XMLTags.ErrorToleranceTag, vcNamespace)));
        // get StochSimOptions
        if (simulation != null && simulation.getMathDescription() != null) {
            if (simulation.getMathDescription().isNonSpatialStoch() && param.getChild(XMLTags.StochSimOptionsTag, vcNamespace) != null) {
                // Amended July 22nd, 2007 to read either stochSimOptions or stochHybridOptions
                solverTaskDesc.setStochOpt(getStochSimOptions(param.getChild(XMLTags.StochSimOptionsTag, vcNamespace)));
                if (sd != null && !sd.equals(SolverDescription.StochGibson)) {
                    solverTaskDesc.setStochHybridOpt(getStochHybridOptions(param.getChild(XMLTags.StochSimOptionsTag, vcNamespace)));
                }
            }
        }
        // get OutputOptions
        if (keepEvery != -1) {
            solverTaskDesc.setOutputTimeSpec(new DefaultOutputTimeSpec(keepEvery, keepAtMost));
        }
        OutputTimeSpec ots = getOutputTimeSpec(param.getChild(XMLTags.OutputOptionsTag, vcNamespace));
        if (ots != null) {
            solverTaskDesc.setOutputTimeSpec(getOutputTimeSpec(param.getChild(XMLTags.OutputOptionsTag, vcNamespace)));
        }
        // set SensitivityParameter
        solverTaskDesc.setSensitivityParameter(sensitivityparam);
        // set StopAtSpatiallyUniform
        Element stopSpatiallyElement = param.getChild(XMLTags.StopAtSpatiallyUniform, vcNamespace);
        if (stopSpatiallyElement != null) {
            Element errTolElement = stopSpatiallyElement.getChild(XMLTags.ErrorToleranceTag, vcNamespace);
            if (errTolElement != null) {
                solverTaskDesc.setStopAtSpatiallyUniformErrorTolerance(getErrorTolerance(errTolElement));
            }
        }
        String runParameterScanSeriallyAttributeValue = param.getAttributeValue(XMLTags.RunParameterScanSerially);
        if (runParameterScanSeriallyAttributeValue != null) {
            solverTaskDesc.setSerialParameterScan(new Boolean(runParameterScanSeriallyAttributeValue).booleanValue());
        }
        Element nfsimSimulationOptionsElement = param.getChild(XMLTags.NFSimSimulationOptions, vcNamespace);
        if (nfsimSimulationOptionsElement != null) {
            NFsimSimulationOptions nfsimSimulationOptions = getNFSimSimulationOptions(nfsimSimulationOptionsElement);
            solverTaskDesc.setNFSimSimulationOptions(nfsimSimulationOptions);
        }
        Element smoldySimulationOptionsElement = param.getChild(XMLTags.SmoldynSimulationOptions, vcNamespace);
        if (smoldySimulationOptionsElement != null) {
            SmoldynSimulationOptions smoldynSimulationOptions = getSmoldySimulationOptions(smoldySimulationOptionsElement);
            solverTaskDesc.setSmoldynSimulationOptions(smoldynSimulationOptions);
        }
        Element sundialsPdeSolverOptionsElement = param.getChild(XMLTags.SundialsSolverOptions, vcNamespace);
        if (sundialsPdeSolverOptionsElement != null) {
            SundialsPdeSolverOptions sundialsPdeSolverOptions = getSundialsPdeSolverOptions(sundialsPdeSolverOptionsElement);
            solverTaskDesc.setSundialsPdeSolverOptions(sundialsPdeSolverOptions);
        }
        Element chomboElement = param.getChild(XMLTags.ChomboSolverSpec, vcNamespace);
        if (chomboElement != null) {
            ChomboSolverSpec chombo = getChomboSolverSpec(solverTaskDesc, chomboElement, simulation.getMathDescription().getGeometry().getDimension());
            solverTaskDesc.setChomboSolverSpec(chombo);
        }
        Element mbElement = param.getChild(XMLTags.MovingBoundarySolverOptionsTag, vcNamespace);
        if (mbElement != null) {
            MovingBoundarySolverOptions mb = getMovingBoundarySolverOptions(solverTaskDesc, mbElement);
            solverTaskDesc.setMovingBoundarySolverOptions(mb);
        }
    } catch (java.beans.PropertyVetoException e) {
        e.printStackTrace();
        throw new XmlParseException(e);
    }
    return solverTaskDesc;
}
Also used : NFsimSimulationOptions(cbit.vcell.solver.NFsimSimulationOptions) SolverDescription(cbit.vcell.solver.SolverDescription) MovingBoundarySolverOptions(cbit.vcell.solvers.mb.MovingBoundarySolverOptions) SundialsPdeSolverOptions(cbit.vcell.solver.SundialsPdeSolverOptions) MacroscopicRateConstant(cbit.vcell.math.MacroscopicRateConstant) Constant(cbit.vcell.math.Constant) Element(org.jdom.Element) ChomboSolverSpec(org.vcell.chombo.ChomboSolverSpec) PropertyVetoException(java.beans.PropertyVetoException) SmoldynSimulationOptions(cbit.vcell.solver.SmoldynSimulationOptions) ExplicitOutputTimeSpec(cbit.vcell.solver.ExplicitOutputTimeSpec) OutputTimeSpec(cbit.vcell.solver.OutputTimeSpec) UniformOutputTimeSpec(cbit.vcell.solver.UniformOutputTimeSpec) DefaultOutputTimeSpec(cbit.vcell.solver.DefaultOutputTimeSpec) SolverTaskDescription(cbit.vcell.solver.SolverTaskDescription) DefaultOutputTimeSpec(cbit.vcell.solver.DefaultOutputTimeSpec)

Example 10 with ChomboSolverSpec

use of org.vcell.chombo.ChomboSolverSpec in project vcell by virtualcell.

the class SolverTaskDescription method readVCML.

// private void setSmoldynDefaultTimeStep() throws PropertyVetoException {
// if (fieldSimulation != null) {
// SmoldynTimeStepVars smoldynTimeStepVars = RunSims.computeMaxSmoldynTimeStep(fieldSimulation);
// double maxDt = smoldynTimeStepVars.getMaxDt();
// setTimeStep(new TimeStep(maxDt, maxDt, maxDt));
// }
// }
/**
 * Insert the method's description here.
 * Creation date: (10/24/00 3:45:12 PM)
 * @return java.lang.String
 */
public void readVCML(CommentStringTokenizer tokens) throws DataAccessException {
    // 
    // read format as follows: (OUT OF DATE)
    // 
    // SolverTaskDescription {
    // TaskType Unsteady
    // MaxTime 1
    // SolverDescription "Runga-Kutta Fehlberg"
    // UseSymbolicJacobian false
    // TimeBounds {
    // StartingTime	0.0
    // EndingTime		0.0
    // }
    // TimeStep {
    // DefaultTimeStep		0.0
    // MinimumTimeStep		0.0
    // MaximumTimeStep		0.0
    // }
    // ErrorTolerance {
    // AbsoluteErrorTolerance 1e-8
    // RelativeErrorTolerance 1e-4
    // }
    // StochSimOptions {
    // UseCustomSeed	false
    // CustomSeed	0
    // NumOfTrials	1
    // if Hybrid, we have following four more
    // Epsilon 100
    // Lambda 10
    // MSRTolerance 0.01
    // SDETolerance 1e-4
    // }
    // 
    // or
    // 
    // StochSimOptions {
    // UseCustomSeed	false
    // CustomSeed	0
    // NumOfTrials	1
    // }
    // StochHybridOptions {
    // Epsilon 100
    // Lambda 10
    // MSRTolerance 0.01
    // SDETolerance 1e-4
    // }
    // StopAtSpatiallyUniform {
    // AbsoluteErrorTolerance	1e-8
    // RelativeErrorTolerance 1e-4
    // }
    // KeepEvery 1
    // KeepAtMost	1000
    // OR
    // OutputOptions {
    // KeepEvery 1
    // KeepAtMost 1000
    // }
    // OR
    // OutputOptions {
    // OutputTimeStep 0.5
    // }
    // OR
    // OutputOptions {
    // OutputTimes 0.1,0.3,0.4,... (comma separated list, no spaces or linefeeds between numbers in list)
    // }
    // 
    // SensitivityParameter {
    // Constant k1 39.0;
    // }
    // RunParameterScanSerially false
    // }
    // 
    // 
    int keepEvery = -1;
    int keepAtMost = -1;
    SolverDescription sd = null;
    try {
        String token = tokens.nextToken();
        if (token.equalsIgnoreCase(VCML.SolverTaskDescription)) {
            token = tokens.nextToken();
            if (!token.equalsIgnoreCase(VCML.BeginBlock)) {
                throw new DataAccessException("unexpected token " + token + " expecting " + VCML.BeginBlock);
            }
        }
        while (tokens.hasMoreTokens()) {
            token = tokens.nextToken();
            lg.debug(token);
            if (token.equalsIgnoreCase(VCML.EndBlock)) {
                lg.debug("end block");
                break;
            }
            if (token.equalsIgnoreCase(VCML.TaskType)) {
                token = tokens.nextToken();
                if (token.equals(VCML.TaskType_Unsteady)) {
                    setTaskType(TASK_UNSTEADY);
                } else if (token.equals(VCML.TaskType_Steady)) {
                    setTaskType(TASK_STEADY);
                } else {
                    throw new DataAccessException("unexpected " + VCML.TaskType + " = " + token);
                }
                continue;
            }
            if (token.equalsIgnoreCase(VCML.SolverDescription)) {
                token = tokens.nextToken();
                // 
                try {
                    sd = SolverDescription.fromDatabaseName(token);
                    setSolverDescription(sd);
                } catch (java.beans.PropertyVetoException e) {
                    e.printStackTrace(System.out);
                }
                continue;
            }
            if (token.equalsIgnoreCase(VCML.UseSymbolicJacobian)) {
                token = tokens.nextToken();
                setUseSymbolicJacobian((new Boolean(token)).booleanValue());
                continue;
            }
            // code allows us to read the old format.
            if (token.equalsIgnoreCase(VCML.MaxTime)) {
                token = tokens.nextToken();
                // double dummyMaxTime = Double.parseDouble(token);
                continue;
            }
            if (token.equalsIgnoreCase(VCML.TimeBounds)) {
                getTimeBounds().readVCML(tokens);
                continue;
            }
            if (token.equalsIgnoreCase(VCML.TimeStep)) {
                getTimeStep().readVCML(tokens);
                continue;
            }
            if (token.equalsIgnoreCase(VCML.ErrorTolerance)) {
                getErrorTolerance().readVCML(tokens);
                continue;
            }
            if (token.equalsIgnoreCase(VCML.NFSimSimulationOptions)) {
                getNFSimSimulationOptions().readVCML(tokens);
                continue;
            }
            if (token.equalsIgnoreCase(VCML.StochSimOptions)) {
                boolean useCustomSeed = false;
                int customSeed = -1;
                long numOfTrials = 1;
                Double epsilon = null;
                Double lambda = null;
                Double MSRTolerance = null;
                Double SDETolerance = null;
                token = tokens.nextToken();
                if (!token.equalsIgnoreCase(VCML.BeginBlock)) {
                    throw new DataAccessException("unexpected token " + token + " expecting " + VCML.BeginBlock);
                }
                while (tokens.hasMoreTokens()) {
                    token = tokens.nextToken();
                    if (token.equalsIgnoreCase(VCML.EndBlock)) {
                        break;
                    }
                    if (token.equalsIgnoreCase(VCML.UseCustomSeed)) {
                        token = tokens.nextToken();
                        useCustomSeed = Boolean.parseBoolean(token);
                        continue;
                    }
                    if (token.equalsIgnoreCase(VCML.CustomSeed)) {
                        token = tokens.nextToken();
                        int val1 = Integer.parseInt(token);
                        if (val1 < 0) {
                            throw new DataAccessException("unexpected token " + token + ", seed is required to be an unsigned interger. ");
                        } else {
                            customSeed = val1;
                        }
                        continue;
                    }
                    if (token.equalsIgnoreCase(VCML.NumOfTrials)) {
                        token = tokens.nextToken();
                        int val2 = Integer.parseInt(token);
                        if (val2 < 1) {
                            throw new DataAccessException("unexpected token " + token + ", num of trials is requied to be at least 1. ");
                        } else {
                            numOfTrials = val2;
                        }
                        continue;
                    }
                    // 
                    if (token.equalsIgnoreCase(VCML.Epsilon)) {
                        token = tokens.nextToken();
                        double val3 = Double.parseDouble(token);
                        if (val3 < 1)
                            throw new DataAccessException("unexpected token " + token + ", Minimum number of molecue is requied to be greater than or equal to 1. ");
                        else
                            epsilon = val3;
                        continue;
                    }
                    if (token.equalsIgnoreCase(VCML.Lambda)) {
                        token = tokens.nextToken();
                        double val4 = Double.parseDouble(token);
                        if (val4 <= 0)
                            throw new DataAccessException("unexpected token " + token + ", num of trials is requied to be greater than 0. ");
                        else
                            lambda = val4;
                        continue;
                    }
                    if (token.equalsIgnoreCase(VCML.MSRTolerance)) {
                        token = tokens.nextToken();
                        double val5 = Double.parseDouble(token);
                        if (val5 <= 0)
                            throw new DataAccessException("unexpected token " + token + ", Maximum allowed effect of slow reactions is requied to be greater than 0. ");
                        else
                            MSRTolerance = val5;
                        continue;
                    }
                    if (token.equalsIgnoreCase(VCML.SDETolerance)) {
                        token = tokens.nextToken();
                        double val6 = Double.parseDouble(token);
                        if (val6 <= 0)
                            throw new DataAccessException("unexpected token " + token + ", SDE allowed value of drift and diffusion errors is requied to be greater than 0. ");
                        else
                            SDETolerance = val6;
                        continue;
                    }
                    throw new DataAccessException("unexpected identifier " + token);
                }
                if (getSimulation() != null && getSimulation().getMathDescription() != null) {
                    if (getSimulation().getMathDescription().isNonSpatialStoch()) {
                        setStochOpt(new NonspatialStochSimOptions(useCustomSeed, customSeed, numOfTrials));
                        if (epsilon != null && lambda != null && MSRTolerance != null && SDETolerance != null) {
                            setStochHybridOpt(new NonspatialStochHybridOptions(epsilon, lambda, MSRTolerance, SDETolerance));
                        }
                    } else {
                        setStochOpt(null);
                    }
                }
                continue;
            }
            if (token.equalsIgnoreCase(VCML.StochHybridOptions)) {
                Double epsilon = null;
                Double lambda = null;
                Double MSRTolerance = null;
                Double SDETolerance = null;
                token = tokens.nextToken();
                if (!token.equalsIgnoreCase(VCML.BeginBlock)) {
                    throw new DataAccessException("unexpected token " + token + " expecting " + VCML.BeginBlock);
                }
                while (tokens.hasMoreTokens()) {
                    token = tokens.nextToken();
                    if (token.equalsIgnoreCase(VCML.EndBlock)) {
                        break;
                    }
                    if (token.equalsIgnoreCase(VCML.Epsilon)) {
                        token = tokens.nextToken();
                        double val3 = Double.parseDouble(token);
                        if (val3 < 1)
                            throw new DataAccessException("unexpected token " + token + ", Minimum number of molecue is requied to be greater than or equal to 1. ");
                        else
                            epsilon = val3;
                        continue;
                    }
                    if (token.equalsIgnoreCase(VCML.Lambda)) {
                        token = tokens.nextToken();
                        double val4 = Double.parseDouble(token);
                        if (val4 <= 0)
                            throw new DataAccessException("unexpected token " + token + ", num of trials is requied to be greater than 0. ");
                        else
                            lambda = val4;
                        continue;
                    }
                    if (token.equalsIgnoreCase(VCML.MSRTolerance)) {
                        token = tokens.nextToken();
                        double val5 = Double.parseDouble(token);
                        if (val5 <= 0)
                            throw new DataAccessException("unexpected token " + token + ", Maximum allowed effect of slow reactions is requied to be greater than 0. ");
                        else
                            MSRTolerance = val5;
                        continue;
                    }
                    if (token.equalsIgnoreCase(VCML.SDETolerance)) {
                        token = tokens.nextToken();
                        double val6 = Double.parseDouble(token);
                        if (val6 <= 0)
                            throw new DataAccessException("unexpected token " + token + ", SDE allowed value of drift and diffusion errors is requied to be greater than 0. ");
                        else
                            SDETolerance = val6;
                        continue;
                    }
                    throw new DataAccessException("unexpected identifier " + token);
                }
                if (getSimulation() != null && getSimulation().getMathDescription() != null) {
                    if (getSimulation().getMathDescription().isNonSpatialStoch()) {
                        if (epsilon != null && lambda != null && MSRTolerance != null && SDETolerance != null) {
                            setStochHybridOpt(new NonspatialStochHybridOptions(epsilon, lambda, MSRTolerance, SDETolerance));
                        }
                    }
                }
                continue;
            }
            if (token.equalsIgnoreCase(VCML.OutputOptions)) {
                fieldOutputTimeSpec = OutputTimeSpec.readVCML(tokens);
                continue;
            }
            if (token.equalsIgnoreCase(VCML.KeepEvery)) {
                token = tokens.nextToken();
                keepEvery = Integer.parseInt(token);
                continue;
            }
            if (token.equalsIgnoreCase(VCML.KeepAtMost)) {
                token = tokens.nextToken();
                keepAtMost = Integer.parseInt(token);
                continue;
            }
            if (token.equalsIgnoreCase(VCML.SensitivityParameter)) {
                token = tokens.nextToken();
                if (!token.equalsIgnoreCase(VCML.BeginBlock)) {
                    throw new DataAccessException("unexpected token " + token + " expecting " + VCML.BeginBlock);
                }
                token = tokens.nextToken();
                if (!token.equalsIgnoreCase(VCML.Constant)) {
                    throw new DataAccessException("unexpected token " + token + " expecting " + VCML.Constant);
                }
                String name = tokens.nextToken();
                Expression exp = MathFunctionDefinitions.fixFunctionSyntax(tokens);
                Constant constant = new Constant(name, exp);
                setSensitivityParameter(constant);
                token = tokens.nextToken();
                if (!token.equalsIgnoreCase(VCML.EndBlock)) {
                    throw new DataAccessException("unexpected token " + token + " expecting " + VCML.EndBlock);
                }
                continue;
            }
            if (token.equalsIgnoreCase(VCML.StopAtSpatiallyUniform)) {
                token = tokens.nextToken();
                stopAtSpatiallyUniformErrorTolerance = ErrorTolerance.getDefaultSpatiallyUniformErrorTolerance();
                stopAtSpatiallyUniformErrorTolerance.readVCML(tokens);
            } else if (token.equalsIgnoreCase(VCML.RunParameterScanSerially)) {
                token = tokens.nextToken();
                setSerialParameterScan((new Boolean(token)).booleanValue());
            } else if (token.equalsIgnoreCase(VCML.SmoldynSimulationOptions)) {
                setSmoldynSimulationOptions(new SmoldynSimulationOptions(tokens));
            } else if (token.equalsIgnoreCase(VCML.SundialsSolverOptions)) {
                setSundialsPdeSolverOptions(new SundialsPdeSolverOptions(tokens));
            } else if (token.equalsIgnoreCase(VCML.ChomboSolverSpec)) {
                chomboSolverSpec = new ChomboSolverSpec(tokens);
            } else if (token.equalsIgnoreCase(VCML.NUM_PROCESSORS)) {
                token = tokens.nextToken();
                numProcessors = Integer.parseInt(token);
            } else if (token.equalsIgnoreCase(VCML.MovingBoundarySolverOptions)) {
                movingBoundarySolverOptions = new MovingBoundarySolverOptions(tokens);
            } else {
                throw new DataAccessException("unexpected identifier " + token);
            }
        }
    } catch (Throwable e) {
        e.printStackTrace(System.out);
        throw new DataAccessException("line #" + (tokens.lineIndex() + 1) + " Exception: " + e.getMessage());
    }
    if (keepEvery != -1) {
        fieldOutputTimeSpec = new DefaultOutputTimeSpec(keepEvery, keepAtMost);
    }
}
Also used : MovingBoundarySolverOptions(cbit.vcell.solvers.mb.MovingBoundarySolverOptions) Constant(cbit.vcell.math.Constant) ChomboSolverSpec(org.vcell.chombo.ChomboSolverSpec) PropertyVetoException(java.beans.PropertyVetoException) Expression(cbit.vcell.parser.Expression) DataAccessException(org.vcell.util.DataAccessException)

Aggregations

ChomboSolverSpec (org.vcell.chombo.ChomboSolverSpec)10 PropertyVetoException (java.beans.PropertyVetoException)5 MovingBoundarySolverOptions (cbit.vcell.solvers.mb.MovingBoundarySolverOptions)4 SolverTaskDescription (cbit.vcell.solver.SolverTaskDescription)3 Element (org.jdom.Element)3 Constant (cbit.vcell.math.Constant)2 Expression (cbit.vcell.parser.Expression)2 NFsimSimulationOptions (cbit.vcell.solver.NFsimSimulationOptions)2 Simulation (cbit.vcell.solver.Simulation)2 SmoldynSimulationOptions (cbit.vcell.solver.SmoldynSimulationOptions)2 SundialsPdeSolverOptions (cbit.vcell.solver.SundialsPdeSolverOptions)2 UniformOutputTimeSpec (cbit.vcell.solver.UniformOutputTimeSpec)2 ArrayList (java.util.ArrayList)2 RefinementRoi (org.vcell.chombo.RefinementRoi)2 ISize (org.vcell.util.ISize)2 ImageException (cbit.image.ImageException)1 VCImage (cbit.image.VCImage)1 VCImageUncompressed (cbit.image.VCImageUncompressed)1 VCPixelClass (cbit.image.VCPixelClass)1 AnalyticSubVolume (cbit.vcell.geometry.AnalyticSubVolume)1