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);
}
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;
}
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;
}
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;
}
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;
}
Aggregations