Search in sources :

Example 11 with SimulationContext

use of cbit.vcell.mapping.SimulationContext in project vcell by virtualcell.

the class SimulationListPanel method quickRun.

/*
	private void particleView() {
		int row = getScrollPaneTable().getSelectedRow();
		if (row < 0) {
			return;
		}
		Simulation selectedSim = getSimulationListTableModel1().getValueAt(row);
		getSimulationWorkspace().getClientSimManager().runSmoldynParticleView(selectedSim);
	}
	*/
private void quickRun(ViewerType viewerType) {
    int row = getScrollPaneTable().getSelectedRow();
    if (row < 0) {
        return;
    }
    activateConsole();
    Simulation selectedSim = getSimulationListTableModel1().getValueAt(row);
    SolverDescription solverDescription = selectedSim.getSolverTaskDescription().getSolverDescription();
    if (solverDescription.equals(SolverDescription.FiniteVolume)) {
        if (getSimulationWorkspace().getSimulationOwner() instanceof SimulationContext) {
            String option = DialogUtils.showOKCancelWarningDialog(SimulationListPanel.this, "Deprecated Solver", VCellErrorMessages.getSemiFVSolverCompiledSolverDeprecated(selectedSim));
            if (option.equals(SimpleUserMessage.OPTION_CANCEL)) {
                return;
            }
            try {
                selectedSim.getSolverTaskDescription().setSolverDescription(SolverDescription.FiniteVolumeStandalone);
                selectedSim.setIsDirty(true);
            } catch (PropertyVetoException e) {
                e.printStackTrace();
            }
        }
    }
    getSimulationWorkspace().getClientSimManager().runQuickSimulation(selectedSim, viewerType);
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) SolverDescription(cbit.vcell.solver.SolverDescription) Simulation(cbit.vcell.solver.Simulation) SimulationContext(cbit.vcell.mapping.SimulationContext)

Example 12 with SimulationContext

use of cbit.vcell.mapping.SimulationContext in project vcell by virtualcell.

the class SimulationListPanel method newSimulation.

/**
 * Comment
 */
private void newSimulation(final NetworkGenerationRequirements networkGenerationRequirements) {
    AsynchClientTask task1 = new AsynchClientTask("new simulation", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            MathMappingCallback mathMappingCallback = new MathMappingCallbackTaskAdapter(getClientTaskStatusSupport());
            if (getSimulationWorkspace().getSimulationOwner() instanceof SimulationContext) {
                SimulationContext simulationContext = (SimulationContext) getSimulationWorkspace().getSimulationOwner();
                simulationContext.refreshMathDescription(mathMappingCallback, networkGenerationRequirements);
            }
        }
    };
    AsynchClientTask task2 = new AsynchClientTask("new simulation", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            MathMappingCallback mathMappingCallback = new MathMappingCallbackTaskAdapter(getClientTaskStatusSupport());
            int newSimIndex = getSimulationWorkspace().newSimulation(SimulationListPanel.this, mathMappingCallback, networkGenerationRequirements);
            getScrollPaneTable().getSelectionModel().setSelectionInterval(newSimIndex, newSimIndex);
            getScrollPaneTable().scrollRectToVisible(getScrollPaneTable().getCellRect(newSimIndex, 0, true));
        }
    };
    ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 });
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) MathMappingCallbackTaskAdapter(cbit.vcell.mapping.MathMappingCallbackTaskAdapter) MathMappingCallback(cbit.vcell.mapping.SimulationContext.MathMappingCallback) Hashtable(java.util.Hashtable) SimulationContext(cbit.vcell.mapping.SimulationContext)

Example 13 with SimulationContext

use of cbit.vcell.mapping.SimulationContext in project vcell by virtualcell.

the class SimulationListPanel method massConservationButtonAdjust.

private void massConservationButtonAdjust() {
    if (fieldSimulationWorkspace != null && fieldSimulationWorkspace.getSimulationOwner() instanceof SimulationContext) {
        SimulationContext simContext = (SimulationContext) fieldSimulationWorkspace.getSimulationOwner();
        if (simContext.getGeometry().getDimension() == 0 && simContext.getApplicationType() == SimulationContext.Application.NETWORK_DETERMINISTIC) {
            getMassConservationModelReductionCheckBox().setVisible(true);
            getMassConservationModelReductionCheckBox().setEnabled(true);
            getMassConservationModelReductionCheckBox().setSelected(simContext.isUsingMassConservationModelReduction());
            getMassConservationModelReductionHelpButton().setVisible(true);
            getMassConservationModelReductionHelpButton().setEnabled(true);
        } else {
            getMassConservationModelReductionCheckBox().setVisible(false);
            getMassConservationModelReductionHelpButton().setVisible(false);
        }
    } else {
        getMassConservationModelReductionCheckBox().setVisible(false);
        getMassConservationModelReductionHelpButton().setVisible(false);
    }
}
Also used : SimulationContext(cbit.vcell.mapping.SimulationContext)

Example 14 with SimulationContext

use of cbit.vcell.mapping.SimulationContext in project vcell by virtualcell.

the class SimulationListPanel method runSimulations.

/**
 * Comment
 */
private void runSimulations() {
    if (User.isGuest(getSimulationWorkspace().getLoggedInUser().getName())) {
        DialogUtils.showErrorDialog(this, User.createGuestErrorMessage("runVCellServerSimulations"));
        return;
    }
    final ArrayList<Simulation> simList = new ArrayList<Simulation>();
    int[] selections = getScrollPaneTable().getSelectedRows();
    for (int i = 0; i < selections.length; i++) {
        Simulation sim = (Simulation) (ivjSimulationListTableModel1.getValueAt(selections[i]));
        if (sim.getSolverTaskDescription().getSolverDescription().equals(SolverDescription.FiniteVolume)) {
            if (getSimulationWorkspace().getSimulationOwner() instanceof SimulationContext) {
                String option = DialogUtils.showOKCancelWarningDialog(SimulationListPanel.this, "Deprecated Solver", VCellErrorMessages.getSemiFVSolverCompiledSolverDeprecated(sim));
                if (option.equals(SimpleUserMessage.OPTION_CANCEL)) {
                    return;
                }
                try {
                    sim.getSolverTaskDescription().setSolverDescription(SolverDescription.FiniteVolumeStandalone);
                    sim.setIsDirty(true);
                } catch (PropertyVetoException e) {
                    e.printStackTrace();
                }
            }
        }
        simList.add(sim);
    }
    if (simList.size() > 0) {
        activateConsole();
        Simulation[] toRun = simList.toArray(new Simulation[0]);
        try {
            getSimulationWorkspace().runSimulations(toRun, this);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            DialogUtils.showErrorDialog(this, e.getMessage());
        }
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) Simulation(cbit.vcell.solver.Simulation) ArrayList(java.util.ArrayList) SimulationContext(cbit.vcell.mapping.SimulationContext) PropertyVetoException(java.beans.PropertyVetoException) NoSuchElementException(java.util.NoSuchElementException) IOException(java.io.IOException)

Example 15 with SimulationContext

use of cbit.vcell.mapping.SimulationContext in project vcell by virtualcell.

the class ImageJHelper method populateDesktopIJModelInfos.

private static void populateDesktopIJModelInfos(IJDocType docType, ArrayList<KeyValue> openVCDocumentVersionKeys, ArrayList<IJModelInfo> modelInfos) {
    if (VCellClientTest.getVCellClient() == null) {
        return;
    }
    Collection<TopLevelWindowManager> windowManagers = VCellClientTest.getVCellClient().getMdiManager().getWindowManagers();
    for (TopLevelWindowManager topLevelWindowManager : windowManagers) {
        if (topLevelWindowManager instanceof DocumentWindowManager) {
            DocumentWindowManager documentWindowManager = (DocumentWindowManager) topLevelWindowManager;
            VCDocument.VCDocumentType currDocType = documentWindowManager.getVCDocument().getDocumentType();
            if (currDocType == docType.getVCDocType()) {
                if (documentWindowManager.getVCDocument().getVersion() != null && documentWindowManager.getVCDocument().getVersion().getVersionKey() != null) {
                    openVCDocumentVersionKeys.add(documentWindowManager.getVCDocument().getVersion().getVersionKey());
                } else {
                    ArrayList<IJContextInfo> ijContextInfos = new ArrayList<>();
                    if (documentWindowManager instanceof BioModelWindowManager) {
                        for (SimulationContext simulationContext : ((BioModelWindowManager) documentWindowManager).getBioModel().getSimulationContexts()) {
                            addSimToIJContextInfo(ijContextInfos, simulationContext.getName(), simulationContext.getMathType(), simulationContext.getGeometryContext().getGeometry().getDimension(), simulationContext.getGeometry().getName(), simulationContext.getSimulations());
                        }
                        modelInfos.add(new IJModelInfo(documentWindowManager.getVCDocument().getName(), null, IJDocType.bm, true, (documentWindowManager.getUser() == null ? null : documentWindowManager.getUser().getName()), null, ijContextInfos));
                    } else if (documentWindowManager instanceof MathModelWindowManager) {
                        MathModel mathModel = ((MathModelWindowManager) documentWindowManager).getMathModel();
                        addSimToIJContextInfo(ijContextInfos, null, mathModel.getMathDescription().getMathType(), mathModel.getGeometry().getDimension(), mathModel.getGeometry().getName(), ((MathModelWindowManager) documentWindowManager).getSimulationWorkspace().getSimulations());
                        modelInfos.add(new IJModelInfo(documentWindowManager.getVCDocument().getName(), null, IJDocType.mm, true, (documentWindowManager.getUser() == null ? null : documentWindowManager.getUser().getName()), null, ijContextInfos));
                    }
                }
            }
        }
    }
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) VCDocument(org.vcell.util.document.VCDocument) TopLevelWindowManager(cbit.vcell.client.TopLevelWindowManager) VCDocumentType(org.vcell.util.document.VCDocument.VCDocumentType) ArrayList(java.util.ArrayList) SimulationContext(cbit.vcell.mapping.SimulationContext) MathModelWindowManager(cbit.vcell.client.MathModelWindowManager) BioModelWindowManager(cbit.vcell.client.BioModelWindowManager) DocumentWindowManager(cbit.vcell.client.DocumentWindowManager)

Aggregations

SimulationContext (cbit.vcell.mapping.SimulationContext)217 BioModel (cbit.vcell.biomodel.BioModel)98 Simulation (cbit.vcell.solver.Simulation)64 MathDescription (cbit.vcell.math.MathDescription)35 Model (cbit.vcell.model.Model)35 PropertyVetoException (java.beans.PropertyVetoException)35 Expression (cbit.vcell.parser.Expression)34 MathModel (cbit.vcell.mathmodel.MathModel)33 ExpressionException (cbit.vcell.parser.ExpressionException)32 Geometry (cbit.vcell.geometry.Geometry)31 XmlParseException (cbit.vcell.xml.XmlParseException)31 ArrayList (java.util.ArrayList)31 IOException (java.io.IOException)29 XMLSource (cbit.vcell.xml.XMLSource)28 DataAccessException (org.vcell.util.DataAccessException)27 SpeciesContextSpec (cbit.vcell.mapping.SpeciesContextSpec)26 KeyValue (org.vcell.util.document.KeyValue)26 SpeciesContext (cbit.vcell.model.SpeciesContext)24 Structure (cbit.vcell.model.Structure)23 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)22