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

J1Spin indexing issue #4612

Merged
merged 8 commits into from
Jun 1, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove useless loop
  • Loading branch information
shivupa committed Jun 1, 2023
commit 933423de56681946e0e0e4952018ec5f64070915
8 changes: 2 additions & 6 deletions src/QMCWaveFunctions/Jastrow/J1Spin.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,8 @@ struct J1Spin : public WaveFunctionComponent
for (int i = 0; i < Nions; i++)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why loop i is even needed.
J1UniqueFunctors[source_type * NumTargetGroups + target_type]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there were more than one combination of i and j then afunc would be moved multiple times.

Looks like that is happening on line 160 😟

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very true. target_type == -1 case seems broken. That needs to be sorted out when unifying J1 and J1Spin.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah not sure what I was doing in the past but this was definitely wrong. target_type should only be -1 for spin independent J1 so the radial jastrow builder should never call this function with target_type == -1. I now raise a runtime error if we ever hit that case.

Also, yes, no loop is even needed.

auto igroup = Ions.getGroupID(i);
if (igroup == source_type)
{
for (int j = 0; j < NumTargetGroups; j++)
if (j == target_type && J1UniqueFunctors[igroup * NumTargetGroups + j] == nullptr)
J1UniqueFunctors[igroup * Nelec + j] = std::move(afunc);
}
if (igroup == source_type && J1UniqueFunctors[igroup * NumTargetGroups + target_type] == nullptr)
J1UniqueFunctors[igroup * Nelec + target_type] = std::move(afunc);
}
}
}
Expand Down