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 static bool IsPlatformAvailable(const SettingsPtr settings);
00071
00072 ost::mol::EntityHandle GetEntity() { return ent_; }
00073
00074 geom::Vec3List GetPositions(bool enforce_periodic_box = false, bool in_angstrom = true);
00075
00076 geom::Vec3List GetVelocities();
00077
00078 geom::Vec3List GetForces();
00079
00080 void SetPositions(const geom::Vec3List& positions, bool in_angstrom = true);
00081
00082 void SetVelocities(geom::Vec3List& velocities);
00083
00084 void UpdatePositions(bool enforce_periodic_box = false);
00085
00086 bool ApplySD(Real tolerance = 100, int max_iterations = 1000);
00087
00088 void ApplyLBFGS(Real tolerance = 1, int max_iterations = 1000);
00089
00090 Real GetEnergy();
00091
00092 Real GetPotentialEnergy();
00093
00094 Real GetKineticEnergy();
00095
00096 TopologyPtr GetTopology() { return top_; }
00097
00098 void Steps(int steps);
00099
00100 void Register(ObserverPtr o);
00101
00102 void ResetHarmonicBond(uint index, Real bond_length, Real force_constant);
00103
00104 void ResetHarmonicAngle(uint index, Real angle, Real force_constant);
00105
00106 void ResetUreyBradleyAngle(uint index, Real angle, Real angle_force_constant, Real bond_length, Real bond_force_constant);
00107
00108 void ResetPeriodicDihedral(uint index, int multiplicity, Real phase, Real force_constant);
00109
00110 void ResetPeriodicImproper(uint index, int multiplicity, Real phase, Real force_constant);
00111
00112 void ResetHarmonicImproper(uint index, Real phase, Real force_constant);
00113
00114 void ResetLJPair(uint index, Real sigma, Real epsilon);
00115
00116 void ResetDistanceConstraint(uint index, Real constraint_length);
00117
00118 void ResetHarmonicPositionRestraint(uint index, const geom::Vec3& ref_position, Real k,
00119 Real x_scale = 1.0, Real y_scale = 1.0, Real z_scale = 1.0);
00120
00121 void ResetHarmonicDistanceRestraint(uint index, Real length, Real force_constant);
00122
00123 void ResetLJ(uint index, Real sigma, Real epsilon);
00124
00125 void ResetGBSA(uint index, Real radius, Real scaling);
00126
00127 void ResetCharge(uint index, Real charge);
00128
00129 void ResetMass(uint index, Real mass);
00130
00131 void AddPositionConstraint(uint index);
00132
00133 void AddPositionConstraints(const std::vector<uint>& index);
00134
00135 void ResetPositionConstraints();
00136
00137 geom::Vec3 GetPeriodicBoxExtents();
00138
00139 void SetPeriodicBoxExtents(geom::Vec3& vec);
00140
00141 private:
00142
00143 Simulation() { }
00144
00145 void Init(const ost::mol::mm::TopologyPtr top,
00146 const SettingsPtr settings);
00147
00148 int TimeToNextNotification();
00149
00150
00151 static void EnsurePluginsLoaded(const String& plugin_path);
00152
00153 SystemPtr system_;
00154 IntegratorPtr integrator_;
00155 ContextPtr context_;
00156 TopologyPtr top_;
00157 std::vector<ObserverPtr> observers_;
00158 std::vector<int> time_to_notify_;
00159 std::map<FuncType,uint> system_force_mapper_;
00160 ost::mol::EntityHandle ent_;
00161 };
00162
00163 }}}
00164
00165 #endif