Search in sources :

Example 1 with SundialsPdeSolverOptions

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

the class Xmlproducer method getXML.

/**
 * This method returns a XML representation of a SolverTaskDescription object.
 * Creation date: (3/2/2001 10:59:55 PM)
 * @return Element
 * @param param cbit.vcell.solver.SolverTaskDescription
 */
private Element getXML(SolverTaskDescription param) {
    Element solvertask = new Element(XMLTags.SolverTaskDescriptionTag);
    // Add Attributes
    if (param.getTaskType() == SolverTaskDescription.TASK_UNSTEADY) {
        solvertask.setAttribute(XMLTags.TaskTypeTag, XMLTags.UnsteadyTag);
    } else if (param.getTaskType() == SolverTaskDescription.TASK_STEADY) {
        solvertask.setAttribute(XMLTags.TaskTypeTag, XMLTags.SteadyTag);
    } else {
        throw new IllegalArgumentException("Unexpected task type:" + param.getTaskType());
    }
    // solvertask.setAttribute(XMLTags.KeepEveryTag, String.valueOf(param.getKeepEvery()));
    // solvertask.setAttribute(XMLTags.KeepAtMostTag, String.valueOf(param.getKeepAtMost()));
    solvertask.setAttribute(XMLTags.UseSymbolicJacobianAttrTag, String.valueOf(param.getUseSymbolicJacobian()));
    // Add timeBounds
    solvertask.addContent(getXML(param.getTimeBounds()));
    // Add timeStep
    solvertask.addContent(getXML(param.getTimeStep()));
    // Add ErrorTolerence
    solvertask.addContent(getXML(param.getErrorTolerance()));
    // Jan 8, 2016 (jim) let getXML(stochOpt) write out the correct stochastic options
    if (param.getStochOpt() != null) {
        solvertask.addContent(getXML(param.getStochOpt(), param.getStochHybridOpt()));
    }
    // Add OutputOptions
    solvertask.addContent(getXML(param.getOutputTimeSpec()));
    // Add sensitivityParameter
    if (param.getSensitivityParameter() != null) {
        solvertask.addContent(getXML(param.getSensitivityParameter()));
    }
    // Add solver name
    solvertask.setAttribute(XMLTags.SolverNameTag, param.getSolverDescription().getDatabaseName());
    // Stop At Spatially Uniform
    ErrorTolerance stopAtSpatiallyUniformErrorTolerance = param.getStopAtSpatiallyUniformErrorTolerance();
    if (stopAtSpatiallyUniformErrorTolerance != null) {
        Element element = new Element(XMLTags.StopAtSpatiallyUniform);
        element.addContent(getXML(stopAtSpatiallyUniformErrorTolerance));
        solvertask.addContent(element);
    }
    boolean bRunParameterScanSerially = param.isSerialParameterScan();
    if (bRunParameterScanSerially) {
        solvertask.setAttribute(XMLTags.RunParameterScanSerially, String.valueOf(bRunParameterScanSerially));
    }
    SmoldynSimulationOptions smoldynSimulationOptions = param.getSmoldynSimulationOptions();
    if (smoldynSimulationOptions != null) {
        solvertask.addContent(getXML(smoldynSimulationOptions));
    }
    NFsimSimulationOptions nfsimSimulationOptions = param.getNFSimSimulationOptions();
    if (nfsimSimulationOptions != null) {
        solvertask.addContent(getXML(nfsimSimulationOptions));
    }
    SundialsPdeSolverOptions sundialsPdeSolverOptions = param.getSundialsPdeSolverOptions();
    if (sundialsPdeSolverOptions != null) {
        solvertask.addContent(getXML(sundialsPdeSolverOptions));
    }
    ChomboSolverSpec chomboSolverSpec = param.getChomboSolverSpec();
    if (chomboSolverSpec != null) {
        Element chomboElement = getXML(chomboSolverSpec);
        solvertask.addContent(chomboElement);
    }
    MovingBoundarySolverOptions mb = param.getMovingBoundarySolverOptions();
    if (mb != null) {
        Element e = getXML(mb);
        solvertask.addContent(e);
    }
    Element numProcessors = new Element(XMLTags.NUM_PROCESSORS);
    numProcessors.setText(Integer.toString(param.getNumProcessors()));
    solvertask.addContent(numProcessors);
    return solvertask;
}
Also used : SmoldynSimulationOptions(cbit.vcell.solver.SmoldynSimulationOptions) NFsimSimulationOptions(cbit.vcell.solver.NFsimSimulationOptions) MovingBoundarySolverOptions(cbit.vcell.solvers.mb.MovingBoundarySolverOptions) SundialsPdeSolverOptions(cbit.vcell.solver.SundialsPdeSolverOptions) Element(org.jdom.Element) ErrorTolerance(cbit.vcell.solver.ErrorTolerance) ChomboSolverSpec(org.vcell.chombo.ChomboSolverSpec)

Example 2 with SundialsPdeSolverOptions

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

the class SundialsPdeSolverOptionsPanel method setNewOptions.

/**
 * Update parameters for stochastic simulations,
 * including using customized seed or not, customized seed, using tractory or histogram, number of trials (for all, and below four paras for hybrid only)
 * Epsilon : minimum number of molecus required for approximation as a continuous Markow process,
 * Lambda : minimum rate of reaction required for approximation to a continuous Markov process,
 * MSR Tolerance : Maximum allowed effect of slow reactions per numerical integration of the SDEs,
 * SDE Tolerance : Maximum allowed value of the drift and diffusion errors
 */
private void setNewOptions() {
    if (!isVisible()) {
        return;
    }
    try {
        int order = (Integer) ivjJComboBoxMaxOrder.getSelectedItem();
        solverTaskDescription.setSundialsPdeSolverOptions(new SundialsPdeSolverOptions(order));
    } catch (Exception e) {
        PopupGenerator.showErrorDialog(this, e.getMessage(), e);
    }
}
Also used : SundialsPdeSolverOptions(cbit.vcell.solver.SundialsPdeSolverOptions)

Example 3 with SundialsPdeSolverOptions

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

the class SundialsPdeSolverOptionsPanel method refresh.

private void refresh() {
    if (solverTaskDescription != null) {
        if (!solverTaskDescription.getSolverDescription().equals(SolverDescription.SundialsPDE) || !solverTaskDescription.getSimulation().getMathDescription().hasVelocity()) {
            setVisible(false);
            return;
        }
    }
    setVisible(true);
    SundialsPdeSolverOptions sso = solverTaskDescription.getSundialsPdeSolverOptions();
    ivjJComboBoxMaxOrder.setSelectedItem(sso.getMaxOrderAdvection());
}
Also used : SundialsPdeSolverOptions(cbit.vcell.solver.SundialsPdeSolverOptions)

Example 4 with SundialsPdeSolverOptions

use of cbit.vcell.solver.SundialsPdeSolverOptions 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)

Aggregations

SundialsPdeSolverOptions (cbit.vcell.solver.SundialsPdeSolverOptions)4 NFsimSimulationOptions (cbit.vcell.solver.NFsimSimulationOptions)2 SmoldynSimulationOptions (cbit.vcell.solver.SmoldynSimulationOptions)2 MovingBoundarySolverOptions (cbit.vcell.solvers.mb.MovingBoundarySolverOptions)2 Element (org.jdom.Element)2 ChomboSolverSpec (org.vcell.chombo.ChomboSolverSpec)2 Constant (cbit.vcell.math.Constant)1 MacroscopicRateConstant (cbit.vcell.math.MacroscopicRateConstant)1 DefaultOutputTimeSpec (cbit.vcell.solver.DefaultOutputTimeSpec)1 ErrorTolerance (cbit.vcell.solver.ErrorTolerance)1 ExplicitOutputTimeSpec (cbit.vcell.solver.ExplicitOutputTimeSpec)1 OutputTimeSpec (cbit.vcell.solver.OutputTimeSpec)1 SolverDescription (cbit.vcell.solver.SolverDescription)1 SolverTaskDescription (cbit.vcell.solver.SolverTaskDescription)1 UniformOutputTimeSpec (cbit.vcell.solver.UniformOutputTimeSpec)1 PropertyVetoException (java.beans.PropertyVetoException)1