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 });
}
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);
}
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);
}
}
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);
}
}
}
}
}
}
}
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);
}
}
}
}
Aggregations