Skip to content

Commit

Permalink
Merge pull request #111 from OpenBioSim/feature_bond_breaking
Browse files Browse the repository at this point in the history
Feature bond breaking
  • Loading branch information
chryswoods authored Oct 10, 2023
2 parents 1d1c97f + 7599bba commit 9e4edb8
Show file tree
Hide file tree
Showing 63 changed files with 4,125 additions and 578 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ To create a new environment:
mamba create -n openbiosim "python<3.11"
mamba activate openbiosim
mamba install -c openbiosim sire
mamba install -c conda-forge -c openbiosim sire
To install the latest development version you can use:

.. code-block:: bash
mamba create -n openbiosim-dev "python<3.11"
mamba activate openbiosim-dev
mamba install -c openbiosim/label/dev sire
mamba install -c conda-forge -c openbiosim/label/dev sire
However, as you are here, it is likely you want to download the latest,
greatest version of the code, which you will need to compile. To compile
Expand Down
38 changes: 31 additions & 7 deletions corelib/src/libs/SireCAS/lambdaschedule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,14 +432,23 @@ void LambdaSchedule::clear()
this->constant_values = Values();
}

/** Append a morph stage onto this schedule. The morph stage is a
* standard stage that scales each forcefield parameter by
* (1-:lambda:).initial + :lambda:.final
*/
void LambdaSchedule::addMorphStage(const QString &name)
{
this->addStage(name, (this->lam() * this->final()) +
((1 - this->lam()) * this->initial()));
}

/** Append a morph stage onto this schedule. The morph stage is a
* standard stage that scales each forcefield parameter by
* (1-:lambda:).initial + :lambda:.final
*/
void LambdaSchedule::addMorphStage()
{
this->addStage("morph", (this->lam() * this->final()) +
((1 - this->lam()) * this->initial()));
this->addMorphStage("morph");
}

/** Sandwich the current set of stages with a charge-descaling and
Expand All @@ -450,7 +459,9 @@ void LambdaSchedule::addMorphStage()
* by :gamma:. A final charge-rescaling stage is then appended that
* scales the charge parameter from :gamma:.final to final.
*/
void LambdaSchedule::addChargeScaleStages(double scale)
void LambdaSchedule::addChargeScaleStages(const QString &decharge_name,
const QString &recharge_name,
double scale)
{
auto scl = this->setConstant("γ", scale);

Expand All @@ -462,11 +473,24 @@ void LambdaSchedule::addChargeScaleStages(double scale)
}

// now prepend the decharging stage, and append the recharging stage
this->prependStage("decharge", this->initial());
this->appendStage("recharge", this->final());
this->prependStage(decharge_name, this->initial());
this->appendStage(recharge_name, this->final());

this->setEquation(decharge_name, "charge", (1.0 - ((1.0 - scl) * this->lam())) * this->initial());
this->setEquation(recharge_name, "charge", (1.0 - ((1.0 - scl) * (1.0 - this->lam()))) * this->final());
}

this->setEquation("decharge", "charge", (1.0 - ((1.0 - scl) * this->lam())) * this->initial());
this->setEquation("recharge", "charge", (1.0 - ((1.0 - scl) * (1.0 - this->lam()))) * this->final());
/** Sandwich the current set of stages with a charge-descaling and
* a charge-scaling stage. This prepends a charge-descaling stage
* that scales the charge parameter down from `initial` to
* :gamma:.initial (where :gamma:=`scale`). The charge parameter in all of
* the exising stages in this schedule are then multiplied
* by :gamma:. A final charge-rescaling stage is then appended that
* scales the charge parameter from :gamma:.final to final.
*/
void LambdaSchedule::addChargeScaleStages(double scale)
{
this->addChargeScaleStages("decharge", "recharge", scale);
}

/** Prepend a stage called 'name' which uses the passed 'equation'
Expand Down
5 changes: 5 additions & 0 deletions corelib/src/libs/SireCAS/lambdaschedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,12 @@ namespace SireCAS
const SireCAS::Expression &equation);

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

void addChargeScaleStages(double scale = 0.2);
void addChargeScaleStages(const QString &decharge_name,
const QString &recharge_name,
double scale = 0.2);

void setEquation(const QString &stage,
const QString &lever,
Expand Down
46 changes: 30 additions & 16 deletions corelib/src/libs/SireIO/moleculeparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2323,17 +2323,24 @@ QStringList MoleculeParser::write(const System &system, const QString &filename,
QStringList filenames;
QStringList fileformats;

const auto format_property = map["fileformat"];

if (format_property.hasValue())
if (map.specified("fileformat"))
{
try
const auto format_property = map["fileformat"];

if (format_property.hasSource())
{
fileformats = format_property.value().asA<StringProperty>().toString().split(",");
fileformats = format_property.source().split(",");
}
catch (...)
else
{
fileformats.append(format_property.value().asA<MoleculeParser>().formatName());
try
{
fileformats = format_property.value().asA<StringProperty>().toString().split(",");
}
catch (...)
{
fileformats.append(format_property.value().asA<MoleculeParser>().formatName());
}
}

const auto fileinfo = QFileInfo(filename);
Expand All @@ -2353,7 +2360,7 @@ QStringList MoleculeParser::write(const System &system, const QString &filename,
// we need to find the format from the system
try
{
fileformats = system.property(format_property).asA<StringProperty>().toString().split(",");
fileformats = system.property(map["fileformat"]).asA<StringProperty>().toString().split(",");
}
catch (...)
{
Expand Down Expand Up @@ -2404,17 +2411,24 @@ QStringList MoleculeParser::write(const System &system, const QStringList &files
QStringList filenames;
QStringList fileformats;

const auto format_property = map["fileformat"];

if (format_property.hasValue())
if (map.specified("fileformat"))
{
try
const auto format_property = map["fileformat"];

if (format_property.hasSource())
{
fileformats = format_property.value().asA<StringProperty>().toString().split(",");
fileformats = format_property.source().split(",");
}
catch (...)
else
{
fileformats.append(format_property.value().asA<MoleculeParser>().formatName());
try
{
fileformats = format_property.value().asA<StringProperty>().toString().split(",");
}
catch (...)
{
fileformats.append(format_property.value().asA<MoleculeParser>().formatName());
}
}

if (files.count() != fileformats.count())
Expand Down Expand Up @@ -2449,7 +2463,7 @@ QStringList MoleculeParser::write(const System &system, const QStringList &files
// we may need to find the format from the system
try
{
fileformats = system.property(format_property).asA<StringProperty>().toString().split(",");
fileformats = system.property(map["fileformat"]).asA<StringProperty>().toString().split(",");
}
catch (...)
{
Expand Down
Loading

0 comments on commit 9e4edb8

Please sign in to comment.