Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature force lever #157

Merged
merged 47 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
f8a5c2d
Added a `sire.v` function to make it easier to create Vector and related
chryswoods Jan 7, 2024
fd1d9d4
I've implemented the full suite of `-not-perturbed` constraints, addi…
chryswoods Jan 7, 2024
d712200
Adding ambertools and gromacs to MacOS/ARM64 BioSimSpace dependencies…
chryswoods Jan 8, 2024
67b1fa5
Fixed a small bug in indexing atoms from an atoms container. Working on
chryswoods Jan 8, 2024
d2df9f9
Fixing small bugs uncovered by fuller tests of which constraints are …
chryswoods Jan 8, 2024
8013b69
Added ability to customise the lambda levers by force, and also to have
chryswoods Jan 9, 2024
6bcf431
Added a unit test that checks an energy scan across lambda for
chryswoods Jan 12, 2024
3bb4cef
Added more to the neopentane tests - these check that things are stil…
chryswoods Jan 13, 2024
9c4ced7
h-bonds-not-perturbed is the same as h-bonds for neopentane/methane.
chryswoods Jan 13, 2024
7df052d
Adding in the somd comparison test for no cutoff
chryswoods Jan 14, 2024
cc00621
Fixed missing copy assigment of cell_matrix_inverse in TriclinicBox t…
chryswoods Jan 14, 2024
ad09b97
Added a "kappa" lambda lever to the OpenMM context. This scales the c…
chryswoods Jan 14, 2024
beafe52
Adding framework for decoupling to LambdaSchedule
chryswoods Jan 15, 2024
b2b651f
Exposed the com_reset_frequency to mols.dynamics(com_reset_frequency=…
chryswoods Jan 15, 2024
a2a2baf
Added a test that checked that the no-charge energy scan gives the
chryswoods Jan 16, 2024
57464dd
Fixed bugs with implementation of h-bonds-not-perturbed constraints
chryswoods Jan 16, 2024
fc69889
Added support for dynamic bond constraints. This is exposed via the "…
chryswoods Jan 17, 2024
fad58f6
Fixed bugs with constraint lengths - now always constrain bonds to th…
chryswoods Jan 18, 2024
058e8d6
Added a test for dynamic constraints
chryswoods Jan 18, 2024
562d697
Allow the user to more easily set the background colour of a 3D view.
chryswoods Jan 22, 2024
cd807bd
Fixed bug in somd code that accidentally caused some perturbable tors…
chryswoods Jan 23, 2024
20cb87b
Added a bugfix where changing the LambdaSchedule would not update any
chryswoods Jan 23, 2024
4b8541c
The `to_alchemlyb` function of EnergyTrajectory will now return a dat…
chryswoods Jan 24, 2024
12a4199
Added the choice of energy unit to the `to_alchemlyb` functions
chryswoods Jan 24, 2024
6e95462
Adding diffs from Lester
chryswoods Jan 25, 2024
59d2e0c
Adding a function that can create a merged molecule from a molecule p…
chryswoods Jan 27, 2024
8daf480
Merge branch 'devel' of https://github.com/openbiosim/sire into featu…
chryswoods Jan 27, 2024
d609dd2
Merge branch 'feature_exception2' of https://github.com/openbiosim/si…
chryswoods Jan 27, 2024
6e0bb92
Merge branch 'feature_exception2' of https://github.com/openbiosim/si…
chryswoods Jan 27, 2024
a816341
Switched SireOpenMM to use auto-generated Python wrappers rather than…
chryswoods Jan 27, 2024
f86dbf3
Working on reporting the perturbations in the molecule
chryswoods Jan 27, 2024
89e58b6
Working on getting the sr.morph.extract_X, sr.morph.create_from_pertf…
chryswoods Jan 28, 2024
42ffadb
Added code to let you query the parameters that go into a perturbatio…
chryswoods Jan 28, 2024
f2709e6
Merge branch 'devel' of https://github.com/openbiosim/sire into featu…
chryswoods Jan 29, 2024
b365b63
Done a lot of work on the new tutorial chapter that describes how to …
chryswoods Jan 29, 2024
0feecf8
Remove erroneous warning message about mixed combining rules.
chryswoods Jan 30, 2024
924f209
I've added in a new constraint type - "X-not-heavy-perturbed". This c…
chryswoods Jan 30, 2024
32e6832
Added zero_ghost_bond and zero_ghost_angle functions, and also matchi…
chryswoods Jan 30, 2024
3c61f63
Added tests that include a solvated neopentane-methane system
chryswoods Jan 31, 2024
c445af4
Added a section on how to set the lambda lever for specific forces, a…
chryswoods Jan 31, 2024
30def97
Fixed a bug in the streaming of LambdaSchedule that was introduced on
chryswoods Feb 2, 2024
69ccc06
I've added a test to check the energy of solvated neopetane-methane
chryswoods Feb 2, 2024
ecd47ca
Added in a shift_coulomb parameter that acts like shift_delta in the …
chryswoods Feb 3, 2024
5602918
Tests now show excellent agreement between somd1 and sire/openmm ener…
chryswoods Feb 4, 2024
83e5ab9
Factorised the LJ equation in the sire/openmm custom forces.
chryswoods Feb 4, 2024
b266e71
Added more documentation about LambdaSchedule. Also added unit tests.
chryswoods Feb 8, 2024
158d36d
Merge branch 'devel' of https://github.com/openbiosim/sire into featu…
chryswoods Feb 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
511 changes: 439 additions & 72 deletions corelib/src/libs/SireCAS/lambdaschedule.cpp

Large diffs are not rendered by default.

86 changes: 66 additions & 20 deletions corelib/src/libs/SireCAS/lambdaschedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ namespace SireCAS
static LambdaSchedule standard_morph();
static LambdaSchedule charge_scaled_morph(double scale = 0.2);

static LambdaSchedule standard_decouple(bool perturbed_is_decoupled = true);
static LambdaSchedule charge_scaled_decouple(double scale = 0.2, bool perturbed_is_decoupled = true);

static SireCAS::Symbol lam();
static SireCAS::Symbol initial();
static SireCAS::Symbol final();
Expand All @@ -95,6 +98,16 @@ namespace SireCAS

QStringList getLevers() const;

void addForce(const QString &force);
void addForces(const QStringList &forces);

void removeForce(const QString &force);
void removeForces(const QStringList &forces);

int nForces() const;

QStringList getForces() const;

int nStages() const;

QStringList getStages() const;
Expand All @@ -116,6 +129,8 @@ namespace SireCAS
const QString &stage,
const SireCAS::Expression &equation);

void removeStage(const QString &stage);

void addMorphStage();
void addMorphStage(const QString &name);

Expand All @@ -124,20 +139,39 @@ namespace SireCAS
const QString &recharge_name,
double scale = 0.2);

void setEquation(const QString &stage,
const QString &lever,
const SireCAS::Expression &equation);
void addDecoupleStage(bool perturbed_is_decoupled = true);
void addDecoupleStage(const QString &name, bool perturbed_is_decoupled = true);

void setDefaultStageEquation(const QString &stage,
const SireCAS::Expression &equation);

void setDefaultEquation(const QString &stage,
const SireCAS::Expression &equation);
void setEquation(const QString &stage = "*",
const QString &force = "*",
const QString &lever = "*",
const SireCAS::Expression &equation = SireCAS::Expression());

void removeEquation(const QString &stage,
const QString &lever);
void removeEquation(const QString &stage = "*",
const QString &force = "*",
const QString &lever = "*");

SireCAS::Expression getEquation(const QString &stage) const;
bool hasForceSpecificEquation(const QString &stage = "*",
const QString &force = "*",
const QString &lever = "*") const;

SireCAS::Expression getEquation(const QString &stage,
const QString &lever) const;
SireCAS::Expression getEquation(const QString &stage = "*",
const QString &force = "*",
const QString &lever = "*") const;

void setMoleculeSchedule(int pert_mol_id,
const LambdaSchedule &schedule);

bool hasMoleculeSchedule(int pert_mol_id) const;

void removeMoleculeSchedule(int pert_mol_id);

LambdaSchedule takeMoleculeSchedule(int pert_mol_id);

const LambdaSchedule &getMoleculeSchedule(int pert_mol_id) const;

QHash<QString, QVector<double>> getLeverValues(const QVector<double> &lambda_values,
double initial = 1.0,
Expand All @@ -160,18 +194,20 @@ namespace SireCAS

SireCAS::Symbol getConstantSymbol(const QString &constant) const;

double morph(const QString &lever,
double initial, double final, double lambda_value) const;
double morph(const QString &force = "*", const QString &lever = "*",
double initial = 0, double final = 1, double lambda_value = 0) const;

QVector<double> morph(const QString &lever,
const QVector<double> &initial,
const QVector<double> &final,
double lambda_value) const;
QVector<double> morph(const QString &force = "*",
const QString &lever = "*",
const QVector<double> &initial = QVector<double>(),
const QVector<double> &final = QVector<double>(),
double lambda_value = 0.0) const;

QVector<int> morph(const QString &lever,
const QVector<int> &initial,
const QVector<int> &final,
double lambda_value) const;
QVector<int> morph(const QString &force = "*",
const QString &lever = "*",
const QVector<int> &initial = QVector<int>(),
const QVector<int> &final = QVector<int>(),
double lambda_value = 0.0) const;

double clamp(double lambda_value) const;

Expand All @@ -180,9 +216,19 @@ namespace SireCAS

std::tuple<int, double> resolve_lambda(double lambda) const;

SireCAS::Expression _getEquation(int stage, const QString &force, const QString &lever) const;

/** Additional schedules for extra molecules, i.e. that
* run in parallel alongside the default schedule
*/
QHash<qint32, LambdaSchedule> mol_schedules;

/** The set of all constants used across all stages */
SireCAS::Values constant_values;

/** The names of all of the forces */
QStringList force_names;

/** The names of all of the levers provided by the forcefields */
QStringList lever_names;

Expand Down
7 changes: 6 additions & 1 deletion corelib/src/libs/SireIO/amberprm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,12 @@ void AmberPrm::rebuildLJParameters()

bool is_exception = false;

if (std::abs(lj_ij.epsilon().value() - expect.epsilon().value()) <= 1e-6)
if (std::abs(epsilon) < 1e-6 and std::abs(expect.epsilon().value()) < 1e-6)
{
// this is a LJ pair that involves a ghost or dummy atom
// It should not impact exceptions or combining rules
}
else if (std::abs(lj_ij.epsilon().value() - expect.epsilon().value()) <= 1e-6)
{
if (std::abs(lj_ij.sigma().value() - expect.sigma().value()) > 1e-6)
{
Expand Down
6 changes: 4 additions & 2 deletions corelib/src/libs/SireMol/moleculedata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,8 @@ bool MoleculeData::operator!=(const MoleculeData &other) const

/** Return a new MoleculeData that contains only the passed selected
atoms. This allows parts of the molecule to be pulled out and used independently */
MoleculeData MoleculeData::extract(const AtomSelection &selected_atoms) const
MoleculeData MoleculeData::extract(const AtomSelection &selected_atoms,
bool to_same_molecule) const
{
selected_atoms.assertCompatibleWith(*this);

Expand Down Expand Up @@ -433,7 +434,8 @@ MoleculeData MoleculeData::extract(const AtomSelection &selected_atoms) const

// renumber the molecule to remove confusion as to why
// extracted molecules cannot be combined
editor.renumber();
if (not to_same_molecule)
editor.renumber();

return editor.commit().data();
}
Expand Down
3 changes: 2 additions & 1 deletion corelib/src/libs/SireMol/moleculedata.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ namespace SireMol
return props;
}

MoleculeData extract(const AtomSelection &selected_atoms) const;
MoleculeData extract(const AtomSelection &selected_atoms,
bool to_same_molecule = false) const;

QStringList propertyKeys() const;

Expand Down
18 changes: 2 additions & 16 deletions corelib/src/libs/SireMol/moleculeview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,20 +476,6 @@ void MoleculeView::update(const MoleculeData &moldata)
{
if (moldata.number() == this->data().number())
{
if (moldata.info().UID() != this->data().info().UID())
{
throw SireError::incompatible_error(QObject::tr(
"Cannot update molecule %1 because the layout for the new "
"version of the molecule (%2) is different. This is likely "
"because the molecule has been edited and the layout of "
"atoms, residues etc has been changed. To update this molecule "
"you will need to replace it in the container.")
.arg(this->molecule().toString())
.arg(Molecule(moldata).toString()),
CODELOC);
}

// this is the same molecule with the same molecular layout
d = moldata;
}
}
Expand Down Expand Up @@ -1934,7 +1920,7 @@ Selector<Segment> MoleculeView::selectAllSegments() const
selected atoms. This allows the used to pull out parts of a larger molecule,
e.g. if they want to have only selected residues in a protein and do not
want to have to store or manipulate the larger protein molecule */
Molecule MoleculeView::extract() const
Molecule MoleculeView::extract(bool to_same_molecule) const
{
if (d->info().nAtoms() == 0 or this->isEmpty())
return Molecule();
Expand All @@ -1944,7 +1930,7 @@ Molecule MoleculeView::extract() const

else
{
return Molecule(d->extract(this->selection()));
return Molecule(d->extract(this->selection(), to_same_molecule));
}
}

Expand Down
2 changes: 1 addition & 1 deletion corelib/src/libs/SireMol/moleculeview.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ namespace SireMol

virtual bool isSelector() const;

Molecule extract() const;
Molecule extract(bool to_same_molecule = false) const;

void update(const MoleculeData &moldata);
void update(const MoleculeView &molview);
Expand Down
10 changes: 6 additions & 4 deletions corelib/src/libs/SireMol/selectorm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ namespace SireMol
{

friend SIREMOL_EXPORT QDataStream & ::operator<< <>(QDataStream &, const SelectorM<T> &);
friend SIREMOL_EXPORT QDataStream & ::operator>><>(QDataStream &, SelectorM<T> &);
friend SIREMOL_EXPORT QDataStream & ::operator>> <>(QDataStream &, SelectorM<T> &);

public:
typedef typename QList<Selector<T>>::const_iterator iterator;
Expand Down Expand Up @@ -93,7 +93,7 @@ namespace SireMol
template <class U>
SelectorM(const SelectorM<U> &other, const QList<qint64> &idxs);
template <class U>
SelectorM(const SelectorM<U> &other, const QString &name);
SelectorM(const SelectorM<U> &other, const QString &name, const SireBase::PropertyMap &map = SireBase::PropertyMap());
template <class U>
SelectorM(const SelectorM<U> &other, const typename T::ID &id);

Expand Down Expand Up @@ -1072,7 +1072,9 @@ namespace SireMol

template <class T>
template <class U>
SIRE_OUTOFLINE_TEMPLATE SelectorM<T>::SelectorM(const SelectorM<U> &other, const QString &name)
SIRE_OUTOFLINE_TEMPLATE SelectorM<T>::SelectorM(const SelectorM<U> &other,
const QString &name,
const SireBase::PropertyMap &map)
: SireBase::ConcreteProperty<SelectorM<T>, SireBase::Property>()
{
for (const auto &view : other)
Expand All @@ -1093,7 +1095,7 @@ namespace SireMol
// try a search
try
{
this->operator=(SelectorM<T>(other.search(name)));
this->operator=(SelectorM<T>(other.search(name, map)));
}
catch (...)
{
Expand Down
Loading
Loading