use of cbit.vcell.solvers.mb.MovingBoundarySolverOptions in project vcell by virtualcell.
the class XmlReader method getMovingBoundarySolverOptions.
private MovingBoundarySolverOptions getMovingBoundarySolverOptions(SolverTaskDescription solverTaskDesc, Element mbElement) {
double frontToNodeRatio = parseDoubleWithDefault(mbElement, XMLTags.FrontToNodeRatioTag, MovingBoundarySolverOptions.DEFAULT_FRONT_TO_NODE_RATIO);
int redistributionFrequency = parseIntWithDefault(mbElement, XMLTags.RedistributionFrequencyTag, MovingBoundarySolverOptions.DEFAULT_REDISTRIBUTION_FREQUENCY);
RedistributionMode redistributionMode = RedistributionMode.FULL_REDIST;
Element child = mbElement.getChild(XMLTags.RedistributionModeTag, vcNamespace);
if (child != null) {
String text = child.getText();
redistributionMode = RedistributionMode.valueOf(text);
}
RedistributionVersion redistributionVersion = RedistributionVersion.EQUI_BOND_REDISTRIBUTE;
child = mbElement.getChild(XMLTags.RedistributionVersionTag, vcNamespace);
if (child != null) {
String text = child.getText();
redistributionVersion = RedistributionVersion.valueOf(text);
}
ExtrapolationMethod extrapolationMethod = ExtrapolationMethod.NEAREST_NEIGHBOR;
child = mbElement.getChild(XMLTags.ExtrapolationMethodTag, vcNamespace);
if (child != null) {
String text = child.getText();
extrapolationMethod = ExtrapolationMethod.valueOf(text);
}
MovingBoundarySolverOptions mb = new MovingBoundarySolverOptions(frontToNodeRatio, redistributionMode, redistributionVersion, redistributionFrequency, extrapolationMethod);
return mb;
}
use of cbit.vcell.solvers.mb.MovingBoundarySolverOptions 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.solvers.mb.MovingBoundarySolverOptions in project vcell by virtualcell.
the class SolverTaskDescription method propertyChange.
/**
* This method gets called when a bound property is changed.
* @param evt A PropertyChangeEvent object describing the event source
* and the property that has changed.
*/
public void propertyChange(java.beans.PropertyChangeEvent evt) {
try {
if (evt.getSource() == this && (evt.getPropertyName().equals(PROPERTY_SOLVER_DESCRIPTION))) {
SolverDescription solverDescription = getSolverDescription();
if (solverDescription.equals(SolverDescription.SundialsPDE) || solverDescription.isSemiImplicitPdeSolver() || solverDescription.isGibsonSolver()) {
TimeBounds timeBounds = getTimeBounds();
if (!(getOutputTimeSpec() instanceof UniformOutputTimeSpec)) {
// set to uniform output if it is not.
double outputTime = (timeBounds.getEndingTime() - timeBounds.getStartingTime()) / 20;
setOutputTimeSpec(new UniformOutputTimeSpec(outputTime));
}
if (solverDescription.equals(SolverDescription.SundialsPDE)) {
setErrorTolerance(ErrorTolerance.getDefaultSundialsErrorTolerance());
setDefaultTimeStep(TimeStep.getDefaultSundialsTimeStep());
if (sundialsPdeSolverOptions == null) {
sundialsPdeSolverOptions = new SundialsPdeSolverOptions();
}
} else {
sundialsPdeSolverOptions = null;
setErrorTolerance(ErrorTolerance.getDefaultSemiImplicitErrorTolerance());
}
} else if (!solverDescription.supports(getOutputTimeSpec())) {
setOutputTimeSpec(solverDescription.createOutputTimeSpec(this));
}
if (solverDescription.isNonSpatialStochasticSolver()) {
if (fieldNonspatialStochOpt == null) {
setStochOpt(new NonspatialStochSimOptions());
} else {
setStochOpt(new NonspatialStochSimOptions(fieldNonspatialStochOpt));
}
if (!solverDescription.equals(SolverDescription.StochGibson)) {
if (fieldNonspatialStochHybridOpt == null) {
setStochHybridOpt(new NonspatialStochHybridOptions());
}
}
} else if (solverDescription.isSpatialStochasticSolver()) {
setTimeStep(TimeStep.getDefaultSmoldynTimeStep());
if (smoldynSimulationOptions == null) {
smoldynSimulationOptions = new SmoldynSimulationOptions();
}
// setSmoldynDefaultTimeStep();
}
if (solverDescription.isNFSimSolver()) {
if (nfsimSimulationOptions == null) {
nfsimSimulationOptions = new NFsimSimulationOptions();
}
}
if (solverDescription.isChomboSolver()) {
if (chomboSolverSpec == null && getSimulation() != null) {
chomboSolverSpec = new ChomboSolverSpec(ChomboSolverSpec.getDefaultMaxBoxSize(getSimulation().getMathDescription().getGeometry().getDimension()));
}
if (getOutputTimeSpec() == null || !(getOutputTimeSpec() instanceof UniformOutputTimeSpec)) {
double outputTime = getTimeBounds().getEndingTime() / 10;
setOutputTimeSpec(new UniformOutputTimeSpec(outputTime));
}
if (chomboSolverSpec != null && chomboSolverSpec.getTimeIntervalList().size() == 0) {
chomboSolverSpec.addTimeInterval(TimeInterval.getDefaultTimeInterval());
}
} else {
chomboSolverSpec = null;
}
if (solverDescription.isMovingBoundarySolver()) {
if (movingBoundarySolverOptions == null && getSimulation() != null) {
movingBoundarySolverOptions = new MovingBoundarySolverOptions();
}
} else {
movingBoundarySolverOptions = null;
}
}
} catch (PropertyVetoException e) {
e.printStackTrace();
}
}
use of cbit.vcell.solvers.mb.MovingBoundarySolverOptions 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;
}
use of cbit.vcell.solvers.mb.MovingBoundarySolverOptions 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);
}
}
Aggregations