Skip to content
Snippets Groups Projects
Commit fd9206bd authored by Studer Gabriel's avatar Studer Gabriel
Browse files

allow to generate simulation without attaching an integrator to

the settings object.

In many cases the user might only want to minimize a structure,
an integrator is therefore useless. To make OpenMM happy, a
dummy integrator (Verlet integrator with timestep 1fs) is
attached to the settings object and simulation in these cases.
parent 41023166
Branches
Tags
No related merge requests found
......@@ -253,10 +253,13 @@ void Simulation::Init(const TopologyPtr top,
top_ = top;
integrator_ = settings->integrator;
if(!integrator_){
throw ost::Error("Settings must have a valid integrator attached to set up a simulation!");
if(!settings->integrator){
//user did not specify an integrator, so let's just use a standard integrator
settings->integrator = IntegratorPtr(new OpenMM::VerletIntegrator(0.001));
}
integrator_ = settings->integrator;
system_ = SystemCreator::Create(top_,settings,system_force_mapper_);
//setting up the context, which combines the system with an integrator
......
......@@ -42,9 +42,6 @@ BOOST_AUTO_TEST_CASE(test_simulation_basics){
top->AddHarmonicPositionRestraint(1,geom::Vec3(0.0,0.0,0.0),10.0);
top->AddHarmonicDistanceRestraint(1,2,10.0,10.0);
//try to set up simulation without an integrator
BOOST_CHECK_THROW(Simulation sim(test_ent,settings),ost::Error);
settings->integrator = IntegratorPtr(new OpenMM::VerletIntegrator(0.002));
Simulation sim(top, test_ent, settings);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment