Search in sources :

Example 6 with MemVariable

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

the class FastSystemAnalyzer method refreshFastVarList.

/**
 * @return java.util.Vector
 */
private void refreshFastVarList() throws MathException, ExpressionException {
    fastVarList.clear();
    // 
    // get list of unique (VolVariables and MemVariables) in fastRate expressions
    // 
    Enumeration<FastRate> fastRatesEnum = fastSystem.getFastRates();
    while (fastRatesEnum.hasMoreElements()) {
        FastRate fr = fastRatesEnum.nextElement();
        Expression exp = fr.getFunction();
        Enumeration<Variable> enum1 = MathUtilities.getRequiredVariables(exp, this);
        while (enum1.hasMoreElements()) {
            Variable var = enum1.nextElement();
            if (var instanceof VolVariable || var instanceof MemVariable) {
                if (!fastVarList.contains(var)) {
                    fastVarList.addElement(var);
                // System.out.println("FastSystemImplicit.refreshFastVarList(), FAST RATE VARIABLE: "+var.getName());
                }
            }
        }
    }
    // 
    // get list of all variables used in invariant expressions that are not used in fast rates
    // 
    Enumeration<FastInvariant> fastInvariantsEnum = fastSystem.getFastInvariants();
    while (fastInvariantsEnum.hasMoreElements()) {
        FastInvariant fi = (FastInvariant) fastInvariantsEnum.nextElement();
        Expression exp = fi.getFunction();
        // System.out.println("FastSystemImplicit.refreshFastVarList(), ORIGINAL FAST INVARIANT: "+exp);
        Enumeration<Variable> enum1 = MathUtilities.getRequiredVariables(exp, this);
        while (enum1.hasMoreElements()) {
            Variable var = enum1.nextElement();
            if (var instanceof VolVariable || var instanceof MemVariable) {
                if (!fastVarList.contains(var)) {
                    fastVarList.addElement(var);
                }
            }
        }
    }
    // 
    // verify that there are N equations (rates+invariants) and N unknowns (fastVariables)
    // 
    int numBoundFunctions = fastSystem.getNumFastInvariants() + fastSystem.getNumFastRates();
    if (fastVarList.size() != numBoundFunctions) {
        throw new MathException("FastSystem.checkDimension(), there are " + fastVarList.size() + " variables and " + numBoundFunctions + " FastInvariant's & FastRates");
    }
}
Also used : ReservedVariable(cbit.vcell.math.ReservedVariable) Variable(cbit.vcell.math.Variable) VolVariable(cbit.vcell.math.VolVariable) MemVariable(cbit.vcell.math.MemVariable) MemVariable(cbit.vcell.math.MemVariable) Expression(cbit.vcell.parser.Expression) VolVariable(cbit.vcell.math.VolVariable) MathException(cbit.vcell.math.MathException) FastRate(cbit.vcell.math.FastRate) FastInvariant(cbit.vcell.math.FastInvariant)

Example 7 with MemVariable

use of cbit.vcell.math.MemVariable 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 8 with MemVariable

use of cbit.vcell.math.MemVariable 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 9 with MemVariable

use of cbit.vcell.math.MemVariable 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 10 with MemVariable

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

the class SimulationData method getVarAndFunctionDataIdentifiers.

/**
 * This method was created in VisualAge.
 * @return java.lang.String[]
 */
public synchronized DataIdentifier[] getVarAndFunctionDataIdentifiers(OutputContext outputContext) throws IOException, DataAccessException {
    // Is this zip format?
    boolean bIsChombo = false;
    try {
        bIsChombo = isChombo();
    } catch (FileNotFoundException e) {
        e.printStackTrace(System.out);
    }
    File zipFile1 = getZipFile(bIsChombo, null);
    File zipFile2 = getZipFile(bIsChombo, 0);
    bZipFormat1 = false;
    bZipFormat2 = false;
    if (zipFile1.exists()) {
        bZipFormat1 = true;
    } else if (zipFile2.exists()) {
        bZipFormat2 = true;
    }
    refreshLogFile();
    if (!isComsol()) {
        try {
            refreshMeshFile();
        } catch (MathException e) {
            e.printStackTrace(System.out);
            throw new DataAccessException(e.getMessage());
        }
    }
    if (!isRulesData && !getIsODEData() && !isComsol() && dataFilenames != null) {
        // read variables only when I have never read the file since variables don't change
        if (dataSetIdentifierList.size() == 0) {
            File file = getPDEDataFile(0.0);
            DataSet dataSet = getPDEDataSet(file, 0.0);
            String[] varNames = dataSet.getDataNames();
            int[] varTypeInts = dataSet.getVariableTypeIntegers();
            if (varNames == null) {
                return null;
            }
            dataSetIdentifierList.clear();
            for (int i = 0; i < varNames.length; i++) {
                VariableType varType = null;
                try {
                    varType = VariableType.getVariableTypeFromInteger(varTypeInts[i]);
                } catch (IllegalArgumentException e) {
                    if (LG.isEnabledFor(Level.WARN)) {
                        LG.warn("Exception typing " + varNames[i] + " has unsupported type " + varTypeInts[i] + ": " + e.getMessage());
                    }
                    varType = SimulationData.getVariableTypeFromLength(mesh, dataSet.getDataLength(varNames[i]));
                }
                Domain domain = Variable.getDomainFromCombinedIdentifier(varNames[i]);
                String varName = Variable.getNameFromCombinedIdentifier(varNames[i]);
                dataSetIdentifierList.addElement(new DataSetIdentifier(varName, varType, domain));
            }
            refreshDataProcessingOutputInfo(outputContext);
            if (dataProcessingOutputInfo != null) {
                for (int i = 0; i < dataProcessingOutputInfo.getVariableNames().length; i++) {
                    if (dataProcessingOutputInfo.getPostProcessDataType(dataProcessingOutputInfo.getVariableNames()[i]).equals(DataProcessingOutputInfo.PostProcessDataType.image)) {
                        dataSetIdentifierList.addElement(new DataSetIdentifier(dataProcessingOutputInfo.getVariableNames()[i], VariableType.POSTPROCESSING, null));
                    }
                }
            }
        }
        // always read functions file since functions might change
        getFunctionDataIdentifiers(outputContext);
    }
    if ((isRulesData || getIsODEData()) && dataSetIdentifierList.size() == 0) {
        ODEDataBlock odeDataBlock = getODEDataBlock();
        if (odeDataBlock == null) {
            throw new DataAccessException("Results are not availabe yet. Please try again later.");
        }
        ODESimData odeSimData = odeDataBlock.getODESimData();
        int colCount = odeSimData.getColumnDescriptionsCount();
        // assume index=0 is time "t"
        int DATA_OFFSET = 1;
        dataSetIdentifierList.clear();
        for (int i = 0; i < (colCount - DATA_OFFSET); i++) {
            String varName = odeSimData.getColumnDescriptions(i + DATA_OFFSET).getDisplayName();
            // TODO domain
            Domain domain = null;
            dataSetIdentifierList.addElement(new DataSetIdentifier(varName, VariableType.NONSPATIAL, domain));
        }
    }
    if (isComsol() && dataSetIdentifierList.size() == 0) {
        ComsolSimFiles comsolSimFiles = getComsolSimFiles();
        if (comsolSimFiles.simTaskXMLFile != null) {
            try {
                String xmlString = FileUtils.readFileToString(comsolSimFiles.simTaskXMLFile);
                SimulationTask simTask = XmlHelper.XMLToSimTask(xmlString);
                Enumeration<Variable> variablesEnum = simTask.getSimulation().getMathDescription().getVariables();
                while (variablesEnum.hasMoreElements()) {
                    Variable var = variablesEnum.nextElement();
                    if (var instanceof VolVariable) {
                        dataSetIdentifierList.addElement(new DataSetIdentifier(var.getName(), VariableType.VOLUME, var.getDomain()));
                    } else if (var instanceof MemVariable) {
                        dataSetIdentifierList.addElement(new DataSetIdentifier(var.getName(), VariableType.MEMBRANE, var.getDomain()));
                    } else if (var instanceof Function) {
                        VariableType varType = VariableType.UNKNOWN;
                        if (var.getDomain() != null && var.getDomain().getName() != null) {
                            SubDomain subDomain = simTask.getSimulation().getMathDescription().getSubDomain(var.getDomain().getName());
                            if (subDomain instanceof CompartmentSubDomain) {
                                varType = VariableType.VOLUME;
                            } else if (subDomain instanceof MembraneSubDomain) {
                                varType = VariableType.MEMBRANE;
                            } else if (subDomain instanceof FilamentSubDomain) {
                                throw new RuntimeException("filament subdomains not supported");
                            } else if (subDomain instanceof PointSubDomain) {
                                varType = VariableType.POINT_VARIABLE;
                            }
                        }
                        dataSetIdentifierList.addElement(new DataSetIdentifier(var.getName(), varType, var.getDomain()));
                    } else if (var instanceof Constant) {
                        System.out.println("ignoring Constant " + var.getName());
                    } else if (var instanceof InsideVariable) {
                        System.out.println("ignoring InsideVariable " + var.getName());
                    } else if (var instanceof OutsideVariable) {
                        System.out.println("ignoring OutsideVariable " + var.getName());
                    } else {
                        throw new RuntimeException("unexpected variable " + var.getName() + " of type " + var.getClass().getName());
                    }
                }
            } catch (XmlParseException | ExpressionException e) {
                e.printStackTrace();
                throw new RuntimeException("failed to read sim task file, msg: " + e.getMessage(), e);
            }
        }
    }
    DataIdentifier[] dis = new DataIdentifier[dataSetIdentifierList.size()];
    for (int i = 0; i < dataSetIdentifierList.size(); i++) {
        DataSetIdentifier dsi = (DataSetIdentifier) dataSetIdentifierList.elementAt(i);
        String displayName = dsi.getName();
        if (dsi.isFunction()) {
            AnnotatedFunction f = null;
            for (int j = 0; j < annotatedFunctionList.size(); j++) {
                AnnotatedFunction function = (AnnotatedFunction) annotatedFunctionList.elementAt(j);
                if (function.getName().equals(dsi.getName())) {
                    f = function;
                    break;
                }
            }
            if (f != null) {
                displayName = f.getDisplayName();
            }
        }
        dis[i] = new DataIdentifier(dsi.getName(), dsi.getVariableType(), dsi.getDomain(), dsi.isFunction(), displayName);
    }
    return dis;
}
Also used : MembraneSubDomain(cbit.vcell.math.MembraneSubDomain) SimulationTask(cbit.vcell.messaging.server.SimulationTask) InsideVariable(cbit.vcell.math.InsideVariable) VolVariable(cbit.vcell.math.VolVariable) ReservedVariable(cbit.vcell.math.ReservedVariable) MemVariable(cbit.vcell.math.MemVariable) OutsideVariable(cbit.vcell.math.OutsideVariable) Variable(cbit.vcell.math.Variable) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier) Constant(cbit.vcell.math.Constant) FileNotFoundException(java.io.FileNotFoundException) PointSubDomain(cbit.vcell.math.PointSubDomain) ODESimData(cbit.vcell.solver.ode.ODESimData) InsideVariable(cbit.vcell.math.InsideVariable) ExpressionException(cbit.vcell.parser.ExpressionException) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) FilamentSubDomain(cbit.vcell.math.FilamentSubDomain) SubDomain(cbit.vcell.math.SubDomain) PointSubDomain(cbit.vcell.math.PointSubDomain) MembraneSubDomain(cbit.vcell.math.MembraneSubDomain) Function(cbit.vcell.math.Function) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction) MemVariable(cbit.vcell.math.MemVariable) DataAccessException(org.vcell.util.DataAccessException) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction) ComsolSimFiles(org.vcell.vis.io.ComsolSimFiles) VariableType(cbit.vcell.math.VariableType) VolVariable(cbit.vcell.math.VolVariable) XmlParseException(cbit.vcell.xml.XmlParseException) FilamentSubDomain(cbit.vcell.math.FilamentSubDomain) MathException(cbit.vcell.math.MathException) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) OutsideVariable(cbit.vcell.math.OutsideVariable) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) FilamentSubDomain(cbit.vcell.math.FilamentSubDomain) SubDomain(cbit.vcell.math.SubDomain) PointSubDomain(cbit.vcell.math.PointSubDomain) Domain(cbit.vcell.math.Variable.Domain) MembraneSubDomain(cbit.vcell.math.MembraneSubDomain) ZipFile(org.apache.commons.compress.archivers.zip.ZipFile) File(java.io.File)

Aggregations

MemVariable (cbit.vcell.math.MemVariable)21 VolVariable (cbit.vcell.math.VolVariable)19 Variable (cbit.vcell.math.Variable)15 MembraneRegionVariable (cbit.vcell.math.MembraneRegionVariable)14 VolumeRegionVariable (cbit.vcell.math.VolumeRegionVariable)13 MembraneSubDomain (cbit.vcell.math.MembraneSubDomain)10 ReservedVariable (cbit.vcell.math.ReservedVariable)10 Expression (cbit.vcell.parser.Expression)10 CompartmentSubDomain (cbit.vcell.math.CompartmentSubDomain)9 FilamentVariable (cbit.vcell.math.FilamentVariable)9 FilamentRegionVariable (cbit.vcell.math.FilamentRegionVariable)8 MathDescription (cbit.vcell.math.MathDescription)8 Constant (cbit.vcell.math.Constant)7 InsideVariable (cbit.vcell.math.InsideVariable)7 OutsideVariable (cbit.vcell.math.OutsideVariable)7 SubDomain (cbit.vcell.math.SubDomain)7 MathException (cbit.vcell.math.MathException)6 SubVolume (cbit.vcell.geometry.SubVolume)4 Equation (cbit.vcell.math.Equation)4 FastInvariant (cbit.vcell.math.FastInvariant)4