Search in sources :

Example 1 with DefaultOutputTimeSpec

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

the class ODETimePlotMultipleScansPanel method updateScanParamChoices.

/**
 * Insert the method's description here.
 * Creation date: (10/18/2005 12:44:06 AM)
 */
private void updateScanParamChoices() {
    AsynchClientTask task1 = new AsynchClientTask("get ode results", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            int[] jobIndexes = scanChoiceTable.getSelectedRows();
            VCSimulationIdentifier vcSimulationIdentifier = simulation.getSimulationInfo().getAuthoritativeVCSimulationIdentifier();
            int plotCount = jobIndexes.length * variableNames.length;
            SymbolTableEntry[] symbolTableEntries = new SymbolTableEntry[plotCount];
            double[][] dataValues = new double[plotCount + 1][];
            PlotData[] plotDatas = new PlotData[plotCount];
            String[] plotNames = new String[plotCount];
            int plotIndex = 0;
            dataValues[0] = null;
            for (int ji = 0; ji < jobIndexes.length; ji++) {
                int jobIndex = jobIndexes[ji];
                final VCDataIdentifier vcdid = new VCSimulationDataIdentifier(vcSimulationIdentifier, jobIndex);
                ODEDataManager odeDatamanager = ((ODEDataManager) dataManager).createNewODEDataManager(vcdid);
                ODESolverResultSet odeSolverResultSet = odeDatamanager.getODESolverResultSet();
                if (ji == 0) {
                    plotPane.setStepViewVisible(simulation.getSolverTaskDescription().getSolverDescription().isNonSpatialStochasticSolver(), odeSolverResultSet.isMultiTrialData());
                    hashTable.put("bMultiTrial", new Boolean(odeSolverResultSet.isMultiTrialData()));
                }
                double[] tdata = null;
                if (!odeSolverResultSet.isMultiTrialData()) {
                    int tcol = odeSolverResultSet.findColumn(ReservedVariable.TIME.getName());
                    tdata = odeSolverResultSet.extractColumn(tcol);
                    if (dataValues[0] == null) {
                        dataValues[0] = tdata;
                    }
                }
                for (int v = 0; v < variableNames.length; v++) {
                    String varname = variableNames[v];
                    int varcol = odeSolverResultSet.findColumn(varname);
                    double[] vdata = odeSolverResultSet.extractColumn(varcol);
                    if (!odeSolverResultSet.isMultiTrialData()) {
                        dataValues[plotIndex + 1] = vdata;
                        // plotNames[plotIndex] = varname + " -- " + JOB_PLOT_NAME + " " + jobIndex;
                        plotDatas[plotIndex] = new PlotData(tdata, vdata);
                    // symbolTableEntries[plotIndex] = simulation.getMathDescription().getVariable(varname);
                    } else {
                        Point2D[] histogram = ODESolverPlotSpecificationPanel.generateHistogram(vdata);
                        double[] x = new double[histogram.length];
                        double[] y = new double[histogram.length];
                        for (int j = 0; j < histogram.length; j++) {
                            x[j] = histogram[j].getX();
                            y[j] = histogram[j].getY();
                        }
                        plotDatas[plotIndex] = new PlotData(x, y);
                    }
                    plotNames[plotIndex] = varname + " -- " + JOB_PLOT_NAME + " " + jobIndex;
                    symbolTableEntries[plotIndex] = simulation.getMathDescription().getVariable(varname);
                    plotIndex++;
                }
            }
            hashTable.put("dataValues", dataValues);
            hashTable.put("plotDatas", plotDatas);
            hashTable.put("plotNames", plotNames);
            hashTable.put("symbolTableEntries", symbolTableEntries);
        }
    };
    AsynchClientTask task2 = new AsynchClientTask("show results", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            double[][] dataValues = (double[][]) hashTable.get("dataValues");
            PlotData[] plotDatas = (PlotData[]) hashTable.get("plotDatas");
            String[] plotNames = (String[]) hashTable.get("plotNames");
            SymbolTableEntry[] symbolTableEntries = (SymbolTableEntry[]) hashTable.get("symbolTableEntries");
            if (plotDatas == null || plotDatas.length == 0 || (plotDatas.length == 1 && plotDatas[0] == null) || plotNames == null) {
                plotPane.setPlot2D(null);
                return;
            }
            Plot2D plot2D = null;
            if (hashTable.get("bMultiTrial") instanceof Boolean && (Boolean) hashTable.get("bMultiTrial")) {
                plot2D = new Plot2D(symbolTableEntries, null, plotNames, plotDatas, new String[] { "Probability Distribution of Species", "Number of Particles", "" });
            } else if (simulation.getSolverTaskDescription().getOutputTimeSpec() instanceof DefaultOutputTimeSpec) {
                plot2D = new Plot2D(symbolTableEntries, null, plotNames, plotDatas, new String[] { "Time Plot", ReservedVariable.TIME.getName(), "" });
            } else {
                plot2D = new SingleXPlot2D(symbolTableEntries, null, ReservedVariable.TIME.getName(), plotNames, dataValues);
            }
            plotPane.setPlot2D(plot2D);
        }
    };
    ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 });
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) Point2D(java.awt.geom.Point2D) ODESolverResultSet(cbit.vcell.solver.ode.ODESolverResultSet) PlotData(cbit.plot.PlotData) Hashtable(java.util.Hashtable) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) SingleXPlot2D(cbit.plot.SingleXPlot2D) ODEDataManager(cbit.vcell.simdata.ODEDataManager) SingleXPlot2D(cbit.plot.SingleXPlot2D) Plot2D(cbit.plot.Plot2D) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) DefaultOutputTimeSpec(cbit.vcell.solver.DefaultOutputTimeSpec)

Example 2 with DefaultOutputTimeSpec

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

the class RbmNetworkGenerator method runNFSim.

public static void runNFSim(PrintWriter writer, RbmModelContainer rbmModelContainer, SimulationContext sc, NetworkGenerationRequirements networkGenerationRequirements) {
    // ex: simulate_nf({t_end=>100,n_steps=>50});
    writer.print("simulate_nf({");
    if (sc.getBioModel() == null || sc.getSimulations() == null || sc.getSimulations().length == 0) {
        writer.print("t_end=>100,n_steps=>50");
        writer.println("})");
        return;
    }
    // we just pick whatever the first simulation has, it'll get too complicated to offer the user a list of simulations and ask him to choose
    SolverTaskDescription solverTaskDescription = sc.getSimulations(0).getSolverTaskDescription();
    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);
        writer.print("t_end=>" + dtime + ",n_steps=>" + steps);
    } else if (solverTaskDescription.getOutputTimeSpec() instanceof DefaultOutputTimeSpec) {
        // currently unsupported, but some old simulations have it
        writer.print("t_end=>" + dtime + ",n_steps=>50");
    } else {
        writer.print("t_end=>100,n_steps=>50");
    }
    writer.println("})");
}
Also used : TimeBounds(cbit.vcell.solver.TimeBounds) UniformOutputTimeSpec(cbit.vcell.solver.UniformOutputTimeSpec) SolverTaskDescription(cbit.vcell.solver.SolverTaskDescription) DefaultOutputTimeSpec(cbit.vcell.solver.DefaultOutputTimeSpec)

Example 3 with DefaultOutputTimeSpec

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

the class XmlReader method getOutputTimeSpec.

/**
 * This method returns a TimeStep object from a XML Element.
 * Creation date: (5/22/2001 11:45:33 AM)
 * @return cbit.vcell.solver.TimeStep
 * @param param org.jdom.Element
 */
private OutputTimeSpec getOutputTimeSpec(Element param) {
    if (param != null) {
        // get attributes
        if (param.getAttributeValue(XMLTags.KeepEveryAttrTag) != null) {
            int keepEvery = Integer.parseInt(param.getAttributeValue(XMLTags.KeepEveryAttrTag));
            int keepAtMost = Integer.parseInt(param.getAttributeValue(XMLTags.KeepAtMostAttrTag));
            return new DefaultOutputTimeSpec(keepEvery, keepAtMost);
        } else if (param.getAttributeValue(XMLTags.OutputTimeStepAttrTag) != null) {
            double outputStep = Double.parseDouble(param.getAttributeValue(XMLTags.OutputTimeStepAttrTag));
            return new UniformOutputTimeSpec(outputStep);
        } else if (param.getAttributeValue(XMLTags.OutputTimesAttrTag) != null) {
            String line = param.getAttributeValue(XMLTags.OutputTimesAttrTag);
            return ExplicitOutputTimeSpec.fromString(line);
        }
    }
    return null;
}
Also used : UniformOutputTimeSpec(cbit.vcell.solver.UniformOutputTimeSpec) DefaultOutputTimeSpec(cbit.vcell.solver.DefaultOutputTimeSpec)

Example 4 with DefaultOutputTimeSpec

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

the class Xmlproducer method getXML.

/**
 * This methos returns a XML representation of a ErrorTolerance.
 * Creation date: (3/3/2001 12:02:33 AM)
 * @return Element
 * @param param cbit.vcell.solver.ErrorTolerance
 */
private Element getXML(OutputTimeSpec param) {
    Element outputOptions = new Element(XMLTags.OutputOptionsTag);
    // Add Atributes
    if (param.isDefault()) {
        DefaultOutputTimeSpec dots = (DefaultOutputTimeSpec) param;
        outputOptions.setAttribute(XMLTags.KeepEveryAttrTag, String.valueOf(dots.getKeepEvery()));
        outputOptions.setAttribute(XMLTags.KeepAtMostAttrTag, String.valueOf(dots.getKeepAtMost()));
    } else if (param.isExplicit()) {
        ExplicitOutputTimeSpec eots = (ExplicitOutputTimeSpec) param;
        outputOptions.setAttribute(XMLTags.OutputTimesAttrTag, eots.toCommaSeperatedOneLineOfString());
    } else if (param.isUniform()) {
        UniformOutputTimeSpec uots = (UniformOutputTimeSpec) param;
        outputOptions.setAttribute(XMLTags.OutputTimeStepAttrTag, String.valueOf(uots.getOutputTimeStep()));
    }
    return outputOptions;
}
Also used : ExplicitOutputTimeSpec(cbit.vcell.solver.ExplicitOutputTimeSpec) UniformOutputTimeSpec(cbit.vcell.solver.UniformOutputTimeSpec) Element(org.jdom.Element) DefaultOutputTimeSpec(cbit.vcell.solver.DefaultOutputTimeSpec)

Example 5 with DefaultOutputTimeSpec

use of cbit.vcell.solver.DefaultOutputTimeSpec 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);
    }
}
Also used : DefaultOutputTimeSpec(cbit.vcell.solver.DefaultOutputTimeSpec) UniformOutputTimeSpec(cbit.vcell.solver.UniformOutputTimeSpec) ExplicitOutputTimeSpec(cbit.vcell.solver.ExplicitOutputTimeSpec) OutputTimeSpec(cbit.vcell.solver.OutputTimeSpec) ExplicitOutputTimeSpec(cbit.vcell.solver.ExplicitOutputTimeSpec) SolverDescription(cbit.vcell.solver.SolverDescription) UniformOutputTimeSpec(cbit.vcell.solver.UniformOutputTimeSpec) DefaultOutputTimeSpec(cbit.vcell.solver.DefaultOutputTimeSpec)

Aggregations

DefaultOutputTimeSpec (cbit.vcell.solver.DefaultOutputTimeSpec)24 UniformOutputTimeSpec (cbit.vcell.solver.UniformOutputTimeSpec)15 OutputTimeSpec (cbit.vcell.solver.OutputTimeSpec)13 SolverTaskDescription (cbit.vcell.solver.SolverTaskDescription)13 ExplicitOutputTimeSpec (cbit.vcell.solver.ExplicitOutputTimeSpec)8 Simulation (cbit.vcell.solver.Simulation)7 TimeBounds (cbit.vcell.solver.TimeBounds)6 ExpressionException (cbit.vcell.parser.ExpressionException)5 ErrorTolerance (cbit.vcell.solver.ErrorTolerance)5 SolverDescription (cbit.vcell.solver.SolverDescription)5 MathException (cbit.vcell.math.MathException)4 SolverException (cbit.vcell.solver.SolverException)4 Constant (cbit.vcell.math.Constant)3 SubDomain (cbit.vcell.math.SubDomain)3 Expression (cbit.vcell.parser.Expression)3 NonspatialStochSimOptions (cbit.vcell.solver.NonspatialStochSimOptions)3 SimulationSymbolTable (cbit.vcell.solver.SimulationSymbolTable)3 File (java.io.File)3 Geometry (cbit.vcell.geometry.Geometry)2 JumpProcess (cbit.vcell.math.JumpProcess)2