Search in sources :

Example 66 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 67 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 68 with SimulationContext

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

the class SimulationListPanel method runSimulations.

/**
 * Comment
 */
private void runSimulations() {
    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]);
        getSimulationWorkspace().runSimulations(toRun, this);
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) Simulation(cbit.vcell.solver.Simulation) ArrayList(java.util.ArrayList) SimulationContext(cbit.vcell.mapping.SimulationContext)

Example 69 with SimulationContext

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

the class VFrapXmlHelper method ReplaceVFrapNamesWithSymbolNames.

// 
// replace vFrap default names in field function arguments with data symbol names -----
// 
public static void ReplaceVFrapNamesWithSymbolNames(BioModel bioModel) throws ExpressionException {
    SimulationContext simContext = bioModel.getSimulationContexts()[0];
    SpeciesContextSpec[] scsArray = simContext.getReactionContext().getSpeciesContextSpecs();
    for (SpeciesContextSpec scs : scsArray) {
        // vFrap('a','c',0.0,'volume')
        Expression exp = scs.getInitialConditionParameter().getExpression();
        FieldFunctionArguments[] fieldFunctionArgs = FieldUtilities.getFieldFunctionArguments(exp);
        if (fieldFunctionArgs != null && fieldFunctionArgs.length > 0) {
            for (FieldFunctionArguments args : fieldFunctionArgs) {
                for (DataSymbol ds : simContext.getDataContext().getDataSymbols()) {
                    if (ds instanceof FieldDataSymbol) {
                        FieldDataSymbol fieldDataSymbol = (FieldDataSymbol) ds;
                        // String extDataIdentName = fieldDataSymbol.getExternalDataIdentifier().getName();	// name of field data
                        // String argsFieldName = args.getFieldName();				// roiData
                        // fieldDataSymbol.getFieldDataVarTime() == args.getTime().evaluateConstant()
                        // name of data symbol  ex: postbleach_first_ccccF
                        String dataSymbolName = fieldDataSymbol.getName();
                        // name in expression as it comes from vFrap   ex: postbleach_first
                        String argsVariableName = args.getVariableName();
                        if (dataSymbolName.startsWith(argsVariableName)) {
                            // vcField('roiData','postbleach_first',0.0,'Volume')
                            String oldExpression = args.infix();
                            exp.substituteInPlace(new Expression(oldExpression), new Expression(dataSymbolName));
                            exp.bindExpression(simContext);
                        }
                    }
                }
            }
        }
    }
}
Also used : FieldDataSymbol(cbit.vcell.data.FieldDataSymbol) DataSymbol(cbit.vcell.data.DataSymbol) Expression(cbit.vcell.parser.Expression) FieldFunctionArguments(cbit.vcell.field.FieldFunctionArguments) SimulationContext(cbit.vcell.mapping.SimulationContext) SpeciesContextSpec(cbit.vcell.mapping.SpeciesContextSpec) FieldDataSymbol(cbit.vcell.data.FieldDataSymbol)

Example 70 with SimulationContext

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

the class BioModelWindowManager method updateApplicationHash.

/**
 * Insert the method's description here.
 * Creation date: (6/1/2004 2:33:41 AM)
 */
private void updateApplicationHash(boolean reset) {
    SimulationContext[] scs = getBioModel().getSimulationContexts();
    Enumeration<SimulationContext> en = getApplicationsHash().keys();
    while (en.hasMoreElements()) {
        SimulationContext sc = (SimulationContext) en.nextElement();
        ApplicationComponents appComponents = getApplicationsHash().get(sc);
        if (!getBioModel().contains(sc)) {
            if (reset) {
                // find one with the same name, if available
                SimulationContext found = null;
                if (scs != null) {
                    for (int i = 0; i < scs.length; i++) {
                        if (scs[i].getName().equals(sc.getName())) {
                            found = scs[i];
                            break;
                        }
                    }
                }
                if (found != null) {
                    // update hash
                    getApplicationsHash().remove(sc);
                    getApplicationsHash().put(found, appComponents);
                    appComponents.resetSimulationContext(found);
                    // check simulation data windows
                    updateSimulationDataViewers(appComponents, found);
                    // rewire listener
                    sc.removePropertyChangeListener(this);
                    found.removePropertyChangeListener(this);
                    found.addPropertyChangeListener(this);
                } else {
                    // we didn't find one, so remove from hash and close all of its windows
                    remove(appComponents, sc);
                }
            } else {
                // shouldn't have it
                remove(appComponents, sc);
            }
        }
    }
}
Also used : ApplicationComponents(cbit.vcell.client.desktop.biomodel.ApplicationComponents) SimulationContext(cbit.vcell.mapping.SimulationContext)

Aggregations

SimulationContext (cbit.vcell.mapping.SimulationContext)181 BioModel (cbit.vcell.biomodel.BioModel)73 Simulation (cbit.vcell.solver.Simulation)57 MathDescription (cbit.vcell.math.MathDescription)32 Geometry (cbit.vcell.geometry.Geometry)29 PropertyVetoException (java.beans.PropertyVetoException)28 MathModel (cbit.vcell.mathmodel.MathModel)25 Model (cbit.vcell.model.Model)25 KeyValue (org.vcell.util.document.KeyValue)25 SpeciesContextSpec (cbit.vcell.mapping.SpeciesContextSpec)23 ArrayList (java.util.ArrayList)23 DataAccessException (org.vcell.util.DataAccessException)23 XMLSource (cbit.vcell.xml.XMLSource)22 XmlParseException (cbit.vcell.xml.XmlParseException)22 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)20 Expression (cbit.vcell.parser.Expression)20 ExpressionException (cbit.vcell.parser.ExpressionException)19 SpeciesContext (cbit.vcell.model.SpeciesContext)17 Structure (cbit.vcell.model.Structure)17 IOException (java.io.IOException)17