Skip to content

Commit

Permalink
Merge branch 'feature_optimise_lever' of https://github.com/openbiosi…
Browse files Browse the repository at this point in the history
…m/sire into feature_format
  • Loading branch information
chryswoods committed Dec 6, 2023
2 parents f0db241 + 07e8dea commit 4a26299
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 36 deletions.
87 changes: 53 additions & 34 deletions corelib/src/libs/SireIO/moleculeparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1929,8 +1929,19 @@ MoleculeParserPtr MoleculeParser::parse(const System &system, const QString &for
cannot be recognised, or if there is an error in parsing. */
MoleculeParserPtr MoleculeParser::parse(const QString &filename, const PropertyMap &map)
{
MoleculeParserPtr parser = MoleculeParser::_pvt_parse(filename, map);
getFileCache()->clear();
MoleculeParserPtr parser;

try
{
parser = MoleculeParser::_pvt_parse(filename, map);
getFileCache()->clear();
}
catch (...)
{
getFileCache()->clear();
throw;
}

return parser;
}

Expand All @@ -1939,48 +1950,56 @@ QList<MoleculeParserPtr> MoleculeParser::parse(const QStringList &filenames, con
{
QList<MoleculeParserPtr> result;

if (filenames.count() == 1)
{
result.append(MoleculeParser::_pvt_parse(filenames[0], map));
}
else
try
{
QVector<MoleculeParserPtr> parsers(filenames.count());

bool run_parallel = true;

if (map["parallel"].hasValue())
if (filenames.count() == 1)
{
run_parallel = map["parallel"].value().asA<BooleanProperty>().value();
}

if (run_parallel)
{
// parse the files in parallel - we use a grain size of 1
// as each file can be pretty big, and there won't be many of them
tbb::parallel_for(
tbb::blocked_range<int>(0, filenames.count(), 1),
[&](tbb::blocked_range<int> r)
{
for (int i = r.begin(); i < r.end(); ++i)
{
parsers[i] = MoleculeParser::_pvt_parse(filenames[i], map);
}
},
tbb::simple_partitioner());
result.append(MoleculeParser::_pvt_parse(filenames[0], map));
}
else
{
for (int i = 0; i < filenames.count(); ++i)
QVector<MoleculeParserPtr> parsers(filenames.count());

bool run_parallel = true;

if (map["parallel"].hasValue())
{
run_parallel = map["parallel"].value().asA<BooleanProperty>().value();
}

if (run_parallel)
{
parsers[i] = MoleculeParser::_pvt_parse(filenames[i], map);
// parse the files in parallel - we use a grain size of 1
// as each file can be pretty big, and there won't be many of them
tbb::parallel_for(
tbb::blocked_range<int>(0, filenames.count(), 1),
[&](tbb::blocked_range<int> r)
{
for (int i = r.begin(); i < r.end(); ++i)
{
parsers[i] = MoleculeParser::_pvt_parse(filenames[i], map);
}
},
tbb::simple_partitioner());
}
else
{
for (int i = 0; i < filenames.count(); ++i)
{
parsers[i] = MoleculeParser::_pvt_parse(filenames[i], map);
}
}

result = parsers.toList();
}

result = parsers.toList();
getFileCache()->clear();
}
catch (...)
{
getFileCache()->clear();
throw;
}

getFileCache()->clear();

return result;
}
Expand Down
10 changes: 8 additions & 2 deletions wrapper/Convert/SireOpenMM/openmmmolecule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,11 +500,17 @@ void OpenMMMolecule::constructFromAmber(const Molecule &mol,
double sig = lj.sigma().to(SireUnits::nanometer);
double eps = lj.epsilon().to(SireUnits::kJ_per_mol);

if (std::abs(sig) < 1e-9)
if (sig == 0)
{
// this must be a null parameter
// Using eps=0 sig=1 causes instability though (NaN errors)
// so we will set sig=1e-9. This seems to be more stable
eps = 0;
sig = 1;
sig = 1e-9;
}
else if (std::abs(sig) < 1e-9)
{
sig = 1e-9;
}

cljs_data[i] = std::make_tuple(chg, sig, eps);
Expand Down

0 comments on commit 4a26299

Please sign in to comment.