-
Notifications
You must be signed in to change notification settings - Fork 21
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
Input parsing cleaning and PhysConsts from QCelemental #404
Input parsing cleaning and PhysConsts from QCelemental #404
Conversation
…n api.py to keep the code consistent there
I believe this file python/mrchem/input_parser/plumbing/init.py should not be committed. It was the one causing problems before (reason still unknown). Are you now able to run with file in source? |
Ah, that one slipped through. Very annoying. Why has this file started causing problems? Another thing. The |
That li_solv has always had weird behavior, I'll check it out |
@robertodr do you know why this file suddenly started to appear? I think one nice way to handle the constants is to let Python define them and feed them into the C++ program through the JSON input. Then we also have complete control and can tweak the parameters without recompiling, by intercepting the input parser and edit the JSON file before execution. |
@Andersmb Which version of |
The quick solution is to ignore any change in that |
I have version |
Mystery understood then. |
0aeaeb5
to
7960907
Compare
@Gabrielgerez I discovered why the "cavity_coords": [
{
"center": [
0.0,
0.0,
0.0
],
"radius": 4.0
},
{
"center": [
0.0,
0.0,
0.0
],
"radius": 4.0
}
] Just deleting the extra sphere lead to a passing test. |
Codecov Report
@@ Coverage Diff @@
## master #404 +/- ##
==========================================
- Coverage 68.14% 68.04% -0.10%
==========================================
Files 180 182 +2
Lines 15170 15208 +38
==========================================
+ Hits 10337 10349 +12
- Misses 4833 4859 +26
Continue to review full report at Codecov.
|
I see MRCPP's pi is used once in |
Btw, I also added a
|
…e constants. Also made the spacing adaptive to the constant names.
python/mrchem/helpers.py
Outdated
"light_speed": user_dict["Constants"]["light_speed"], | ||
"derivative": user_dict["Derivatives"]["zora"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are not used in mrchem.x
, light_speed
is fetched directly form PhysicalConstants::get("ligth_speed")
and derivative
is taken as the MomentumOperator
in the kinetic energy. So just remove these two parameters.
python/template.yml
Outdated
First boundary vector for plot. | ||
- name: B | ||
type: List[float] | ||
default: [0.0, 1.0, 0.0] | ||
predicates: | ||
- len(value) == 3 | ||
docstring: | | ||
Second boundary vector for plot. | ||
- name: C | ||
type: List[float] | ||
default: [0.0, 0.0, 1.0] | ||
predicates: | ||
- len(value) == 3 | ||
docstring: | | ||
Third boundary vector for plot. | ||
- name: MPI | ||
docstring: | | ||
Define MPI related parameters. | ||
keywords: | ||
- name: numerically_exact |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the indentation has changed in the entire template.yml
file, is this intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, this must be an effect of the yaml->dict->yaml
roundtrip with ruamel.yaml
. There are some options for setting indentation - I can see if I can reproduce the original indentation scheme.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the following gets the old indentation (source: https://yaml.readthedocs.io/en/latest/detail.html#:~:text=yaml.indent(mapping%3D2%2C%20sequence%3D4%2C%20offset%3D2))
yaml.indent(sequence=4, mapping=2, offset=2)
Excerpt:
keywords:
- name: world_prec
type: float
predicates:
- 1.0e-10 < value < 1.0
docstring: |
Overall relative precision in the calculation.
- name: world_size
type: int
default: -1
predicates:
- value <= 10
docstring: |
Total size of computational domain given as 2**(``world_size``). Always cubic
and symmetric around the origin. Negative value means it will be computed
from the molecular geometry.
- name: world_unit
type: str
default: bohr
predicates:
- value.lower() in ["bohr", "angstrom"]
docstring: |
Length unit for *all* coordinates given in user input. Everything will be
converted to atomic units (bohr) before the main executable is launched,
so the JSON input is *always* given in bohrs.
- name: world_origin
type: List[float]
default: [0.0, 0.0, 0.0]
predicates:
- len(value) == 3
docstring: |
Global gauge origin of the calculation.
sections:
- name: Precisions
docstring: |
Define specific precision parameters.
keywords:
- name: nuclear_prec
type: float
default: user['world_prec']
predicates:
- 1.0e-10 < value < 1.0
docstring: |
Precision parameter used in smoothing and projection of nuclear potential.
- name: poisson_prec
type: float
default: user['world_prec']
predicates:
- 1.0e-10 < value < 1.0
docstring: |
Precision parameter used in construction of Poisson operators.
- name: exchange_prec
type: float
default: -1.0
docstring: |
Precision parameter used in construction of Exchange operators.
Negative value means it will follow the dynamic precision in SCF.
- name: helmholtz_prec
type: float
default: -1.0
docstring: |
Precision parameter used in construction of Helmholtz operators.
Negative value means it will follow the dynamic precision in SCF.
src/mrchem.cpp
Outdated
// Instantiate the physical constants singleton | ||
PhysicalConstants::Initialize(con_inp); | ||
int print_prec = json_inp["printer"]["print_prec"]; | ||
if (json_inp["printer"]["print_constants"]) PhysicalConstants::Print(print_prec); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about the print_prec
for this output. If you want to print it (print_constants == true
), then you probably want the exact value that is used? There's also plenty of space on the line here, so I suggest we just fix it to print_prec = 14
decimal places here.
src/chemistry/PhysicalConstants.cpp
Outdated
double val = item.value().get<double>(); | ||
print_utils::scalar(0, key, val, "", pprec, true); | ||
} | ||
mrcpp::print::separator(0, '='); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add some more space between this output and the next:
mrcpp::print::separator(0, '=', 2);
src/utils/print_utils.cpp
Outdated
@@ -122,7 +122,7 @@ void print_utils::coord(int level, const std::string &txt, const mrcpp::Coord<3> | |||
void print_utils::scalar(int level, const std::string &txt, double val, const std::string &unit, int p, bool s) { | |||
if (p < 0) p = Printer::getPrecision(); | |||
int w0 = Printer::getWidth() - 2; | |||
int w1 = w0 * 2 / 9; | |||
int w1 = w0 * 2 / 10; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This misaligned some of the :
's in the output, but with the old value the name hartree2simagnetizability
becomes too long... Perhaps abbreviate magnetizability?
|
||
|
||
from pathlib import Path | ||
from ruamel.yaml import YAML |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ruamel.yaml
not listed in dev-packages
…ical constants. Removed print precision option, now print constants exactly as given.
I think all the suggested edits have been made. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good to go now. I'm going to squash merge due to the large number of commits
Summary of changes
On the Python side
python/mrchem/api.py
to a separate classMoleculeValidator
inpython/mrchem/validators.py
. I think this makes the structure and flow of the input parsing a bit clearer and readable, and cleans the responsibility ofapi.py
to converting from user.json to program.json (with some help fromhelpers.py
)qcelemental
. Now (almost) all constants are derived directly from NIST constants collected in CODATA2018.python/mrchem/update_input_parser.py
, which also runs parselglossy and syncs the user ref file. The user can therefore overwrite the constant defaults in the input file for their calculation.program.json
in theconstants
field, so that the c++ code gains access to theseOn the c++ side
chemistry/PhysicalConstants
has been created that stores the constants fromprogram.json
in anlohmann::json
object.ToDo