use of cbit.vcell.math.OutsideVariable 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, MembraneSubDomain 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; symbols != null && i < symbols.length; i++) {
Variable var = (Variable) substitutedExp.getSymbolBinding(symbols[i]);
if (var instanceof MemVariable) {
String exactVarName = var.getName() + "_" + subDomain.getName() + "_exact";
substitutedExp.substituteInPlace(new Expression(var.getName()), new Expression(exactVarName));
} else if (var instanceof InsideVariable) {
String exactVarName = var.getName() + "_" + subDomain.getInsideCompartment().getName() + "_exact";
substitutedExp.substituteInPlace(new Expression(var.getName()), new Expression(exactVarName));
} else if (var instanceof OutsideVariable) {
String exactVarName = var.getName() + "_" + subDomain.getOutsideCompartment().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