Search in sources :

Example 31 with VolVariable

use of cbit.vcell.math.VolVariable in project vcell by virtualcell.

the class PDEDataViewer method showSpatialPlot.

/**
 * Comment
 */
private void showSpatialPlot() {
    // check selections
    final SpatialSelection[] sl = getPDEDataContextPanel1().fetchSpatialSelections(false, true);
    if (sl == null) {
        PopupGenerator.showErrorDialog(this, "Nothing selected!");
        return;
    }
    for (int i = 0; i < sl.length; i++) {
        if (sl[i].isPoint()) {
            PopupGenerator.showErrorDialog(this, "One or more selections are single points - no spatial plot will be produced for those selections");
            break;
        }
    }
    final String varName = getPdeDataContext().getVariableName();
    final double timePoint = getPdeDataContext().getTimePoint();
    final SymbolTableEntry[] symbolTableEntries = new SymbolTableEntry[1];
    if (getSimulation() != null && getSimulation().getMathDescription() != null) {
        symbolTableEntries[0] = getSimulation().getMathDescription().getEntry(varName);
    }
    if (symbolTableEntries[0] == null) {
        // TODO domain
        Domain domain = null;
        symbolTableEntries[0] = new VolVariable(varName, domain);
    }
    AsynchClientTask task1 = new AsynchClientTask("Retrieving spatial series for variable '" + varName, AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            // get plots, ignoring points
            PlotData[] plotDatas = new PlotData[sl.length];
            for (int i = 0; i < sl.length; i++) {
                PlotData plotData = null;
                if (getPdeDataContext() instanceof PDEDataViewerPostProcess.PostProcessDataPDEDataContext) {
                    SpatialSelectionVolume ssVolume = (SpatialSelectionVolume) sl[i];
                    SpatialSelection.SSHelper ssvHelper = ssVolume.getIndexSamples(0.0, 1.0);
                    ssvHelper.initializeValues_VOLUME(getPdeDataContext().getDataValues());
                    double[] values = ssvHelper.getSampledValues();
                    plotData = new PlotData(ssvHelper.getWorldCoordinateLengths(), values);
                } else {
                    plotData = getPdeDataContext().getLineScan(varName, timePoint, sl[i]);
                }
                plotDatas[i] = plotData;
            }
            hashTable.put("plotDatas", plotDatas);
        }
    };
    AsynchClientTask task2 = new AsynchClientTask("Showing spatial plot for variable" + varName, AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            PlotData[] plotDatas = (PlotData[]) hashTable.get("plotDatas");
            for (PlotData plotData : plotDatas) {
                if (plotData != null) {
                    PlotPane plotPane = new PlotPane();
                    Plot2D plot2D = new Plot2D(symbolTableEntries, getSimulationModelInfo().getDataSymbolMetadataResolver(), new String[] { varName }, new PlotData[] { plotData }, new String[] { "Values along curve", "Distance (\u00b5m)", "[" + varName + "]" });
                    plotPane.setPlot2D(plot2D);
                    String title = createContextTitle(PDEDataViewer.this.isPostProcess(), "Spatial Plot:'" + varName + "' ", getPdeDataContext(), getSimulationModelInfo(), getSimulation());
                    ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(PDEDataViewer.this);
                    ChildWindow childWindow = childWindowManager.addChildWindow(plotPane, plotPane, title);
                    childWindow.setIsCenteredOnParent();
                    childWindow.pack();
                    childWindow.show();
                // System.out.println("Spatial plot requesting focus.  Result is: "+childWindow.requestFocusInWindow());
                }
            }
        }
    };
    ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 }, false);
}
Also used : PlotData(cbit.plot.PlotData) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) VolVariable(cbit.vcell.math.VolVariable) Hashtable(java.util.Hashtable) PostProcessDataPDEDataContext(cbit.vcell.client.data.PDEDataViewerPostProcess.PostProcessDataPDEDataContext) ChildWindowManager(cbit.vcell.client.ChildWindowManager) ChildWindow(cbit.vcell.client.ChildWindowManager.ChildWindow) Point(java.awt.Point) SinglePoint(cbit.vcell.geometry.SinglePoint) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) SpatialSelection(cbit.vcell.simdata.SpatialSelection) SSHelper(cbit.vcell.simdata.SpatialSelection.SSHelper) SpatialSelectionVolume(cbit.vcell.simdata.SpatialSelectionVolume) PlotPane(cbit.plot.gui.PlotPane) SingleXPlot2D(cbit.plot.SingleXPlot2D) Plot2D(cbit.plot.Plot2D) VariableDomain(cbit.vcell.math.VariableType.VariableDomain) Domain(cbit.vcell.math.Variable.Domain)

Example 32 with VolVariable

use of cbit.vcell.math.VolVariable in project vcell by virtualcell.

the class XmlReader method getComputeMembraneMetric.

private ComputeMembraneMetricEquation getComputeMembraneMetric(Element param, MathDescription mathDesc) throws XmlParseException {
    // get attributes
    String varname = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
    // find reference in the dictionnary
    // try a MembraneRegionVariable
    VolVariable varref = (VolVariable) mathDesc.getVariable(varname);
    if (varref == null) {
        throw new XmlParseException("The reference to the Volume variable " + varname + " could not be resolved!");
    }
    MembraneMetricComponent normalComponent = null;
    String normalComponentString = param.getAttributeValue(XMLTags.ComputeMembraneMetricComponentAttrTag);
    if (normalComponentString.equals(XMLTags.ComputeMembraneMetricComponentAttrTagValue_directionX)) {
        normalComponent = MembraneMetricComponent.directionToMembraneX;
    } else if (normalComponentString.equals(XMLTags.ComputeMembraneMetricComponentAttrTagValue_directionY)) {
        normalComponent = MembraneMetricComponent.directionToMembraneY;
    } else if (normalComponentString.equals(XMLTags.ComputeMembraneMetricComponentAttrTagValue_directionZ)) {
        normalComponent = MembraneMetricComponent.directionToMembraneZ;
    } else if (normalComponentString.equals(XMLTags.ComputeMembraneMetricComponentAttrTagValue_distance)) {
        normalComponent = MembraneMetricComponent.distanceToMembrane;
    }
    ComputeMembraneMetricEquation computeMembraneMetric = new ComputeMembraneMetricEquation(varref, normalComponent);
    String membraneName = param.getAttributeValue(XMLTags.ComputeMembraneMetricTargetMembraneAttrTag);
    computeMembraneMetric.setTargetMembraneName(membraneName);
    return computeMembraneMetric;
}
Also used : StochVolVariable(cbit.vcell.math.StochVolVariable) VolVariable(cbit.vcell.math.VolVariable) ComputeMembraneMetricEquation(cbit.vcell.math.ComputeMembraneMetricEquation) MembraneMetricComponent(cbit.vcell.math.ComputeMembraneMetricEquation.MembraneMetricComponent)

Example 33 with VolVariable

use of cbit.vcell.math.VolVariable in project vcell by virtualcell.

the class XmlReader method getOdeEquation.

/**
 * This method returns an OdeEquation from a XML Element.
 * Creation date: (5/17/2001 3:52:40 PM)
 * @return cbit.vcell.math.OdeEquation
 * @param param org.jdom.Element
 * @exception cbit.vcell.xml.XmlParseException The exception description.
 */
private OdeEquation getOdeEquation(Element param, MathDescription mathDesc) throws XmlParseException {
    // get attributes
    String varname = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
    // find reference in the dictionnary
    // try as a VolVariable
    Variable varref = mathDesc.getVariable(varname);
    // Make sure that the reference is not empty!!!
    if (varref == null) {
        throw new XmlParseException("The reference to the variable " + varname + " in a OdeEquation could not be resolved!");
    }
    // get Initial condition
    String temp = param.getChildText(XMLTags.InitialTag, vcNamespace);
    Expression initialexp = null;
    if (temp != null && temp.length() > 0) {
        initialexp = unMangleExpression(temp);
    }
    // Get Rate condition
    temp = param.getChildText(XMLTags.RateTag, vcNamespace);
    Expression rateexp = null;
    if (temp != null && temp.length() > 0) {
        rateexp = unMangleExpression((temp));
    }
    // --- Create the OdeEquation object ---
    OdeEquation odeEquation = new OdeEquation(varref, initialexp, rateexp);
    // add specific solutions expressions
    String solType = param.getAttributeValue(XMLTags.SolutionTypeTag);
    if (solType.equalsIgnoreCase(XMLTags.ExactTypeTag)) {
        String solutionExp = param.getChildText(XMLTags.SolutionExpressionTag, vcNamespace);
        if (solutionExp != null && solutionExp.length() > 0) {
            Expression expression = unMangleExpression(solutionExp);
            odeEquation.setExactSolution(expression);
        }
    }
    return odeEquation;
}
Also used : FilamentVariable(cbit.vcell.math.FilamentVariable) OutsideVariable(cbit.vcell.math.OutsideVariable) StochVolVariable(cbit.vcell.math.StochVolVariable) RandomVariable(cbit.vcell.math.RandomVariable) VolumeRandomVariable(cbit.vcell.math.VolumeRandomVariable) VolumeParticleVariable(cbit.vcell.math.VolumeParticleVariable) VolumeRegionVariable(cbit.vcell.math.VolumeRegionVariable) InsideVariable(cbit.vcell.math.InsideVariable) VolVariable(cbit.vcell.math.VolVariable) MembraneRegionVariable(cbit.vcell.math.MembraneRegionVariable) PointVariable(cbit.vcell.math.PointVariable) MembraneRandomVariable(cbit.vcell.math.MembraneRandomVariable) MembraneParticleVariable(cbit.vcell.math.MembraneParticleVariable) ParticleVariable(cbit.vcell.math.ParticleVariable) MemVariable(cbit.vcell.math.MemVariable) FilamentRegionVariable(cbit.vcell.math.FilamentRegionVariable) Variable(cbit.vcell.math.Variable) OdeEquation(cbit.vcell.math.OdeEquation) Expression(cbit.vcell.parser.Expression)

Example 34 with VolVariable

use of cbit.vcell.math.VolVariable in project vcell by virtualcell.

the class XmlReader method getVolVariable.

/**
 * This method returns a VolVariable object from a XML Element.
 * Creation date: (5/16/2001 2:56:34 PM)
 * @return cbit.vcell.math.VolVariable
 * @param param org.jdom.Element
 */
private VolVariable getVolVariable(Element param) {
    String name = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
    String domainStr = unMangle(param.getAttributeValue(XMLTags.DomainAttrTag));
    Domain domain = null;
    if (domainStr != null) {
        domain = new Domain(domainStr);
    }
    // -- create new VolVariable object
    VolVariable volVariable = new VolVariable(name, domain);
    transcribeComments(param, volVariable);
    return volVariable;
}
Also used : StochVolVariable(cbit.vcell.math.StochVolVariable) VolVariable(cbit.vcell.math.VolVariable) MembraneSubDomain(cbit.vcell.math.MembraneSubDomain) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) FilamentSubDomain(cbit.vcell.math.FilamentSubDomain) PointSubDomain(cbit.vcell.math.PointSubDomain) Domain(cbit.vcell.math.Variable.Domain)

Example 35 with VolVariable

use of cbit.vcell.math.VolVariable in project vcell by virtualcell.

the class MathTestingUtilities method substituteWithExactSolution.

/**
 * Insert the method's description here.
 * Creation date: (1/24/2003 10:18:14 AM)
 * @return cbit.vcell.parser.Expression
 * @param origExp cbit.vcell.parser.Expression
 * @param subDomain cbit.vcell.math.SubDomain
 */
private static Expression substituteWithExactSolution(Expression origExp, CompartmentSubDomain subDomain, MathDescription exactMathDesc) throws ExpressionException {
    Expression substitutedExp = new Expression(origExp);
    substitutedExp.bindExpression(exactMathDesc);
    substitutedExp = MathUtilities.substituteFunctions(substitutedExp, exactMathDesc);
    substitutedExp.bindExpression(null);
    substitutedExp = substitutedExp.flatten();
    substitutedExp.bindExpression(exactMathDesc);
    String[] symbols = substitutedExp.getSymbols();
    for (int i = 0; i < symbols.length; i++) {
        Variable var = (Variable) substitutedExp.getSymbolBinding(symbols[i]);
        if (var instanceof VolVariable) {
            String exactVarName = var.getName() + "_" + subDomain.getName() + "_exact";
            substitutedExp.substituteInPlace(new Expression(var.getName()), new Expression(exactVarName));
        } else if (var instanceof VolumeRegionVariable || var instanceof MemVariable || var instanceof MembraneRegionVariable || var instanceof FilamentVariable || var instanceof FilamentRegionVariable) {
            throw new RuntimeException("variable substitution not yet implemented for Variable type " + var.getClass().getName() + "(" + var.getName() + ")");
        }
    }
    substitutedExp.bindExpression(null);
    return substitutedExp;
}
Also used : VolumeRegionVariable(cbit.vcell.math.VolumeRegionVariable) MembraneRegionVariable(cbit.vcell.math.MembraneRegionVariable) InsideVariable(cbit.vcell.math.InsideVariable) SensVariable(cbit.vcell.solver.ode.SensVariable) FilamentVariable(cbit.vcell.math.FilamentVariable) VolVariable(cbit.vcell.math.VolVariable) VolumeRegionVariable(cbit.vcell.math.VolumeRegionVariable) ReservedVariable(cbit.vcell.math.ReservedVariable) MemVariable(cbit.vcell.math.MemVariable) OutsideVariable(cbit.vcell.math.OutsideVariable) FilamentRegionVariable(cbit.vcell.math.FilamentRegionVariable) Variable(cbit.vcell.math.Variable) MemVariable(cbit.vcell.math.MemVariable) MembraneRegionVariable(cbit.vcell.math.MembraneRegionVariable) Expression(cbit.vcell.parser.Expression) VolVariable(cbit.vcell.math.VolVariable) FilamentRegionVariable(cbit.vcell.math.FilamentRegionVariable) FilamentVariable(cbit.vcell.math.FilamentVariable)

Aggregations

VolVariable (cbit.vcell.math.VolVariable)46 Variable (cbit.vcell.math.Variable)29 Expression (cbit.vcell.parser.Expression)25 MemVariable (cbit.vcell.math.MemVariable)24 MembraneRegionVariable (cbit.vcell.math.MembraneRegionVariable)19 VolumeRegionVariable (cbit.vcell.math.VolumeRegionVariable)17 ReservedVariable (cbit.vcell.math.ReservedVariable)16 CompartmentSubDomain (cbit.vcell.math.CompartmentSubDomain)15 Constant (cbit.vcell.math.Constant)14 FilamentVariable (cbit.vcell.math.FilamentVariable)13 MembraneSubDomain (cbit.vcell.math.MembraneSubDomain)13 Vector (java.util.Vector)13 Function (cbit.vcell.math.Function)12 MathDescription (cbit.vcell.math.MathDescription)11 SubDomain (cbit.vcell.math.SubDomain)11 Equation (cbit.vcell.math.Equation)10 FilamentRegionVariable (cbit.vcell.math.FilamentRegionVariable)10 MathException (cbit.vcell.math.MathException)10 OdeEquation (cbit.vcell.math.OdeEquation)10 Domain (cbit.vcell.math.Variable.Domain)10