Skip to content

Draft:Lambda dynamics module interface

Pavel Buslaev requested to merge pbuslaev-lambdaDynamics-module-interface into main

Implementation of Lambda Dynamics module interface. All basic data structures are implemented, as well as reading all data from mdp file. This includes also an additional grompp option, to pass a file with lambda dynamics force field parameters and a new energy contribution to edr. This new energy term might be causing the tests, which use reference tpr files to fail.

Currently, there is no initialization of AtomSets, because it might require the change in the MDModule preprocessing. Now, mdp options are first all read (initMdpTransform), and then the parameters for those are initialized (assignOptionsToModules):

 {
        gmx::KeyValueTreeObject      convertedValues = flatKeyValueTreeFromInpFile(inp);
        gmx::KeyValueTreeTransformer transform;
        transform.rules()->addRule().keyMatchType("/", gmx::StringCompareType::CaseAndDashInsensitive);
        mdModules->initMdpTransform(transform.rules());
        for (const auto& path : transform.mappedPaths())
        {
            GMX_ASSERT(path.size() == 1, "Inconsistent mapping back to mdp options");
            mark_einp_set(inp, path[0].c_str());
        }
        MdpErrorHandler errorHandler(wi);
        auto            result = transform.transform(convertedValues, &errorHandler);
        ir->params             = new gmx::KeyValueTreeObject(result.object());
        mdModules->adjustInputrecBasedOnModules(ir);
        errorHandler.setBackMapping(result.backMapping());
        mdModules->assignOptionsToModules(*ir->params, &errorHandler);
    }

This doesn't work if we need to assign options with names depending on the previous input (like in COM pulling, where the number and name of pull-groupX-name depend on pull-ngroups). This can be overcome by either adding addition callbacks (e.g. initMdpDependentTransform and assignDependentOptionsToModules), or by merging declaration of mdp options with initialization.

Related to issue #4273 and MR !2730

Merge request reports