faunus
actions.h
1 #pragma once
2 
3 #include "geometry.h"
4 #include "space.h"
5 
6 namespace Faunus {
7 
8 namespace Energy {
9 class Hamiltonian;
10 class NonbondedBase;
11 } // namespace Energy
12 class XTCWriter;
13 
18 {
19  virtual void operator()(Space& space, Energy::Hamiltonian& hamiltonian) = 0;
20  virtual ~SystemAction() = default;
21 };
22 
30 class AngularScan : public SystemAction
31 {
32  static constexpr std::string_view NAME = "angular scan";
33 
35  class EnergyAnalysis
36  {
37  double partition_sum = 0.0;
38  double energy_sum = 0.0;
39  Average<double> mean_exp_energy;
40  public:
41  void clear();
42  void add(double energy);
43  [[nodiscard]] double getFreeEnergy() const;
44  [[nodiscard]] double getMeanEnergy() const;
45  void printLog() const;
46  };
47 
49  struct Molecule
50  {
51  Space::GroupVector::size_type index;
52  std::vector<Point> ref_positions;
53  void initialize(const Space::GroupVector& groups,
54  int index);
55  ParticleVector getRotatedReference(const Space::GroupVector& groups,
56  const Eigen::Quaterniond& q);
57  };
58 
59  double zmin = 0;
60  double zmax = 0;
61  double dz = 0;
62  double max_energy = pc::infty;
63  EnergyAnalysis energy_analysis;
64 
65  std::pair<Molecule, Molecule> molecules;
66  std::unique_ptr<std::ostream> stream;
67  std::unique_ptr<XTCWriter> trajectory;
69 
71  void report(const Group& group1, const Group& group2, const Eigen::Quaterniond& q1,
72  const Eigen::Quaterniond& q2, Energy::NonbondedBase& nonbonded);
73 
74  public:
75  AngularScan(const json& input, const Space& spc);
76  void operator()(Space& space, Energy::Hamiltonian& hamiltonian) override;
77 };
78 
80 std::unique_ptr<SystemAction> createAction(std::string_view name, const json& properties,
81  Space& spc);
82 
84 std::vector<std::unique_ptr<SystemAction>> createActionList(const json& input, Space& spc);
85 
86 } // namespace Faunus
nlohmann::json json
JSON object.
Definition: json_support.h:10
Rotate and translate two molecules to explore all poses.
Definition: actions.h:30
std::vector< Particle > ParticleVector
Storage type for collections of particles.
Definition: particle.h:253
std::unique_ptr< SystemAction > createAction(std::string_view name, const json &j, Space &spc)
Create single action from JSON input.
Definition: actions.cpp:151
std::vector< std::unique_ptr< SystemAction > > createActionList(const json &input, Space &spc)
Create vector of actions from JSON list input.
Definition: actions.cpp:164
Structure for exploring a discrete, uniform angular space between two rigid bodies.
Definition: geometry.h:875
Cell list class templates.
Definition: actions.cpp:11
End of Group class.
Definition: group.h:177
Aggregate and sum energy terms.
Definition: energy.h:1954
std::vector< MoleculeData > molecules
List of molecule types.
Definition: molecule.cpp:22
Placeholder for atoms and molecules.
Definition: space.h:92
Definition: energy.h:1498
Performs a task or "action" on the system, typically before or after a simulation.
Definition: actions.h:17
Writes frames into an XTC file (GROMACS compressed trajectory file format).
Definition: io.h:661