Skip to content

Commit

Permalink
add new radius_factor keyword.
Browse files Browse the repository at this point in the history
  • Loading branch information
moritzgubler committed Aug 7, 2024
1 parent 6c75108 commit 4992efd
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 10 deletions.
6 changes: 6 additions & 0 deletions doc/users/user_ref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,12 @@ User input reference
**Predicates**
- ``value.lower() in ['low', 'medium', 'high']``

:radius_factor: Sets the radius of the surface used in the computation of forces. The radius is given by this factor times the distance to the neariest neighbour. Must be between 0.1 and 0.9. This should rarely need to be changed. Different values can change the accuracy of the forces.

**Type** ``float``

**Default** ``0.6``

:ExternalFields: Define external electromagnetic fields.

:red:`Keywords`
Expand Down
1 change: 1 addition & 0 deletions python/mrchem/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ def write_scf_properties(user_dict, origin):
"smoothing": user_dict["Precisions"]["nuclear_prec"],
"method": user_dict["Forces"]["method"],
"surface_integral_precision": user_dict["Forces"]["surface_integral_precision"],
"radius_factor": user_dict["Forces"]["radius_factor"],
}
return prop_dict

Expand Down
2 changes: 1 addition & 1 deletion python/mrchem/input_parser/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
This file was automatically generated by parselglossy on 2024-08-01
This file was automatically generated by parselglossy on 2024-08-07
Editing is *STRONGLY DISCOURAGED*
2 changes: 1 addition & 1 deletion python/mrchem/input_parser/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-

# This file was automatically generated by parselglossy on 2024-08-01
# This file was automatically generated by parselglossy on 2024-08-07
# Editing is *STRONGLY DISCOURAGED*
7 changes: 5 additions & 2 deletions python/mrchem/input_parser/api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

# This file was automatically generated by parselglossy on 2024-08-01
# This file was automatically generated by parselglossy on 2024-08-07
# Editing is *STRONGLY DISCOURAGED*

from copy import deepcopy
Expand Down Expand Up @@ -376,7 +376,10 @@ def stencil() -> JSONDict:
"in ['low', "
"'medium', "
"'high']"],
'type': 'str'}],
'type': 'str'},
{ 'default': 0.6,
'name': 'radius_factor',
'type': 'float'}],
'name': 'Forces'},
{ 'keywords': [ { 'default': [],
'name': 'electric_field',
Expand Down
2 changes: 1 addition & 1 deletion python/mrchem/input_parser/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

# This file was automatically generated by parselglossy on 2024-08-01
# This file was automatically generated by parselglossy on 2024-08-07
# Editing is *STRONGLY DISCOURAGED*

import argparse
Expand Down
6 changes: 6 additions & 0 deletions python/mrchem/input_parser/docs/user_ref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,12 @@ User input reference
**Predicates**
- ``value.lower() in ['low', 'medium', 'high']``

:radius_factor: Sets the radius of the surface used in the computation of forces. The radius is given by this factor times the distance to the neariest neighbour. Must be between 0.1 and 0.9. This should rarely need to be changed. Different values can change the accuracy of the forces.

**Type** ``float``

**Default** ``0.6``

:ExternalFields: Define external electromagnetic fields.

:red:`Keywords`
Expand Down
2 changes: 1 addition & 1 deletion python/mrchem/input_parser/plumbing/lexer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

# This file was automatically generated by parselglossy on 2024-08-01
# This file was automatically generated by parselglossy on 2024-08-07
# Editing is *STRONGLY DISCOURAGED*

import json
Expand Down
7 changes: 7 additions & 0 deletions python/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,13 @@ sections:
docstring: |
Precision of the surface integrals used in the computation of forces. Determines the number of Lebedev grid points used in the
surface integration.
- name: radius_factor
type: float
default: 0.6
docstring: |
Sets the radius of the surface used in the computation of forces.
The radius is given by this factor times the distance to the neariest neighbour. Must be between 0.1 and 0.9.
This should rarely need to be changed. Different values can change the accuracy of the forces.
- name: ExternalFields
docstring: |
Define external electromagnetic fields.
Expand Down
3 changes: 2 additions & 1 deletion src/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,8 @@ void driver::scf::calc_properties(const json &json_prop, Molecule &mol, const js
Timer t_surface;
t_surface.start();
std::string leb_prec = json_prop["geometric_derivative"]["geom-1"]["surface_integral_precision"];
Eigen::MatrixXd surfaceForces = surface_force::surface_forces(mol, Phi, prec, json_fock, leb_prec);
double radius_factor = json_prop["geometric_derivative"]["geom-1"]["radius_factor"];
Eigen::MatrixXd surfaceForces = surface_force::surface_forces(mol, Phi, prec, json_fock, leb_prec, radius_factor);
t_surface.stop();
GeometricDerivative &G = mol.getGeometricDerivative("geom-1");
auto &nuc = G.getNuclear();
Expand Down
9 changes: 7 additions & 2 deletions src/surface_forces/SurfaceForce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,12 @@ VectorXd distanceToNearestNeighbour(MatrixXd pos){
* @return The matrix of forces, shape (nAtoms, 3).
*/
Eigen::MatrixXd surface_forces(mrchem::Molecule &mol, mrchem::OrbitalVector &Phi, double prec, const json &json_fock
, std::string leb_prec) {
, std::string leb_prec, double radius_factor) {

if (radius_factor > 0.95 && radius_factor < 0.05){
MSG_ABORT("Invalid value of radius_factor")
}
std::cout << "Radius factor " << radius_factor << std::endl;

// setup density
mrchem::Density rho(false);
Expand Down Expand Up @@ -357,7 +362,7 @@ Eigen::MatrixXd surface_forces(mrchem::Molecule &mol, mrchem::OrbitalVector &Phi
Eigen::MatrixXd forces = Eigen::MatrixXd::Zero(numAtoms, 3);

for (int iAtom = 0; iAtom < numAtoms; iAtom++) {
radius = dist(iAtom) * .6;
radius = dist(iAtom) * radius_factor;
coord = mol.getNuclei()[iAtom].getCoord();
center << coord[0], coord[1], coord[2];

Expand Down
2 changes: 1 addition & 1 deletion src/surface_forces/SurfaceForce.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace surface_force {

// Function declaration
Eigen::MatrixXd surface_forces(mrchem::Molecule &mol, mrchem::OrbitalVector &Phi, double prec
, const json &json_fock, std::string leb_prec);
, const json &json_fock, std::string leb_prec, double radius_factor);

} // namespace surface_force

Expand Down

0 comments on commit 4992efd

Please sign in to comment.