use of cbit.vcell.solver.SolverTaskDescription in project vcell by virtualcell.
the class OutputOptionsPanel method setSolverTaskDescription.
/**
* set solver description. The contained {@link SolverTaskDescription#getSimulation()}
* is usually a temporary cloned object with a null {@link SimulationOwner} ; therefore
* we required the {@link UnitInfo} of the actual {@link Simulation} owner as a parameter
* @param newValue
* @param unitInfo not null
*/
public final void setSolverTaskDescription(SolverTaskDescription newValue, UnitInfo unitInfo) {
Objects.requireNonNull(unitInfo);
SolverTaskDescription oldValue = solverTaskDescription;
/* Stop listening for events from the current object */
if (oldValue != null) {
oldValue.removePropertyChangeListener(ivjEventHandler);
}
solverTaskDescription = newValue;
/* Listen for events from the new object */
if (newValue != null) {
newValue.addPropertyChangeListener(ivjEventHandler);
}
solverTaskDescription = newValue;
chomboOutputOptionsPanel.setSolverTaskDescription(solverTaskDescription);
firePropertyChange("solverTaskDescription", oldValue, newValue);
getOutputTimeStepTextField().addFocusListener(ivjEventHandler);
getDefaultOutputRadioButton().addActionListener(ivjEventHandler);
getUniformOutputRadioButton().addActionListener(ivjEventHandler);
getExplicitOutputRadioButton().addActionListener(ivjEventHandler);
getKeepEveryTextField().addFocusListener(ivjEventHandler);
getKeepAtMostTextField().addFocusListener(ivjEventHandler);
getOutputTimesTextField().addFocusListener(ivjEventHandler);
getOutputTimeStepTextField().setInputVerifier(new InputVerifier() {
@Override
public boolean verify(JComponent input) {
return false;
}
@Override
public boolean shouldYieldFocus(JComponent input) {
boolean bValid = true;
try {
double outputTime = Double.parseDouble(getOutputTimeStepTextField().getText());
if (solverTaskDescription.getOutputTimeSpec().isUniform() && !solverTaskDescription.getSolverDescription().hasVariableTimestep()) {
double timeStep = solverTaskDescription.getTimeStep().getDefaultTimeStep();
double suggestedInterval = outputTime;
if (outputTime < timeStep) {
suggestedInterval = timeStep;
bValid = false;
} else if (!BeanUtils.isIntegerMultiple(outputTime, timeStep)) {
double n = outputTime / timeStep;
int intn = (int) Math.round(n);
if (intn != n) {
bValid = false;
suggestedInterval = (intn * timeStep);
}
}
if (!bValid) {
String ret = PopupGenerator.showWarningDialog(OutputOptionsPanel.this, "Output Interval", "Output Interval must " + "be integer multiple of time step.\n\nChange Output Interval to " + suggestedInterval + "?", new String[] { UserMessage.OPTION_YES, UserMessage.OPTION_NO }, UserMessage.OPTION_YES);
if (ret.equals(UserMessage.OPTION_YES)) {
getOutputTimeStepTextField().setText(suggestedInterval + "");
bValid = true;
}
}
}
} catch (NumberFormatException ex) {
DialogUtils.showErrorDialog(OutputOptionsPanel.this, "Wrong number format " + ex.getMessage().toLowerCase());
bValid = false;
}
if (bValid) {
getOutputTimeStepTextField().setBorder(UIManager.getBorder("TextField.border"));
} else {
getOutputTimeStepTextField().setBorder(GuiConstants.ProblematicTextFieldBorder);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
getOutputTimeStepTextField().requestFocus();
}
});
}
return bValid;
}
});
getOutputTimesTextField().setInputVerifier(new InputVerifier() {
@Override
public boolean verify(JComponent input) {
return false;
}
@Override
public boolean shouldYieldFocus(JComponent input) {
ExplicitOutputTimeSpec eots = ExplicitOutputTimeSpec.fromString(getOutputTimesTextField().getText());
return checkExplicitOutputTimes(eots);
}
});
// set time label units
JLabel timeUnitsLabel = getTimeStepUnitsLabel();
timeUnitsLabel.setText(unitInfo.getTimeUnitString());
}
use of cbit.vcell.solver.SolverTaskDescription in project vcell by virtualcell.
the class SimulationSummaryPanel method displayTask.
/**
* Comment
*/
private void displayTask() {
SolverTaskDescription solverTaskDescription = getSimulation().getSolverTaskDescription();
try {
NonspatialStochSimOptions stochOpt = solverTaskDescription.getStochOpt();
if (stochOpt != null && stochOpt.getNumOfTrials() > 1) {
getJLabelOutput().setText("Histogram with " + stochOpt.getNumOfTrials() + " Trials(@last time point)");
} else {
// gcwtodo
String text = solverTaskDescription.getOutputTimeSpec().getShortDescription();
if (solverTaskDescription.getSolverDescription().isChomboSolver()) {
text = "Variable";
if (solverTaskDescription.getChomboSolverSpec().getTimeIntervalList().size() == 1) {
text = "Every " + solverTaskDescription.getChomboSolverSpec().getLastTimeInterval().getOutputTimeStep() + "s";
}
} else if (solverTaskDescription.getOutputTimeSpec().isDefault() && !solverTaskDescription.getSolverDescription().isSemiImplicitPdeSolver() && !solverTaskDescription.getSolverDescription().equals(SolverDescription.StochGibson)) {
text += ", at most " + ((DefaultOutputTimeSpec) solverTaskDescription.getOutputTimeSpec()).getKeepAtMost();
}
getJLabelOutput().setText(text);
}
} catch (Exception exc) {
exc.printStackTrace(System.out);
getJLabelOutput().setText("");
}
SolverDescription solverDescription = solverTaskDescription.getSolverDescription();
try {
ErrorTolerance errorTolerance = solverTaskDescription.getErrorTolerance();
TimeStep timeStep = solverTaskDescription.getTimeStep();
getJLabelRelTol().setText("Rel tol");
getJLabelAbsTol().setText("Abs tol");
getJLabel12().setText("Timestep");
getJLabelRelTol().setEnabled(false);
getJLabelAbsTol().setEnabled(false);
getJLabel12().setEnabled(false);
getJLabel10().setText("Sensitivity Analysis");
getJLabel10().setEnabled(true);
if (solverDescription.equals(SolverDescription.StochGibson)) {
getJLabel12().setEnabled(false);
getJLabelTimestep().setText("");
} else if (solverDescription.equals(SolverDescription.NFSim)) {
TimeBounds tb = solverTaskDescription.getTimeBounds();
double dtime = tb.getEndingTime() - tb.getStartingTime();
if (solverTaskDescription.getOutputTimeSpec() instanceof UniformOutputTimeSpec) {
UniformOutputTimeSpec uots = (UniformOutputTimeSpec) solverTaskDescription.getOutputTimeSpec();
double interval = uots.getOutputTimeStep();
int steps = (int) Math.round(dtime / interval);
getJLabel12().setEnabled(true);
getJLabel12().setText("Timepoints");
getJLabelTimestep().setText(steps + "");
} else if (solverTaskDescription.getOutputTimeSpec() instanceof DefaultOutputTimeSpec) {
DefaultOutputTimeSpec uots = (DefaultOutputTimeSpec) solverTaskDescription.getOutputTimeSpec();
getJLabel12().setEnabled(true);
getJLabel12().setText("End Time");
getJLabelTimestep().setText(solverTaskDescription.getTimeBounds().getEndingTime() + "");
} else {
getJLabel12().setEnabled(false);
getJLabel12().setText("End Time");
getJLabelTimestep().setText("na");
}
NFsimSimulationOptions nfsso = solverTaskDescription.getNFSimSimulationOptions();
String utl = "default";
Integer moleculeDistance = nfsso.getMoleculeDistance();
if (moleculeDistance != null) {
utl = moleculeDistance + "";
}
getJLabelRelTol().setEnabled(true);
getJLabelRelTol().setText("Universal Transversal Limit");
getJLabelRelTolValue().setText(utl);
String gml = "default";
Integer maxMoleculesPerType = nfsso.getMaxMoleculesPerType();
if (maxMoleculesPerType != null) {
gml = maxMoleculesPerType + "";
}
getJLabelAbsTol().setEnabled(true);
getJLabelAbsTol().setText("Max # of each " + MolecularType.typeName);
getJLabelAbsTolValue().setText(gml);
} else if (solverDescription.isNonSpatialStochasticSolver()) {
getJLabel12().setEnabled(true);
getJLabel12().setText("Timestep");
getJLabelTimestep().setText(timeStep.getDefaultTimeStep() + "s");
} else if (solverDescription.hasVariableTimestep()) {
getJLabel12().setEnabled(true);
getJLabel12().setText("Max timestep");
getJLabelTimestep().setText(timeStep.getMaximumTimeStep() + "s");
getJLabelRelTol().setEnabled(true);
getJLabelRelTolValue().setText("" + errorTolerance.getRelativeErrorTolerance());
getJLabelAbsTol().setEnabled(true);
getJLabelAbsTolValue().setText("" + errorTolerance.getAbsoluteErrorTolerance());
} else {
getJLabel12().setEnabled(true);
getJLabel12().setText("Timestep");
if (solverDescription.isChomboSolver()) {
String text = "Variable";
if (solverTaskDescription.getChomboSolverSpec().getTimeIntervalList().size() == 1) {
text = solverTaskDescription.getChomboSolverSpec().getLastTimeInterval().getTimeStep() + "s";
}
getJLabelTimestep().setText(text);
} else {
getJLabelTimestep().setText(timeStep.getDefaultTimeStep() + "s");
}
if (solverDescription.isSemiImplicitPdeSolver()) {
getJLabelRelTol().setEnabled(true);
getJLabelRelTolValue().setText("" + errorTolerance.getRelativeErrorTolerance());
} else {
getJLabelRelTol().setEnabled(false);
getJLabelRelTolValue().setText("");
}
getJLabelAbsTol().setEnabled(false);
getJLabelAbsTolValue().setText("");
}
} catch (Exception exc) {
exc.printStackTrace(System.out);
getJLabelTimestep().setText("");
getJLabelRelTolValue().setText("");
getJLabelAbsTolValue().setText("");
}
try {
boolean bChomboSolver = solverDescription.isChomboSolver();
getJLabelTitleNumProcessors().setVisible(bChomboSolver);
getJLabelNumProcessors().setVisible(bChomboSolver);
if (bChomboSolver) {
getJLabelNumProcessors().setText(String.valueOf(solverTaskDescription.getNumProcessors()));
}
if (getSimulation().isSpatial() || solverDescription.isNonSpatialStochasticSolver()) {
getJLabelSensitivity().setVisible(false);
getJLabel10().setVisible(false);
} else if (solverDescription.equals(SolverDescription.NFSim)) {
getJLabel10().setText("On-the-fly observ comp.");
NFsimSimulationOptions nfsso = solverTaskDescription.getNFSimSimulationOptions();
boolean goc = nfsso.getObservableComputationOff();
getJLabelSensitivity().setText(goc + "");
} else {
getJLabelSensitivity().setVisible(true);
getJLabel10().setVisible(true);
Constant param = solverTaskDescription.getSensitivityParameter();
if (param == null) {
getJLabelSensitivity().setText("no");
} else {
getJLabelSensitivity().setText(param.getName());
}
}
} catch (Exception exc) {
exc.printStackTrace(System.out);
getJLabelSensitivity().setText("");
}
if (solverDescription.isNonSpatialStochasticSolver()) {
getJLabelRelTol().setVisible(false);
getJLabelAbsTol().setVisible(false);
getJLabelRelTolValue().setVisible(false);
getJLabelAbsTolValue().setVisible(false);
} else {
getJLabelRelTol().setVisible(true);
getJLabelAbsTol().setVisible(true);
}
}
use of cbit.vcell.solver.SolverTaskDescription in project vcell by virtualcell.
the class SundialsPdeSolverOptionsPanel method setSolverTaskDescription.
public final void setSolverTaskDescription(SolverTaskDescription newValue) {
SolverTaskDescription oldValue = solverTaskDescription;
/* Stop listening for events from the current object */
if (oldValue != null) {
oldValue.removePropertyChangeListener(ivjEventHandler);
}
solverTaskDescription = newValue;
/* Listen for events from the new object */
if (newValue != null) {
newValue.addPropertyChangeListener(ivjEventHandler);
}
solverTaskDescription = newValue;
refresh();
}
use of cbit.vcell.solver.SolverTaskDescription in project vcell by virtualcell.
the class TimeStepPanel method setSolverTaskDescription.
/**
* Sets the timeStep property (cbit.vcell.solver.TimeStep) value.
* @param timeStep The new value for the property.
* @exception java.beans.PropertyVetoException The exception description.
* @see #getTimeStep
*/
public void setSolverTaskDescription(SolverTaskDescription newValue) throws java.beans.PropertyVetoException {
SolverTaskDescription oldValue = solverTaskDescription;
/* Stop listening for events from the current object */
if (oldValue != null) {
oldValue.removePropertyChangeListener(ivjEventHandler);
}
solverTaskDescription = newValue;
/* Listen for events from the new object */
if (newValue != null) {
newValue.addPropertyChangeListener(ivjEventHandler);
}
solverTaskDescription = newValue;
firePropertyChange("solverTaskDescription", oldValue, newValue);
initConnections();
}
use of cbit.vcell.solver.SolverTaskDescription in project vcell by virtualcell.
the class FVSolverStandalone method getChomboCommands.
private Collection<ExecutableCommand> getChomboCommands() {
assert (isChombo);
ArrayList<ExecutableCommand> commands = new ArrayList<ExecutableCommand>(2);
String inputFilename = getInputFilename();
String executableName = null;
Simulation simulation = getSimulationJob().getSimulation();
SolverTaskDescription sTaskDesc = simulation.getSolverTaskDescription();
final boolean isParallel = sTaskDesc.isParallel();
int dimension = simulation.getMeshSpecification().getGeometry().getDimension();
switch(dimension) {
case 2:
try {
executableName = SolverUtilities.getExes(SolverDescription.Chombo)[0].getAbsolutePath();
} catch (IOException e) {
throw new RuntimeException("failed to get executable for 2D solver " + SolverDescription.Chombo.getDisplayLabel() + ": " + e.getMessage(), e);
}
break;
case 3:
try {
executableName = SolverUtilities.getExes(SolverDescription.Chombo)[1].getAbsolutePath();
} catch (IOException e) {
throw new RuntimeException("failed to get executable for 3D solver " + SolverDescription.Chombo.getDisplayLabel() + ": " + e.getMessage(), e);
}
break;
default:
throw new IllegalArgumentException("VCell Chombo solver does not support " + dimension + "problems");
}
if (isParallel) {
String parallelName = executableName + "parallel";
ExecutableCommand solve = new ExecutableCommand(new ExecutableCommand.LibraryPath(ResourceUtil.getLocalSolversDirectory().getAbsolutePath()), true, true, parallelName, inputFilename);
commands.add(solve);
ChomboSolverSpec css = sTaskDesc.getChomboSolverSpec();
Objects.requireNonNull(css);
if (css.isSaveVCellOutput()) {
ExecutableCommand convertChomboData = new ExecutableCommand(new ExecutableCommand.LibraryPath(ResourceUtil.getLocalSolversDirectory().getAbsolutePath()), true, false, executableName, "-ccd", inputFilename);
commands.add(convertChomboData);
}
} else {
ExecutableCommand ec = new ExecutableCommand(new ExecutableCommand.LibraryPath(ResourceUtil.getLocalSolversDirectory().getAbsolutePath()), true, false, executableName, inputFilename);
commands.add(ec);
primaryCommand = ec;
}
return commands;
}
Aggregations