Search in sources :

Example 6 with MembraneRegionVariable

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

the class MathTestingUtilities method comparePDEResultsWithExact.

/**
 * Insert the method's description here.
 * Creation date: (8/20/2003 12:58:10 PM)
 */
public static SimulationComparisonSummary comparePDEResultsWithExact(SimulationSymbolTable simSymbolTable, PDEDataManager dataManager, String type, double absErrorThreshold, double relErrorThreshold) throws DataAccessException, ExpressionException {
    java.util.Hashtable<String, DataErrorSummary> tempVarHash = new java.util.Hashtable<String, DataErrorSummary>();
    double[] timeArray = dataManager.getDataSetTimes();
    Variable[] vars = simSymbolTable.getVariables();
    CartesianMesh mesh = dataManager.getMesh();
    MathDescription mathDesc = simSymbolTable.getSimulation().getMathDescription();
    // Get volumeSubdomains from mathDesc/mesh and store in lookupTable
    int numVol = mesh.getSizeX() * mesh.getSizeY() * mesh.getSizeZ();
    CompartmentSubDomain[] volSubDomainLookup = new CompartmentSubDomain[numVol];
    for (int i = 0; i < numVol; i++) {
        int subVolumeIndex = mesh.getSubVolumeFromVolumeIndex(i);
        SubVolume subVolume = mathDesc.getGeometry().getGeometrySpec().getSubVolume(subVolumeIndex);
        CompartmentSubDomain compSubDomain = mathDesc.getCompartmentSubDomain(subVolume.getName());
        volSubDomainLookup[i] = compSubDomain;
    }
    // Get membraneSubdomains from mathDesc/mesh and store in lookupTable
    int numMem = mesh.getMembraneElements().length;
    MembraneSubDomain[] memSubDomainLookup = new MembraneSubDomain[numMem];
    for (int i = 0; i < numMem; i++) {
        int insideVolIndex = mesh.getMembraneElements()[i].getInsideVolumeIndex();
        int outsideVolIndex = mesh.getMembraneElements()[i].getOutsideVolumeIndex();
        MembraneSubDomain memSubDomain = mathDesc.getMembraneSubDomain(volSubDomainLookup[insideVolIndex], volSubDomainLookup[outsideVolIndex]);
        memSubDomainLookup[i] = memSubDomain;
    }
    double[] valueArray = new double[4];
    SimpleSymbolTable symbolTable = new SimpleSymbolTable(new String[] { "t", "x", "y", "z" });
    int tIndex = symbolTable.getEntry("t").getIndex();
    int xIndex = symbolTable.getEntry("x").getIndex();
    int yIndex = symbolTable.getEntry("y").getIndex();
    int zIndex = symbolTable.getEntry("z").getIndex();
    SimulationComparisonSummary simComparisonSummary = new SimulationComparisonSummary();
    String hashKey = new String("");
    long dataLength = 0;
    // for each var, do the following :
    for (int i = 0; i < vars.length; i++) {
        if (vars[i] instanceof VolVariable || vars[i] instanceof MemVariable || vars[i] instanceof FilamentVariable || vars[i] instanceof VolumeRegionVariable || vars[i] instanceof MembraneRegionVariable || vars[i] instanceof FilamentRegionVariable) {
            // for each time in timeArray,
            for (int j = 0; j < timeArray.length; j++) {
                if (type.equals(TestCaseNew.EXACT_STEADY)) {
                    if (j != (timeArray.length - 1)) {
                        continue;
                    }
                }
                // get data block from varName, data from datablock
                SimDataBlock simDataBlock = dataManager.getSimDataBlock(vars[i].getName(), timeArray[j]);
                double[] data = simDataBlock.getData();
                dataLength = data.length;
                SubDomain subDomain = null;
                Coordinate subDomainCoord = null;
                // for each point in data block ...
                for (int k = 0; k < dataLength; k++) {
                    // Get subdomain from mesh (from the lookupTable), get coordinates (x,y,z) from mesh, evaluate EXACT SOLN at that coord
                    if (vars[i] instanceof VolVariable) {
                        subDomain = volSubDomainLookup[k];
                        subDomainCoord = mesh.getCoordinateFromVolumeIndex(k);
                    } else if (vars[i] instanceof MemVariable) {
                        subDomain = memSubDomainLookup[k];
                        subDomainCoord = mesh.getCoordinateFromMembraneIndex(k);
                    } else {
                        throw new RuntimeException("Var " + vars[i].getName() + " not supported yet!");
                    }
                    hashKey = vars[i].getName() + ":" + subDomain.getName();
                    DataErrorSummary tempVar = (DataErrorSummary) tempVarHash.get(hashKey);
                    if (tempVar == null) {
                        Expression exp = new Expression(subDomain.getEquation(vars[i]).getExactSolution());
                        exp.bindExpression(simSymbolTable);
                        exp = MathUtilities.substituteFunctions(exp, simSymbolTable);
                        exp = exp.flatten();
                        exp.bindExpression(symbolTable);
                        tempVar = new DataErrorSummary(exp);
                        tempVarHash.put(hashKey, tempVar);
                    }
                    // time
                    valueArray[tIndex] = timeArray[j];
                    // x
                    valueArray[xIndex] = subDomainCoord.getX();
                    // y
                    valueArray[yIndex] = subDomainCoord.getY();
                    // z
                    valueArray[zIndex] = subDomainCoord.getZ();
                    // EXACT soln at coord subDomainCoord
                    double value = tempVar.getExactExp().evaluateVector(valueArray);
                    tempVar.addDataValues(value, data[k], timeArray[j], k, absErrorThreshold, relErrorThreshold);
                }
            // end for (k)
            }
        // end for (j)
        }
    // end - if (var)
    }
    // end for (i)
    Enumeration<String> enumKeys = tempVarHash.keys();
    while (enumKeys.hasMoreElements()) {
        String key = enumKeys.nextElement();
        DataErrorSummary tempVarSummary = tempVarHash.get(key);
        simComparisonSummary.addVariableComparisonSummary(new VariableComparisonSummary(key, tempVarSummary.getMinRef(), tempVarSummary.getMaxRef(), tempVarSummary.getMaxAbsoluteError(), tempVarSummary.getMaxRelativeError(), tempVarSummary.getL2Norm(), tempVarSummary.getTimeAtMaxAbsoluteError(), tempVarSummary.getIndexAtMaxAbsoluteError(), tempVarSummary.getTimeAtMaxRelativeError(), tempVarSummary.getIndexAtMaxRelativeError()));
    }
    return simComparisonSummary;
}
Also used : MembraneSubDomain(cbit.vcell.math.MembraneSubDomain) 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) MembraneRegionVariable(cbit.vcell.math.MembraneRegionVariable) MathDescription(cbit.vcell.math.MathDescription) VolumeRegionVariable(cbit.vcell.math.VolumeRegionVariable) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) SubDomain(cbit.vcell.math.SubDomain) MembraneSubDomain(cbit.vcell.math.MembraneSubDomain) MemVariable(cbit.vcell.math.MemVariable) SimDataBlock(cbit.vcell.simdata.SimDataBlock) SubVolume(cbit.vcell.geometry.SubVolume) AnalyticSubVolume(cbit.vcell.geometry.AnalyticSubVolume) VolVariable(cbit.vcell.math.VolVariable) FilamentRegionVariable(cbit.vcell.math.FilamentRegionVariable) CartesianMesh(cbit.vcell.solvers.CartesianMesh) SimpleSymbolTable(cbit.vcell.parser.SimpleSymbolTable) Coordinate(org.vcell.util.Coordinate) Expression(cbit.vcell.parser.Expression) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) FilamentVariable(cbit.vcell.math.FilamentVariable)

Example 7 with MembraneRegionVariable

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

the class SimulationSymbolTable method hasTimeVaryingDiffusionOrAdvection.

public boolean hasTimeVaryingDiffusionOrAdvection(Variable variable) throws MathException, ExpressionException {
    Enumeration<SubDomain> enum1 = simulation.getMathDescription().getSubDomains();
    while (enum1.hasMoreElements()) {
        SubDomain subDomain = enum1.nextElement();
        Equation equation = subDomain.getEquation(variable);
        // 
        if (equation instanceof PdeEquation) {
            Vector<Expression> spatialExpressionList = new Vector<Expression>();
            spatialExpressionList.add(((PdeEquation) equation).getDiffusionExpression());
            if (((PdeEquation) equation).getVelocityX() != null) {
                spatialExpressionList.add(((PdeEquation) equation).getVelocityX());
            }
            if (((PdeEquation) equation).getVelocityY() != null) {
                spatialExpressionList.add(((PdeEquation) equation).getVelocityY());
            }
            if (((PdeEquation) equation).getVelocityZ() != null) {
                spatialExpressionList.add(((PdeEquation) equation).getVelocityZ());
            }
            for (int i = 0; i < spatialExpressionList.size(); i++) {
                Expression spatialExp = spatialExpressionList.elementAt(i);
                spatialExp = substituteFunctions(spatialExp);
                String[] symbols = spatialExp.getSymbols();
                if (symbols != null) {
                    for (int j = 0; j < symbols.length; j++) {
                        SymbolTableEntry entry = spatialExp.getSymbolBinding(symbols[j]);
                        if (entry instanceof ReservedVariable) {
                            if (((ReservedVariable) entry).isTIME()) {
                                return true;
                            }
                        }
                        if (entry instanceof VolVariable) {
                            return true;
                        }
                        if (entry instanceof VolumeRegionVariable) {
                            return true;
                        }
                        if (entry instanceof MemVariable || entry instanceof MembraneRegionVariable) {
                            return true;
                        }
                    }
                }
            }
        }
    }
    return false;
}
Also used : MembraneRegionVariable(cbit.vcell.math.MembraneRegionVariable) VolVariable(cbit.vcell.math.VolVariable) PdeEquation(cbit.vcell.math.PdeEquation) Equation(cbit.vcell.math.Equation) SubDomain(cbit.vcell.math.SubDomain) MembraneSubDomain(cbit.vcell.math.MembraneSubDomain) PdeEquation(cbit.vcell.math.PdeEquation) VolumeRegionVariable(cbit.vcell.math.VolumeRegionVariable) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) ReservedVariable(cbit.vcell.math.ReservedVariable) MemVariable(cbit.vcell.math.MemVariable) Expression(cbit.vcell.parser.Expression) Vector(java.util.Vector)

Example 8 with MembraneRegionVariable

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

the class SimulationSymbolTable method createAnnotatedFunctionsList.

public Vector<AnnotatedFunction> createAnnotatedFunctionsList(MathDescription mathDescription) throws InconsistentDomainException {
    // Get the list of (volVariables) in the simulation. Needed to determine 'type' of  functions
    boolean bSpatial = getSimulation().isSpatial();
    String[] variableNames = null;
    VariableType[] variableTypes = null;
    if (bSpatial) {
        Variable[] allVariables = getVariables();
        Vector<Variable> varVector = new Vector<Variable>();
        for (int i = 0; i < allVariables.length; i++) {
            if ((allVariables[i] instanceof VolVariable) || (allVariables[i] instanceof VolumeRegionVariable) || (allVariables[i] instanceof MemVariable) || (allVariables[i] instanceof MembraneRegionVariable) || (allVariables[i] instanceof FilamentVariable) || (allVariables[i] instanceof FilamentRegionVariable) || (allVariables[i] instanceof PointVariable) || (allVariables[i] instanceof ParticleVariable) || (allVariables[i] instanceof InsideVariable) || (allVariables[i] instanceof OutsideVariable)) {
                varVector.addElement(allVariables[i]);
            } else if (allVariables[i] instanceof Constant || (allVariables[i] instanceof Function)) {
            } else {
                System.err.println("SimulationSymbolTable.createAnnotatedFunctionsList() found unexpected variable type " + allVariables[i].getClass().getSimpleName() + " in spatial simulation");
            }
        }
        variableNames = new String[varVector.size()];
        for (int i = 0; i < variableNames.length; i++) {
            variableNames[i] = varVector.get(i).getName();
        }
        // Lookup table for variableType for each variable in 'variables' array.
        variableTypes = new VariableType[variableNames.length];
        for (int i = 0; i < variableNames.length; i++) {
            variableTypes[i] = VariableType.getVariableType(varVector.get(i));
        }
    }
    // 
    // Bind and substitute functions to simulation before storing them in the '.functions' file
    // 
    Function[] functions = getFunctions();
    Vector<AnnotatedFunction> annotatedFunctionVector = new Vector<AnnotatedFunction>();
    for (int i = 0; i < functions.length; i++) {
        if (isFunctionSaved(functions[i])) {
            String errString = "";
            VariableType funcType = null;
            try {
                Expression substitutedExp = substituteFunctions(functions[i].getExpression());
                substitutedExp.bindExpression(this);
                functions[i].setExpression(substitutedExp.flatten());
            } catch (MathException e) {
                e.printStackTrace(System.out);
                errString = errString + ", " + e.getMessage();
            // throw new RuntimeException(e.getMessage());
            } catch (ExpressionException e) {
                e.printStackTrace(System.out);
                errString = errString + ", " + e.getMessage();
            // throw new RuntimeException(e.getMessage());
            }
            // 
            // get function's data type from the types of it's identifiers
            // 
            funcType = bSpatial ? getFunctionVariableType(functions[i], mathDescription, variableNames, variableTypes, bSpatial) : VariableType.NONSPATIAL;
            AnnotatedFunction annotatedFunc = new AnnotatedFunction(functions[i].getName(), functions[i].getExpression(), functions[i].getDomain(), errString, funcType, FunctionCategory.PREDEFINED);
            annotatedFunctionVector.addElement(annotatedFunc);
        }
    }
    return annotatedFunctionVector;
}
Also used : MembraneRegionVariable(cbit.vcell.math.MembraneRegionVariable) VolumeRegionVariable(cbit.vcell.math.VolumeRegionVariable) ReservedVariable(cbit.vcell.math.ReservedVariable) PointVariable(cbit.vcell.math.PointVariable) ParticleVariable(cbit.vcell.math.ParticleVariable) MemVariable(cbit.vcell.math.MemVariable) InsideVariable(cbit.vcell.math.InsideVariable) OutsideVariable(cbit.vcell.math.OutsideVariable) FilamentRegionVariable(cbit.vcell.math.FilamentRegionVariable) Variable(cbit.vcell.math.Variable) FilamentVariable(cbit.vcell.math.FilamentVariable) VolVariable(cbit.vcell.math.VolVariable) MembraneRegionVariable(cbit.vcell.math.MembraneRegionVariable) ParticleVariable(cbit.vcell.math.ParticleVariable) Constant(cbit.vcell.math.Constant) InsideVariable(cbit.vcell.math.InsideVariable) ExpressionException(cbit.vcell.parser.ExpressionException) VolumeRegionVariable(cbit.vcell.math.VolumeRegionVariable) Function(cbit.vcell.math.Function) MemVariable(cbit.vcell.math.MemVariable) Vector(java.util.Vector) VariableType(cbit.vcell.math.VariableType) VolVariable(cbit.vcell.math.VolVariable) FilamentRegionVariable(cbit.vcell.math.FilamentRegionVariable) Expression(cbit.vcell.parser.Expression) MathException(cbit.vcell.math.MathException) FilamentVariable(cbit.vcell.math.FilamentVariable) PointVariable(cbit.vcell.math.PointVariable) OutsideVariable(cbit.vcell.math.OutsideVariable)

Example 9 with MembraneRegionVariable

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

the class Xmlproducer method getXML.

/**
 * This method returns a XML representation of a MathDescription object.
 * Creation date: (3/2/2001 10:57:25 AM)
 * @return Element
 * @param mathdes cbit.vcell.math.MathDescription
 */
Element getXML(MathDescription mathdes) throws XmlParseException {
    Element math = new Element(XMLTags.MathDescriptionTag);
    // Add attributes
    math.setAttribute(XMLTags.NameAttrTag, mangle(mathdes.getName()));
    // Add annotation
    if (mathdes.getDescription() != null && mathdes.getDescription().length() > 0) {
        Element annotationElem = new Element(XMLTags.AnnotationTag);
        annotationElem.setText(mangle(mathdes.getDescription()));
        math.addContent(annotationElem);
    }
    List<ParticleMolecularType> particleMolecularTypes = mathdes.getParticleMolecularTypes();
    for (ParticleMolecularType particleMolecularType : particleMolecularTypes) {
        math.addContent(getXML(particleMolecularType));
    }
    // Add Constant subelements
    Enumeration<Variable> enum1 = mathdes.getVariables();
    /*java.util.Iterator k;
    try {
    	VariableHash varHash = new VariableHash();
    	while (enum1.hasMoreElements()) 
    	 	varHash.addVariable((Variable)enum1.nextElement());
    	Variable vars [] = varHash.getReorderedVariables();
    	k = new ArrayList(java.util.Arrays.asList(vars)).iterator();
    } catch (cbit.vcell.mapping.MappingException e) {
		e.printStackTrace();
		return null;
    }*/
    while (enum1.hasMoreElements()) {
        Variable var = enum1.nextElement();
        Element element = null;
        if (var instanceof Constant) {
            element = getXML((Constant) var);
        } else if (var instanceof FilamentRegionVariable) {
            element = getXML((FilamentRegionVariable) var);
        } else if (var instanceof FilamentVariable) {
            element = getXML((FilamentVariable) var);
        } else if (var instanceof PointVariable) {
            element = getXML((PointVariable) var);
        } else if (var instanceof Function) {
            element = getXML((Function) var);
        } else if (var instanceof RandomVariable) {
            element = getXML((RandomVariable) var);
        } else if (var instanceof InsideVariable) {
            // *** for internal use! Ignore it ***
            continue;
        } else if (var instanceof MembraneRegionVariable) {
            element = getXML((MembraneRegionVariable) var);
        } else if (var instanceof MemVariable) {
            element = getXML((MemVariable) var);
        } else if (var instanceof OutsideVariable) {
            // *** for internal use! Ignore it ****
            continue;
        } else if (var instanceof VolumeRegionVariable) {
            element = getXML((VolumeRegionVariable) var);
        } else if (var instanceof VolVariable) {
            element = getXML((VolVariable) var);
        } else if (var instanceof StochVolVariable) {
            // added for stochastic volumn variables
            element = getXML((StochVolVariable) var);
        } else if (var instanceof ParticleVariable) {
            element = getXML((ParticleVariable) var);
        } else if (var instanceof ParticleObservable) {
            element = getXML((ParticleObservable) var);
        } else {
            throw new XmlParseException("An unknown variable type " + var.getClass().getName() + " was found when parsing the mathdescription " + mathdes.getName() + "!");
        }
        transcribeComments(var, element);
        math.addContent(element);
    }
    // this was moved to the simspec!
    /*	buffer.append("\n");
    	if (geometry != null){
    		buffer.append(geometry.getXML());
    	}	
    	buffer.append("\n");*/
    // Add subdomains
    Enumeration<SubDomain> enum2 = mathdes.getSubDomains();
    while (enum2.hasMoreElements()) {
        SubDomain subDomain = enum2.nextElement();
        math.addContent(getXML(subDomain));
    }
    // Add Metadata (Version) if there is!
    if (mathdes.getVersion() != null) {
        math.addContent(getXML(mathdes.getVersion(), mathdes));
    }
    Iterator<Event> iter = mathdes.getEvents();
    while (iter.hasNext()) {
        math.addContent(getXML(iter.next()));
    }
    PostProcessingBlock postProcessingBlock = mathdes.getPostProcessingBlock();
    if (postProcessingBlock.getNumDataGenerators() > 0) {
        math.addContent(getXML(postProcessingBlock));
    }
    return math;
}
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) 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) MembraneRegionVariable(cbit.vcell.math.MembraneRegionVariable) MacroscopicRateConstant(cbit.vcell.math.MacroscopicRateConstant) Constant(cbit.vcell.math.Constant) VolumeParticleVariable(cbit.vcell.math.VolumeParticleVariable) MembraneParticleVariable(cbit.vcell.math.MembraneParticleVariable) ParticleVariable(cbit.vcell.math.ParticleVariable) Element(org.jdom.Element) RandomVariable(cbit.vcell.math.RandomVariable) VolumeRandomVariable(cbit.vcell.math.VolumeRandomVariable) InsideVariable(cbit.vcell.math.InsideVariable) PostProcessingBlock(cbit.vcell.math.PostProcessingBlock) VolumeRegionVariable(cbit.vcell.math.VolumeRegionVariable) SubDomain(cbit.vcell.math.SubDomain) MembraneSubDomain(cbit.vcell.math.MembraneSubDomain) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) FilamentSubDomain(cbit.vcell.math.FilamentSubDomain) PointSubDomain(cbit.vcell.math.PointSubDomain) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction) Function(cbit.vcell.math.Function) MemVariable(cbit.vcell.math.MemVariable) ParticleMolecularType(cbit.vcell.math.ParticleMolecularType) StochVolVariable(cbit.vcell.math.StochVolVariable) StochVolVariable(cbit.vcell.math.StochVolVariable) VolVariable(cbit.vcell.math.VolVariable) FilamentRegionVariable(cbit.vcell.math.FilamentRegionVariable) FilamentVariable(cbit.vcell.math.FilamentVariable) Event(cbit.vcell.math.Event) BioEvent(cbit.vcell.mapping.BioEvent) PointVariable(cbit.vcell.math.PointVariable) OutsideVariable(cbit.vcell.math.OutsideVariable) VolumeParticleObservable(cbit.vcell.math.VolumeParticleObservable) ParticleObservable(cbit.vcell.math.ParticleObservable)

Example 10 with MembraneRegionVariable

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

the class ModelOptimizationSpec method removeUncoupledParameters.

public void removeUncoupledParameters() {
    try {
        localIssueList.clear();
        MathMapping mathMapping = getSimulationContext().createNewMathMapping();
        MathDescription mathDesc = mathMapping.getMathDescription();
        MathSystemHash mathSystemHash = fromMath(mathDesc);
        Graph graph = mathSystemHash.getDependencyGraph(mathSystemHash.getSymbols());
        Tree[] spanningTrees = graph.getSpanningForest();
        // 
        for (int i = 0; i < spanningTrees.length; i++) {
            Node[] treeNodes = spanningTrees[i].getNodes();
            boolean bHasStateVariables = false;
            for (int j = 0; j < treeNodes.length; j++) {
                Node node = treeNodes[j];
                Variable var = mathDesc.getVariable(node.getName());
                if (var instanceof VolVariable || var instanceof MemVariable || var instanceof FilamentVariable || var instanceof VolumeRegionVariable || var instanceof MembraneRegionVariable || var instanceof FilamentRegionVariable) {
                    bHasStateVariables = true;
                    break;
                }
            }
            if (!bHasStateVariables) {
                spanningTrees = (Tree[]) BeanUtils.removeElement(spanningTrees, spanningTrees[i]);
                i--;
            }
        }
        // 
        // remove parameters not mapped to a surviving tree (not coupled to any state variables
        // 
        ArrayList<ParameterMappingSpec> paramMappingSpecsList = new ArrayList<ParameterMappingSpec>();
        paramMappingSpecsList.addAll(Arrays.asList(fieldParameterMappingSpecs));
        for (int i = 0; i < paramMappingSpecsList.size(); i++) {
            Parameter parameter = paramMappingSpecsList.get(i).getModelParameter();
            String mathName = mathMapping.getMathSymbolMapping().getVariable(parameter).getName();
            boolean bFoundInTree = false;
            for (int j = 0; j < spanningTrees.length; j++) {
                Node node = spanningTrees[j].getNode(mathName);
                if (node != null) {
                    bFoundInTree = true;
                }
            }
            if (!bFoundInTree) {
                paramMappingSpecsList.remove(i);
                i--;
            }
        }
        ParameterMappingSpec[] parameterMappingSpecs = new ParameterMappingSpec[paramMappingSpecsList.size()];
        paramMappingSpecsList.toArray(parameterMappingSpecs);
        setParameterMappingSpecs(parameterMappingSpecs);
    } catch (Exception e) {
        e.printStackTrace(System.out);
        localIssueList.add(new Issue(this, localIssueContext, IssueCategory.ParameterEstimationGeneralWarning, e.getMessage(), Issue.SEVERITY_WARNING));
    // throw new RuntimeException(e.getMessage());
    }
}
Also used : MembraneRegionVariable(cbit.vcell.math.MembraneRegionVariable) FilamentVariable(cbit.vcell.math.FilamentVariable) VolVariable(cbit.vcell.math.VolVariable) VolumeRegionVariable(cbit.vcell.math.VolumeRegionVariable) MemVariable(cbit.vcell.math.MemVariable) FilamentRegionVariable(cbit.vcell.math.FilamentRegionVariable) Variable(cbit.vcell.math.Variable) Issue(org.vcell.util.Issue) MembraneRegionVariable(cbit.vcell.math.MembraneRegionVariable) MathDescription(cbit.vcell.math.MathDescription) Node(cbit.util.graph.Node) ArrayList(java.util.ArrayList) VolumeRegionVariable(cbit.vcell.math.VolumeRegionVariable) MemVariable(cbit.vcell.math.MemVariable) Tree(cbit.util.graph.Tree) VolVariable(cbit.vcell.math.VolVariable) FilamentRegionVariable(cbit.vcell.math.FilamentRegionVariable) PropertyVetoException(java.beans.PropertyVetoException) ExpressionException(cbit.vcell.parser.ExpressionException) Graph(cbit.util.graph.Graph) FilamentVariable(cbit.vcell.math.FilamentVariable) MathMapping(cbit.vcell.mapping.MathMapping) Parameter(cbit.vcell.model.Parameter) KineticsParameter(cbit.vcell.model.Kinetics.KineticsParameter) ModelParameter(cbit.vcell.model.Model.ModelParameter) KineticsProxyParameter(cbit.vcell.model.Kinetics.KineticsProxyParameter) SpeciesContextSpecParameter(cbit.vcell.mapping.SpeciesContextSpec.SpeciesContextSpecParameter)

Aggregations

MembraneRegionVariable (cbit.vcell.math.MembraneRegionVariable)15 MemVariable (cbit.vcell.math.MemVariable)13 VolVariable (cbit.vcell.math.VolVariable)13 VolumeRegionVariable (cbit.vcell.math.VolumeRegionVariable)12 Variable (cbit.vcell.math.Variable)10 Expression (cbit.vcell.parser.Expression)10 FilamentVariable (cbit.vcell.math.FilamentVariable)8 MembraneSubDomain (cbit.vcell.math.MembraneSubDomain)8 CompartmentSubDomain (cbit.vcell.math.CompartmentSubDomain)7 FilamentRegionVariable (cbit.vcell.math.FilamentRegionVariable)7 SubDomain (cbit.vcell.math.SubDomain)7 Constant (cbit.vcell.math.Constant)6 MathDescription (cbit.vcell.math.MathDescription)6 ReservedVariable (cbit.vcell.math.ReservedVariable)6 InsideVariable (cbit.vcell.math.InsideVariable)5 OutsideVariable (cbit.vcell.math.OutsideVariable)5 Equation (cbit.vcell.math.Equation)4 Function (cbit.vcell.math.Function)4 MembraneRegionEquation (cbit.vcell.math.MembraneRegionEquation)4 PdeEquation (cbit.vcell.math.PdeEquation)4