OpenStructure
Loading...
Searching...
No Matches
simulation.hh
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// This file is part of the OpenStructure project <www.openstructure.org>
3//
4// Copyright (C) 2008-2020 by the OpenStructure authors
5//
6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License as published by the Free
8// Software Foundation; either version 3.0 of the License, or (at your option)
9// any later version.
10// This library is distributed in the hope that it will be useful, but WITHOUT
11// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13// details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with this library; if not, write to the Free Software Foundation, Inc.,
17// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18//------------------------------------------------------------------------------
19
20#ifndef OST_MM_SIMULATION_HH
21#define OST_MM_SIMULATION_HH
22
23#include <vector>
24#include <map>
25
26#include <ost/mol/mol.hh>
32#include <ost/geom/vec3.hh>
35#include <ost/mol/mm/steep.hh>
36
37#include <time.h>
38
39namespace OpenMM{
40 class Integrator;
41 class Context;//hacky way of telling the Context and Integrator
42 //are around.
43 //will be included in source file to avoid
44 //dependencies on external libraries
45}
46
47namespace ost { namespace mol{ namespace mm{
48
49class Simulation;
50
51typedef boost::shared_ptr<OpenMM::Integrator> IntegratorPtr;
52typedef boost::shared_ptr<OpenMM::Context> ContextPtr;
53typedef boost::shared_ptr<Simulation> SimulationPtr;
54
56
57public:
58
60 const SettingsPtr settings);
61
63 const ost::mol::EntityHandle& handle,
64 const SettingsPtr settings);
65
66 void Save(const String& filename);
67
68 static SimulationPtr Load(const String& filename, SettingsPtr settings);
69
70 static bool IsPlatformAvailable(const SettingsPtr settings);
71
73
74 geom::Vec3List GetPositions(bool enforce_periodic_box = false, bool in_angstrom = true);
75
77
79
80 void SetPositions(const geom::Vec3List& positions, bool in_angstrom = true);
81
82 void SetVelocities(geom::Vec3List& velocities);
83
84 void UpdatePositions(bool enforce_periodic_box = false);
85
86 bool ApplySD(Real tolerance = 100, int max_iterations = 1000);
87
88 void ApplyLBFGS(Real tolerance = 1, int max_iterations = 1000);
89
91
93
95
96 TopologyPtr GetTopology() { return top_; }
97
98 void Steps(int steps);
99
101
102 void ResetHarmonicBond(uint index, Real bond_length, Real force_constant);
103
104 void ResetHarmonicAngle(uint index, Real angle, Real force_constant);
105
106 void ResetUreyBradleyAngle(uint index, Real angle, Real angle_force_constant, Real bond_length, Real bond_force_constant);
107
108 void ResetPeriodicDihedral(uint index, int multiplicity, Real phase, Real force_constant);
109
110 void ResetPeriodicImproper(uint index, int multiplicity, Real phase, Real force_constant);
111
112 void ResetHarmonicImproper(uint index, Real phase, Real force_constant);
113
114 void ResetLJPair(uint index, Real sigma, Real epsilon);
115
116 void ResetDistanceConstraint(uint index, Real constraint_length);
117
118 void ResetHarmonicPositionRestraint(uint index, const geom::Vec3& ref_position, Real k,
119 Real x_scale = 1.0, Real y_scale = 1.0, Real z_scale = 1.0);
120
121 void ResetHarmonicDistanceRestraint(uint index, Real length, Real force_constant);
122
123 void ResetLJ(uint index, Real sigma, Real epsilon);
124
125 void ResetGBSA(uint index, Real radius, Real scaling);
126
127 void ResetCharge(uint index, Real charge);
128
129 void ResetMass(uint index, Real mass);
130
132
133 void AddPositionConstraints(const std::vector<uint>& index);
134
136
138
140
141private:
142
143 Simulation() { } //hidden constructor...
144
145 void Init(const ost::mol::mm::TopologyPtr top,
146 const ost::mol::EntityHandle& ent,
147 const SettingsPtr settings);
148
149 int TimeToNextNotification();
150
151 void ReinitializeContext();
152
153 // loads plugins from directory for OpenMM BUT only once per unique path!
154 static void EnsurePluginsLoaded(const String& plugin_path);
155
156 SystemPtr system_;
157 IntegratorPtr integrator_;
158 ContextPtr context_;
159 TopologyPtr top_;
160 std::vector<ObserverPtr> observers_;
161 std::vector<int> time_to_notify_;
162 std::map<FuncType,uint> system_force_mapper_;
164 ost::mol::AtomHandleList atom_list_;
165};
166
167}}} //ns
168
169#endif
Three dimensional vector class, using Real precision.
Definition vec3.hh:48
Protein or molecule.
Simulation(const ost::mol::EntityHandle &handle, const SettingsPtr settings)
geom::Vec3List GetForces()
Simulation(const ost::mol::mm::TopologyPtr top, const ost::mol::EntityHandle &handle, const SettingsPtr settings)
void SetPeriodicBoxExtents(geom::Vec3 &vec)
void ResetGBSA(uint index, Real radius, Real scaling)
geom::Vec3List GetPositions(bool enforce_periodic_box=false, bool in_angstrom=true)
void ResetHarmonicImproper(uint index, Real phase, Real force_constant)
void ResetPeriodicImproper(uint index, int multiplicity, Real phase, Real force_constant)
void ResetPeriodicDihedral(uint index, int multiplicity, Real phase, Real force_constant)
void SetPositions(const geom::Vec3List &positions, bool in_angstrom=true)
void ResetHarmonicPositionRestraint(uint index, const geom::Vec3 &ref_position, Real k, Real x_scale=1.0, Real y_scale=1.0, Real z_scale=1.0)
void ResetDistanceConstraint(uint index, Real constraint_length)
static bool IsPlatformAvailable(const SettingsPtr settings)
void AddPositionConstraint(uint index)
void Register(ObserverPtr o)
void ResetHarmonicBond(uint index, Real bond_length, Real force_constant)
bool ApplySD(Real tolerance=100, int max_iterations=1000)
void ResetLJPair(uint index, Real sigma, Real epsilon)
void ResetMass(uint index, Real mass)
void ResetUreyBradleyAngle(uint index, Real angle, Real angle_force_constant, Real bond_length, Real bond_force_constant)
void Steps(int steps)
void UpdatePositions(bool enforce_periodic_box=false)
void Save(const String &filename)
static SimulationPtr Load(const String &filename, SettingsPtr settings)
void SetVelocities(geom::Vec3List &velocities)
geom::Vec3 GetPeriodicBoxExtents()
ost::mol::EntityHandle GetEntity()
Definition simulation.hh:72
void ApplyLBFGS(Real tolerance=1, int max_iterations=1000)
void ResetCharge(uint index, Real charge)
void ResetLJ(uint index, Real sigma, Real epsilon)
void AddPositionConstraints(const std::vector< uint > &index)
geom::Vec3List GetVelocities()
TopologyPtr GetTopology()
Definition simulation.hh:96
void ResetHarmonicDistanceRestraint(uint index, Real length, Real force_constant)
void ResetHarmonicAngle(uint index, Real angle, Real force_constant)
unsigned int uint
Definition base.hh:29
float Real
Definition base.hh:44
std::string String
Definition base.hh:54
boost::shared_ptr< OpenMM::System > SystemPtr
boost::shared_ptr< Simulation > SimulationPtr
Definition simulation.hh:53
boost::shared_ptr< OpenMM::Integrator > IntegratorPtr
Definition simulation.hh:51
boost::shared_ptr< Observer > ObserverPtr
Definition observer.hh:47
boost::shared_ptr< OpenMM::Context > ContextPtr
Definition simulation.hh:52
boost::shared_ptr< Topology > TopologyPtr
Definition topology.hh:49
boost::shared_ptr< Settings > SettingsPtr
Definition settings.hh:47
std::vector< AtomHandle > AtomHandleList
Definition base.dox:1