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

Bug in Basis.cpp regarding component ID #315

Open
HomesGH opened this issue May 30, 2024 · 0 comments · May be fixed by #319
Open

Bug in Basis.cpp regarding component ID #315

HomesGH opened this issue May 30, 2024 · 0 comments · May be fixed by #319
Assignees
Labels
bug Something isn't working

Comments

@HomesGH
Copy link
Contributor

HomesGH commented May 30, 2024

Describe the bug
In ls1 in general, the usage of the component ID is very error-prone since it starts internally with 0 and externally (e.g. in the config.xml) with a 1. This leads to a bug in the Basis.cpp where the externally specified component ID does not start with a 1.
See here:

xmlconfig.getNodeValue("componentid", componentid);
molecule.setComponent(ensemble->getComponent(componentid));

 

It should be as in the ReplicaFiller.cpp:

if (xmlconfig.getNodeValue("componentid", componentid)) {
const size_t numComps = global_simulation->getEnsemble()->getComponents()->size();
if ((componentid < 1) || (componentid > numComps)) {
Log::global_log->error() << "[ReplicaFiller] Specified componentid is invalid. Valid range: 1 <= componentid <= " << numComps << std::endl;
Simulation::exit(1);
}
_componentid = componentid - 1; // Internally stored in array starting at index 0
_keepComponent = false;
}

 

Due to this bug, e.g., the component ID here in the Injection scenario must be 2 instead of 3 (see components.xml) to properly work.

A short-term solution would be to fix the Basis.cpp.
However, the problem with the internal vs external component ID is one of the most error-prone things in ls1. In my opinion, the components should be stored within a std::map instead of std::vector. Until now, the component ID is not really used but the position of the single component in the components vector is used as/for the "ID".

@HomesGH HomesGH added the bug Something isn't working label May 30, 2024
@HomesGH HomesGH linked a pull request Jun 4, 2024 that will close this issue
1 task
@FG-TUM FG-TUM assigned HomesGH and unassigned FG-TUM and cniethammer Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants