IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
ExamplePairScore.h
Go to the documentation of this file.
1/**
2 * \file IMP/example/ExamplePairScore.h
3 * \brief A Score on the distance between a pair of particles.
4 *
5 * Copyright 2007-2026 IMP Inventors. All rights reserved.
6 */
7
8#ifndef IMPEXAMPLE_EXAMPLE_PAIR_SCORE_H
9#define IMPEXAMPLE_EXAMPLE_PAIR_SCORE_H
10
11#include <IMP/example/example_config.h>
12#include <IMP/core/XYZ.h>
13#include <IMP/PairScore.h>
14#include <IMP/pair_macros.h>
15#include <IMP/UnaryFunction.h>
16#include <IMP/Pointer.h>
17#include <cereal/access.hpp>
18
19IMPEXAMPLE_BEGIN_NAMESPACE
20
21//! Apply a harmonic to the distance between two particles.
22/** The source code is as follows:
23 \include ExamplePairScore.h
24 \include ExamplePairScore.cpp
25*/
26class IMPEXAMPLEEXPORT ExamplePairScore : public PairScore {
27 double x0_, k_;
28
29 public:
30 ExamplePairScore(double x0, double k);
31 ExamplePairScore() {}
32
33 double get_mean() const { return x0_; }
34 double get_force_constant() const { return k_; }
35
36 virtual double evaluate_index(Model *m,
37 const ParticleIndexPair &p,
38 DerivativeAccumulator *da) const override;
40 Model *m, const ParticleIndexes &pis) const override;
41 IMP_PAIR_SCORE_METHODS(ExamplePairScore);
42 IMP_OBJECT_METHODS(ExamplePairScore);
43
44 // Serialization support
45 private:
46 friend class cereal::access;
47 template<class Archive> void serialize(Archive &ar) {
48 ar(cereal::base_class<PairScore>(this), x0_, k_);
49 }
51
52};
53
55
56IMPEXAMPLE_END_NAMESPACE
57
58#endif /* IMPEXAMPLE_EXAMPLE_PAIR_SCORE_H */
Define PairScore.
A nullptr-initialized pointer to an IMP Object.
Single variable function.
Simple XYZ decorator.
Class for adding derivatives from restraints to the model.
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
Apply a harmonic to the distance between two particles.
virtual ModelObjectsTemp do_get_inputs(Model *m, const ParticleIndexes &pis) const override
Overload this method to specify the inputs.
virtual double evaluate_index(Model *m, const ParticleIndexPair &p, DerivativeAccumulator *da) const override
Compute the score and the derivative if needed.
IMP::Vector< IMP::Pointer< ExamplePairScore > > ExamplePairScores
Vector< ParticleIndex, std::allocator< ParticleIndex > > ParticleIndexes
A list of particles, each identified by its ParticleIndex.
Definition base_types.h:199
Array< 2, ParticleIndex > ParticleIndexPair
An ordered pair of particles, each identified by its ParticleIndex.
Definition base_types.h:202
IMP::Vector< IMP::WeakPointer< ModelObject > > ModelObjectsTemp
Definition base_types.h:122
#define IMP_OBJECT_SERIALIZE_DECL(Name)
Declare methods needed for serialization of Object pointers.
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing lists of object pointers.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Macros for various classes.
#define IMP_PAIR_SCORE_METHODS(Name)
Definition pair_macros.h:25