Search in sources :

Example 6 with TimeBounds

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

the class ClientTaskManager method changeEndTime.

public static void changeEndTime(JComponent requester, SolverTaskDescription solverTaskDescription, double newEndTime) throws PropertyVetoException {
    TimeBounds oldTimeBounds = solverTaskDescription.getTimeBounds();
    TimeBounds timeBounds = new TimeBounds(oldTimeBounds.getStartingTime(), newEndTime);
    solverTaskDescription.setTimeBounds(timeBounds);
    if (solverTaskDescription.getOutputTimeSpec() instanceof UniformOutputTimeSpec) {
        UniformOutputTimeSpec uniformOutputTimeSpec = (UniformOutputTimeSpec) solverTaskDescription.getOutputTimeSpec();
        if (timeBounds.getEndingTime() < uniformOutputTimeSpec.getOutputTimeStep()) {
            double outputTime = solverTaskDescription.getTimeBounds().getEndingTime() / 20.0;
            String ret = PopupGenerator.showWarningDialog(requester, "Output Interval", "Output interval(" + uniformOutputTimeSpec.getOutputTimeStep() + "s) is greater than end time(" + timeBounds.getEndingTime() + "s) which will not output any results. Do you want to change " + "output interval to every " + outputTime + "s (20 time points)?\n\nIf not, output interval will change to " + timeBounds.getEndingTime() + "s(the end time).", new String[] { UserMessage.OPTION_YES, UserMessage.OPTION_NO }, UserMessage.OPTION_YES);
            if (ret.equals(UserMessage.OPTION_YES)) {
                solverTaskDescription.setOutputTimeSpec(new UniformOutputTimeSpec(outputTime));
            } else {
                solverTaskDescription.setOutputTimeSpec(new UniformOutputTimeSpec(timeBounds.getEndingTime()));
            }
        }
    }
}
Also used : TimeBounds(cbit.vcell.solver.TimeBounds) UniformOutputTimeSpec(cbit.vcell.solver.UniformOutputTimeSpec)

Example 7 with TimeBounds

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

the class OutputOptionsPanel method checkExplicitOutputTimes.

private boolean checkExplicitOutputTimes(ExplicitOutputTimeSpec ots) {
    boolean bValid = true;
    double startingTime = solverTaskDescription.getTimeBounds().getStartingTime();
    double endingTime = solverTaskDescription.getTimeBounds().getEndingTime();
    double[] times = ((ExplicitOutputTimeSpec) ots).getOutputTimes();
    if (times[0] < startingTime || times[times.length - 1] > endingTime) {
        bValid = false;
        String ret = PopupGenerator.showWarningDialog(OutputOptionsPanel.this, "Output times should be within [" + startingTime + "," + endingTime + "].\n\nChange ENDING TIME to " + times[times.length - 1] + "?", new String[] { UserMessage.OPTION_YES, UserMessage.OPTION_NO }, UserMessage.OPTION_YES);
        if (ret.equals(UserMessage.OPTION_YES)) {
            try {
                solverTaskDescription.setTimeBounds(new TimeBounds(startingTime, times[times.length - 1]));
                bValid = true;
            } catch (PropertyVetoException e) {
                e.printStackTrace(System.out);
                DialogUtils.showErrorDialog(OutputOptionsPanel.this, e.getMessage());
            }
        }
    }
    if (bValid) {
        getOutputTimesTextField().setBorder(UIManager.getBorder("TextField.border"));
    } else {
        getOutputTimesTextField().setBorder(GuiConstants.ProblematicTextFieldBorder);
        javax.swing.SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                getOutputTimesTextField().requestFocus();
            }
        });
    }
    return bValid;
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) TimeBounds(cbit.vcell.solver.TimeBounds) ExplicitOutputTimeSpec(cbit.vcell.solver.ExplicitOutputTimeSpec)

Example 8 with TimeBounds

use of cbit.vcell.solver.TimeBounds 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);
    }
}
Also used : NFsimSimulationOptions(cbit.vcell.solver.NFsimSimulationOptions) SolverDescription(cbit.vcell.solver.SolverDescription) UniformOutputTimeSpec(cbit.vcell.solver.UniformOutputTimeSpec) Constant(cbit.vcell.math.Constant) NonspatialStochSimOptions(cbit.vcell.solver.NonspatialStochSimOptions) PropertyVetoException(java.beans.PropertyVetoException) TimeStep(cbit.vcell.solver.TimeStep) TimeBounds(cbit.vcell.solver.TimeBounds) ErrorTolerance(cbit.vcell.solver.ErrorTolerance) SolverTaskDescription(cbit.vcell.solver.SolverTaskDescription) DefaultOutputTimeSpec(cbit.vcell.solver.DefaultOutputTimeSpec)

Example 9 with TimeBounds

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

the class AbstractCompiledSolver method getProgress.

/**
 * Insert the method's description here.
 * Creation date: (6/28/01 2:48:52 PM)
 * @return double
 */
public double getProgress() {
    Simulation simulation = simTask.getSimulationJob().getSimulation();
    TimeBounds timeBounds = simulation.getSolverTaskDescription().getTimeBounds();
    double startTime = timeBounds.getStartingTime();
    double endTime = timeBounds.getEndingTime();
    return (currentTime - startTime) / (endTime - startTime);
}
Also used : TimeBounds(cbit.vcell.solver.TimeBounds) Simulation(cbit.vcell.solver.Simulation)

Example 10 with TimeBounds

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

the class DefaultODESolver method updateResultSet.

/**
 * This method was created by a SmartGuide.
 */
protected final void updateResultSet() throws IOException, ExpressionException {
    ODESolverResultSet results = getODESolverResultSet();
    synchronized (results) {
        // so that we don't mess up when saving or reading intermediate results; performance penalty minimal
        double[] valueVector = getValueVector(0);
        // one extra index for time.
        double[] values = new double[getStateVariableCount() + 1];
        for (int i = 0; i < getStateVariableCount(); i++) {
            int c = results.findColumn(getStateVariable(i).getVariable().getName());
            // cbit.util.Assertion.assert(c >= 0 && c < results.getDataColumnCount());
            values[c] = valueVector[getVariableIndex(i)];
        }
        values[ReservedVariable.TIME.getIndex()] = getCurrentTime();
        results.addRow(values);
    }
    // setSolverStatus(new SolverStatus (SolverStatus.SOLVER_RUNNING));
    Simulation sim = simTask.getSimulation();
    double t = getCurrentTime();
    TimeBounds timeBounds = sim.getSolverTaskDescription().getTimeBounds();
    double t0 = timeBounds.getStartingTime();
    double t1 = timeBounds.getEndingTime();
    printToFile((t - t0) / (t1 - t0));
}
Also used : TimeBounds(cbit.vcell.solver.TimeBounds) Simulation(cbit.vcell.solver.Simulation)

Aggregations

TimeBounds (cbit.vcell.solver.TimeBounds)28 Simulation (cbit.vcell.solver.Simulation)16 UniformOutputTimeSpec (cbit.vcell.solver.UniformOutputTimeSpec)15 Expression (cbit.vcell.parser.Expression)10 BioModel (cbit.vcell.biomodel.BioModel)9 SimulationContext (cbit.vcell.mapping.SimulationContext)8 KeyValue (org.vcell.util.document.KeyValue)8 MathMapping (cbit.vcell.mapping.MathMapping)7 MathDescription (cbit.vcell.math.MathDescription)7 TimeStep (cbit.vcell.solver.TimeStep)7 ArrayList (java.util.ArrayList)7 SimulationVersion (org.vcell.util.document.SimulationVersion)7 Model (cbit.vcell.model.Model)6 DefaultOutputTimeSpec (cbit.vcell.solver.DefaultOutputTimeSpec)6 OutputTimeSpec (cbit.vcell.solver.OutputTimeSpec)6 IOException (java.io.IOException)6 Geometry (cbit.vcell.geometry.Geometry)5 SubVolume (cbit.vcell.geometry.SubVolume)5 SpeciesContext (cbit.vcell.model.SpeciesContext)5 SolverTaskDescription (cbit.vcell.solver.SolverTaskDescription)5