use of gov.sandia.n2a.eqset.EquationSet.UnresolvedVariable in project n2a by frothga.
the class ExportJob method makeExecutable.
/**
* Make eqset minimally executable.
*/
public static void makeExecutable(EquationSet equations, boolean findConstants) {
// This name should be unique enough that we don't have to check.
EquationSet fakePart = new EquationSet(equations, "N2A_fakePart");
// Always added, even if we don't need it.
equations.parts.add(fakePart);
fakeConnectionTarget(equations);
try {
equations.resolveConnectionBindings();
}// Still try to finish rest of compilation. Maybe only one or two minor parts were affected.
catch (Exception e) {
}
try {
equations.addGlobalConstants();
// $connect, $index, $init, $n, $t, $t', $type
equations.addSpecials();
equations.resolveLHS();
equations.fillIntegratedVariables();
equations.findIntegrated();
LinkedList<UnresolvedVariable> unresolved = new LinkedList<UnresolvedVariable>();
equations.resolveRHS(unresolved);
if (// Make one attempt to fake the variables
unresolved.size() > 0) {
for (UnresolvedVariable uv : unresolved) {
if (!uv.name.startsWith("A.") && !uv.name.startsWith("B."))
continue;
String name = uv.name.substring(2);
Variable v = Variable.from(name + "=0");
if (fakePart.add(v)) {
v.reference = new VariableReference();
v.reference.variable = v;
}
}
// Creates excess dependency counts on connection bindings, but is otherwise OK to run again.
equations.resolveRHS();
}
equations.findExternal();
equations.sortParts();
equations.determineUnits();
// This can hurt the analysis. It simplifies expressions and substitutes constants, breaking some dependency chains.
if (findConstants)
equations.findConstants();
equations.determineTraceVariableName();
equations.determineTypes();
equations.clearVariables();
}// It may still be possible to complete the export.
catch (Exception e) {
e.printStackTrace();
}
}
Aggregations