Search in sources :

Example 41 with Geometry

use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.

the class GeometrySubVolumeTableModel method setGeometry.

/**
 * Sets the geometry property (cbit.vcell.geometry.Geometry) value.
 * @param geometry The new value for the property.
 * @see #getGeometry
 */
public void setGeometry(Geometry geometry) {
    if (fieldGeometry == geometry) {
        return;
    }
    Geometry oldValue = fieldGeometry;
    if (oldValue != null) {
        oldValue.getGeometrySpec().removePropertyChangeListener(this);
        for (SubVolume sv : oldValue.getGeometrySpec().getSubVolumes()) {
            sv.removePropertyChangeListener(this);
        }
    }
    fieldGeometry = geometry;
    if (fieldGeometry != null) {
        fieldGeometry.getGeometrySpec().addPropertyChangeListener(this);
        for (SubVolume sv : fieldGeometry.getGeometrySpec().getSubVolumes()) {
            sv.addPropertyChangeListener(this);
        }
        autoCompleteSymbolFilter = new AutoCompleteSymbolFilter() {

            public boolean accept(SymbolTableEntry ste) {
                int dimension = fieldGeometry.getDimension();
                if (ste.equals(ReservedVariable.X) || dimension > 1 && ste.equals(ReservedVariable.Y) || dimension > 2 && ste.equals(ReservedVariable.Z)) {
                    return true;
                }
                return false;
            }

            public boolean acceptFunction(String funcName) {
                return true;
            }
        };
    }
    firePropertyChange("geometry", oldValue, fieldGeometry);
}
Also used : Geometry(cbit.vcell.geometry.Geometry) AutoCompleteSymbolFilter(cbit.vcell.parser.AutoCompleteSymbolFilter) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) SubVolume(cbit.vcell.geometry.SubVolume) AnalyticSubVolume(cbit.vcell.geometry.AnalyticSubVolume)

Example 42 with Geometry

use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.

the class GeometrySummaryPanel method setgeometry1.

/**
 * Set the geometry1 to a new value.
 * @param newValue cbit.vcell.geometry.Geometry
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void setgeometry1(cbit.vcell.geometry.Geometry newValue) {
    if (ivjgeometry1 != newValue) {
        try {
            cbit.vcell.geometry.Geometry oldValue = getgeometry1();
            ivjgeometry1 = newValue;
            connPtoP3SetSource();
            getJLabelExtent().setText(this.getExtentString());
            getJLabelOrigin().setText(this.getOriginString());
            setcellRenderer1(this.createListCellRenderer());
            connEtoM9(ivjgeometry1);
            connEtoM10(ivjgeometry1);
            connEtoC1(ivjgeometry1);
            firePropertyChange("geometry", oldValue, newValue);
        // user code begin {1}
        // user code end
        } catch (java.lang.Throwable ivjExc) {
            // user code begin {2}
            // user code end
            handleException(ivjExc);
        }
    }
    ;
// user code begin {3}
// user code end
}
Also used : Geometry(cbit.vcell.geometry.Geometry)

Example 43 with Geometry

use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.

the class SimulationWorkspace method checkSimulationParameters.

/**
 * Insert the method's description here.
 * Creation date: (5/11/2004 2:57:10 PM)
 * @return boolean
 * @param simulation cbit.vcell.solver.Simulation
 */
private static boolean checkSimulationParameters(Simulation simulation, Component parent) {
    SimulationSymbolTable simSymbolTable = new SimulationSymbolTable(simulation, 0);
    String errorMessage = null;
    long maxTimepoints = Simulation.MAX_LIMIT_NON_SPATIAL_TIMEPOINTS;
    long warningTimepoints = Simulation.WARNING_NON_SPATIAL_TIMEPOINTS;
    boolean bSpatial = simulation.isSpatial();
    if (bSpatial) {
        maxTimepoints = Simulation.MAX_LIMIT_SPATIAL_TIMEPOINTS;
        warningTimepoints = Simulation.WARNING_SPATIAL_TIMEPOINTS;
    }
    long maxSizeBytes = megabytesToBytes(Simulation.MAX_LIMIT_0DE_MEGABYTES);
    long warningSizeBytes = megabytesToBytes(Simulation.WARNING_0DE_MEGABYTES);
    if (bSpatial) {
        maxSizeBytes = megabytesToBytes(Simulation.MAX_LIMIT_PDE_MEGABYTES);
        warningSizeBytes = megabytesToBytes(Simulation.WARNING_PDE_MEGABYTES);
    } else if (simulation.getMathDescription().isNonSpatialStoch()) {
        maxSizeBytes = megabytesToBytes(Simulation.MAX_LIMIT_STOCH_MEGABYTES);
        warningSizeBytes = megabytesToBytes(Simulation.WARNING_STOCH_MEGABYTES);
    }
    long expectedNumTimePoints = getExpectedNumTimePoints(simulation);
    long expectedSizeBytes = getExpectedSizeBytes(simSymbolTable);
    // 
    // check for error conditions (hard limits on resources) ... Note: each user should have it's own limits (and quotas).
    // 
    SolverTaskDescription solverTaskDescription = simulation.getSolverTaskDescription();
    SolverDescription solverDescription = solverTaskDescription.getSolverDescription();
    if (expectedNumTimePoints > maxTimepoints) {
        errorMessage = "Errors in Simulation: '" + simulation.getName() + "'!\n" + "The simulation has too many timepoints (" + expectedNumTimePoints + ") to be saved, which has exceeded our limit.\n\n" + "maximum saving timepoints limits are:\n" + "     " + Simulation.MAX_LIMIT_NON_SPATIAL_TIMEPOINTS + " for compartmental simulations\n" + "     " + Simulation.MAX_LIMIT_SPATIAL_TIMEPOINTS + " for spatial simulations\n" + "suggested saving timepoints limits are:\n" + "     " + Simulation.WARNING_NON_SPATIAL_TIMEPOINTS + " for compartmental simulations\n" + "     " + Simulation.WARNING_SPATIAL_TIMEPOINTS + " for spatial simulations\n" + "Try saving fewer timepoints\n" + "If you need to exceed the quota, please contact us";
        // not used for multiple stochastic run
        if (solverTaskDescription.getStochOpt() != null && solverTaskDescription.getStochOpt().getNumOfTrials() > 1) {
            errorMessage = null;
        }
    } else if (expectedSizeBytes > maxSizeBytes) {
        errorMessage = "Errors in Simulation: '" + simulation.getName() + "'!\n" + "The simulation's result dataset (" + CodeUtil.humanBytePrint(expectedSizeBytes) + ") is too large, which has exceeded our limit.\n\n" + "maximum size limits are:\n" + "     " + Simulation.MAX_LIMIT_0DE_MEGABYTES + " MB for compartmental ODE simulations\n" + "     " + Simulation.MAX_LIMIT_PDE_MEGABYTES + " MB for spatial simulations\n" + "     " + Simulation.MAX_LIMIT_STOCH_MEGABYTES + " MB for compartmental stochastic simulations\n" + "suggested size limits are:\n" + "     " + Simulation.WARNING_0DE_MEGABYTES + " MB for compartmental ODE simulations\n" + "     " + Simulation.WARNING_PDE_MEGABYTES + " MB for spatial simulations\n" + "     " + Simulation.WARNING_STOCH_MEGABYTES + " MB for compartmental stochastic simulations\n" + "Try saving fewer timepoints or using a smaller mesh (if spatial)\n" + "If you need to exceed the quota, please contact us";
        // not used for multiple stochastic run
        if (solverTaskDescription.getStochOpt() != null && solverTaskDescription.getStochOpt().getNumOfTrials() > 1) {
            errorMessage = null;
        }
    } else if (simulation.getScanCount() > Simulation.MAX_LIMIT_SCAN_JOBS) {
        errorMessage = "Errors in Simulation: '" + simulation.getName() + "'!\n" + "The simulation generates too many simulations (" + simulation.getScanCount() + ") required for parameter scan, which has exceeded our limit.\n\n" + "maximum number of parameter sets is: " + Simulation.MAX_LIMIT_SCAN_JOBS + " \n" + "suggested limit for number of parameter sets is: " + Simulation.WARNING_SCAN_JOBS + " \n" + "Try choosing fewer parameters or reducing the size of scan for each parameter.";
        // not used for multiple stochastic run
        if (simulation.getMathDescription().isNonSpatialStoch() && solverTaskDescription.getStochOpt() != null && solverTaskDescription.getStochOpt().getNumOfTrials() > 1) {
            errorMessage = null;
        }
    } else if (solverDescription.equals(SolverDescription.SundialsPDE)) {
        if (solverTaskDescription.getOutputTimeSpec().isDefault()) {
            DefaultOutputTimeSpec dot = (DefaultOutputTimeSpec) solverTaskDescription.getOutputTimeSpec();
            int maxNumberOfSteps = dot.getKeepEvery() * dot.getKeepAtMost();
            double maximumTimeStep = solverTaskDescription.getTimeStep().getMaximumTimeStep();
            double maxSimTime = maxNumberOfSteps * maximumTimeStep;
            double endingTime = solverTaskDescription.getTimeBounds().getEndingTime();
            if (maxSimTime < endingTime) {
                errorMessage = "Errors in Simulation: '" + simulation.getName() + "'!\n" + "The maximum possible simulation time (keepEvery * maxTimestep * keepAtMost = " + maxSimTime + ") is less than simulation end time (" + endingTime + ").\n\n" + "You have chosen a variable time step solver and specified a maximum number of time steps of " + maxNumberOfSteps + " (keepEvery*keepAtMost).  " + "Actual time steps are often small, but even if all steps were at the maximum time step of " + maximumTimeStep + ", the simulation end time of " + endingTime + " would not be reached. \n\n" + "Either adjust the parameters or choose the \"Output Interval\" option.";
            }
        }
    } else if (simulation.getMathDescription().isNonSpatialStoch() && !(solverDescription.isNonSpatialStochasticSolver())) {
        // to guarantee stochastic model uses stochastic methods and deterministic model uses ODE/PDE methods.
        errorMessage = "Errors in Simulation: '" + simulation.getName() + "'!\n" + "Stochastic simulation(s) must use stochastic solver(s).\n" + solverDescription.getDisplayLabel() + " is not a stochastic solver!";
    } else if (!simulation.getMathDescription().isNonSpatialStoch() && (solverDescription.isNonSpatialStochasticSolver())) {
        errorMessage = "Errors in Simulation: '" + simulation.getName() + "'!\n" + "ODE/PDE simulation(s) must use ODE/PDE solver(s).\n" + solverDescription.getDisplayLabel() + " is not a ODE/PDE solver!";
    } else if (simulation.getSolverTaskDescription().getSolverDescription().isChomboSolver()) {
        MeshSpecification meshSpecification = simulation.getMeshSpecification();
        boolean bCellCentered = simulation.hasCellCenteredMesh();
        if (meshSpecification != null && !meshSpecification.isAspectRatioOK(1e-4, bCellCentered)) {
            errorMessage = "Non uniform spatial step is detected. This will affect the accuracy of the solution.\n\n" + "\u0394x=" + meshSpecification.getDx(bCellCentered) + "\n" + "\u0394y=" + meshSpecification.getDy(bCellCentered) + (meshSpecification.getGeometry().getDimension() < 3 ? "" : "\n\u0394z=" + meshSpecification.getDz(bCellCentered));
        }
    } else {
        errorMessage = null;
    }
    if (errorMessage != null) {
        DialogUtils.showErrorDialog(parent, errorMessage);
        return false;
    } else if (simulation.getSolverTaskDescription().getSolverDescription().isChomboSolver()) {
        Geometry geometry = simulation.getMathDescription().getGeometry();
        ChomboMeshValidator meshValidator = new ChomboMeshValidator(geometry, simulation.getSolverTaskDescription().getChomboSolverSpec());
        ChomboMeshRecommendation chomboMeshRecommendation = meshValidator.computeMeshSpecs();
        boolean bValid = chomboMeshRecommendation.validate();
        if (!bValid) {
            String option = DialogUtils.showWarningDialog(parent, "Error", chomboMeshRecommendation.getErrorMessage(), chomboMeshRecommendation.getDialogOptions(), ChomboMeshRecommendation.optionClose);
            if (ChomboMeshRecommendation.optionSuggestions.equals(option)) {
                DialogUtils.showInfoDialog(parent, ChomboMeshRecommendation.optionSuggestions, chomboMeshRecommendation.getMeshSuggestions());
            }
        }
        return bValid;
    } else {
        String warningMessage = null;
        // don't check warning message for stochastic multiple trials, let it run.
        if (simulation.getMathDescription().isNonSpatialStoch() && simulation.getSolverTaskDescription().getStochOpt() != null && simulation.getSolverTaskDescription().getStochOpt().getNumOfTrials() > 1) {
            return true;
        }
        // 
        if (expectedNumTimePoints > warningTimepoints) {
            warningMessage = "Warnings from Simulation: '" + simulation.getName() + "'!\n" + "The simulation has large number of saving timepoints (" + expectedNumTimePoints + "), suggested saving timepoints limits are:\n" + "     " + Simulation.WARNING_NON_SPATIAL_TIMEPOINTS + " for compartmental simulations\n" + "     " + Simulation.WARNING_SPATIAL_TIMEPOINTS + " for spatial simulations\n" + "Try saving fewer timepoints";
        } else if (expectedSizeBytes > warningSizeBytes) {
            warningMessage = "Warnings from Simulation: '" + simulation.getName() + "'!\n" + "The simulation has large result dataset (" + (expectedSizeBytes / 1000000L) + "MB), suggested size limits are:\n" + "     " + Simulation.WARNING_0DE_MEGABYTES + " MB for compartmental ODE simulations\n" + "     " + Simulation.WARNING_PDE_MEGABYTES + " MB for spatial simulations\n" + "     " + Simulation.WARNING_STOCH_MEGABYTES + " MB for compartmental stochastic simulations\n" + "Try saving fewer timepoints or using a coarser mesh if spatial.";
        } else if (simulation.getScanCount() > Simulation.WARNING_SCAN_JOBS) {
            warningMessage = "Warnings from Simulation: '" + simulation.getName() + "'!\n" + "The simulation generates a large number of simulations (" + simulation.getScanCount() + ") required for parameter scan.\n" + "maximum number of parameter sets is: " + Simulation.MAX_LIMIT_SCAN_JOBS + " \n" + "suggested limit for the number of parameter sets is: " + Simulation.WARNING_SCAN_JOBS + " \n" + "Try choosing fewer parameters or reducing the size of scan for each parameter.";
        }
        if (solverDescription.equals(SolverDescription.SundialsPDE)) {
            if (solverTaskDescription.getErrorTolerance().getRelativeErrorTolerance() > 1e-4) {
                String msg = "Warnings from Simulation: '" + simulation.getName() + "'!\n" + "Warning: it is not reccomended to use a relative tolerance that is greater than \n1e-4 for " + solverDescription.getDisplayLabel() + ".";
                warningMessage = warningMessage == null ? msg : warningMessage + "\n\n" + msg;
            }
        } else if (solverDescription.isSemiImplicitPdeSolver()) {
            if (solverTaskDescription.getErrorTolerance().getRelativeErrorTolerance() > 1e-8) {
                String msg = "Warnings from Simulation: '" + simulation.getName() + "'!\n" + "Warning: it is not reccomended to use a relative tolerance that is greater than \n1e-8 for " + solverDescription.getDisplayLabel() + ".";
                warningMessage = warningMessage == null ? msg : warningMessage + "\n\n" + msg;
            }
        }
        MeshSpecification meshSpecification = simulation.getMeshSpecification();
        boolean bCellCentered = simulation.hasCellCenteredMesh();
        if (meshSpecification != null && !meshSpecification.isAspectRatioOK(bCellCentered)) {
            warningMessage = (warningMessage == null ? "" : warningMessage + "\n\n") + "Non uniform spatial step is detected. This might affect the accuracy of the solution.\n\n" + "\u0394x=" + meshSpecification.getDx(bCellCentered) + "\n" + "\u0394y=" + meshSpecification.getDy(bCellCentered) + (meshSpecification.getGeometry().getDimension() < 3 ? "" : "\n\u0394z=" + meshSpecification.getDz(bCellCentered));
        }
        if (warningMessage != null) {
            String result = DialogUtils.showWarningDialog(parent, warningMessage + "\n\nDo you want to continue anyway?", new String[] { UserMessage.OPTION_OK, UserMessage.OPTION_CANCEL }, UserMessage.OPTION_OK);
            return (result != null && result.equals(UserMessage.OPTION_OK));
        } else {
            return true;
        }
    }
}
Also used : Geometry(cbit.vcell.geometry.Geometry) ChomboMeshRecommendation(org.vcell.chombo.ChomboMeshValidator.ChomboMeshRecommendation) ChomboMeshValidator(org.vcell.chombo.ChomboMeshValidator) SolverDescription(cbit.vcell.solver.SolverDescription) SimulationSymbolTable(cbit.vcell.solver.SimulationSymbolTable) SolverTaskDescription(cbit.vcell.solver.SolverTaskDescription) DefaultOutputTimeSpec(cbit.vcell.solver.DefaultOutputTimeSpec) MeshSpecification(cbit.vcell.solver.MeshSpecification)

Example 44 with Geometry

use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.

the class Generate2DExpModelOpAbstract method generateModel.

public final GeneratedModelResults generateModel(double deltaX, double bleachRadius, double cellRadius, double bleachDuration, double bleachRate, double postbleachDelay, double postbleachDuration, double psfSigma, double outputTimeStep, double primaryDiffusionRate, double primaryFraction, double bleachMonitorRate, double secondaryDiffusionRate, double secondaryFraction, String extracellularName, String cytosolName, Context context) throws PropertyVetoException, ExpressionException, GeometryException, ImageException, ModelException, MappingException, MathException, MatrixException {
    double domainSize = 2.2 * cellRadius;
    Extent extent = new Extent(domainSize, domainSize, 1.0);
    Origin origin = new Origin(-extent.getX() / 2.0, -extent.getY() / 2.0, -extent.getZ() / 2.0);
    String EXTRACELLULAR_NAME = extracellularName;
    String CYTOSOL_NAME = cytosolName;
    AnalyticSubVolume cytosolSubVolume = new AnalyticSubVolume(CYTOSOL_NAME, new Expression("pow(x,2)+pow(y,2)<pow(" + cellRadius + ",2)"));
    AnalyticSubVolume extracellularSubVolume = new AnalyticSubVolume(EXTRACELLULAR_NAME, new Expression(1.0));
    Geometry geometry = new Geometry("geometry", 2);
    geometry.getGeometrySpec().setExtent(extent);
    geometry.getGeometrySpec().setOrigin(origin);
    geometry.getGeometrySpec().addSubVolume(extracellularSubVolume);
    geometry.getGeometrySpec().addSubVolume(cytosolSubVolume, true);
    geometry.getGeometrySurfaceDescription().updateAll();
    BioModel bioModel = new BioModel(null);
    bioModel.setName("unnamed");
    Model model = new Model("model");
    bioModel.setModel(model);
    model.addFeature(EXTRACELLULAR_NAME);
    Feature extracellular = (Feature) model.getStructure(EXTRACELLULAR_NAME);
    model.addFeature(CYTOSOL_NAME);
    Feature cytosol = (Feature) model.getStructure(CYTOSOL_NAME);
    SpeciesContext immobileSC = model.createSpeciesContext(cytosol);
    SpeciesContext primarySC = model.createSpeciesContext(cytosol);
    SpeciesContext secondarySC = model.createSpeciesContext(cytosol);
    // 
    // common bleaching rate for all species
    // 
    double bleachStart = 10 * outputTimeStep - bleachDuration - postbleachDelay;
    double bleachEnd = bleachStart + bleachDuration;
    Expression bleachRateExp = createBleachExpression(bleachRadius, bleachRate, bleachMonitorRate, bleachStart, bleachEnd);
    {
        SimpleReaction immobileBWM = model.createSimpleReaction(cytosol);
        GeneralKinetics immobileBWMKinetics = new GeneralKinetics(immobileBWM);
        immobileBWM.setKinetics(immobileBWMKinetics);
        immobileBWM.addReactant(immobileSC, 1);
        immobileBWMKinetics.getReactionRateParameter().setExpression(Expression.mult(bleachRateExp, new Expression(immobileSC.getName())));
    }
    {
        SimpleReaction primaryBWM = model.createSimpleReaction(cytosol);
        GeneralKinetics primaryBWMKinetics = new GeneralKinetics(primaryBWM);
        primaryBWM.setKinetics(primaryBWMKinetics);
        primaryBWM.addReactant(primarySC, 1);
        primaryBWMKinetics.getReactionRateParameter().setExpression(Expression.mult(bleachRateExp, new Expression(primarySC.getName())));
    }
    {
        SimpleReaction secondaryBWM = model.createSimpleReaction(cytosol);
        GeneralKinetics secondaryBWMKinetics = new GeneralKinetics(secondaryBWM);
        secondaryBWM.setKinetics(secondaryBWMKinetics);
        secondaryBWM.addReactant(secondarySC, 1);
        secondaryBWMKinetics.getReactionRateParameter().setExpression(Expression.mult(bleachRateExp, new Expression(secondarySC.getName())));
    }
    // create simulation context
    SimulationContext simContext = bioModel.addNewSimulationContext("simContext", SimulationContext.Application.NETWORK_DETERMINISTIC);
    simContext.setGeometry(geometry);
    FeatureMapping cytosolFeatureMapping = (FeatureMapping) simContext.getGeometryContext().getStructureMapping(cytosol);
    FeatureMapping extracellularFeatureMapping = (FeatureMapping) simContext.getGeometryContext().getStructureMapping(extracellular);
    SubVolume cytSubVolume = geometry.getGeometrySpec().getSubVolume(CYTOSOL_NAME);
    SubVolume exSubVolume = geometry.getGeometrySpec().getSubVolume(EXTRACELLULAR_NAME);
    // unused? SurfaceClass pmSurfaceClass = geometry.getGeometrySurfaceDescription().getSurfaceClass(exSubVolume, cytSubVolume);
    cytosolFeatureMapping.setGeometryClass(cytSubVolume);
    extracellularFeatureMapping.setGeometryClass(exSubVolume);
    cytosolFeatureMapping.getUnitSizeParameter().setExpression(new Expression(1.0));
    extracellularFeatureMapping.getUnitSizeParameter().setExpression(new Expression(1.0));
    double fixedFraction = 1.0 - primaryFraction - secondaryFraction;
    SpeciesContextSpec immobileSCS = simContext.getReactionContext().getSpeciesContextSpec(immobileSC);
    immobileSCS.getInitialConditionParameter().setExpression(new Expression(fixedFraction));
    immobileSCS.getDiffusionParameter().setExpression(new Expression(0.0));
    SpeciesContextSpec primarySCS = simContext.getReactionContext().getSpeciesContextSpec(primarySC);
    primarySCS.getInitialConditionParameter().setExpression(new Expression(primaryFraction));
    primarySCS.getDiffusionParameter().setExpression(new Expression(primaryDiffusionRate));
    SpeciesContextSpec secondarySCS = simContext.getReactionContext().getSpeciesContextSpec(secondarySC);
    secondarySCS.getInitialConditionParameter().setExpression(new Expression(secondaryFraction));
    secondarySCS.getDiffusionParameter().setExpression(new Expression(secondaryDiffusionRate));
    simContext.getMicroscopeMeasurement().addFluorescentSpecies(immobileSC);
    simContext.getMicroscopeMeasurement().addFluorescentSpecies(primarySC);
    simContext.getMicroscopeMeasurement().addFluorescentSpecies(secondarySC);
    simContext.getMicroscopeMeasurement().setConvolutionKernel(new GaussianConvolutionKernel(new Expression(psfSigma), new Expression(psfSigma)));
    MathMapping mathMapping = simContext.createNewMathMapping();
    MathDescription mathDesc = mathMapping.getMathDescription();
    simContext.setMathDescription(mathDesc);
    User owner = context.getDefaultOwner();
    int meshSize = (int) (domainSize / deltaX);
    if (meshSize % 2 == 0) {
        // want an odd-sized mesh in x and y ... so centered at the origin.
        meshSize = meshSize + 1;
    }
    TimeBounds timeBounds = new TimeBounds(0.0, postbleachDuration);
    // 
    // simulation to use for data generation (output time steps as recorded by the microscope)
    // 
    double bleachBlackoutBegin = bleachStart - postbleachDelay;
    double bleachBlackoutEnd = bleachEnd + postbleachDelay;
    // ArrayList<Double> times = new ArrayList<Double>();
    // double time = 0;
    // while (time<=timeBounds.getEndingTime()){
    // if (time<=bleachBlackoutBegin || time>bleachBlackoutEnd){
    // // postbleachDelay is the time it takes to switch the filters.
    // times.add(time);
    // }
    // time += outputTimeStep.getData();
    // }
    // double[] timeArray = new double[times.size()];
    // for (int i=0;i<timeArray.length;i++){
    // timeArray[i] = times.get(i);
    // }
    // OutputTimeSpec fakeDataSimOutputTimeSpec = new ExplicitOutputTimeSpec(timeArray);
    OutputTimeSpec fakeDataSimOutputTimeSpec = new UniformOutputTimeSpec(outputTimeStep);
    KeyValue fakeDataSimKey = context.createNewKeyValue();
    SimulationVersion fakeDataSimVersion = new SimulationVersion(fakeDataSimKey, "fakeDataSim", owner, new GroupAccessNone(), new KeyValue("0"), new BigDecimal(0), new Date(), VersionFlag.Current, "", null);
    Simulation fakeDataSim = new Simulation(fakeDataSimVersion, mathDesc);
    simContext.addSimulation(fakeDataSim);
    fakeDataSim.getSolverTaskDescription().setTimeBounds(timeBounds);
    fakeDataSim.getMeshSpecification().setSamplingSize(new ISize(meshSize, meshSize, 1));
    fakeDataSim.getSolverTaskDescription().setSolverDescription(SolverDescription.SundialsPDE);
    fakeDataSim.getSolverTaskDescription().setOutputTimeSpec(fakeDataSimOutputTimeSpec);
    // 
    // simulation to use for viewing the protocol (output time steps to understand the physics)
    // 
    KeyValue fullExperimentSimKey = context.createNewKeyValue();
    SimulationVersion fullExperimentSimVersion = new SimulationVersion(fullExperimentSimKey, "fullExperiment", owner, new GroupAccessNone(), new KeyValue("0"), new BigDecimal(0), new Date(), VersionFlag.Current, "", null);
    Simulation fullExperimentSim = new Simulation(fullExperimentSimVersion, mathDesc);
    simContext.addSimulation(fullExperimentSim);
    OutputTimeSpec fullExperimentOutputTimeSpec = new UniformOutputTimeSpec(outputTimeStep / 10.0);
    fullExperimentSim.getSolverTaskDescription().setTimeBounds(timeBounds);
    fullExperimentSim.getMeshSpecification().setSamplingSize(new ISize(meshSize, meshSize, 1));
    fullExperimentSim.getSolverTaskDescription().setSolverDescription(SolverDescription.SundialsPDE);
    fullExperimentSim.getSolverTaskDescription().setOutputTimeSpec(fullExperimentOutputTimeSpec);
    GeneratedModelResults results = new GeneratedModelResults();
    results.bioModel_2D = bioModel;
    results.simulation_2D = fakeDataSim;
    results.bleachBlackoutBeginTime = bleachBlackoutBegin;
    results.bleachBlackoutEndTime = bleachBlackoutEnd;
    return results;
}
Also used : Origin(org.vcell.util.Origin) User(org.vcell.util.document.User) KeyValue(org.vcell.util.document.KeyValue) Extent(org.vcell.util.Extent) MathDescription(cbit.vcell.math.MathDescription) ISize(org.vcell.util.ISize) SpeciesContext(cbit.vcell.model.SpeciesContext) GeneralKinetics(cbit.vcell.model.GeneralKinetics) SpeciesContextSpec(cbit.vcell.mapping.SpeciesContextSpec) Feature(cbit.vcell.model.Feature) TimeBounds(cbit.vcell.solver.TimeBounds) GroupAccessNone(org.vcell.util.document.GroupAccessNone) UniformOutputTimeSpec(cbit.vcell.solver.UniformOutputTimeSpec) OutputTimeSpec(cbit.vcell.solver.OutputTimeSpec) SimulationVersion(org.vcell.util.document.SimulationVersion) FeatureMapping(cbit.vcell.mapping.FeatureMapping) SubVolume(cbit.vcell.geometry.SubVolume) AnalyticSubVolume(cbit.vcell.geometry.AnalyticSubVolume) SimpleReaction(cbit.vcell.model.SimpleReaction) UniformOutputTimeSpec(cbit.vcell.solver.UniformOutputTimeSpec) SimulationContext(cbit.vcell.mapping.SimulationContext) GaussianConvolutionKernel(cbit.vcell.mapping.MicroscopeMeasurement.GaussianConvolutionKernel) BigDecimal(java.math.BigDecimal) Date(java.util.Date) Geometry(cbit.vcell.geometry.Geometry) Simulation(cbit.vcell.solver.Simulation) Expression(cbit.vcell.parser.Expression) BioModel(cbit.vcell.biomodel.BioModel) BioModel(cbit.vcell.biomodel.BioModel) Model(cbit.vcell.model.Model) MathMapping(cbit.vcell.mapping.MathMapping) AnalyticSubVolume(cbit.vcell.geometry.AnalyticSubVolume)

Example 45 with Geometry

use of cbit.vcell.geometry.Geometry in project vcell by virtualcell.

the class RuleBasedTest method main.

public static void main(String[] args) {
    try {
        PropertyLoader.loadProperties();
    } catch (Exception e) {
        e.printStackTrace();
    }
    final int numTrials = 40;
    VCDatabaseVisitor vcDatabaseVisitor = new VCDatabaseVisitor() {

        @Override
        public void visitMathModel(MathModel mathModel, PrintStream logFilePrintStream) {
            throw new IllegalArgumentException("Not Implemented");
        }

        @Override
        public void visitGeometry(Geometry geometry, PrintStream logFilePrintStream) {
            throw new IllegalArgumentException("Not Implemented");
        }

        @Override
        public void visitBioModel(BioModel bioModel, PrintStream logFilePrintStream) {
            SimulationContext[] simulationContexts = bioModel.getSimulationContexts();
            for (SimulationContext simContext : simulationContexts) {
                if ((simContext.getApplicationType() == Application.NETWORK_STOCHASTIC) && simContext.getGeometry().getDimension() == 0) {
                    File baseDirectory = createDirFile(simContext);
                    try {
                        checkNonspatialStochasticSimContext(simContext, baseDirectory, numTrials);
                    } catch (Exception e) {
                        e.printStackTrace();
                        if (!e.getMessage().contains("Only Mass Action Kinetics supported ")) {
                            writeMessageTofile(baseDirectory, e.getMessage());
                        }
                    }
                }
            }
        }

        @Override
        public boolean filterMathModel(MathModelInfo mathModelInfo) {
            return false;
        }

        @Override
        public boolean filterGeometry(GeometryInfo geometryInfo) {
            return false;
        }

        @Override
        public boolean filterBioModel(BioModelInfo bioModelInfo) {
            return // bioModelInfo.getVersion().getName().equals("model");
            bioModelInfo.getVersion().getName().equals("simpleModel_Network_orig");
        }
    };
    String currentUserID = "schaff";
    String[] allUsers = new String[] { /*-all*/
    currentUserID, "-" };
    VCDatabaseScanner.scanBioModels(allUsers, vcDatabaseVisitor, false);
}
Also used : PrintStream(java.io.PrintStream) MathModel(cbit.vcell.mathmodel.MathModel) BioModelInfo(org.vcell.util.document.BioModelInfo) MathModelInfo(org.vcell.util.document.MathModelInfo) SimulationContext(cbit.vcell.mapping.SimulationContext) Geometry(cbit.vcell.geometry.Geometry) BioModel(cbit.vcell.biomodel.BioModel) GeometryInfo(cbit.vcell.geometry.GeometryInfo) VCDatabaseVisitor(cbit.vcell.modeldb.VCDatabaseVisitor) File(java.io.File)

Aggregations

Geometry (cbit.vcell.geometry.Geometry)121 MathDescription (cbit.vcell.math.MathDescription)32 SimulationContext (cbit.vcell.mapping.SimulationContext)31 Simulation (cbit.vcell.solver.Simulation)29 PropertyVetoException (java.beans.PropertyVetoException)24 BioModel (cbit.vcell.biomodel.BioModel)23 DataAccessException (org.vcell.util.DataAccessException)23 VCImage (cbit.image.VCImage)22 SubVolume (cbit.vcell.geometry.SubVolume)21 MathModel (cbit.vcell.mathmodel.MathModel)21 Expression (cbit.vcell.parser.Expression)19 ISize (org.vcell.util.ISize)19 Hashtable (java.util.Hashtable)18 GeometryThumbnailImageFactoryAWT (cbit.vcell.geometry.GeometryThumbnailImageFactoryAWT)17 UserCancelException (org.vcell.util.UserCancelException)17 KeyValue (org.vcell.util.document.KeyValue)17 ImageException (cbit.image.ImageException)16 Extent (org.vcell.util.Extent)16 SurfaceClass (cbit.vcell.geometry.SurfaceClass)15 ExpressionException (cbit.vcell.parser.ExpressionException)15