00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef OST_MM_SIMULATION_HH
00021 #define OST_MM_SIMULATION_HH
00022
00023 #include <vector>
00024 #include <map>
00025
00026 #include <ost/mol/mol.hh>
00027 #include <ost/mol/mm/system_creator.hh>
00028 #include <ost/mol/mm/topology.hh>
00029 #include <ost/mol/mm/topology_creator.hh>
00030 #include <ost/mol/mm/settings.hh>
00031 #include <ost/mol/mm/modeller.hh>
00032 #include <ost/geom/vec3.hh>
00033 #include <ost/mol/mm/observer.hh>
00034 #include <ost/mol/mm/state_extractor.hh>
00035 #include <ost/mol/mm/steep.hh>
00036
00037 #include <time.h>
00038
00039 namespace OpenMM{
00040 class Integrator;
00041 class Context;
00042
00043
00044
00045 }
00046
00047 namespace ost { namespace mol{ namespace mm{
00048
00049 class Simulation;
00050
00051 typedef boost::shared_ptr<OpenMM::Integrator> IntegratorPtr;
00052 typedef boost::shared_ptr<OpenMM::Context> ContextPtr;
00053 typedef boost::shared_ptr<Simulation> SimulationPtr;
00054
00055 class Simulation {
00056
00057 public:
00058
00059 Simulation(const ost::mol::EntityHandle& handle,
00060 const SettingsPtr settings);
00061
00062 Simulation(const ost::mol::mm::TopologyPtr top,
00063 const ost::mol::EntityHandle& handle,
00064 const SettingsPtr settings);
00065
00066 void Save(const String& filename);
00067
00068 static SimulationPtr Load(const String& filename, SettingsPtr settings);
00069
00070 ost::mol::EntityHandle GetEntity() { return ent_; }
00071
00072 geom::Vec3List GetPositions(bool enforce_periodic_box = false, bool in_angstrom = true);
00073
00074 geom::Vec3List GetVelocities();
00075
00076 geom::Vec3List GetForces();
00077
00078 void SetPositions(const geom::Vec3List& positions, bool in_angstrom = true);
00079
00080 void SetVelocities(geom::Vec3List& velocities);
00081
00082 void UpdatePositions(bool enforce_periodic_box = false);
00083
00084 bool ApplySD(Real tolerance = 100, int max_iterations = 1000);
00085
00086 void ApplyLBFGS(Real tolerance = 1, int max_iterations = 1000);
00087
00088 Real GetEnergy();
00089
00090 Real GetPotentialEnergy();
00091
00092 Real GetKineticEnergy();
00093
00094 TopologyPtr GetTopology() { return top_; }
00095
00096 void Steps(int steps);
00097
00098 void Register(ObserverPtr o);
00099
00100 void ResetHarmonicBond(uint index, Real bond_length, Real force_constant);
00101
00102 void ResetHarmonicAngle(uint index, Real angle, Real force_constant);
00103
00104 void ResetUreyBradleyAngle(uint index, Real angle, Real angle_force_constant, Real bond_length, Real bond_force_constant);
00105
00106 void ResetPeriodicDihedral(uint index, int multiplicity, Real phase, Real force_constant);
00107
00108 void ResetPeriodicImproper(uint index, int multiplicity, Real phase, Real force_constant);
00109
00110 void ResetHarmonicImproper(uint index, Real phase, Real force_constant);
00111
00112 void ResetLJPair(uint index, Real sigma, Real epsilon);
00113
00114 void ResetDistanceConstraint(uint index, Real constraint_length);
00115
00116 void ResetHarmonicPositionRestraint(uint index, const geom::Vec3& ref_position, Real k,
00117 Real x_scale = 1.0, Real y_scale = 1.0, Real z_scale = 1.0);
00118
00119 void ResetHarmonicDistanceRestraint(uint index, Real length, Real force_constant);
00120
00121 void ResetLJ(uint index, Real sigma, Real epsilon);
00122
00123 void ResetGBSA(uint index, Real radius, Real scaling);
00124
00125 void ResetCharge(uint index, Real charge);
00126
00127 void ResetMass(uint index, Real mass);
00128
00129 void AddPositionConstraint(uint index);
00130
00131 void AddPositionConstraints(const std::vector<uint>& index);
00132
00133 void ResetPositionConstraints();
00134
00135 geom::Vec3 GetPeriodicBoxExtents();
00136
00137 void SetPeriodicBoxExtents(geom::Vec3& vec);
00138
00139 private:
00140
00141 Simulation() { }
00142
00143 void Init(const ost::mol::mm::TopologyPtr top,
00144 const SettingsPtr settings);
00145
00146 int TimeToNextNotification();
00147
00148 SystemPtr system_;
00149 IntegratorPtr integrator_;
00150 ContextPtr context_;
00151 TopologyPtr top_;
00152 std::vector<ObserverPtr> observers_;
00153 std::vector<int> time_to_notify_;
00154 std::map<FuncType,uint> system_force_mapper_;
00155 ost::mol::EntityHandle ent_;
00156 };
00157
00158 }}}
00159
00160 #endif