use of cbit.vcell.solver.UniformOutputTimeSpec in project vcell by virtualcell.
the class OutputOptionsPanel method refresh.
/**
* Comment
*/
private void refresh() {
if (solverTaskDescription == null) {
return;
}
// enables the panel where the output interval is set if the solver is IDA
// Otherwise, that panel is disabled.
getUniformOutputRadioButton().setEnabled(false);
BeanUtils.enableComponents(getUniformOutputPanel(), false);
if (solverTaskDescription.getSolverDescription().equals(SolverDescription.Smoldyn)) {
getDefaultOutputPanel().setVisible(false);
getDefaultOutputRadioButton().setVisible(false);
} else if (solverTaskDescription.getSolverDescription().isChomboSolver()) {
getDefaultOutputPanel().setVisible(false);
getDefaultOutputRadioButton().setVisible(false);
getUniformOutputPanel().setVisible(false);
getUniformOutputRadioButton().setVisible(false);
} else {
getDefaultOutputPanel().setVisible(true);
getDefaultOutputRadioButton().setVisible(true);
getDefaultOutputRadioButton().setEnabled(false);
getUniformOutputPanel().setVisible(true);
getUniformOutputRadioButton().setVisible(true);
BeanUtils.enableComponents(getDefaultOutputPanel(), false);
}
if (solverTaskDescription.getSimulation().getMathDescription().getGeometry().getDimension() > 0 || solverTaskDescription.getSimulation().getMathDescription().isNonSpatialStoch()) {
getExplicitOutputPanel().setVisible(false);
getExplicitOutputRadioButton().setVisible(false);
} else {
getExplicitOutputPanel().setVisible(true);
getExplicitOutputRadioButton().setVisible(true);
getExplicitOutputRadioButton().setEnabled(false);
BeanUtils.enableComponents(getExplicitOutputPanel(), false);
}
if (solverTaskDescription == null || solverTaskDescription.getSolverDescription() == null) {
// Also, disable its radiobutton and fields.
return;
}
SolverDescription solverDesc = solverTaskDescription.getSolverDescription();
// Amended June 2009, no output option for stochastic gibson multiple trials
if (solverTaskDescription.getStochOpt() != null && solverTaskDescription.getStochOpt().getNumOfTrials() > 1 && solverTaskDescription.getSolverDescription().equals(SolverDescription.StochGibson)) {
return;
}
OutputTimeSpec ots = solverTaskDescription.getOutputTimeSpec();
if (ots.isDefault()) {
// if solver is not IDA, if the output Time step radio button had been set,
// change the setting to the 'keep every' radio button and flush the contents of the output timestep text field.
// Also, disable its radiobutton and fields.
getDefaultOutputRadioButton().setSelected(true);
getKeepEveryTextField().setText(((DefaultOutputTimeSpec) ots).getKeepEvery() + "");
if (solverTaskDescription.getSolverDescription().isSemiImplicitPdeSolver()) {
getKeepAtMostTextField().setText("");
} else {
getKeepAtMostTextField().setText(((DefaultOutputTimeSpec) ots).getKeepAtMost() + "");
}
getOutputTimeStepTextField().setText("");
getOutputTimesTextField().setText("");
} else if (ots.isUniform()) {
getUniformOutputRadioButton().setSelected(true);
getKeepEveryTextField().setText("");
getKeepAtMostTextField().setText("");
getOutputTimeStepTextField().setText(((UniformOutputTimeSpec) ots).getOutputTimeStep() + "");
getOutputTimesTextField().setText("");
} else if (ots.isExplicit()) {
getExplicitOutputRadioButton().setSelected(true);
getKeepEveryTextField().setText("");
getKeepAtMostTextField().setText("");
getOutputTimeStepTextField().setText("");
getOutputTimesTextField().setText(((ExplicitOutputTimeSpec) ots).toCommaSeperatedOneLineOfString() + "");
getOutputTimesTextField().setCaretPosition(0);
}
DefaultOutputTimeSpec dots = new DefaultOutputTimeSpec();
UniformOutputTimeSpec uots = new UniformOutputTimeSpec(0.05);
ExplicitOutputTimeSpec eots = new ExplicitOutputTimeSpec(new double[] { 0.1 });
if (solverDesc.supports(dots)) {
if (!solverDesc.isSemiImplicitPdeSolver() || ots.isDefault()) {
getDefaultOutputRadioButton().setEnabled(true);
if (getDefaultOutputRadioButton().isSelected() || ots.isDefault()) {
BeanUtils.enableComponents(getDefaultOutputPanel(), true);
}
}
}
if (solverDesc.supports(uots)) {
getUniformOutputRadioButton().setEnabled(true);
if (getUniformOutputRadioButton().isSelected() || ots.isUniform()) {
BeanUtils.enableComponents(getUniformOutputPanel(), true);
}
}
if (solverDesc.supports(eots)) {
getExplicitOutputRadioButton().setEnabled(true);
if (getExplicitOutputRadioButton().isSelected() || ots.isExplicit()) {
BeanUtils.enableComponents(getExplicitOutputPanel(), true);
}
}
if (solverDesc.isSemiImplicitPdeSolver()) {
getKeepAtMostTextField().setText("");
getKeepAtMostTextField().setEnabled(false);
}
}
use of cbit.vcell.solver.UniformOutputTimeSpec in project vcell by virtualcell.
the class SimulationSummaryPanel method displayTask.
/**
* Comment
*/
private void displayTask() {
SolverTaskDescription solverTaskDescription = getSimulation().getSolverTaskDescription();
try {
NonspatialStochSimOptions stochOpt = solverTaskDescription.getStochOpt();
if (stochOpt != null && stochOpt.getNumOfTrials() > 1) {
getJLabelOutput().setText("Histogram with " + stochOpt.getNumOfTrials() + " Trials(@last time point)");
} else {
// gcwtodo
String text = solverTaskDescription.getOutputTimeSpec().getShortDescription();
if (solverTaskDescription.getSolverDescription().isChomboSolver()) {
text = "Variable";
if (solverTaskDescription.getChomboSolverSpec().getTimeIntervalList().size() == 1) {
text = "Every " + solverTaskDescription.getChomboSolverSpec().getLastTimeInterval().getOutputTimeStep() + "s";
}
} else if (solverTaskDescription.getOutputTimeSpec().isDefault() && !solverTaskDescription.getSolverDescription().isSemiImplicitPdeSolver() && !solverTaskDescription.getSolverDescription().equals(SolverDescription.StochGibson)) {
text += ", at most " + ((DefaultOutputTimeSpec) solverTaskDescription.getOutputTimeSpec()).getKeepAtMost();
}
getJLabelOutput().setText(text);
}
} catch (Exception exc) {
exc.printStackTrace(System.out);
getJLabelOutput().setText("");
}
SolverDescription solverDescription = solverTaskDescription.getSolverDescription();
try {
ErrorTolerance errorTolerance = solverTaskDescription.getErrorTolerance();
TimeStep timeStep = solverTaskDescription.getTimeStep();
getJLabelRelTol().setText("Rel tol");
getJLabelAbsTol().setText("Abs tol");
getJLabel12().setText("Timestep");
getJLabelRelTol().setEnabled(false);
getJLabelAbsTol().setEnabled(false);
getJLabel12().setEnabled(false);
getJLabel10().setText("Sensitivity Analysis");
getJLabel10().setEnabled(true);
if (solverDescription.equals(SolverDescription.StochGibson)) {
getJLabel12().setEnabled(false);
getJLabelTimestep().setText("");
} else if (solverDescription.equals(SolverDescription.NFSim)) {
TimeBounds tb = solverTaskDescription.getTimeBounds();
double dtime = tb.getEndingTime() - tb.getStartingTime();
if (solverTaskDescription.getOutputTimeSpec() instanceof UniformOutputTimeSpec) {
UniformOutputTimeSpec uots = (UniformOutputTimeSpec) solverTaskDescription.getOutputTimeSpec();
double interval = uots.getOutputTimeStep();
int steps = (int) Math.round(dtime / interval);
getJLabel12().setEnabled(true);
getJLabel12().setText("Timepoints");
getJLabelTimestep().setText(steps + "");
} else if (solverTaskDescription.getOutputTimeSpec() instanceof DefaultOutputTimeSpec) {
DefaultOutputTimeSpec uots = (DefaultOutputTimeSpec) solverTaskDescription.getOutputTimeSpec();
getJLabel12().setEnabled(true);
getJLabel12().setText("End Time");
getJLabelTimestep().setText(solverTaskDescription.getTimeBounds().getEndingTime() + "");
} else {
getJLabel12().setEnabled(false);
getJLabel12().setText("End Time");
getJLabelTimestep().setText("na");
}
NFsimSimulationOptions nfsso = solverTaskDescription.getNFSimSimulationOptions();
String utl = "default";
Integer moleculeDistance = nfsso.getMoleculeDistance();
if (moleculeDistance != null) {
utl = moleculeDistance + "";
}
getJLabelRelTol().setEnabled(true);
getJLabelRelTol().setText("Universal Transversal Limit");
getJLabelRelTolValue().setText(utl);
String gml = "default";
Integer maxMoleculesPerType = nfsso.getMaxMoleculesPerType();
if (maxMoleculesPerType != null) {
gml = maxMoleculesPerType + "";
}
getJLabelAbsTol().setEnabled(true);
getJLabelAbsTol().setText("Max # of each " + MolecularType.typeName);
getJLabelAbsTolValue().setText(gml);
} else if (solverDescription.isNonSpatialStochasticSolver()) {
getJLabel12().setEnabled(true);
getJLabel12().setText("Timestep");
getJLabelTimestep().setText(timeStep.getDefaultTimeStep() + "s");
} else if (solverDescription.hasVariableTimestep()) {
getJLabel12().setEnabled(true);
getJLabel12().setText("Max timestep");
getJLabelTimestep().setText(timeStep.getMaximumTimeStep() + "s");
getJLabelRelTol().setEnabled(true);
getJLabelRelTolValue().setText("" + errorTolerance.getRelativeErrorTolerance());
getJLabelAbsTol().setEnabled(true);
getJLabelAbsTolValue().setText("" + errorTolerance.getAbsoluteErrorTolerance());
} else {
getJLabel12().setEnabled(true);
getJLabel12().setText("Timestep");
if (solverDescription.isChomboSolver()) {
String text = "Variable";
if (solverTaskDescription.getChomboSolverSpec().getTimeIntervalList().size() == 1) {
text = solverTaskDescription.getChomboSolverSpec().getLastTimeInterval().getTimeStep() + "s";
}
getJLabelTimestep().setText(text);
} else {
getJLabelTimestep().setText(timeStep.getDefaultTimeStep() + "s");
}
if (solverDescription.isSemiImplicitPdeSolver()) {
getJLabelRelTol().setEnabled(true);
getJLabelRelTolValue().setText("" + errorTolerance.getRelativeErrorTolerance());
} else {
getJLabelRelTol().setEnabled(false);
getJLabelRelTolValue().setText("");
}
getJLabelAbsTol().setEnabled(false);
getJLabelAbsTolValue().setText("");
}
} catch (Exception exc) {
exc.printStackTrace(System.out);
getJLabelTimestep().setText("");
getJLabelRelTolValue().setText("");
getJLabelAbsTolValue().setText("");
}
try {
boolean bChomboSolver = solverDescription.isChomboSolver();
getJLabelTitleNumProcessors().setVisible(bChomboSolver);
getJLabelNumProcessors().setVisible(bChomboSolver);
if (bChomboSolver) {
getJLabelNumProcessors().setText(String.valueOf(solverTaskDescription.getNumProcessors()));
}
if (getSimulation().isSpatial() || solverDescription.isNonSpatialStochasticSolver()) {
getJLabelSensitivity().setVisible(false);
getJLabel10().setVisible(false);
} else if (solverDescription.equals(SolverDescription.NFSim)) {
getJLabel10().setText("On-the-fly observ comp.");
NFsimSimulationOptions nfsso = solverTaskDescription.getNFSimSimulationOptions();
boolean goc = nfsso.getObservableComputationOff();
getJLabelSensitivity().setText(goc + "");
} else {
getJLabelSensitivity().setVisible(true);
getJLabel10().setVisible(true);
Constant param = solverTaskDescription.getSensitivityParameter();
if (param == null) {
getJLabelSensitivity().setText("no");
} else {
getJLabelSensitivity().setText(param.getName());
}
}
} catch (Exception exc) {
exc.printStackTrace(System.out);
getJLabelSensitivity().setText("");
}
if (solverDescription.isNonSpatialStochasticSolver()) {
getJLabelRelTol().setVisible(false);
getJLabelAbsTol().setVisible(false);
getJLabelRelTolValue().setVisible(false);
getJLabelAbsTolValue().setVisible(false);
} else {
getJLabelRelTol().setVisible(true);
getJLabelAbsTol().setVisible(true);
}
}
use of cbit.vcell.solver.UniformOutputTimeSpec in project vcell by virtualcell.
the class TimeStepPanel method correctUniformOutputTimeStep.
public void correctUniformOutputTimeStep() {
boolean bValid = true;
double timeStep = Double.parseDouble(getDefaultTimeStepTextField().getText());
if (solverTaskDescription.getOutputTimeSpec().isUniform() && !solverTaskDescription.getSolverDescription().hasVariableTimestep()) {
OutputTimeSpec outputTimeSpec = solverTaskDescription.getOutputTimeSpec();
if (outputTimeSpec instanceof UniformOutputTimeSpec) {
UniformOutputTimeSpec uniformTimeSpec = (UniformOutputTimeSpec) outputTimeSpec;
double outputTime = uniformTimeSpec.getOutputTimeStep();
double suggestedInterval = outputTime;
if (outputTime < timeStep) {
suggestedInterval = timeStep;
bValid = false;
} else if (!BeanUtils.isIntegerMultiple(outputTime, timeStep)) {
double n = outputTime / timeStep;
int intn = (int) Math.round(n);
if (intn != n) {
bValid = false;
suggestedInterval = (intn * timeStep);
}
}
if (!bValid) {
String ret = PopupGenerator.showWarningDialog(TimeStepPanel.this, "Output Interval", "Output Interval must " + "be integer multiple of time step.\n\nChange Output Interval to " + suggestedInterval + "?", new String[] { UserMessage.OPTION_YES, UserMessage.OPTION_NO }, UserMessage.OPTION_YES);
if (ret.equals(UserMessage.OPTION_YES)) {
uniformTimeSpec.setOuputTimeStep(suggestedInterval);
bValid = true;
}
}
}
}
}
use of cbit.vcell.solver.UniformOutputTimeSpec in project vcell by virtualcell.
the class FiniteVolumeFileWriter method writeSimulationParamters.
/**
* @param timeFunction
* @param startTime
* @param endTime
* @param rootFinder
* @param uniqueRootTimes
* @param bPrintIterations
* @throws ExpressionException
*
* for testing within scrapbook, see below:
*
* try {
* edu.northwestern.at.utils.math.rootfinders.MonadicFunctionRootFinder rootFinder =
*// new edu.northwestern.at.utils.math.rootfinders.Brent();
* new edu.northwestern.at.utils.math.rootfinders.Bisection();
*// new edu.northwestern.at.utils.math.rootfinders.NewtonRaphson();
*// new edu.northwestern.at.utils.math.rootfinders.Secant();
* cbit.vcell.parser.SimpleSymbolTable simpleSymbolTable = new cbit.vcell.parser.SimpleSymbolTable(new String[] { "t" });
*
* cbit.vcell.parser.Expression exp = new cbit.vcell.parser.Expression("t-0.56");
*
* exp.bindExpression(simpleSymbolTable);
* java.util.TreeSet<Double> rootTimes = new java.util.TreeSet<Double>();
* double startTime = 0.0;
* double endTime = 100.0;
* System.out.print("exp = '"+ exp.infix() + "'");
* long currentTimeMS = System.currentTimeMillis();
* cbit.vcell.solvers.FiniteVolumeFileWriter.findAllRoots(exp,startTime,endTime,rootFinder,rootTimes,false);
* long finalTimeMS = System.currentTimeMillis();
* for (double root : rootTimes){
* System.out.println("root = "+root);
* }
* System.out.println("elapsedTime of computation = "+(finalTimeMS-currentTimeMS)+" ms, found " + rootTimes.size() + " roots (not unique)");
*
*}catch (Exception e){
* e.printStackTrace(System.out);
*}
*/
/*public static void findAllRoots(Expression timeFunction, double startTime, double endTime, MonadicFunctionRootFinder rootFinder, TreeSet<Double> uniqueRootTimes, boolean bPrintIterations) throws ExpressionException{
TreeSet<Double> allRootTimes = new TreeSet<Double>();
final Expression function_exp = new Expression(timeFunction);
MonadicFunction valueFunction = new MonadicFunction() {
double[] values = new double[1];
public double f(double t) {
values[0] = t;
try {
return function_exp.evaluateVector(values);
} catch (ExpressionException e) {
e.printStackTrace();
throw new RuntimeException("expression exception "+e.getMessage());
}
}
};
final Expression derivative_exp = new Expression(timeFunction.differentiate(ReservedVariable.TIME.getName()));
MonadicFunction derivativeFunction = new MonadicFunction() {
double[] values = new double[1];
public double f(double t) {
values[0] = t;
try {
return derivative_exp.evaluateVector(values);
} catch (ExpressionException e) {
e.printStackTrace();
throw new RuntimeException("expression exception "+e.getMessage());
}
}
};
RootFinderConvergenceTest convergenceTest = new StandardRootFinderConvergenceTest();
RootFinderIterationInformation iterationInformation = null;
if (bPrintIterations){
iterationInformation = new RootFinderIterationInformation() {
public void iterationInformation(double x, double fx, double dfx, int currentIteration) {
System.out.println(currentIteration+") x="+x+", fx="+fx+", dfx="+dfx);
}
};
}
int NUM_BRACKETS = 1000;
double simulationTime = endTime - startTime;
double tolerance = simulationTime/1e10;
int maxIter = 1000;
for (int i=0;i<NUM_BRACKETS-1;i++){
double bracketMin = startTime + simulationTime*i/NUM_BRACKETS;
double bracketMax = startTime + simulationTime*(i+1)/NUM_BRACKETS;
double root = rootFinder.findRoot(bracketMin, bracketMax, tolerance, maxIter, valueFunction, derivativeFunction, convergenceTest, iterationInformation);
if (root>startTime && root<endTime && valueFunction.f(root)<=tolerance){
allRootTimes.add(root);
}
}
double uniqueTolerance = tolerance * 100;
double lastUniqueRoot = Double.NEGATIVE_INFINITY;
for (double root : allRootTimes){
if (root-lastUniqueRoot > uniqueTolerance){
uniqueRootTimes.add(root);
}
lastUniqueRoot = root;
}
} ---------------------------------JIM's CODE COMMENTTED FOR FUTURE DEVELOPMENT*/
/**
*# Simulation Parameters
*SIMULATION_PARAM_BEGIN
*SOLVER SUNDIALS_PDE_SOLVER 1.0E-7 1.0E-9
*DISCONTINUITY_TIMES 2 1.0E-4 3.0000000000000003E-4
*BASE_FILE_NAME c:/Vcell/users/fgao/SimID_31746636_0_
*ENDING_TIME 4.0E-4
*KEEP_EVERY ONE_STEP 3
*KEEP_AT_MOST 1000
*SIMULATION_PARAM_END
* @throws MathException
* @throws ExpressionException
*/
private void writeSimulationParamters() throws ExpressionException, MathException {
Simulation simulation = simTask.getSimulation();
SolverTaskDescription solverTaskDesc = simulation.getSolverTaskDescription();
printWriter.println("# Simulation Parameters");
printWriter.println(FVInputFileKeyword.SIMULATION_PARAM_BEGIN);
if (solverTaskDesc.getSolverDescription().equals(SolverDescription.SundialsPDE)) {
printWriter.print(FVInputFileKeyword.SOLVER + " " + FVInputFileKeyword.SUNDIALS_PDE_SOLVER + " " + solverTaskDesc.getErrorTolerance().getRelativeErrorTolerance() + " " + solverTaskDesc.getErrorTolerance().getAbsoluteErrorTolerance() + " " + solverTaskDesc.getTimeStep().getMaximumTimeStep());
if (simulation.getMathDescription().hasVelocity()) {
printWriter.print(" " + solverTaskDesc.getSundialsPdeSolverOptions().getMaxOrderAdvection());
}
printWriter.println();
Vector<Discontinuity> discontinuities = new Vector<Discontinuity>();
TreeSet<Double> discontinuityTimes = new TreeSet<Double>();
MathDescription mathDesc = simulation.getMathDescription();
Enumeration<SubDomain> enum1 = mathDesc.getSubDomains();
while (enum1.hasMoreElements()) {
SubDomain sd = enum1.nextElement();
Enumeration<Equation> enum_equ = sd.getEquations();
while (enum_equ.hasMoreElements()) {
Equation equation = enum_equ.nextElement();
equation.getDiscontinuities(simTask.getSimulationJob().getSimulationSymbolTable(), discontinuities);
}
}
getDiscontinuityTimes(discontinuities, discontinuityTimes);
if (discontinuityTimes.size() > 0) {
printWriter.print(FVInputFileKeyword.DISCONTINUITY_TIMES + " " + discontinuityTimes.size());
for (double d : discontinuityTimes) {
printWriter.print(" " + d);
}
printWriter.println();
}
} else if (solverTaskDesc.getSolverDescription().equals(SolverDescription.Chombo)) {
printWriter.println(FVInputFileKeyword.SOLVER + " " + FVInputFileKeyword.CHOMBO_SEMIIMPLICIT_SOLVER);
} else if (solverTaskDesc.getSolverDescription().equals(SolverDescription.VCellPetsc)) {
printWriter.println(FVInputFileKeyword.SOLVER + " " + FVInputFileKeyword.VCELL_PETSC_SOLVER);
} else {
printWriter.println(FVInputFileKeyword.SOLVER + " " + FVInputFileKeyword.FV_SOLVER + " " + solverTaskDesc.getErrorTolerance().getRelativeErrorTolerance());
}
printWriter.println(FVInputFileKeyword.BASE_FILE_NAME + " " + new File(workingDirectory, simTask.getSimulationJob().getSimulationJobID()).getAbsolutePath());
if (solverTaskDesc.isParallel() && destinationDirectory != null && !destinationDirectory.equals(workingDirectory)) {
printWriter.println(FVInputFileKeyword.PRIMARY_DATA_DIR + " " + destinationDirectory.getAbsolutePath());
}
printWriter.println(FVInputFileKeyword.ENDING_TIME + " " + solverTaskDesc.getTimeBounds().getEndingTime());
OutputTimeSpec outputTimeSpec = solverTaskDesc.getOutputTimeSpec();
if (solverTaskDesc.getSolverDescription().isChomboSolver()) {
List<TimeInterval> timeIntervalList = solverTaskDesc.getChomboSolverSpec().getTimeIntervalList();
printWriter.println(FVInputFileKeyword.TIME_INTERVALS + " " + timeIntervalList.size());
for (TimeInterval ti : timeIntervalList) {
printWriter.println(ti.getEndingTime() + " " + ti.getTimeStep() + " " + ti.getKeepEvery());
}
} else if (solverTaskDesc.getSolverDescription().equals(SolverDescription.SundialsPDE)) {
if (outputTimeSpec.isDefault()) {
DefaultOutputTimeSpec defaultOutputTimeSpec = (DefaultOutputTimeSpec) outputTimeSpec;
printWriter.println(FVInputFileKeyword.KEEP_EVERY + " " + FVInputFileKeyword.ONE_STEP + " " + defaultOutputTimeSpec.getKeepEvery());
printWriter.println(FVInputFileKeyword.KEEP_AT_MOST + " " + defaultOutputTimeSpec.getKeepAtMost());
} else {
printWriter.println(FVInputFileKeyword.TIME_STEP + " " + ((UniformOutputTimeSpec) outputTimeSpec).getOutputTimeStep());
printWriter.println(FVInputFileKeyword.KEEP_EVERY + " 1");
}
} else {
double defaultTimeStep = solverTaskDesc.getTimeStep().getDefaultTimeStep();
printWriter.println(FVInputFileKeyword.TIME_STEP + " " + defaultTimeStep);
int keepEvery = 1;
if (outputTimeSpec.isDefault()) {
keepEvery = ((DefaultOutputTimeSpec) outputTimeSpec).getKeepEvery();
} else if (outputTimeSpec.isUniform()) {
UniformOutputTimeSpec uots = (UniformOutputTimeSpec) outputTimeSpec;
double ots = uots.getOutputTimeStep();
keepEvery = (int) Math.round(ots / defaultTimeStep);
} else {
throw new RuntimeException("unexpected OutputTime specification type :" + outputTimeSpec.getClass().getName());
}
if (keepEvery <= 0) {
throw new RuntimeException("Output KeepEvery must be a positive integer. Try to change the output option.");
}
printWriter.println(FVInputFileKeyword.KEEP_EVERY + " " + keepEvery);
}
ErrorTolerance stopAtSpatiallyUniformErrorTolerance = solverTaskDesc.getStopAtSpatiallyUniformErrorTolerance();
if (stopAtSpatiallyUniformErrorTolerance != null) {
printWriter.println(FVInputFileKeyword.CHECK_SPATIALLY_UNIFORM + " " + stopAtSpatiallyUniformErrorTolerance.getAbsoluteErrorTolerance() + " " + stopAtSpatiallyUniformErrorTolerance.getRelativeErrorTolerance());
}
printWriter.println(FVInputFileKeyword.SIMULATION_PARAM_END);
printWriter.println();
}
use of cbit.vcell.solver.UniformOutputTimeSpec in project vcell by virtualcell.
the class ITextWriter method writeSimulation.
// container can be a chapter or a section of a chapter.
protected void writeSimulation(Section container, Simulation sim) throws DocumentException {
if (sim == null) {
return;
}
Section simSection = container.addSection(sim.getName(), container.numberDepth() + 1);
writeMetadata(simSection, sim.getName(), sim.getDescription(), null, "Simulation ");
// add overriden params
Table overParamTable = null;
MathOverrides mo = sim.getMathOverrides();
if (mo != null) {
String[] constants = mo.getOverridenConstantNames();
for (int i = 0; i < constants.length; i++) {
String actualStr = "", defStr = "";
Expression tempExp = mo.getDefaultExpression(constants[i]);
if (tempExp != null) {
defStr = tempExp.infix();
}
if (mo.isScan(constants[i])) {
actualStr = mo.getConstantArraySpec(constants[i]).toString();
} else {
tempExp = mo.getActualExpression(constants[i], 0);
if (tempExp != null) {
actualStr = tempExp.infix();
}
}
if (overParamTable == null) {
overParamTable = getTable(3, 75, 1, 3, 3);
overParamTable.setAlignment(Table.ALIGN_LEFT);
overParamTable.addCell(createCell("Overriden Parameters", getBold(DEF_HEADER_FONT_SIZE), 3, 1, Element.ALIGN_CENTER, true));
overParamTable.addCell(createHeaderCell("Name", getBold(), 1));
overParamTable.addCell(createHeaderCell("Actual Value", getBold(), 1));
overParamTable.addCell(createHeaderCell("Default Value", getBold(), 1));
}
overParamTable.addCell(createCell(constants[i], getFont()));
overParamTable.addCell(createCell(actualStr, getFont()));
overParamTable.addCell(createCell(defStr, getFont()));
}
}
if (overParamTable != null) {
simSection.add(overParamTable);
}
// add spatial details
// sim.isSpatial();
Table meshTable = null;
MeshSpecification mesh = sim.getMeshSpecification();
if (mesh != null) {
Geometry geom = mesh.getGeometry();
Extent extent = geom.getExtent();
String extentStr = "(" + extent.getX() + ", " + extent.getY() + ", " + extent.getZ() + ")";
ISize meshSize = mesh.getSamplingSize();
String meshSizeStr = "(" + meshSize.getX() + ", " + meshSize.getY() + ", " + meshSize.getZ() + ")";
meshTable = getTable(2, 75, 1, 3, 3);
meshTable.setAlignment(Table.ALIGN_LEFT);
meshTable.addCell(createCell("Geometry Setting", getBold(DEF_HEADER_FONT_SIZE), 2, 1, Element.ALIGN_CENTER, true));
meshTable.addCell(createCell("Geometry Size (um)", getFont()));
meshTable.addCell(createCell(extentStr, getFont()));
meshTable.addCell(createCell("Mesh Size (elements)", getFont()));
meshTable.addCell(createCell(meshSizeStr, getFont()));
}
if (meshTable != null) {
simSection.add(meshTable);
}
// write advanced sim settings
Table simAdvTable = null;
SolverTaskDescription solverDesc = sim.getSolverTaskDescription();
if (solverDesc != null) {
String solverName = solverDesc.getSolverDescription().getDisplayLabel();
simAdvTable = getTable(2, 75, 1, 3, 3);
simAdvTable.setAlignment(Table.ALIGN_LEFT);
simAdvTable.addCell(createCell("Advanced Settings", getBold(DEF_HEADER_FONT_SIZE), 2, 1, Element.ALIGN_CENTER, true));
simAdvTable.addCell(createCell("Solver Name", getFont()));
simAdvTable.addCell(createCell(solverName, getFont()));
simAdvTable.addCell(createCell("Time Bounds - Starting", getFont()));
simAdvTable.addCell(createCell("" + solverDesc.getTimeBounds().getStartingTime(), getFont()));
simAdvTable.addCell(createCell("Time Bounds - Ending", getFont()));
simAdvTable.addCell(createCell("" + solverDesc.getTimeBounds().getEndingTime(), getFont()));
simAdvTable.addCell(createCell("Time Step - Min", getFont()));
simAdvTable.addCell(createCell("" + solverDesc.getTimeStep().getMinimumTimeStep(), getFont()));
simAdvTable.addCell(createCell("Time Step - Default", getFont()));
simAdvTable.addCell(createCell("" + solverDesc.getTimeStep().getDefaultTimeStep(), getFont()));
simAdvTable.addCell(createCell("Time Step - Max", getFont()));
simAdvTable.addCell(createCell("" + solverDesc.getTimeStep().getMaximumTimeStep(), getFont()));
ErrorTolerance et = solverDesc.getErrorTolerance();
if (et != null) {
simAdvTable.addCell(createCell("Error Tolerance - Absolute", getFont()));
simAdvTable.addCell(createCell("" + et.getAbsoluteErrorTolerance(), getFont()));
simAdvTable.addCell(createCell("Error Tolerance - Relative", getFont()));
simAdvTable.addCell(createCell("" + et.getRelativeErrorTolerance(), getFont()));
}
OutputTimeSpec ots = solverDesc.getOutputTimeSpec();
if (ots.isDefault()) {
simAdvTable.addCell(createCell("Keep Every", getFont()));
simAdvTable.addCell(createCell("" + ((DefaultOutputTimeSpec) ots).getKeepEvery(), getFont()));
simAdvTable.addCell(createCell("Keep At Most", getFont()));
simAdvTable.addCell(createCell("" + ((DefaultOutputTimeSpec) ots).getKeepAtMost(), getFont()));
} else if (ots.isUniform()) {
simAdvTable.addCell(createCell("Output Time Step", getFont()));
simAdvTable.addCell(createCell("" + ((UniformOutputTimeSpec) ots).getOutputTimeStep(), getFont()));
} else if (ots.isExplicit()) {
simAdvTable.addCell(createCell("Output Time Points", getFont()));
simAdvTable.addCell(createCell("" + ((ExplicitOutputTimeSpec) ots).toCommaSeperatedOneLineOfString(), getFont()));
}
simAdvTable.addCell(createCell("Use Symbolic Jacobian (T/F)", getFont()));
simAdvTable.addCell(createCell((solverDesc.getUseSymbolicJacobian() ? " T " : " F "), getFont()));
Constant sp = solverDesc.getSensitivityParameter();
if (sp != null) {
simAdvTable.addCell(createCell("Sensitivity Analysis Param", getFont()));
simAdvTable.addCell(createCell(sp.getName(), getFont()));
}
}
if (simAdvTable != null) {
simSection.add(simAdvTable);
}
}
Aggregations