Skip to content

Allow setting the number of grid points in the short range eward summation of Coulomb interaction#4928

Merged
ye-luo merged 22 commits intoQMCPACK:developfrom
Paul-St-Young:vr_spline_grid
Mar 4, 2024
Merged

Allow setting the number of grid points in the short range eward summation of Coulomb interaction#4928
ye-luo merged 22 commits intoQMCPACK:developfrom
Paul-St-Young:vr_spline_grid

Conversation

@Paul-St-Young
Copy link
Copy Markdown
Contributor

Proposed changes

Avoid instantiation of LinearGrid object at call time in createSpline4RbyVs*, because it silently defaults to 1001 grid points without user control.
Instead, I added a new ewald_grid input to set the density of the linear grid, which is used to interpolate the short-range part of the Ewald Coulomb interaction.

What type(s) of changes does this code introduce?

  • Refactoring

Does this introduce a breaking change?

  • No

What systems has this change been tested on?

Intel workstation

Checklist

  • Yes. This PR is up to date with current the current state of 'develop'
  • No. Code added or changed in the PR has been clang-formatted
  • No. This PR adds tests to cover any new code, or to catch a bug that is being fixed
  • No. Documentation has been added (if appropriate)

@prckent
Copy link
Copy Markdown
Contributor

prckent commented Feb 15, 2024

Test this please

Copy link
Copy Markdown
Contributor

@ye-luo ye-luo left a comment

Choose a reason for hiding this comment

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

Since there are many pointer manipulation, I will need to review it more closely. For now, could you put up a manual entry explaining what is "ewald_grid"? It is ewald related but what grid it is and how it's been used?

Copy link
Copy Markdown
Contributor

@ye-luo ye-luo left a comment

Choose a reason for hiding this comment

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

I'm still going through CoulombPBCAB about how grids are managed. Please address other comment.

Comment thread docs/simulationcell.rst Outdated
+---------------------+--------------+---------------------------+-------------------+----------------------------------------------------+
| ``LR_tol`` | float | float | 3e-4 | Tolerance in Ha for Ewald ion-ion energy per atom. |
+---------------------+--------------+---------------------------+-------------------+----------------------------------------------------+
| ``ewald_grid`` | int | int | 1001 | Linear grid used for short-range part of Ewald. |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"The number of linear grid points used for ..."

///number of strictly enforced periodic spatial dimensions
/// ewald_strict2d sets ndim=2, otherwise ndim=3
unsigned ndim;
unsigned ewaldGrid;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In the source code, we better to use a clear name for the variable. "ewald_num_grid_points". Also please add a line of documentation.

Comment thread src/Particle/LongRange/LRCoulombSingleton.h
Comment thread src/QMCHamiltonians/CoulombPBCAA.h Outdated
///cutoff radius of the short-range part
RealType myRcut;
///radial grid
std::shared_ptr<GridType> myGrid;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just define it locally in initBreakup. I don't even think we need a pointer.

Copy link
Copy Markdown
Contributor

@ye-luo ye-luo left a comment

Choose a reason for hiding this comment

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

@Paul-St-Young please address my review when you get a chance.

RealType h; //this is for finite differencing.
std::vector<PosType> sphericalgrid;
GridType* myGrid;
std::shared_ptr<GridType> myGrid;
Copy link
Copy Markdown
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 you choose shared_ptr. Should be "unique_ptr"

@Paul-St-Young
Copy link
Copy Markdown
Contributor Author

@ye-luo thanks for the great suggestions!
Indeed, no pointer to the LinearGrid is needed in any of the cases I touched.

@ye-luo
Copy link
Copy Markdown
Contributor

ye-luo commented Feb 23, 2024

Test this please

@ye-luo ye-luo changed the title forbid nullptr as LinearGrid input to createSpline4RbyVs Allow setting the number of grid points in the short range eward summation of Coulomb interaction Feb 23, 2024
@ye-luo
Copy link
Copy Markdown
Contributor

ye-luo commented Feb 23, 2024

@Paul-St-Young did you play with the number of grid points and what was your finding?

ye-luo
ye-luo previously approved these changes Feb 23, 2024
Comment thread docs/simulationcell.rst Outdated
+---------------------+--------------+---------------------------+-------------------+----------------------------------------------------+
| ``LR_tol`` | float | float | 3e-4 | Tolerance in Ha for Ewald ion-ion energy per atom. |
+---------------------+--------------+---------------------------+-------------------+----------------------------------------------------+
| ``ewald_grid`` | int | int | 1001 | The number of linear grid points used for short-range part of the Ewald potential. |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There is formatting issue causing the table not being rendered.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Took care of.

Comment thread src/Particle/Lattice/CrystalLattice.h Outdated
Base::LR_dim_cutoff = rhs.LR_dim_cutoff;
Base::LR_kc = rhs.LR_kc;
Base::LR_rc = rhs.LR_rc;
Base::num_ewald_grid_points = rhs.num_ewald_grid_points;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Run clang-format please.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Took care of.

@ye-luo ye-luo enabled auto-merge February 23, 2024 17:06
@prckent
Copy link
Copy Markdown
Contributor

prckent commented Feb 23, 2024

Very happy to see the exposure of this hidden default. Thanks Paul

Weirdly the estimator unit test failed in the complex coverage test. Will retry it.

@ye-luo
Copy link
Copy Markdown
Contributor

ye-luo commented Feb 23, 2024

Very happy to see the exposure of this hidden default. Thanks Paul

Weirdly the estimator unit test failed in the complex coverage test. Will retry it.

Still failing @PDoakORNL any clue? https://github.com/QMCPACK/qmcpack/actions/runs/8022503383/job/21922019273?pr=4928

@Paul-St-Young
Copy link
Copy Markdown
Contributor Author

Paul-St-Young commented Feb 24, 2024

@ye-luo Yes, I tried different number of grid points for both the bare and screened Coulomb potential.
In the bare Coulomb case, 1001 grid points has never been a problem.
However, much denser grid is needed for the screened potential in a large supercell, because it falls off more quickly than the bare Coulomb. For example, if the screened potential vanishes at Rcut/10, then effectively its using only 100 grid points. One can also imagine using a more wiggly effective e-e interaction, which would require more grid points to represent accurately.

Short answer: the number of grid points may need adjustment if people want to use anything other than 1/r interaction.

@ye-luo
Copy link
Copy Markdown
Contributor

ye-luo commented Mar 4, 2024

Test this please

@ye-luo ye-luo merged commit fc5089c into QMCPACK:develop Mar 4, 2024
@Paul-St-Young Paul-St-Young deleted the vr_spline_grid branch March 13, 2024 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants