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;
}
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);
}
}
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());
}
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;
}
Aggregations