use of cbit.vcell.solvers.MathExecutable in project vcell by virtualcell.
the class SmoldynSolver method initialize.
/**
* This method takes the place of the old runUnsteady()...
*/
protected void initialize() throws SolverException {
if (lg.isTraceEnabled())
lg.trace("SmoldynSolver.initialize()");
fireSolverStarting(SimulationMessage.MESSAGE_SOLVEREVENT_STARTING_INIT);
writeFunctionsFile();
// write subdomains file
try {
SubdomainInfo.write(new File(getBaseName() + SimDataConstants.SUBDOMAINS_FILE_SUFFIX), simTask.getSimulation().getMathDescription());
} catch (IOException e1) {
e1.printStackTrace();
throw new SolverException(e1.getMessage());
} catch (MathException e1) {
e1.printStackTrace();
throw new SolverException(e1.getMessage());
}
String inputFilename = getInputFilename();
if (lg.isTraceEnabled())
lg.trace("SmoldynSolver.initialize() baseName = " + getBaseName());
setSolverStatus(new SolverStatus(SolverStatus.SOLVER_RUNNING, SimulationMessage.MESSAGE_SOLVER_RUNNING_INPUT_FILE));
fireSolverStarting(SimulationMessage.MESSAGE_SOLVEREVENT_STARTING_INPUT_FILE);
PrintWriter pw = null;
try {
pw = new PrintWriter(inputFilename);
if (SystemUtils.IS_OS_WINDOWS) {
//
// the windows executable is compiled under cygwin (or mingw) and expect Unix style line termination characters.
// so SmoldynInput file is written with platform default Java convention (different on windows) to a String.
// Then the string is translated to Unix style before written to the file.
// smoldyn is particularly sensitive to this issue, other compiled solvers are more tolerant.
//
StringWriter stringWriter = new StringWriter();
PrintWriter pw2 = new PrintWriter(stringWriter);
SmoldynFileWriter stFileWriter = new SmoldynFileWriter(pw2, false, getBaseName(), simTask, bMessaging);
stFileWriter.write();
String fileContents = stringWriter.getBuffer().toString();
fileContents = fileContents.replace("\r\n", "\n");
pw.write(fileContents);
} else {
//
// for linux or macos, no translation is necessary.
//
SmoldynFileWriter stFileWriter = new SmoldynFileWriter(pw, false, getBaseName(), simTask, bMessaging);
stFileWriter.write();
}
} catch (Exception e) {
setSolverStatus(new SolverStatus(SolverStatus.SOLVER_ABORTED, SimulationMessage.solverAborted("Could not generate input file: " + e.getMessage())));
e.printStackTrace(System.out);
throw new SolverException(e.getMessage());
} finally {
if (pw != null) {
pw.close();
}
}
setSolverStatus(new SolverStatus(SolverStatus.SOLVER_RUNNING, SimulationMessage.MESSAGE_SOLVER_RUNNING_START));
// get executable path+name.
setMathExecutable(new MathExecutable(getMathExecutableCommand(), getSaveDirectory()));
// setMathExecutable(new cbit.vcell.solvers.MathExecutable(executableName + " gibson " + getBaseName() + ".stochInput" + " " + getBaseName() + ".stoch"));
}
use of cbit.vcell.solvers.MathExecutable in project vcell by virtualcell.
the class CVodeSolverStandalone method initialize.
/**
* This method takes the place of the old runUnsteady()...
*/
protected void initialize() throws SolverException {
fireSolverStarting(SimulationMessage.MESSAGE_SOLVEREVENT_STARTING_INIT);
super.initialize();
String inputFilename = getInputFilename();
setSolverStatus(new SolverStatus(SolverStatus.SOLVER_RUNNING, SimulationMessage.MESSAGE_SOLVER_RUNNING_INPUT_FILE));
fireSolverStarting(SimulationMessage.MESSAGE_SOLVEREVENT_STARTING_INPUT_FILE);
PrintWriter pw = null;
try {
pw = new java.io.PrintWriter(inputFilename);
CVodeFileWriter cvodeFileWriter = new CVodeFileWriter(pw, simTask, bMessaging);
cvodeFileWriter.write();
} catch (Exception e) {
setSolverStatus(new SolverStatus(SolverStatus.SOLVER_ABORTED, SimulationMessage.solverAborted("CVODE solver could not generate input file: " + e.getMessage())));
e.printStackTrace(System.out);
throw new SolverException("CVODE solver could not generate input file: " + e.getMessage());
} finally {
if (pw != null) {
pw.close();
}
}
setSolverStatus(new SolverStatus(SolverStatus.SOLVER_RUNNING, SimulationMessage.MESSAGE_SOLVER_RUNNING_START));
setMathExecutable(new MathExecutable(getMathExecutableCommand(), getSaveDirectory()));
}
use of cbit.vcell.solvers.MathExecutable in project vcell by virtualcell.
the class IDASolverStandalone method initialize.
/**
* This method takes the place of the old runUnsteady()...
*/
protected void initialize() throws SolverException {
fireSolverStarting(SimulationMessage.MESSAGE_SOLVEREVENT_STARTING_INIT);
super.initialize();
String inputFilename = getInputFilename();
setSolverStatus(new SolverStatus(SolverStatus.SOLVER_RUNNING, SimulationMessage.MESSAGE_SOLVER_RUNNING_INPUT_FILE));
fireSolverStarting(SimulationMessage.MESSAGE_SOLVEREVENT_STARTING_INPUT_FILE);
PrintWriter pw = null;
try {
pw = new PrintWriter(inputFilename);
IDAFileWriter idaFileWriter = new IDAFileWriter(pw, simTask, bMessaging);
idaFileWriter.write();
} catch (Exception e) {
setSolverStatus(new SolverStatus(SolverStatus.SOLVER_ABORTED, SimulationMessage.solverAborted("Could not generate input file: " + e.getMessage())));
e.printStackTrace(System.out);
throw new SolverException("IDA solver could not generate input file: " + e.getMessage());
} finally {
if (pw != null) {
pw.close();
}
}
setSolverStatus(new SolverStatus(SolverStatus.SOLVER_RUNNING, SimulationMessage.MESSAGE_SOLVER_RUNNING_START));
setMathExecutable(new MathExecutable(getMathExecutableCommand(), getSaveDirectory()));
}
use of cbit.vcell.solvers.MathExecutable in project vcell by virtualcell.
the class GibsonSolver method initialize.
/**
* This method takes the place of the old runUnsteady()...
*/
protected void initialize() throws SolverException {
if (lg.isTraceEnabled())
lg.trace("StochSolver.initialize()");
fireSolverStarting(SimulationMessage.MESSAGE_SOLVEREVENT_STARTING_INIT);
writeFunctionsFile();
writeLogFile();
String inputFilename = getInputFilename();
if (lg.isTraceEnabled())
lg.trace("StochSolver.initialize() baseName = " + getBaseName());
setSolverStatus(new SolverStatus(SolverStatus.SOLVER_RUNNING, SimulationMessage.MESSAGE_SOLVER_RUNNING_INPUT_FILE));
fireSolverStarting(SimulationMessage.MESSAGE_SOLVEREVENT_STARTING_INPUT_FILE);
PrintWriter pw = null;
try {
pw = new PrintWriter(inputFilename);
StochFileWriter stFileWriter = new StochFileWriter(pw, simTask, bMessaging);
stFileWriter.write();
} catch (Exception e) {
setSolverStatus(new SolverStatus(SolverStatus.SOLVER_ABORTED, SimulationMessage.solverAborted("Could not generate input file: " + e.getMessage())));
e.printStackTrace(System.out);
throw new SolverException("solver input file exception: " + e.getMessage());
} finally {
if (pw != null) {
pw.close();
}
}
setSolverStatus(new SolverStatus(SolverStatus.SOLVER_RUNNING, SimulationMessage.MESSAGE_SOLVER_RUNNING_START));
// get executable path+name.
setMathExecutable(new MathExecutable(getMathExecutableCommand(), getSaveDirectory()));
// setMathExecutable(new cbit.vcell.solvers.MathExecutable(executableName + " gibson " + getBaseName() + ".stochInput" + " " + getBaseName() + ".stoch"));
}
use of cbit.vcell.solvers.MathExecutable in project vcell by virtualcell.
the class HybridSolver method initialize.
/**
* This method takes the place of the old runUnsteady()...
*/
protected void initialize() throws SolverException {
if (lg.isTraceEnabled())
lg.trace("HybridSolver.initialize()");
fireSolverStarting(SimulationMessage.MESSAGE_SOLVEREVENT_STARTING_INIT);
writeFunctionsFile();
writeLogFile();
//
// file used by precompiled solver.
String inputFilename = getInputFilename();
//
if (lg.isTraceEnabled())
lg.trace("HybridSolver.initialize() baseName = " + getBaseName());
//
NetCDFWriter ncWriter = new NetCDFWriter(simTask, inputFilename, bMessaging);
try {
ncWriter.initialize();
} catch (Exception e) {
setSolverStatus(new cbit.vcell.solver.server.SolverStatus(SolverStatus.SOLVER_ABORTED, SimulationMessage.solverAborted("Could not initialize StochFileWriter...")));
e.printStackTrace(System.out);
throw new SolverException("autocode init exception: " + e.getMessage());
}
setSolverStatus(new SolverStatus(SolverStatus.SOLVER_RUNNING, SimulationMessage.MESSAGE_SOLVER_RUNNING_INPUT_FILE));
fireSolverStarting(SimulationMessage.MESSAGE_SOLVEREVENT_STARTING_INPUT_FILE);
//
try {
ncWriter.writeHybridInputFile();
} catch (Exception e) {
setSolverStatus(new SolverStatus(SolverStatus.SOLVER_ABORTED, SimulationMessage.solverAborted("Could not generate input file: " + e.getMessage())));
e.printStackTrace(System.err);
throw new SolverException("solver input file exception: " + e.getMessage());
}
//
//
setSolverStatus(new SolverStatus(SolverStatus.SOLVER_RUNNING, SimulationMessage.MESSAGE_SOLVER_RUNNING_START));
// get executable path+name.
// Hybrid solver's usage: ProgramName <NetCDF Filename> <epsilon> <lambda> <MSR_Tolerance> <SDE_Tolerance> <SDE_dt> [-R <Random Seed>] [-OV]
setMathExecutable(new MathExecutable(getMathExecutableCommand(), getSaveDirectory()));
}
Aggregations