File: sketcherMinimizerStretchInteraction.h

package info (click to toggle)
schroedinger-coordgenlibs 3.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,212 kB
  • sloc: cpp: 17,910; python: 128; makefile: 4
file content (51 lines) | stat: -rw-r--r-- 1,566 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 *  sketcherMinimizerStretchInteraction.h
 *
 *  Created by Nicola Zonta on 13/04/2010.
 *   Copyright Schrodinger, LLC. All rights reserved.
 *
 */

#ifndef sketcherMINIMIZERSTRETCHMINIMIZERINTERACTION
#define sketcherMINIMIZERSTRETCHMINIMIZERINTERACTION

#include "sketcherMinimizerInteraction.h"

/* force field bond stretches */
class sketcherMinimizerStretchInteraction : public sketcherMinimizerInteraction
{
  public:
    sketcherMinimizerStretchInteraction(sketcherMinimizerAtom* at1,
                                        sketcherMinimizerAtom* at2)
        : sketcherMinimizerInteraction(at1, at2)
    {
    }
    ~sketcherMinimizerStretchInteraction() override = default;

    /* calculate forces and apply them */
    void score(float& totalE, bool = false) override
    {
        energy(totalE);
        sketcherMinimizerPointF l = atom1->coordinates - atom2->coordinates;
        float m = l.length();
        float dr = 0;
        if (m < restV - tolerance) dr =  restV - tolerance - m;
        else if (m > restV + tolerance) dr =  restV + tolerance - m;
        else return;

        float shortBondThreshold = restV * 0.4f;
        float penaltyForVeryShortBonds = (shortBondThreshold - m);
        if (penaltyForVeryShortBonds < 0) {
            penaltyForVeryShortBonds = 0;
        }
        if (m > SKETCHER_EPSILON) {
            l /= m;
        }
        l *= (k * dr + penaltyForVeryShortBonds * 10);
        atom1->force += l;
        atom2->force -= l;
    }
    float tolerance = 0;
};

#endif // sketcherMINIMIZERSTRETCHINTERACTION