Skip to content

Commit 98246ff

Browse files
authored
Merge pull request #380 from OpenBioSim/feature_inverse_bond_restraint
Add inverse bond/distance restraint and fix issue #379
2 parents 84b7ddd + 5998a7a commit 98246ff

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2723
-473
lines changed

corelib/src/libs/SireMM/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ set ( SIREMM_HEADERS
7171
intragroupff.h
7272
intraljff.h
7373
intrasoftcljff.h
74+
inversebondrestraints.h
7475
lj1264parameter.h
7576
ljfunction.h
7677
ljpair.h
@@ -167,6 +168,7 @@ set ( SIREMM_SOURCES
167168
intragroupff.cpp
168169
intraljff.cpp
169170
intrasoftcljff.cpp
171+
inversebondrestraints.cpp
170172
lj1264parameter.cpp
171173
ljpair.cpp
172174
ljparameter.cpp

corelib/src/libs/SireMM/anglerestraints.cpp

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,11 @@ static const RegisterMetaType<AngleRestraints> r_angrests;
227227

228228
QDataStream &operator<<(QDataStream &ds, const AngleRestraints &angrests)
229229
{
230-
writeHeader(ds, r_angrests, 1);
230+
writeHeader(ds, r_angrests, 2);
231231

232232
SharedDataStream sds(ds);
233233

234-
sds << angrests.r
234+
sds << angrests.r << angrests.use_pbc
235235
<< static_cast<const Restraints &>(angrests);
236236

237237
return ds;
@@ -249,8 +249,15 @@ QDataStream &operator>>(QDataStream &ds, AngleRestraints &angrests)
249249
sds >> angrests.r >>
250250
static_cast<Restraints &>(angrests);
251251
}
252+
else if (v == 2)
253+
{
254+
SharedDataStream sds(ds);
255+
256+
sds >> angrests.r >> angrests.use_pbc
257+
>> static_cast<Restraints &>(angrests);
258+
}
252259
else
253-
throw version_error(v, "1", r_angrests, CODELOC);
260+
throw version_error(v, "1,2", r_angrests, CODELOC);
254261

255262
return ds;
256263
}
@@ -303,7 +310,7 @@ AngleRestraints::AngleRestraints(const QString &name,
303310
}
304311

305312
AngleRestraints::AngleRestraints(const AngleRestraints &other)
306-
: ConcreteProperty<AngleRestraints, Restraints>(other), r(other.r)
313+
: ConcreteProperty<AngleRestraints, Restraints>(other), r(other.r), use_pbc(other.use_pbc)
307314
{
308315
}
309316

@@ -318,14 +325,15 @@ AngleRestraints &AngleRestraints::operator=(const AngleRestraints &other)
318325
{
319326
Restraints::operator=(other);
320327
r = other.r;
328+
use_pbc = other.use_pbc;
321329
}
322330

323331
return *this;
324332
}
325333

326334
bool AngleRestraints::operator==(const AngleRestraints &other) const
327335
{
328-
return r == other.r and Restraints::operator==(other);
336+
return r == other.r and Restraints::operator==(other) and use_pbc == other.use_pbc;
329337
}
330338

331339
bool AngleRestraints::operator!=(const AngleRestraints &other) const
@@ -379,9 +387,10 @@ QString AngleRestraints::toString() const
379387
}
380388
}
381389

382-
return QObject::tr("AngleRestraints( name=%1, size=%2\n%3\n )")
390+
return QObject::tr("AngleRestraints( name=%1, size=%2, use_pbc=%3\n%4\n )")
383391
.arg(this->name())
384392
.arg(n)
393+
.arg(this->use_pbc ? "true" : "false")
385394
.arg(parts.join("\n"));
386395
}
387396

@@ -477,3 +486,15 @@ AngleRestraints AngleRestraints::operator+(const AngleRestraints &restraints) co
477486
ret += restraints;
478487
return *this;
479488
}
489+
490+
/** Set whether or not periodic boundary conditions are to be used */
491+
void AngleRestraints::setUsesPbc(bool use_pbc)
492+
{
493+
this->use_pbc = use_pbc;
494+
}
495+
496+
/** Return whether or not periodic boundary conditions are to be used */
497+
bool AngleRestraints::usesPbc() const
498+
{
499+
return this->use_pbc;
500+
}

corelib/src/libs/SireMM/anglerestraints.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,15 @@ namespace SireMM
161161
AngleRestraints operator+(const AngleRestraint &restraint) const;
162162
AngleRestraints operator+(const AngleRestraints &restraints) const;
163163

164+
void setUsesPbc(bool use_pbc);
165+
bool usesPbc() const;
166+
164167
private:
165168
/** List of restraints */
166169
QList<AngleRestraint> r;
170+
171+
/** Whether the restraints use periodic boundary conditions */
172+
bool use_pbc = false;
167173
};
168174
}
169175

corelib/src/libs/SireMM/bondrestraints.cpp

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -350,11 +350,11 @@ static const RegisterMetaType<BondRestraints> r_bndrests;
350350

351351
QDataStream &operator<<(QDataStream &ds, const BondRestraints &bndrests)
352352
{
353-
writeHeader(ds, r_bndrests, 1);
353+
writeHeader(ds, r_bndrests, 2);
354354

355355
SharedDataStream sds(ds);
356356

357-
sds << bndrests.r
357+
sds << bndrests.r << bndrests.use_pbc
358358
<< static_cast<const Restraints &>(bndrests);
359359

360360
return ds;
@@ -370,8 +370,15 @@ QDataStream &operator>>(QDataStream &ds, BondRestraints &bndrests)
370370

371371
sds >> bndrests.r >> static_cast<Restraints &>(bndrests);
372372
}
373+
else if (v == 2)
374+
{
375+
SharedDataStream sds(ds);
376+
377+
sds >> bndrests.r >> bndrests.use_pbc
378+
>> static_cast<Restraints &>(bndrests);
379+
}
373380
else
374-
throw version_error(v, "1", r_bndrests, CODELOC);
381+
throw version_error(v, "1,2", r_bndrests, CODELOC);
375382

376383
return ds;
377384
}
@@ -424,7 +431,7 @@ BondRestraints::BondRestraints(const QString &name,
424431
}
425432

426433
BondRestraints::BondRestraints(const BondRestraints &other)
427-
: ConcreteProperty<BondRestraints, Restraints>(other), r(other.r)
434+
: ConcreteProperty<BondRestraints, Restraints>(other), r(other.r), use_pbc(other.use_pbc)
428435
{
429436
}
430437

@@ -435,13 +442,14 @@ BondRestraints::~BondRestraints()
435442
BondRestraints &BondRestraints::operator=(const BondRestraints &other)
436443
{
437444
r = other.r;
445+
use_pbc = other.use_pbc;
438446
Restraints::operator=(other);
439447
return *this;
440448
}
441449

442450
bool BondRestraints::operator==(const BondRestraints &other) const
443451
{
444-
return r == other.r and Restraints::operator==(other);
452+
return r == other.r and Restraints::operator==(other) and use_pbc == other.use_pbc;
445453
}
446454

447455
bool BondRestraints::operator!=(const BondRestraints &other) const
@@ -495,7 +503,11 @@ QString BondRestraints::toString() const
495503
}
496504
}
497505

498-
return QObject::tr("BondRestraints( name=%1, size=%2\n%3\n)").arg(this->name()).arg(n).arg(parts.join("\n"));
506+
return QObject::tr("BondRestraints( name=%1, size=%2, use_pbc=$3\n%4\n)")
507+
.arg(this->name())
508+
.arg(n)
509+
.arg(this->use_pbc ? "true" : "false")
510+
.arg(parts.join("\n"));
499511
}
500512

501513
/** Return whether or not this is empty */
@@ -678,3 +690,15 @@ BondRestraints BondRestraints::operator+(const BondRestraints &restraints) const
678690
ret += restraints;
679691
return *this;
680692
}
693+
694+
/** Set whether or not periodic boundary conditions are to be used */
695+
void BondRestraints::setUsesPbc(bool use_pbc)
696+
{
697+
this->use_pbc = use_pbc;
698+
}
699+
700+
/** Return whether or not periodic boundary conditions are to be used */
701+
bool BondRestraints::usesPbc() const
702+
{
703+
return this->use_pbc;
704+
}

corelib/src/libs/SireMM/bondrestraints.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,15 @@ namespace SireMM
191191
BondRestraints operator+(const BondRestraint &restraint) const;
192192
BondRestraints operator+(const BondRestraints &restraints) const;
193193

194+
void setUsesPbc(bool use_pbc);
195+
bool usesPbc() const;
196+
194197
private:
195198
/** The actual list of restraints*/
196199
QList<BondRestraint> r;
200+
201+
/** Whether the restraints use periodic boundary conditions */
202+
bool use_pbc = false;
197203
};
198204

199205
}

corelib/src/libs/SireMM/boreschrestraints.cpp

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ QDataStream &operator>>(QDataStream &ds, BoreschRestraint &borrest)
7474
{
7575
SharedDataStream sds(ds);
7676

77-
sds >> borrest.receptor_atms >> borrest.ligand_atms >> borrest._r0 >> borrest._theta0 >> borrest._phi0 >> borrest._kr >> borrest._ktheta >> borrest._kphi >> static_cast<Property &>(borrest);
77+
sds >> borrest.receptor_atms >> borrest.ligand_atms >> borrest._r0
78+
>> borrest._theta0 >> borrest._phi0 >> borrest._kr >> borrest._ktheta
79+
>> borrest._kphi >> static_cast<Property &>(borrest);
7880
}
7981
else
8082
throw version_error(v, "1", r_borrest, CODELOC);
@@ -343,11 +345,11 @@ static const RegisterMetaType<BoreschRestraints> r_borrests;
343345

344346
QDataStream &operator<<(QDataStream &ds, const BoreschRestraints &borrests)
345347
{
346-
writeHeader(ds, r_borrests, 1);
348+
writeHeader(ds, r_borrests, 2);
347349

348350
SharedDataStream sds(ds);
349351

350-
sds << borrests.r
352+
sds << borrests.r << borrests.use_pbc
351353
<< static_cast<const Restraints &>(borrests);
352354

353355
return ds;
@@ -363,8 +365,15 @@ QDataStream &operator>>(QDataStream &ds, BoreschRestraints &borrests)
363365

364366
sds >> borrests.r >> static_cast<Restraints &>(borrests);
365367
}
368+
else if (v == 2)
369+
{
370+
SharedDataStream sds(ds);
371+
372+
sds >> borrests.r >> borrests.use_pbc
373+
>> static_cast<Restraints &>(borrests);
374+
}
366375
else
367-
throw version_error(v, "1", r_borrests, CODELOC);
376+
throw version_error(v, "1,2", r_borrests, CODELOC);
368377

369378
return ds;
370379
}
@@ -417,7 +426,7 @@ BoreschRestraints::BoreschRestraints(const QString &name,
417426
}
418427

419428
BoreschRestraints::BoreschRestraints(const BoreschRestraints &other)
420-
: ConcreteProperty<BoreschRestraints, Restraints>(other), r(other.r)
429+
: ConcreteProperty<BoreschRestraints, Restraints>(other), r(other.r), use_pbc(other.use_pbc)
421430
{
422431
}
423432

@@ -428,13 +437,15 @@ BoreschRestraints::~BoreschRestraints()
428437
BoreschRestraints &BoreschRestraints::operator=(const BoreschRestraints &other)
429438
{
430439
r = other.r;
440+
use_pbc = other.use_pbc;
431441
Restraints::operator=(other);
432442
return *this;
433443
}
434444

435445
bool BoreschRestraints::operator==(const BoreschRestraints &other) const
436446
{
437-
return r == other.r and Restraints::operator==(other);
447+
return r == other.r and Restraints::operator==(other) and
448+
use_pbc == other.use_pbc;
438449
}
439450

440451
bool BoreschRestraints::operator!=(const BoreschRestraints &other) const
@@ -488,7 +499,11 @@ QString BoreschRestraints::toString() const
488499
}
489500
}
490501

491-
return QObject::tr("BoreschRestraints( name=%1, size=%2\n%3\n)").arg(this->name()).arg(n).arg(parts.join("\n"));
502+
return QObject::tr("BoreschRestraints( name=%1, size=%2, use_pbc=%3\n%4\n)")
503+
.arg(this->name())
504+
.arg(n)
505+
.arg(this->use_pbc ? "true" : "false")
506+
.arg(parts.join("\n"));
492507
}
493508

494509
/** Return whether or not this is empty */
@@ -583,3 +598,15 @@ BoreschRestraints BoreschRestraints::operator+(const BoreschRestraints &restrain
583598
ret += restraints;
584599
return *this;
585600
}
601+
602+
/** Set whether or not periodic boundary conditions are to be used */
603+
void BoreschRestraints::setUsesPbc(bool use_pbc)
604+
{
605+
this->use_pbc = use_pbc;
606+
}
607+
608+
/** Return whether or not periodic boundary conditions are to be used */
609+
bool BoreschRestraints::usesPbc() const
610+
{
611+
return this->use_pbc;
612+
}

corelib/src/libs/SireMM/boreschrestraints.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,15 @@ namespace SireMM
194194
BoreschRestraints operator+(const BoreschRestraint &restraint) const;
195195
BoreschRestraints operator+(const BoreschRestraints &restraints) const;
196196

197+
void setUsesPbc(bool use_pbc);
198+
bool usesPbc() const;
199+
197200
private:
198201
/** The actual list of restraints*/
199202
QList<BoreschRestraint> r;
203+
204+
/** Whether the restraints use periodic boundary conditions */
205+
bool use_pbc = false;
200206
};
201207

202208
}

0 commit comments

Comments
 (0)