use of cbit.vcell.math.Constant in project vcell by virtualcell.
the class MathOverrides method getVCML.
/**
* Insert the method's description here.
* Creation date: (10/24/00 12:41:09 PM)
* @return java.lang.String
*/
public String getVCML() {
//
// write format as follows:
//
// MathOverrides {
// Constant K1 200;
// Constant K2 400;
// Constant K3 494.0;
// }
//
//
StringBuffer buffer = new StringBuffer();
buffer.append(VCML.MathOverrides + " " + VCML.BeginBlock + "\n");
java.util.Enumeration<String> enum1 = getOverridesHash().keys();
while (enum1.hasMoreElements()) {
String name = enum1.nextElement();
MathOverrides.Element element = (MathOverrides.Element) getOverridesHash().get(name);
Expression exp = element.actualValue;
if (exp != null) {
// regular override
Constant constant = new Constant(name, exp);
buffer.append(" " + constant.getVCML());
} else {
// scan override
buffer.append(" " + element.spec.getVCML());
}
}
buffer.append("\n" + VCML.EndBlock + "\n");
return buffer.toString();
}
use of cbit.vcell.math.Constant in project vcell by virtualcell.
the class MathOverrides method gatherIssues.
/**
* This method was created in VisualAge.
* @return boolean
*/
public void gatherIssues(IssueContext issueContext, List<Issue> issueList) {
MathDescription mathDescription = getSimulation().getMathDescription();
//
// get list of names of constants in this math
//
Enumeration<Constant> enumeration = mathDescription.getConstants();
java.util.HashSet<String> mathDescriptionHash = new java.util.HashSet<String>();
while (enumeration.hasMoreElements()) {
Constant constant = enumeration.nextElement();
mathDescriptionHash.add(constant.getName());
}
//
// for any elements in this MathOverrides but not in the new MathDescription, add an "error" issue
//
Enumeration<String> mathOverrideNamesEnum = getOverridesHash().keys();
while (mathOverrideNamesEnum.hasMoreElements()) {
String name = mathOverrideNamesEnum.nextElement();
if (!mathDescriptionHash.contains(name)) {
Issue issue = new Issue(getSimulation(), issueContext, IssueCategory.Simulation_Override_NotFound, VCellErrorMessages.getErrorMessage(VCellErrorMessages.SIMULATION_OVERRIDE_NOTFOUND, name, getSimulation().getName()), Issue.SEVERITY_ERROR);
issueList.add(issue);
}
Variable var = mathDescription.getVariable(name);
if (getSimulation().getSimulationOwner() != null) {
Issue issue = getSimulation().getSimulationOwner().gatherIssueForMathOverride(issueContext, getSimulation(), name);
if (issue != null) {
issueList.add(issue);
}
}
}
}
use of cbit.vcell.math.Constant in project vcell by virtualcell.
the class OutputFunctionContext method getEntry.
public SymbolTableEntry getEntry(java.lang.String identifierString) {
//
// use MathDescription as the primary SymbolTable, just replace the Constants with the overrides.
//
SymbolTableEntry ste = null;
MathDescription mathDescription = simulationOwner.getMathDescription();
if (mathDescription != null) {
ste = mathDescription.getEntry(identifierString);
if (ste != null && !(ste instanceof PseudoConstant) && !(ste instanceof Constant)) {
return ste;
}
ste = mathDescription.getPostProcessingBlock().getDataGenerator(identifierString);
if (ste instanceof DataGenerator) {
return ste;
}
}
// see if it is an output function.
ste = getOutputFunction(identifierString);
return ste;
}
use of cbit.vcell.math.Constant in project vcell by virtualcell.
the class SimulationSymbolTable method getLocalConstant.
/**
* Insert the method's description here.
* Creation date: (6/6/2001 7:52:15 PM)
* @return cbit.vcell.math.Function
* @param functionName java.lang.String
*/
private Constant getLocalConstant(Constant referenceConstant) throws ExpressionException {
if (localVariableHash == null) {
localVariableHash = new HashMap<String, Variable>();
}
Variable var = localVariableHash.get(referenceConstant.getName());
if (var instanceof Constant) {
Constant localConstant = (Constant) var;
//
// make sure expression for localConstant is still up to date with MathOverrides table
//
Expression exp = simulation.getMathOverrides().getActualExpression(referenceConstant.getName(), index);
if (exp.compareEqual(localConstant.getExpression())) {
// localConstant.bind(this); // update bindings to latest mathOverrides
return localConstant;
} else {
//
// MathOverride's Expression changed for this Constant, remove and create new one
//
localVariableHash.remove(localConstant.getName());
}
} else if (var != null) {
throw new RuntimeException("Variable " + var + " expected to be a Constant");
}
//
// if local Constant not found, create new one, bind it to the Simulation (which ensures MathOverrides), and add to list
//
String name = referenceConstant.getName();
Constant newLocalConstant = new Constant(name, simulation.getMathOverrides().getActualExpression(name, index));
// newLocalConstant.bind(this);
localVariableHash.put(newLocalConstant.getName(), newLocalConstant);
return newLocalConstant;
}
use of cbit.vcell.math.Constant in project vcell by virtualcell.
the class SimulationSymbolTable method getVariables.
/**
* Insert the method's description here.
* Creation date: (5/25/01 11:34:08 AM)
* @return cbit.vcell.math.Variable[]
*/
public Variable[] getVariables() {
Vector<Variable> varList = new Vector<Variable>();
//
// get all variables from MathDescription, but replace MathOverrides
//
Enumeration<Variable> enum1 = simulation.getMathDescription().getVariables();
while (enum1.hasMoreElements()) {
Variable mathDescriptionVar = enum1.nextElement();
//
if (mathDescriptionVar instanceof Constant) {
try {
Constant overriddenConstant = getLocalConstant((Constant) mathDescriptionVar);
varList.addElement(overriddenConstant);
} catch (ExpressionException e) {
e.printStackTrace(System.out);
throw new RuntimeException("local Constant " + mathDescriptionVar.getName() + " not found for Simulation");
}
//
// replace all Functions with local Functions that are bound to this Simulation
//
} else if (mathDescriptionVar instanceof Function) {
try {
Function overriddenFunction = getLocalFunction((Function) mathDescriptionVar);
varList.addElement(overriddenFunction);
} catch (ExpressionException e) {
e.printStackTrace(System.out);
throw new RuntimeException("local Function " + mathDescriptionVar.getName() + " not found for Simulation");
}
//
// pass all other Variables through
//
} else {
varList.addElement(mathDescriptionVar);
}
}
Variable[] variables = (Variable[]) BeanUtils.getArray(varList, Variable.class);
return variables;
}
Aggregations