Search in sources :

Example 31 with Domain

use of cbit.vcell.math.Variable.Domain in project vcell by virtualcell.

the class OutputFunctionContext method computeFunctionTypeWRTExpression.

// check if the new expression is valid for outputFunction of functionType
public VariableType computeFunctionTypeWRTExpression(AnnotatedFunction outputFunction, Expression exp) throws ExpressionException, InconsistentDomainException {
    MathDescription mathDescription = getSimulationOwner().getMathDescription();
    boolean bSpatial = getSimulationOwner().getGeometry().getDimension() > 0;
    if (!bSpatial) {
        return VariableType.NONSPATIAL;
    }
    Expression newexp = new Expression(exp);
    // making sure that output function is not direct function of constant.
    newexp.bindExpression(this);
    // here use math description as symbol table because we allow
    // new expression itself to be function of constant.
    newexp = MathUtilities.substituteFunctions(newexp, this).flatten();
    String[] symbols = newexp.getSymbols();
    VariableType functionType = outputFunction.getFunctionType();
    String funcName = outputFunction.getName();
    Domain funcDomain = outputFunction.getDomain();
    VariableType[] varTypes = null;
    if (symbols != null && symbols.length > 0) {
        // making sure that new expression is defined in the same domain
        varTypes = new VariableType[symbols.length];
        for (int i = 0; i < symbols.length; i++) {
            if (ReservedMathSymbolEntries.getReservedVariableEntry(symbols[i]) != null) {
                varTypes[i] = functionType;
            } else {
                Variable var = mathDescription.getVariable(symbols[i]);
                if (var == null) {
                    var = mathDescription.getPostProcessingBlock().getDataGenerator(symbols[i]);
                }
                varTypes[i] = VariableType.getVariableType(var);
                if (funcDomain != null) {
                    if (var.getDomain() == null) {
                        // OK
                        continue;
                    }
                    GeometryClass funcGeoClass = simulationOwner.getGeometry().getGeometryClass(funcDomain.getName());
                    GeometryClass varGeoClass = simulationOwner.getGeometry().getGeometryClass(var.getDomain().getName());
                    if (varGeoClass instanceof SubVolume && funcGeoClass instanceof SurfaceClass) {
                        // seems ok if membrane refereces volume
                        if (!((SurfaceClass) funcGeoClass).isAdjacentTo((SubVolume) varGeoClass)) {
                            // but has to be adjacent
                            String errMsg = "'" + funcName + "' defined on Membrane '" + funcDomain.getName() + "' directly or indirectly references " + " variable '" + symbols[i] + "' defined on Volume '" + var.getDomain().getName() + " which is not adjacent to Membrane '" + funcDomain.getName() + "'.";
                            throw new ExpressionException(errMsg);
                        }
                    } else if (!var.getDomain().compareEqual(funcDomain)) {
                        String errMsg = "'" + funcName + "' defined on '" + funcDomain.getName() + "' directly or indirectly references " + " variable '" + symbols[i] + "' defined on '" + var.getDomain().getName() + ".";
                        throw new ExpressionException(errMsg);
                    }
                }
            }
        }
    }
    // if there are no variables (like built in function, vcRegionArea), check with flattened expression to find out the variable type of the new expression
    VariableDomain functionVariableDomain = functionType.getVariableDomain();
    Function flattenedFunction = new Function(funcName, newexp, funcDomain);
    flattenedFunction.bind(this);
    VariableType newVarType = SimulationSymbolTable.getFunctionVariableType(flattenedFunction, getSimulationOwner().getMathDescription(), symbols, varTypes, bSpatial);
    if (!newVarType.getVariableDomain().equals(functionVariableDomain)) {
        String errMsg = "The expression for '" + funcName + "' includes at least one " + newVarType.getVariableDomain().getName() + " variable. Please make sure that only " + functionVariableDomain.getName() + " variables are " + "referenced in " + functionVariableDomain.getName() + " output functions.";
        throw new ExpressionException(errMsg);
    }
    return newVarType;
}
Also used : GeometryClass(cbit.vcell.geometry.GeometryClass) ReservedVariable(cbit.vcell.math.ReservedVariable) InsideVariable(cbit.vcell.math.InsideVariable) OutsideVariable(cbit.vcell.math.OutsideVariable) Variable(cbit.vcell.math.Variable) VariableDomain(cbit.vcell.math.VariableType.VariableDomain) VariableType(cbit.vcell.math.VariableType) MathDescription(cbit.vcell.math.MathDescription) SurfaceClass(cbit.vcell.geometry.SurfaceClass) ExpressionException(cbit.vcell.parser.ExpressionException) Function(cbit.vcell.math.Function) Expression(cbit.vcell.parser.Expression) SubVolume(cbit.vcell.geometry.SubVolume) VariableDomain(cbit.vcell.math.VariableType.VariableDomain) Domain(cbit.vcell.math.Variable.Domain)

Example 32 with Domain

use of cbit.vcell.math.Variable.Domain in project vcell by virtualcell.

the class MathTestingUtilities method constructOdesForSensitivity.

// 
// This method is used to solve for sensitivity of variables to a given parameter.
// The mathDescription and the sensitivity parameter are passed as arguments.
// New variables and ODEs are constructed according to the rule listed below and are added to the mathDescription.
// The method returns the modified mathDescription.
// 
public static MathDescription constructOdesForSensitivity(MathDescription mathDesc, Constant sensParam) throws ExpressionException, MathException, MappingException {
    // 
    // For each ODE :
    // 
    // dX/dt = F(X, P)
    // 
    // (where P is the sensitivity parameter)
    // 
    // we create two other ODEs :
    // 
    // dX_1/dt = F(X_1, P_1)    and
    // 
    // dX_2/dt = F(X_2, P_2)
    // 
    // where P_1 = P + epsilon, and
    // P_2 = P - epsilon.
    // 
    // We keep the initial conditions for both the new ODEs to be the same,
    // i.e., X_1_init = X_2_init.
    // 
    // Then, solving for X_1 & X_2, sensitivity of X wrt P can be computed as :
    // 
    // dX = (X_1 - X_2)
    // --	 -----------   .
    // dP	 (P_1 - P_2)
    // 
    // 
    // REMOVE PRINTS AFTER CHECKING !!!
    System.out.println(" \n\n------------  Old Math Description -----------------");
    System.out.println(mathDesc.getVCML_database());
    if (mathDesc.getGeometry().getDimension() > 0) {
        throw new RuntimeException("Suppport for Spatial systems not yet implemented.");
    }
    VariableHash varHash = new VariableHash();
    Enumeration<Variable> enumVar = mathDesc.getVariables();
    while (enumVar.hasMoreElements()) {
        varHash.addVariable(enumVar.nextElement());
    }
    // 
    // Get 2 values of senstivity parameter (P + epsilon) & (P - epsilon)
    // 
    Constant epsilon = new Constant("epsilon", new Expression(sensParam.getConstantValue() * 1e-3));
    Constant sensParam1 = new Constant(sensParam.getName() + "_1", new Expression(sensParam.getConstantValue() + epsilon.getConstantValue()));
    Constant sensParam2 = new Constant(sensParam.getName() + "_2", new Expression(sensParam.getConstantValue() - epsilon.getConstantValue()));
    // 
    // Iterate through each subdomain (only 1 in compartmental case), and each equation in the subdomain
    // 
    Enumeration<SubDomain> subDomainEnum = mathDesc.getSubDomains();
    // 
    // Create a vector of equations to store the 2 equations for each ODE variable in the subdomain.
    // Later, add it to the equations list in the subdomain.
    // 
    Vector<Equation> equnsVector = new Vector<Equation>();
    Vector<Variable> varsVector = new Vector<Variable>();
    Vector<Variable> var1s = new Vector<Variable>();
    Vector<Variable> var2s = new Vector<Variable>();
    while (subDomainEnum.hasMoreElements()) {
        SubDomain subDomain = subDomainEnum.nextElement();
        Enumeration<Equation> equationEnum = subDomain.getEquations();
        Domain domain = new Domain(subDomain);
        while (equationEnum.hasMoreElements()) {
            Equation equation = equationEnum.nextElement();
            if (equation instanceof OdeEquation) {
                OdeEquation odeEquation = (OdeEquation) equation;
                // Similar to substituteWithExactSolutions, to bind and substitute functions in the ODE
                Expression substitutedRateExp = substituteFunctions(odeEquation.getRateExpression(), mathDesc);
                String varName = odeEquation.getVariable().getName();
                VolVariable var = new VolVariable(varName, domain);
                varsVector.addElement(var);
                // 
                // Create the variable var1, and get the initExpr and rateExpr from the original ODE.
                // Substitute the new vars (var1 and param1) in the old initExpr and rateExpr and create a new ODE
                // 
                String varName1 = new String("__" + varName + "_1");
                Expression initExpr1 = odeEquation.getInitialExpression();
                Expression rateExpr1 = new Expression(substitutedRateExp);
                rateExpr1.substituteInPlace(new Expression(varName), new Expression(varName1));
                rateExpr1.substituteInPlace(new Expression(sensParam.getName()), new Expression(sensParam1.getName()));
                VolVariable var1 = new VolVariable(varName1, domain);
                var1s.addElement(var1);
                OdeEquation odeEqun1 = new OdeEquation(var1, initExpr1, rateExpr1);
                equnsVector.addElement(odeEqun1);
                // 
                // Create the variable var2, and get the initExpr and rateExpr from the original ODE.
                // Substitute the new vars (var2 and param2) in the old initExpr and rateExpr and create a new ODE
                // 
                String varName2 = new String("__" + varName + "_2");
                Expression initExpr2 = odeEquation.getInitialExpression();
                Expression rateExpr2 = new Expression(substitutedRateExp);
                rateExpr2.substituteInPlace(new Expression(varName), new Expression(varName2));
                rateExpr2.substituteInPlace(new Expression(sensParam.getName()), new Expression(sensParam2.getName()));
                VolVariable var2 = new VolVariable(varName2, domain);
                var2s.addElement(var2);
                OdeEquation odeEqun2 = new OdeEquation(var2, initExpr2, rateExpr2);
                equnsVector.addElement(odeEqun2);
                // 
                // Create a function for the sensitivity function expression (X1-X2)/(P1-P2), and save in varHash
                // 
                Expression diffVar = Expression.add(new Expression(var1.getName()), Expression.negate(new Expression(var2.getName())));
                Expression diffParam = Expression.add(new Expression(sensParam1.getName()), Expression.negate(new Expression(sensParam2.getName())));
                Expression sensitivityExpr = Expression.mult(diffVar, Expression.invert(diffParam));
                Function sens_Func = new Function("__sens" + varName + "_wrt_" + sensParam.getName(), sensitivityExpr, domain);
                varHash.addVariable(epsilon);
                varHash.addVariable(sensParam1);
                varHash.addVariable(sensParam2);
                varHash.addVariable(var1);
                varHash.addVariable(var2);
                varHash.addVariable(sens_Func);
            } else {
                // sensitivity not implemented for PDEs or other equation types.
                throw new RuntimeException("SolverTest.constructedExactMath(): equation type " + equation.getClass().getName() + " not yet implemented");
            }
        }
        // 
        // Need to substitute the new variables in the new ODEs.
        // i.e., if Rate Expr for ODE_1 for variable X_1 contains variable Y, variable Z, etc.
        // Rate Expr is already substituted with X_1, but it also needs substitute Y with Y_1, Z with Z_1, etc.
        // So get the volume variables, from the vectors for vars, var_1s and var_2s
        // Substitute the rate expressions for the newly added ODEs in equnsVector.
        // 
        Variable[] vars = (Variable[]) BeanUtils.getArray(varsVector, Variable.class);
        Variable[] var_1s = (Variable[]) BeanUtils.getArray(var1s, Variable.class);
        Variable[] var_2s = (Variable[]) BeanUtils.getArray(var2s, Variable.class);
        Vector<Equation> newEqunsVector = new Vector<Equation>();
        for (int i = 0; i < equnsVector.size(); i++) {
            Equation equn = equnsVector.elementAt(i);
            Expression initEx = equn.getInitialExpression();
            Expression rateEx = equn.getRateExpression();
            for (int j = 0; j < vars.length; j++) {
                if (equn.getVariable().getName().endsWith("_1")) {
                    rateEx.substituteInPlace(new Expression(vars[j].getName()), new Expression(var_1s[j].getName()));
                } else if (equn.getVariable().getName().endsWith("_2")) {
                    rateEx.substituteInPlace(new Expression(vars[j].getName()), new Expression(var_2s[j].getName()));
                }
            }
            OdeEquation odeEqun = new OdeEquation(equn.getVariable(), initEx, rateEx);
            newEqunsVector.addElement(odeEqun);
        }
        // 
        for (int i = 0; i < newEqunsVector.size(); i++) {
            mathDesc.getSubDomain(subDomain.getName()).addEquation((Equation) newEqunsVector.elementAt(i));
        }
        // 
        // FAST SYSTEM
        // If the subdomain has a fast system, create a new fast system by substituting the high-low variables/parameters
        // in the expressions for the fastInvariants and fastRates and adding them to the fast system.
        // 
        Vector<FastInvariant> invarsVector = new Vector<FastInvariant>();
        Vector<FastRate> ratesVector = new Vector<FastRate>();
        Enumeration<FastInvariant> fastInvarsEnum = null;
        Enumeration<FastRate> fastRatesEnum = null;
        // Get the fast invariants and fast rates in the system.
        FastSystem fastSystem = subDomain.getFastSystem();
        if (fastSystem != null) {
            fastInvarsEnum = fastSystem.getFastInvariants();
            fastRatesEnum = fastSystem.getFastRates();
            // 
            while (fastInvarsEnum.hasMoreElements()) {
                FastInvariant fastInvar = fastInvarsEnum.nextElement();
                Expression fastInvarExpr = fastInvar.getFunction();
                fastInvarExpr = MathUtilities.substituteFunctions(fastInvarExpr, mathDesc);
                Expression fastInvarExpr1 = new Expression(fastInvarExpr);
                Expression fastInvarExpr2 = new Expression(fastInvarExpr);
                for (int i = 0; i < vars.length; i++) {
                    fastInvarExpr1.substituteInPlace(new Expression(vars[i].getName()), new Expression(var_1s[i].getName()));
                    fastInvarExpr2.substituteInPlace(new Expression(vars[i].getName()), new Expression(var_2s[i].getName()));
                }
                fastInvarExpr1.substituteInPlace(new Expression(sensParam.getName()), new Expression(sensParam1.getName()));
                FastInvariant fastInvar1 = new FastInvariant(fastInvarExpr1);
                invarsVector.addElement(fastInvar1);
                fastInvarExpr2.substituteInPlace(new Expression(sensParam.getName()), new Expression(sensParam2.getName()));
                FastInvariant fastInvar2 = new FastInvariant(fastInvarExpr2);
                invarsVector.addElement(fastInvar2);
            }
            // Add the newly created fast invariants to the existing list of fast invariants in the fast system.
            for (int i = 0; i < invarsVector.size(); i++) {
                FastInvariant inVar = (FastInvariant) invarsVector.elementAt(i);
                fastSystem.addFastInvariant(inVar);
            }
            // 
            while (fastRatesEnum.hasMoreElements()) {
                FastRate fastRate = fastRatesEnum.nextElement();
                Expression fastRateExpr = fastRate.getFunction();
                fastRateExpr = MathUtilities.substituteFunctions(fastRateExpr, mathDesc);
                Expression fastRateExpr1 = new Expression(fastRateExpr);
                Expression fastRateExpr2 = new Expression(fastRateExpr);
                for (int i = 0; i < vars.length; i++) {
                    fastRateExpr1.substituteInPlace(new Expression(vars[i].getName()), new Expression(var_1s[i].getName()));
                    fastRateExpr2.substituteInPlace(new Expression(vars[i].getName()), new Expression(var_2s[i].getName()));
                }
                fastRateExpr1.substituteInPlace(new Expression(sensParam.getName()), new Expression(sensParam1.getName()));
                FastRate fastRate1 = new FastRate(fastRateExpr1);
                ratesVector.addElement(fastRate1);
                fastRateExpr2.substituteInPlace(new Expression(sensParam.getName()), new Expression(sensParam2.getName()));
                FastRate fastRate2 = new FastRate(fastRateExpr2);
                ratesVector.addElement(fastRate2);
            }
            // Add the newly created fast rates to the existing list of fast rates in the fast system.
            for (int i = 0; i < ratesVector.size(); i++) {
                FastRate rate = (FastRate) ratesVector.elementAt(i);
                fastSystem.addFastRate(rate);
            }
        }
    }
    // Reset all variables in mathDesc.
    mathDesc.setAllVariables(varHash.getAlphabeticallyOrderedVariables());
    // REMOVE PRINTS AFTER CHECKING
    System.out.println(" \n\n------------  New Math Description -----------------");
    System.out.println(mathDesc.getVCML_database());
    return mathDesc;
}
Also used : 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) VariableHash(cbit.vcell.math.VariableHash) Constant(cbit.vcell.math.Constant) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) SubDomain(cbit.vcell.math.SubDomain) MembraneSubDomain(cbit.vcell.math.MembraneSubDomain) Function(cbit.vcell.math.Function) Vector(java.util.Vector) VolVariable(cbit.vcell.math.VolVariable) OdeEquation(cbit.vcell.math.OdeEquation) PdeEquation(cbit.vcell.math.PdeEquation) Equation(cbit.vcell.math.Equation) FastRate(cbit.vcell.math.FastRate) FastInvariant(cbit.vcell.math.FastInvariant) OdeEquation(cbit.vcell.math.OdeEquation) Expression(cbit.vcell.parser.Expression) FastSystem(cbit.vcell.math.FastSystem) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) SubDomain(cbit.vcell.math.SubDomain) Domain(cbit.vcell.math.Variable.Domain) MembraneSubDomain(cbit.vcell.math.MembraneSubDomain)

Example 33 with Domain

use of cbit.vcell.math.Variable.Domain in project vcell by virtualcell.

the class DisplayTimeSeriesOp method getDataSetControllerProvider.

private DataSetControllerProvider getDataSetControllerProvider(final ImageTimeSeries<? extends Image> imageTimeSeries, final PDEDataViewer pdeDataViewer) throws ImageException, IOException {
    ISize size = imageTimeSeries.getISize();
    int dimension = (size.getZ() > 0) ? (3) : (2);
    Extent extent = imageTimeSeries.getExtent();
    Origin origin = imageTimeSeries.getAllImages()[0].getOrigin();
    // don't care ... no surfaces
    double filterCutoffFrequency = 0.5;
    VCImage vcImage = new VCImageUncompressed(null, new byte[size.getXYZ()], extent, size.getX(), size.getY(), size.getZ());
    RegionImage regionImage = new RegionImage(vcImage, dimension, extent, origin, filterCutoffFrequency);
    final CartesianMesh mesh = CartesianMesh.createSimpleCartesianMesh(origin, extent, size, regionImage);
    final DataIdentifier dataIdentifier = new DataIdentifier("var", VariableType.VOLUME, new Domain("domain"), false, "var");
    final DataSetController dataSetController = new DataSetController() {

        @Override
        public ExportEvent makeRemoteFile(OutputContext outputContext, ExportSpecs exportSpecs) throws DataAccessException, RemoteProxyException {
            throw new RuntimeException("not yet implemented");
        }

        @Override
        public TimeSeriesJobResults getTimeSeriesValues(OutputContext outputContext, VCDataIdentifier vcdataID, TimeSeriesJobSpec timeSeriesJobSpec) throws RemoteProxyException, DataAccessException {
            pdeDataViewer.dataJobMessage(new DataJobEvent(timeSeriesJobSpec.getVcDataJobID(), MessageEvent.DATA_START, vcdataID.getDataKey(), vcdataID.getID(), new Double(0)));
            if (!timeSeriesJobSpec.isCalcSpaceStats() && !timeSeriesJobSpec.isCalcTimeStats()) {
                int[][] indices = timeSeriesJobSpec.getIndices();
                double[] timeStamps = imageTimeSeries.getImageTimeStamps();
                // [var][dataindex+1][timeindex]
                double[][][] dataValues = new double[1][indices[0].length + 1][timeStamps.length];
                for (int timeIndex = 0; timeIndex < timeStamps.length; timeIndex++) {
                    // index 0 is time
                    dataValues[0][0][timeIndex] = timeStamps[timeIndex];
                }
                for (int timeIndex = 0; timeIndex < timeStamps.length; timeIndex++) {
                    float[] pixelValues = imageTimeSeries.getAllImages()[timeIndex].getFloatPixels();
                    for (int samplePointIndex = 0; samplePointIndex < indices[0].length; samplePointIndex++) {
                        int pixelIndex = indices[0][samplePointIndex];
                        dataValues[0][samplePointIndex + 1][timeIndex] = pixelValues[pixelIndex];
                    }
                }
                TSJobResultsNoStats timeSeriesJobResults = new TSJobResultsNoStats(new String[] { "var" }, indices, timeStamps, dataValues);
                pdeDataViewer.dataJobMessage(new DataJobEvent(timeSeriesJobSpec.getVcDataJobID(), MessageEvent.DATA_COMPLETE, vcdataID.getDataKey(), vcdataID.getID(), new Double(0)));
                return timeSeriesJobResults;
            }
            return null;
        }

        @Override
        public SimDataBlock getSimDataBlock(OutputContext outputContext, VCDataIdentifier vcdataID, String varName, double time) throws RemoteProxyException, DataAccessException {
            double timePoint = time;
            double[] timePoints = getDataSetTimes(vcdataID);
            int index = -1;
            for (int i = 0; i < timePoints.length; i++) {
                if (timePoint == timePoints[i]) {
                    index = i;
                    break;
                }
            }
            double[] data = imageTimeSeries.getAllImages()[index].getDoublePixels();
            PDEDataInfo pdeDataInfo = new PDEDataInfo(null, null, varName, time, 0);
            VariableType varType = VariableType.VOLUME;
            return new SimDataBlock(pdeDataInfo, data, varType);
        }

        @Override
        public boolean getParticleDataExists(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
            return false;
        }

        @Override
        public ParticleDataBlock getParticleDataBlock(VCDataIdentifier vcdataID, double time) throws DataAccessException, RemoteProxyException {
            return null;
        }

        @Override
        public ODESimData getODEData(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
            return null;
        }

        @Override
        public CartesianMesh getMesh(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
            return mesh;
        }

        @Override
        public PlotData getLineScan(OutputContext outputContext, VCDataIdentifier vcdataID, String variable, double time, SpatialSelection spatialSelection) throws RemoteProxyException, DataAccessException {
            throw new RuntimeException("not yet implemented");
        }

        @Override
        public AnnotatedFunction[] getFunctions(OutputContext outputContext, VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
            return new AnnotatedFunction[0];
        }

        @Override
        public double[] getDataSetTimes(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
            return imageTimeSeries.getImageTimeStamps();
        }

        @Override
        public DataSetTimeSeries getDataSetTimeSeries(VCDataIdentifier vcdataID, String[] variableNames) throws DataAccessException, RemoteProxyException {
            throw new RuntimeException("not yet implemented");
        }

        @Override
        public DataSetMetadata getDataSetMetadata(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
            throw new RuntimeException("not yet implemented");
        }

        @Override
        public DataIdentifier[] getDataIdentifiers(OutputContext outputContext, VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
            return new DataIdentifier[] { dataIdentifier };
        }

        @Override
        public FieldDataFileOperationResults fieldDataFileOperation(FieldDataFileOperationSpec fieldDataFileOperationSpec) throws RemoteProxyException, DataAccessException {
            throw new RuntimeException("not yet implemented");
        }

        @Override
        public DataOperationResults doDataOperation(DataOperation dataOperation) throws DataAccessException, RemoteProxyException {
            throw new RuntimeException("not yet implemented");
        }

        @Override
        public VtuFileContainer getEmptyVtuMeshFiles(VCDataIdentifier vcdataID, int timeIndex) throws RemoteProxyException, DataAccessException {
            throw new RuntimeException("not yet implemented");
        }

        @Override
        public double[] getVtuTimes(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
            throw new RuntimeException("not yet implemented");
        }

        @Override
        public double[] getVtuMeshData(OutputContext outputContext, VCDataIdentifier vcdataID, VtuVarInfo var, double time) throws RemoteProxyException, DataAccessException {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        public VtuVarInfo[] getVtuVarInfos(OutputContext outputContext, VCDataIdentifier vcDataIdentifier) throws DataAccessException, RemoteProxyException {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        public NFSimMolecularConfigurations getNFSimMolecularConfigurations(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
            // TODO Auto-generated method stub
            return null;
        }
    };
    DataSetControllerProvider dataSetControllerProvider = new DataSetControllerProvider() {

        @Override
        public DataSetController getDataSetController() throws DataAccessException {
            return dataSetController;
        }
    };
    return dataSetControllerProvider;
}
Also used : Origin(org.vcell.util.Origin) VtuVarInfo(org.vcell.vis.io.VtuVarInfo) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) DataIdentifier(cbit.vcell.simdata.DataIdentifier) TimeSeriesJobSpec(org.vcell.util.document.TimeSeriesJobSpec) Extent(org.vcell.util.Extent) ISize(org.vcell.util.ISize) ExportSpecs(cbit.vcell.export.server.ExportSpecs) FieldDataFileOperationSpec(cbit.vcell.field.io.FieldDataFileOperationSpec) VCImage(cbit.image.VCImage) PDEDataInfo(cbit.vcell.simdata.PDEDataInfo) DataSetControllerProvider(cbit.vcell.server.DataSetControllerProvider) SimDataBlock(cbit.vcell.simdata.SimDataBlock) SpatialSelection(cbit.vcell.simdata.SpatialSelection) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction) DataOperation(cbit.vcell.simdata.DataOperation) VariableType(cbit.vcell.math.VariableType) DataSetController(cbit.vcell.server.DataSetController) VCImageUncompressed(cbit.image.VCImageUncompressed) OutputContext(cbit.vcell.simdata.OutputContext) DataJobEvent(cbit.rmi.event.DataJobEvent) CartesianMesh(cbit.vcell.solvers.CartesianMesh) RegionImage(cbit.vcell.geometry.RegionImage) Domain(cbit.vcell.math.Variable.Domain) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) TSJobResultsNoStats(org.vcell.util.document.TSJobResultsNoStats)

Example 34 with Domain

use of cbit.vcell.math.Variable.Domain in project vcell by virtualcell.

the class Equation method checkValid_Volume.

protected void checkValid_Volume(MathDescription mathDesc, List<Expression> expList, CompartmentSubDomain compartmentSubDomain) throws MathException, ExpressionException {
    for (Expression exp : expList) {
        if (exp == null) {
            return;
        }
        Domain volumeDomain = new Domain(compartmentSubDomain);
        Enumeration<Variable> varEnum = MathUtilities.getRequiredVariables(getInitialExpression(), mathDesc);
        while (varEnum.hasMoreElements()) {
            Variable refVar = varEnum.nextElement();
            if (refVar != null && refVar.getDomain() != null) {
                // if variable defined on this surface or the appropriate volume domain, then it is ok.
                if (refVar.getDomain().compareEqual(volumeDomain)) {
                    continue;
                }
            }
            if ((refVar instanceof MemVariable || refVar instanceof MembraneRandomVariable || refVar instanceof MembraneParticleVariable || refVar instanceof MembraneRegionVariable)) {
                String varType = "membrane";
                if (refVar instanceof MembraneRandomVariable) {
                    varType = "membrane random";
                } else if (refVar instanceof MembraneRegionVariable) {
                    varType = "membrane region";
                } else if (refVar instanceof MembraneParticleVariable) {
                    varType = "membrane particle";
                }
                throw new MathException("Equation for volume variable '" + getVariable().getName() + "' references " + varType + " variable '" + refVar.getName() + "'.");
            }
        }
    }
}
Also used : Expression(cbit.vcell.parser.Expression) Domain(cbit.vcell.math.Variable.Domain)

Example 35 with Domain

use of cbit.vcell.math.Variable.Domain in project vcell by virtualcell.

the class Equation method checkValid_PointSubDomain.

protected void checkValid_PointSubDomain(MathDescription mathDesc, List<Expression> expList, PointSubDomain pointSubDomain) throws MathException, ExpressionException {
    for (Expression exp : expList) {
        if (exp == null) {
            return;
        }
        Domain domain = new Domain(pointSubDomain);
        Enumeration<Variable> varEnum = MathUtilities.getRequiredVariables(getInitialExpression(), mathDesc);
        while (varEnum.hasMoreElements()) {
            Variable refVar = varEnum.nextElement();
            if (refVar != null && refVar.getDomain() != null) {
                // if variable defined on this surface or the appropriate volume domain, then it is ok.
                if (!refVar.getDomain().compareEqual(domain)) {
                    throw new MathException("Equation for point variable '" + getVariable().getName() + "' references variable not defined on this point, not yet supported (variable is '" + refVar.getName() + "'.");
                }
            }
        }
    }
}
Also used : Expression(cbit.vcell.parser.Expression) Domain(cbit.vcell.math.Variable.Domain)

Aggregations

Domain (cbit.vcell.math.Variable.Domain)54 CompartmentSubDomain (cbit.vcell.math.CompartmentSubDomain)35 Expression (cbit.vcell.parser.Expression)34 MembraneSubDomain (cbit.vcell.math.MembraneSubDomain)28 PointSubDomain (cbit.vcell.math.PointSubDomain)22 FilamentSubDomain (cbit.vcell.math.FilamentSubDomain)19 VolVariable (cbit.vcell.math.VolVariable)15 ExpressionException (cbit.vcell.parser.ExpressionException)14 Function (cbit.vcell.math.Function)13 SubDomain (cbit.vcell.math.SubDomain)13 Variable (cbit.vcell.math.Variable)13 AnnotatedFunction (cbit.vcell.solver.AnnotatedFunction)10 Element (org.jdom.Element)10 Constant (cbit.vcell.math.Constant)9 MemVariable (cbit.vcell.math.MemVariable)9 VariableHash (cbit.vcell.math.VariableHash)9 VariableType (cbit.vcell.math.VariableType)9 VolumeRegionVariable (cbit.vcell.math.VolumeRegionVariable)8 GeometryClass (cbit.vcell.geometry.GeometryClass)7 SubVolume (cbit.vcell.geometry.SubVolume)7