mlatom 2.1.0__tar.gz → 2.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {MLatom-2.1.0 → MLatom-2.1.2}/PKG-INFO +14 -9
- {MLatom-2.1.0 → MLatom-2.1.2}/README.md +13 -8
- {MLatom-2.1.0 → MLatom-2.1.2}/setup.py +1 -1
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/AIQM1.py +32 -14
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/ML_NEA.py +13 -2
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/MLatom.py +21 -10
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/MLatomF +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/MLatomF_src/A_KRR.f90 +38 -9
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/MLatomF_src/A_KRR_kernel.f90 +24 -1
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/MLatomF_src/MLatomF.f90 +3 -3
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/MLatomF_src/MLmodel.f90 +41 -4
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/MLatomF_src/Makefile +1 -1
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/MLatomF_src/constants.f90 +1 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/MLatomF_src/dataset.f90 +1 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/MLatomF_src/optionsModule.f90 +44 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/MLtasks.py +473 -90
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/README +11 -10
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/calculator.py +11 -3
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/doc.py +42 -33
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/geomopt.py +112 -27
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/header.py +16 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/interface_MLatomF.py +15 -7
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/interfaces/DeePMDkit/interface_DeePMDkit.py +84 -43
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/interfaces/DeePMDkit/template.json +3 -3
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/interfaces/GAP/interface_GAP.py +27 -13
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/interfaces/PhysNet/PhysNet_train.py +25 -2
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/interfaces/PhysNet/interface_PhysNet.py +28 -8
- MLatom-2.1.2/src/MLatom/interfaces/TorchANI/TorchANI_predict.py +208 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/interfaces/TorchANI/TorchANI_train.py +48 -19
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/interfaces/TorchANI/interface_TorchANI.py +96 -42
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/interfaces/sGDML/interface_sGDML.py +6 -3
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/ref.json +4 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/thermo.py +25 -9
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom.egg-info/PKG-INFO +14 -9
- MLatom-2.1.0/src/MLatom/interfaces/TorchANI/TorchANI_predict.py +0 -82
- {MLatom-2.1.0 → MLatom-2.1.2}/LICENSE.txt +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/setup.cfg +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/LICENSE.CC-BY-NC-ND-4.0 +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/MLatomF_src/D_CoulombMatrix.f90 +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/MLatomF_src/D_rel2eq.f90 +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/MLatomF_src/MLatomFInfo.f90 +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/MLatomF_src/Makefile.intel +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/MLatomF_src/analyze.f90 +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/MLatomF_src/cs.cpp +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/MLatomF_src/mathUtils.f90 +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/MLatomF_src/molDescr.f90 +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/MLatomF_src/precision.f90 +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/MLatomF_src/sampling.f90 +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/MLatomF_src/statistics.f90 +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/MLatomF_src/stopper.f90 +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/MLatomF_src/strings.f90 +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/MLatomF_src/timing.f90 +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/MLatomF_src/types.f90 +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/__init__.py +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/aiqm1_model/aiqm1_cc_cv0.pt +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/aiqm1_model/aiqm1_cc_cv1.pt +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/aiqm1_model/aiqm1_cc_cv2.pt +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/aiqm1_model/aiqm1_cc_cv3.pt +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/aiqm1_model/aiqm1_cc_cv4.pt +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/aiqm1_model/aiqm1_cc_cv5.pt +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/aiqm1_model/aiqm1_cc_cv6.pt +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/aiqm1_model/aiqm1_cc_cv7.pt +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/aiqm1_model/aiqm1_dft_cv0.pt +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/aiqm1_model/aiqm1_dft_cv1.pt +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/aiqm1_model/aiqm1_dft_cv2.pt +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/aiqm1_model/aiqm1_dft_cv3.pt +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/aiqm1_model/aiqm1_dft_cv4.pt +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/aiqm1_model/aiqm1_dft_cv5.pt +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/aiqm1_model/aiqm1_dft_cv6.pt +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/aiqm1_model/aiqm1_dft_cv7.pt +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/args_class.py +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/cs.so +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/documentation/installation.txt +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/example/E_FCI_451.dat +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/example/E_UHF_451.dat +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/example/R_451.dat +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/example/isubtrain.dat +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/example/itest.dat +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/example/itrain.dat +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/example/ivalidate.dat +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/example/mlatom.inp +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/example/mlatom.saved +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/example/test.sh +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/interfaces/DeePMDkit/DP_inference.py +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/interfaces/DeePMDkit/__init__.py +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/interfaces/GAP/__init__.py +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/interfaces/PhysNet/PhysNet_predict.py +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/interfaces/PhysNet/__init__.py +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/interfaces/TorchANI/__init__.py +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/interfaces/__init__.py +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/interfaces/sGDML/__init__.py +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/interfaces/sGDML/sgdml_dataset_from_extxyz.py +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/mlatom_gui.py +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/shell_cmd.py +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/sliceData.py +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom/stopper.py +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom.egg-info/SOURCES.txt +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom.egg-info/dependency_links.txt +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom.egg-info/entry_points.txt +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom.egg-info/requires.txt +0 -0
- {MLatom-2.1.0 → MLatom-2.1.2}/src/MLatom.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: MLatom
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.2
|
|
4
4
|
Summary: A Package for Atomistic Simulations with Machine Learning
|
|
5
5
|
Home-page: http://mlatom.com
|
|
6
6
|
Author: Pavlo O. Dral
|
|
@@ -71,9 +71,15 @@ Permutationally invariant kernel and self-correction are also supported.
|
|
|
71
71
|
- permuted.
|
|
72
72
|
|
|
73
73
|
|
|
74
|
-
#
|
|
74
|
+
# ML models
|
|
75
75
|
The [ KREG (Kernel-ridge-regression using RE descriptor and the Gaussian kernel function )](http://dx.doi.org/10.1021/acs.jpclett.8b02469) model is the default ML method.
|
|
76
76
|
|
|
77
|
+
## General-purpose ML models
|
|
78
|
+
- AIQM1 (requires interfaces to other programs as described in http://MLatom.com/AIQM1)
|
|
79
|
+
- Models available via interface to [TorchANI](https://doi.org/10.1021/acs.jcim.0c00451)
|
|
80
|
+
- ANI-1x
|
|
81
|
+
- ANI-1ccx
|
|
82
|
+
- ANI-2x
|
|
77
83
|
|
|
78
84
|
# Model Validation
|
|
79
85
|
[ ML model can be validated (generalization error can be estimated) in several ways: ](https://web.stanford.edu/~hastie/ElemStatLearn/)
|
|
@@ -103,13 +109,12 @@ MLatom can be also used to estimate first derivatives from an ML model. Two scen
|
|
|
103
109
|
- derivatives for interfaced models
|
|
104
110
|
|
|
105
111
|
|
|
106
|
-
#
|
|
112
|
+
# UV/vis spectra
|
|
107
113
|
MLatom can significantly accelerate the calculation of cross-section with the Nuclear Ensemble Approach (NEA).
|
|
108
114
|
|
|
109
|
-
In brief, this feature uses fewer QC calculation to achieve higher precision and reduce computational cost. You can find more detail on this paper (please cite it when using this feature:
|
|
115
|
+
In brief, this feature uses fewer QC calculation to achieve higher precision and reduce computational cost. You can find more detail on this paper (please cite it when using this feature):
|
|
110
116
|
|
|
111
|
-
> Bao-Xin Xue, Mario Barbatti
|
|
112
|
-
> [ Preprint on ChemRxiv ](https://doi.org/10.26434/chemrxiv.12594191), DOI: 10.26434/chemrxiv.12594191.
|
|
117
|
+
> Bao-Xin Xue, Mario Barbatti, Pavlo O. Dral, [ Machine Learning for Absorption Cross Sections ](https://doi.org/10.1021/acs.jpca.0c05310), J. Phys. Chem. A 2020, 124, 7199–7210. DOI: 10.1021/acs.jpca.0c05310.
|
|
113
118
|
|
|
114
119
|
# Interfaces to 3<sup>rd</sup>-party software
|
|
115
120
|
MLatom also provides interfaces to some third-party software where extra ML model types are natively implemented. It allows users to access other popular ML model types within MLatom's workflow. Currently available third-party model types are:
|
|
@@ -122,10 +127,10 @@ MLatom also provides interfaces to some third-party software where extra ML mode
|
|
|
122
127
|
|
|
123
128
|
# About Program
|
|
124
129
|
MLatom: a Package for Atomistic Simulations with Machine Learning
|
|
125
|
-
Version 2.1.
|
|
130
|
+
Version 2.1.2
|
|
126
131
|
http://mlatom.com/
|
|
127
132
|
|
|
128
|
-
Copyright (c) 2013-
|
|
133
|
+
Copyright (c) 2013-2022 Pavlo O. Dral
|
|
129
134
|
http://dr-dral.com/
|
|
130
135
|
|
|
131
136
|
All rights reserved. This work is licensed under the [Attribution-NonCommercial-NoDerivatives 4.0 International](http://creativecommons.org/licenses/by-nc-nd/4.0/) license. See LICENSE.CC-BY-NC-ND-4.0.
|
|
@@ -136,7 +141,7 @@ Cite as:
|
|
|
136
141
|
|
|
137
142
|
1. Pavlo O. Dral, J. Comput. Chem. 2019, 40, 2339-2347
|
|
138
143
|
2. Pavlo O. Dral, Fuchun Ge, Bao-Xin Xue, Yi-Fan Hou, Max Pinheiro Jr, Jianxing Huang, Mario Barbatti, Top. Curr. Chem. 2021, 379, 27
|
|
139
|
-
3. Pavlo O. Dral, Peikun Zheng, Bao-Xin Xue, Fuchun Ge, Yi-Fan Hou, Max Pinheiro Jr, MLatom: A Package for Atomistic Simulations with Machine Learning, version 2.1.
|
|
144
|
+
3. Pavlo O. Dral, Peikun Zheng, Bao-Xin Xue, Fuchun Ge, Yi-Fan Hou, Max Pinheiro Jr, MLatom: A Package for Atomistic Simulations with Machine Learning, version 2.1.2, Xiamen University, Xiamen, China, 2013-2022.
|
|
140
145
|
|
|
141
146
|
|
|
142
147
|
# License
|
|
@@ -53,9 +53,15 @@ Permutationally invariant kernel and self-correction are also supported.
|
|
|
53
53
|
- permuted.
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
#
|
|
56
|
+
# ML models
|
|
57
57
|
The [ KREG (Kernel-ridge-regression using RE descriptor and the Gaussian kernel function )](http://dx.doi.org/10.1021/acs.jpclett.8b02469) model is the default ML method.
|
|
58
58
|
|
|
59
|
+
## General-purpose ML models
|
|
60
|
+
- AIQM1 (requires interfaces to other programs as described in http://MLatom.com/AIQM1)
|
|
61
|
+
- Models available via interface to [TorchANI](https://doi.org/10.1021/acs.jcim.0c00451)
|
|
62
|
+
- ANI-1x
|
|
63
|
+
- ANI-1ccx
|
|
64
|
+
- ANI-2x
|
|
59
65
|
|
|
60
66
|
# Model Validation
|
|
61
67
|
[ ML model can be validated (generalization error can be estimated) in several ways: ](https://web.stanford.edu/~hastie/ElemStatLearn/)
|
|
@@ -85,13 +91,12 @@ MLatom can be also used to estimate first derivatives from an ML model. Two scen
|
|
|
85
91
|
- derivatives for interfaced models
|
|
86
92
|
|
|
87
93
|
|
|
88
|
-
#
|
|
94
|
+
# UV/vis spectra
|
|
89
95
|
MLatom can significantly accelerate the calculation of cross-section with the Nuclear Ensemble Approach (NEA).
|
|
90
96
|
|
|
91
|
-
In brief, this feature uses fewer QC calculation to achieve higher precision and reduce computational cost. You can find more detail on this paper (please cite it when using this feature:
|
|
97
|
+
In brief, this feature uses fewer QC calculation to achieve higher precision and reduce computational cost. You can find more detail on this paper (please cite it when using this feature):
|
|
92
98
|
|
|
93
|
-
> Bao-Xin Xue, Mario Barbatti
|
|
94
|
-
> [ Preprint on ChemRxiv ](https://doi.org/10.26434/chemrxiv.12594191), DOI: 10.26434/chemrxiv.12594191.
|
|
99
|
+
> Bao-Xin Xue, Mario Barbatti, Pavlo O. Dral, [ Machine Learning for Absorption Cross Sections ](https://doi.org/10.1021/acs.jpca.0c05310), J. Phys. Chem. A 2020, 124, 7199–7210. DOI: 10.1021/acs.jpca.0c05310.
|
|
95
100
|
|
|
96
101
|
# Interfaces to 3<sup>rd</sup>-party software
|
|
97
102
|
MLatom also provides interfaces to some third-party software where extra ML model types are natively implemented. It allows users to access other popular ML model types within MLatom's workflow. Currently available third-party model types are:
|
|
@@ -104,10 +109,10 @@ MLatom also provides interfaces to some third-party software where extra ML mode
|
|
|
104
109
|
|
|
105
110
|
# About Program
|
|
106
111
|
MLatom: a Package for Atomistic Simulations with Machine Learning
|
|
107
|
-
Version 2.1.
|
|
112
|
+
Version 2.1.2
|
|
108
113
|
http://mlatom.com/
|
|
109
114
|
|
|
110
|
-
Copyright (c) 2013-
|
|
115
|
+
Copyright (c) 2013-2022 Pavlo O. Dral
|
|
111
116
|
http://dr-dral.com/
|
|
112
117
|
|
|
113
118
|
All rights reserved. This work is licensed under the [Attribution-NonCommercial-NoDerivatives 4.0 International](http://creativecommons.org/licenses/by-nc-nd/4.0/) license. See LICENSE.CC-BY-NC-ND-4.0.
|
|
@@ -118,7 +123,7 @@ Cite as:
|
|
|
118
123
|
|
|
119
124
|
1. Pavlo O. Dral, J. Comput. Chem. 2019, 40, 2339-2347
|
|
120
125
|
2. Pavlo O. Dral, Fuchun Ge, Bao-Xin Xue, Yi-Fan Hou, Max Pinheiro Jr, Jianxing Huang, Mario Barbatti, Top. Curr. Chem. 2021, 379, 27
|
|
121
|
-
3. Pavlo O. Dral, Peikun Zheng, Bao-Xin Xue, Fuchun Ge, Yi-Fan Hou, Max Pinheiro Jr, MLatom: A Package for Atomistic Simulations with Machine Learning, version 2.1.
|
|
126
|
+
3. Pavlo O. Dral, Peikun Zheng, Bao-Xin Xue, Fuchun Ge, Yi-Fan Hou, Max Pinheiro Jr, MLatom: A Package for Atomistic Simulations with Machine Learning, version 2.1.2, Xiamen University, Xiamen, China, 2013-2022.
|
|
122
127
|
|
|
123
128
|
|
|
124
129
|
# License
|
|
@@ -43,7 +43,7 @@ with open(os.path.join(here, 'README.md')) as f:
|
|
|
43
43
|
|
|
44
44
|
setup(
|
|
45
45
|
name = pkg_name,
|
|
46
|
-
version = "2.1.
|
|
46
|
+
version = "2.1.2",
|
|
47
47
|
author = "Pavlo O. Dral",
|
|
48
48
|
author_email = "admin@mlatom.com",
|
|
49
49
|
license = 'CC BY-NC-ND 4.0', # https://creativecommons.org/licenses/by-nc-nd/4.0/
|
|
@@ -119,10 +119,10 @@ class AIQM1Cls(object):
|
|
|
119
119
|
models.append(model)
|
|
120
120
|
self.models = models
|
|
121
121
|
|
|
122
|
-
def predict(self, device, d4, sae
|
|
122
|
+
def predict(self, device, d4, sae):
|
|
123
123
|
|
|
124
124
|
numbers, coordinates = get_xyz(self.xyzfile)
|
|
125
|
-
charges, mults, odm2_energies, odm2_grads, odm2_hesses = run_odm2_calculation(self.mndobin, numbers, coordinates, self.hesscalc, self.mndokw
|
|
125
|
+
charges, mults, odm2_energies, odm2_grads, odm2_hesses = run_odm2_calculation(self.mndobin, numbers, coordinates, self.hesscalc, self.mndokw)
|
|
126
126
|
shifts = cal_shifts(numbers, sae)
|
|
127
127
|
if d4:
|
|
128
128
|
d4_energies, d4_grads, d4_hesses = run_d4_calculation(self.dftd4bin, self.xyzfile, numbers, coordinates, charges, self.hesscalc)
|
|
@@ -151,10 +151,22 @@ class AIQM1Cls(object):
|
|
|
151
151
|
delta_hess = torchani.utils.hessian(coordinate, energies=delta_energy)
|
|
152
152
|
delta_hesses.append(delta_hess)
|
|
153
153
|
|
|
154
|
-
delta_energy = torch.stack([e for e in delta_energies], dim=0)
|
|
154
|
+
delta_energy = torch.stack([e for e in delta_energies], dim=0)
|
|
155
|
+
|
|
156
|
+
fmt = ' %-40s: %15.8f Hartree'
|
|
157
|
+
if len(self.models) == 8:
|
|
158
|
+
e_std = delta_energy.std(dim=0, unbiased=False)
|
|
159
|
+
print(fmt % ('Standard deviation of NN contribution', e_std), end='')
|
|
160
|
+
e_std = hartree2kcalmol(e_std)
|
|
161
|
+
print('%15.5f kcal/mol' % e_std)
|
|
162
|
+
np.savetxt('std', e_std.detach().numpy())
|
|
163
|
+
delta_energy = delta_energy.mean(0)
|
|
155
164
|
delta_grad = torch.stack([g for g in delta_grads], dim=0).mean(0)
|
|
156
165
|
energy = delta_energy[0] + odm2_energy + shift
|
|
157
166
|
grad = delta_grad[0] + odm2_grad
|
|
167
|
+
print(fmt % ('NN contribution', delta_energy))
|
|
168
|
+
print(fmt % ('Sum of atomic self energies', shift))
|
|
169
|
+
print(fmt % ('ODM2* contribution', odm2_energy), file=sys.stdout)
|
|
158
170
|
if self.hesscalc:
|
|
159
171
|
odm2_hess = torch.tensor(odm2_hesses[i]).to(device)
|
|
160
172
|
delta_hess = torch.stack([h for h in delta_hesses], dim=0).mean(0)
|
|
@@ -164,9 +176,12 @@ class AIQM1Cls(object):
|
|
|
164
176
|
d4_grad = torch.tensor(d4_grads[i]).to(device)
|
|
165
177
|
energy = energy + d4_energy
|
|
166
178
|
grad = grad + d4_grad
|
|
179
|
+
print(fmt % ('D4 contribution', d4_energy))
|
|
167
180
|
if self.hesscalc:
|
|
168
181
|
d4_hess = torch.tensor(d4_hesses[i]).to(device)
|
|
169
182
|
hess = hess + d4_hess
|
|
183
|
+
print(fmt % ('Total energy', energy))
|
|
184
|
+
print('')
|
|
170
185
|
fenergy.write('%20.12f\n' % energy)
|
|
171
186
|
fgrad.write('%d\n\n' % nat)
|
|
172
187
|
for j in range(nat):
|
|
@@ -182,15 +197,14 @@ class AIQM1Cls(object):
|
|
|
182
197
|
fhess.close()
|
|
183
198
|
return charges, mults
|
|
184
199
|
|
|
185
|
-
def forward(self
|
|
186
|
-
# optmol is used for geomopt
|
|
200
|
+
def forward(self):
|
|
187
201
|
if self.level == 'dft':
|
|
188
202
|
sae = self.dftsae
|
|
189
203
|
elif self.level == 'cc':
|
|
190
204
|
sae = self.ccsae
|
|
191
205
|
self.define_aev()
|
|
192
206
|
self.load_models()
|
|
193
|
-
charges, mults = self.predict(self.device, self.d4, sae
|
|
207
|
+
charges, mults = self.predict(self.device, self.d4, sae)
|
|
194
208
|
return charges, mults
|
|
195
209
|
|
|
196
210
|
class args(object):
|
|
@@ -216,11 +230,13 @@ class args(object):
|
|
|
216
230
|
import torch
|
|
217
231
|
import torchani
|
|
218
232
|
from torchani.utils import ChemicalSymbolsToInts
|
|
233
|
+
from torchani.units import hartree2kcalmol
|
|
219
234
|
except:
|
|
220
235
|
stopper.stopMLatom('Please install all Python module required for TorchANI')
|
|
221
236
|
globals()['torch'] = torch
|
|
222
237
|
globals()['torchani'] = torchani
|
|
223
238
|
globals()['ChemicalSymbolsToInts'] = ChemicalSymbolsToInts
|
|
239
|
+
globals()['hartree2kcalmol'] = hartree2kcalmol
|
|
224
240
|
|
|
225
241
|
cls.mndobin = mndobin
|
|
226
242
|
cls.dftd4bin = dftd4bin
|
|
@@ -301,12 +317,12 @@ def get_xyz(xyzfile):
|
|
|
301
317
|
coordinates.append(coordinate)
|
|
302
318
|
return numbers, coordinates
|
|
303
319
|
|
|
304
|
-
def run_odm2_calculation(mndobin, numbers, coordinates, hesscalc, mndokw
|
|
320
|
+
def run_odm2_calculation(mndobin, numbers, coordinates, hesscalc, mndokw):
|
|
305
321
|
charges = np.full(len(numbers), 0)
|
|
306
322
|
mults = np.full(len(numbers), 1)
|
|
307
323
|
energies = []; grads = []; hesses = []
|
|
308
324
|
if mndokw:
|
|
309
|
-
mndokeywords, charges, mults = read_mndokw(mndokw
|
|
325
|
+
mndokeywords, charges, mults = read_mndokw(mndokw)
|
|
310
326
|
if len(mndokeywords) != len(numbers):
|
|
311
327
|
stopper.stopMLatom('Inconsistency of the nubmer of keywords and molecules')
|
|
312
328
|
for i in range(len(numbers)):
|
|
@@ -338,16 +354,18 @@ def run_odm2_calculation(mndobin, numbers, coordinates, hesscalc, mndokw, optmol
|
|
|
338
354
|
energies.append(energy)
|
|
339
355
|
grads.append(grad)
|
|
340
356
|
hesses.append(hess)
|
|
357
|
+
|
|
358
|
+
#energies = np.array(energies)
|
|
341
359
|
return charges, mults, energies, grads, hesses
|
|
342
360
|
|
|
343
|
-
def read_mndokw(mndokw,
|
|
361
|
+
def read_mndokw(mndokw, split=False):
|
|
344
362
|
with open(mndokw, 'r') as f:
|
|
345
363
|
mndokeywords = f.read().strip('\n')
|
|
346
364
|
mndokeywords = mndokeywords.split('\n\n')
|
|
347
365
|
charges = np.full(len(mndokeywords), 0)
|
|
348
366
|
mults = np.full(len(mndokeywords), 1)
|
|
349
367
|
for i in range(len(mndokeywords)):
|
|
350
|
-
status = re.search('kharge
|
|
368
|
+
status = re.search('kharge=-?\+?\d+', mndokeywords[i])
|
|
351
369
|
if status:
|
|
352
370
|
charges[i] = int(status.group().split('=')[1])
|
|
353
371
|
status = re.search('imult=\d+', mndokeywords[i])
|
|
@@ -357,10 +375,10 @@ def read_mndokw(mndokw, optmol):
|
|
|
357
375
|
mults[i] = 1
|
|
358
376
|
else:
|
|
359
377
|
mults[i] = imult
|
|
360
|
-
if
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
378
|
+
if split:
|
|
379
|
+
for i in range(len(mndokeywords)):
|
|
380
|
+
with open(f'mndokw_split{i+1}', 'w') as f:
|
|
381
|
+
f.write(mndokeywords[i])
|
|
364
382
|
|
|
365
383
|
return mndokeywords, charges, mults
|
|
366
384
|
|
|
@@ -93,9 +93,11 @@ def err_print(content: str): # need to improve
|
|
|
93
93
|
print('--- ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ---')
|
|
94
94
|
print(content)
|
|
95
95
|
print('--- ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ---')
|
|
96
|
+
sys.stdout.flush()
|
|
96
97
|
|
|
97
98
|
def warning_print(content: str):
|
|
98
99
|
print(f'!!!!! {content} !!!!!')
|
|
100
|
+
sys.stdout.flush()
|
|
99
101
|
|
|
100
102
|
# todo: complete the typing of logger decorator
|
|
101
103
|
def logger(log_content: str, logfile: str='out.log') -> Callable[[Any], Any]:
|
|
@@ -105,6 +107,7 @@ def logger(log_content: str, logfile: str='out.log') -> Callable[[Any], Any]:
|
|
|
105
107
|
log_string = '\n\n' + '=' * 90 + '\n'
|
|
106
108
|
log_string += f'{log_content} ( {func.__name__} ) started at {time.ctime()} {time.tzname[0]}'
|
|
107
109
|
print(log_string)
|
|
110
|
+
sys.stdout.flush()
|
|
108
111
|
|
|
109
112
|
start_time = time.time()
|
|
110
113
|
result: Any = func(*args, **kwargs)
|
|
@@ -114,6 +117,7 @@ def logger(log_content: str, logfile: str='out.log') -> Callable[[Any], Any]:
|
|
|
114
117
|
log_string = f'{log_content} ( {func.__name__} ) finished at {time.ctime()} {time.tzname[0]} |||| total spent {spend_time:.2f} sec'
|
|
115
118
|
log_string += '\n' + '=' * 90 + '\n\n'
|
|
116
119
|
print(log_string)
|
|
120
|
+
sys.stdout.flush()
|
|
117
121
|
|
|
118
122
|
return result
|
|
119
123
|
return wrapped_function
|
|
@@ -219,6 +223,7 @@ class LinuxInterface():
|
|
|
219
223
|
print('*' * 80)
|
|
220
224
|
print(content)
|
|
221
225
|
print('*' * 80)
|
|
226
|
+
sys.stdout.flush()
|
|
222
227
|
|
|
223
228
|
|
|
224
229
|
class XYZ():
|
|
@@ -808,6 +813,7 @@ class NewtonXCalc(LinuxInterface):
|
|
|
808
813
|
self.mv(freq_file, os.path.join(self.NX_path, 'freq.out') )
|
|
809
814
|
nx_inp = '&dat\n nact = 2\n numat = %d\n npoints = %d\n file_geom = geom\n iprog = 4\n' % (atom_num, NEA_point) + \
|
|
810
815
|
' file_nmodes = freq.out\n anh_f = 1\n temp = 0.0\n ics_flg = n\n chk_e = 0\n' + \
|
|
816
|
+
' file_out = ini_qv\n file_vib = qvector\n' + \
|
|
811
817
|
' nis = 1\n nfs = 2\n kvert = 1\n de = 100\n prog = 6.5\n iseed = 0\n lvprt = 1\n /'
|
|
812
818
|
with open('initqp_input', 'w') as f:
|
|
813
819
|
f.write(nx_inp)
|
|
@@ -821,6 +827,7 @@ class NewtonXCalc(LinuxInterface):
|
|
|
821
827
|
self.mv(freq_file, os.path.join(self.NX_path, 'freq.out') )
|
|
822
828
|
nx_inp = '&dat\n nact = 2\n numat = %d\n npoints = %d\n file_geom = "geom"\n iprog = 4\n' % (atom_num, NEA_point) + \
|
|
823
829
|
' file_nmodes = "freq.out"\n anh_f = 1\n temp = 0.0\n ics_flg = "n"\n chk_e = 0\n' + \
|
|
830
|
+
' file_out = "ini_qv"\n file_vib = "qvector"\n' + \
|
|
824
831
|
' nis = 1\n nfs = 2\n kvert = 1\n de = 100\n prog = 6.5\n iseed = 1234\n lvprt = 1\n/\n'
|
|
825
832
|
with open(inp_name, 'w') as f:
|
|
826
833
|
f.write(nx_inp)
|
|
@@ -1395,6 +1402,7 @@ class ML_cross_section(CrossSection_calc, ML_calc):
|
|
|
1395
1402
|
self._iter_calc_QC(0, self.TD_point)
|
|
1396
1403
|
rmse = self._train_epoch(self.TD_point)
|
|
1397
1404
|
print(f'\nRMSE_geom value for {self.TD_point} point: {rmse}')
|
|
1405
|
+
sys.stdout.flush()
|
|
1398
1406
|
self._train_final(self.TD_point)
|
|
1399
1407
|
self._collect_ML_result(self.use_model_pred_path)
|
|
1400
1408
|
self.mix_multiple_file(self.max_state, self.pred_data_path, self.this.gauss.gauss_data_path, self.mix_data_path)
|
|
@@ -1411,13 +1419,15 @@ class ML_cross_section(CrossSection_calc, ML_calc):
|
|
|
1411
1419
|
# attention: In fact, we have TD_point number: (self.TD_point + 1)
|
|
1412
1420
|
while current_point < self.TD_point + 1:
|
|
1413
1421
|
rmse = self._train_epoch(current_point)
|
|
1414
|
-
rRMSE =
|
|
1422
|
+
rRMSE = (rmse - prev_rmse) / rmse
|
|
1415
1423
|
print(f'ML-NEA iteration {iter_cnt}: train_number = {current_point}; RMSE_geom = {rmse}; rRMSE = {rRMSE}\n')
|
|
1424
|
+
sys.stdout.flush()
|
|
1416
1425
|
iter_cnt += 1
|
|
1417
1426
|
# todo 4: print log about the RMSE variation
|
|
1418
|
-
if rRMSE <= threshold:
|
|
1427
|
+
if abs(rRMSE) <= threshold:
|
|
1419
1428
|
# calc cross section
|
|
1420
1429
|
print(f'ML-NEA iteration ended after {iter_cnt - 1} iteration!')
|
|
1430
|
+
sys.stdout.flush()
|
|
1421
1431
|
# todo 5: extract all data and mix data
|
|
1422
1432
|
self._train_final(current_point)
|
|
1423
1433
|
self._collect_ML_result(self.use_model_pred_path)
|
|
@@ -1431,6 +1441,7 @@ class ML_cross_section(CrossSection_calc, ML_calc):
|
|
|
1431
1441
|
print(f'max training number exceeded, use all point for ML-NEA training\n')
|
|
1432
1442
|
rmse = self._train_epoch(current_point)
|
|
1433
1443
|
print(f'ML-NEA iteration {iter_cnt}: train_number = {current_point}; RMSE_geom = {rmse}; rRMSE = {rRMSE}\n')
|
|
1444
|
+
sys.stdout.flush()
|
|
1434
1445
|
self._train_final(current_point)
|
|
1435
1446
|
self._collect_ML_result(self.use_model_pred_path)
|
|
1436
1447
|
self.mix_multiple_file(self.max_state, self.pred_data_path, self.this.gauss.gauss_data_path, self.mix_data_path)
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
!---------------------------------------------------------------------------!
|
|
5
5
|
! !
|
|
6
6
|
! MLatom: a Package for Atomistic Simulations with Machine Learning !
|
|
7
|
-
! Version 2.
|
|
7
|
+
! Version 2.1.2 !
|
|
8
8
|
! http://mlatom.com/ !
|
|
9
9
|
! !
|
|
10
|
-
! Copyright (c) 2013-
|
|
10
|
+
! Copyright (c) 2013-2022 Pavlo O. Dral !
|
|
11
11
|
! http://dr-dral.com/ !
|
|
12
12
|
! !
|
|
13
13
|
! All rights reserved. This work is licensed under the !
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
! Pavlo O. Dral, Peikun Zheng, Bao-Xin Xue, Fuchun Ge, Yi-Fan Hou, !
|
|
35
35
|
! Max Pinheiro Jr, !
|
|
36
36
|
! MLatom: A Package for Atomistic Simulations with Machine Learning !
|
|
37
|
-
! version 2.1, Xiamen University, Xiamen, China, 2013-
|
|
37
|
+
! version 2.1.2, Xiamen University, Xiamen, China, 2013-2022 !
|
|
38
38
|
! !
|
|
39
39
|
!---------------------------------------------------------------------------!
|
|
40
40
|
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
|
|
43
43
|
import os, sys, subprocess, time, shutil, re, copy
|
|
44
44
|
import sliceData, stopper
|
|
45
|
-
import MLtasks
|
|
45
|
+
import MLtasks
|
|
46
46
|
import interface_MLatomF
|
|
47
47
|
import header
|
|
48
48
|
from args_class import ArgsBase
|
|
@@ -79,7 +79,15 @@ class MLatomMainCls(object):
|
|
|
79
79
|
if args.nthreads:
|
|
80
80
|
os.environ["OMP_NUM_THREADS"] = str(args.nthreads)
|
|
81
81
|
os.environ["MKL_NUM_THREADS"] = str(args.nthreads)
|
|
82
|
-
os.environ["OMP_PROC_BIND"] = 'true'
|
|
82
|
+
# os.environ["OMP_PROC_BIND"] = 'true'
|
|
83
|
+
try:
|
|
84
|
+
f_cpu = open('/proc/cpuinfo')
|
|
85
|
+
for line in f_cpu:
|
|
86
|
+
if 'AMD'.lower() in line.lower():
|
|
87
|
+
os.environ['MKL_DEBUG_CPU_TYPE'] = '5'
|
|
88
|
+
break
|
|
89
|
+
f_cpu.close()
|
|
90
|
+
except: pass
|
|
83
91
|
|
|
84
92
|
# Perform requested task
|
|
85
93
|
if args.XYZ2X or args.sample or args.analyze:
|
|
@@ -89,8 +97,8 @@ class MLatomMainCls(object):
|
|
|
89
97
|
sliceData.sliceDataCls(argsSD = args.args2pass)
|
|
90
98
|
elif (args.useMLmodel or args.createMLmodel or
|
|
91
99
|
args.estAccMLmodel or args.learningCurve or
|
|
92
|
-
args.AIQM1DFTstar or args.AIQM1DFT or args.AIQM1 or
|
|
93
|
-
args.geomopt or args.freq or
|
|
100
|
+
args.AIQM1DFTstar or args.AIQM1DFT or args.AIQM1 or
|
|
101
|
+
args.geomopt or args.freq or args.ts or args.irc or
|
|
94
102
|
args.MLNEA):
|
|
95
103
|
MLtasks.MLtasksCls(argsMLtasks = args.args2pass)
|
|
96
104
|
|
|
@@ -109,13 +117,13 @@ class Args(ArgsBase):
|
|
|
109
117
|
'XYZ2X', 'analyze', 'sample', 'sampleFromSlices', 'mergeSlices','slice',
|
|
110
118
|
'useMLmodel', 'createMLmodel', 'estAccMLmodel', 'learningCurve',
|
|
111
119
|
'crossSection', # Interfaces
|
|
112
|
-
'
|
|
113
|
-
'geomopt', 'freq'
|
|
120
|
+
'AIQM1DFTstar', 'AIQM1DFT', 'AIQM1', # DEVELOPMENT VERSION
|
|
121
|
+
'geomopt', 'freq', 'ts', 'irc'
|
|
114
122
|
]
|
|
115
123
|
self.add_default_dict_args(self.task_list, bool)
|
|
116
124
|
self.add_default_dict_args([
|
|
117
125
|
'useMLmodel', 'createMLmodel', 'estAccMLmodel', 'learningCurve','deltaLearn','selfCorrect','MLmodelType',
|
|
118
|
-
'geomopt', 'freq'
|
|
126
|
+
'geomopt', 'freq', 'ts', 'irc'
|
|
119
127
|
],
|
|
120
128
|
bool
|
|
121
129
|
)
|
|
@@ -139,6 +147,9 @@ class Args(ArgsBase):
|
|
|
139
147
|
self.set_keyword_alias('crossSection', ['ML-NEA', 'ML_NEA', 'crossSection', 'cross-section', 'cross_section','MLNEA'])
|
|
140
148
|
self.set_keyword_alias('AIQM1DFTstar', ['AIQM1@DFT*'])
|
|
141
149
|
self.set_keyword_alias('AIQM1DFT', ['AIQM1@DFT'])
|
|
150
|
+
self.set_keyword_alias('usemlmodel mlmodeltype=ani1ccx', ['ANI-1ccx'])
|
|
151
|
+
self.set_keyword_alias('usemlmodel mlmodeltype=ani1x', ['ANI-1x'])
|
|
152
|
+
self.set_keyword_alias('usemlmodel mlmodeltype=ani2x', ['ANI-2x'])
|
|
142
153
|
self.args2pass = []
|
|
143
154
|
|
|
144
155
|
def parse(self, argsraw):
|
|
Binary file
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
module A_KRR
|
|
9
9
|
use A_KRR_kernel, only : NtrTot, NtrVal, itrval
|
|
10
|
-
use dataset, only : arrayOfArrays, Nprops, NgradXYZmax!, Yest, NitemsTot
|
|
10
|
+
use dataset, only : arrayOfArrays, Yprior, Nprops, NgradXYZmax!, Yest, NitemsTot
|
|
11
11
|
use optionsModule, only : option
|
|
12
12
|
use precision, only : rprec
|
|
13
13
|
use stopper, only : stopMLatomF
|
|
@@ -27,7 +27,7 @@ contains
|
|
|
27
27
|
!==============================================================================
|
|
28
28
|
subroutine init_KRR()
|
|
29
29
|
!==============================================================================
|
|
30
|
-
use A_KRR_kernel, only : getSigma, getC, getD, getNN
|
|
30
|
+
use A_KRR_kernel, only : getSigma, getPeriod, getSigmaP, getC, getD, getNN
|
|
31
31
|
use optionsModule, only : option
|
|
32
32
|
use timing, only : timeTaken
|
|
33
33
|
implicit none
|
|
@@ -44,6 +44,11 @@ subroutine init_KRR()
|
|
|
44
44
|
(trim(option%kernel) == 'exponential')) then
|
|
45
45
|
! Get user-defined sigma or request for optimizing it
|
|
46
46
|
call getSigma()
|
|
47
|
+
if (option%periodKernel) call getPeriod
|
|
48
|
+
if (option%decayKernel) then
|
|
49
|
+
call getSigmaP
|
|
50
|
+
call getPeriod
|
|
51
|
+
end if
|
|
47
52
|
elseif (trim(option%kernel) == 'Matern') then
|
|
48
53
|
! Get user-defined c and d or request for optimizing them
|
|
49
54
|
call getNN()
|
|
@@ -193,6 +198,7 @@ subroutine optHyper_KRR(hyperOptDataPt, indicesCVoptSplitsPt, doNotCalcStats)
|
|
|
193
198
|
if (doNotCalcStats) doNotCalcStatsLocal = .true.
|
|
194
199
|
end if
|
|
195
200
|
if (.not. option%CVopt .and. .not. doNotCalcStatsLocal) then
|
|
201
|
+
if (option%prior/='0') write(6,'(" Prior value = ",F25.13)') Yprior
|
|
196
202
|
! Predict values using ML model for its own sub-training set
|
|
197
203
|
call calcEst_KRR(Nsubtrain, indicesSubtrain)
|
|
198
204
|
! Calculate errors of the predicted values
|
|
@@ -276,6 +282,7 @@ subroutine train_KRR(doNotCalcStats)
|
|
|
276
282
|
! Calculate regression coefficients alpha
|
|
277
283
|
call calcAlpha(NtrTot, Nprops, K(1)%twoDrArr, Ytrain)
|
|
278
284
|
deallocate(Ytrain)
|
|
285
|
+
if (option%prior/='0' .and. .not. present(doNotCalcStats)) write(6,'(" Prior value = ",F25.13)') Yprior
|
|
279
286
|
|
|
280
287
|
! Predict values using ML model for its own training set
|
|
281
288
|
if (present(doNotCalcStats)) then
|
|
@@ -396,7 +403,7 @@ subroutine validate1_KRR(NsubtrainPoints, indicesSubtrainPoints, &
|
|
|
396
403
|
call calcEst_KRR(NvalidatePoints, indicesValidatePoints)
|
|
397
404
|
elseif (present(KvalidateMatrix)) then
|
|
398
405
|
! Predict values using ML model for its validation set
|
|
399
|
-
Yest =
|
|
406
|
+
Yest = Yprior
|
|
400
407
|
!$OMP PARALLEL DO PRIVATE(a,i) &
|
|
401
408
|
!$OMP SHARED(Yest,indicesValidatePoints,Kvalidate,alpha,NsubtrainPoints,NvalidatePoints) &
|
|
402
409
|
!$OMP SCHEDULE(STATIC)
|
|
@@ -699,6 +706,7 @@ subroutine calcAlpha(NtrainPoints, Nprops, Kmatrix, Yref)
|
|
|
699
706
|
! by solving the system of equations (K+lambda*I)*alpha = Yref
|
|
700
707
|
! Input: Kmatrix - K, kernel matrix
|
|
701
708
|
! Yref - Yref, vector(s) with reference value for various properties
|
|
709
|
+
! WARNING: may be modified if prior/=0 is requested
|
|
702
710
|
! Output: alpha - alpha, the regression coefficients
|
|
703
711
|
!==============================================================================
|
|
704
712
|
use dataset, only : Y
|
|
@@ -732,6 +740,27 @@ subroutine calcAlpha(NtrainPoints, Nprops, Kmatrix, Yref)
|
|
|
732
740
|
do jj=1,NtrainPoints
|
|
733
741
|
InvMat(jj,jj) = InvMat(jj,jj) + lambda
|
|
734
742
|
end do
|
|
743
|
+
|
|
744
|
+
! Get prior (intercept)
|
|
745
|
+
Yprior = 0.0_rprec
|
|
746
|
+
if (option%prior=='mean' .and. Nprops==1) then
|
|
747
|
+
Yprior = 0.0_rprec
|
|
748
|
+
do jj=1,NtrTot
|
|
749
|
+
Yprior = Yprior + Yref(jj,1)
|
|
750
|
+
end do
|
|
751
|
+
Yprior = Yprior / NtrTot
|
|
752
|
+
if (option%debug) write(6,'(" Mean prior = ",F25.13)') Yprior
|
|
753
|
+
elseif (option%prior/='0') then
|
|
754
|
+
if (Nprops > 1) call stopMLatomF('Only prior=0 can be used for these calculations')
|
|
755
|
+
read(option%prior,*) Yprior
|
|
756
|
+
end if
|
|
757
|
+
|
|
758
|
+
! Center the data around prior
|
|
759
|
+
if (option%prior/='0') then
|
|
760
|
+
do jj=1,NtrVal
|
|
761
|
+
Yref(jj,1) = Yref(jj,1) - Yprior
|
|
762
|
+
end do
|
|
763
|
+
end if
|
|
735
764
|
|
|
736
765
|
! Get vector with regression coefficients alpha:
|
|
737
766
|
! Solve the system of linear equations (K+lambda*I)*alpha = Yref
|
|
@@ -789,10 +818,10 @@ subroutine calcEst_KRR(NestIndices, indicesForEst)
|
|
|
789
818
|
call initializeAllArrays()
|
|
790
819
|
|
|
791
820
|
if (option%calcVal) then
|
|
792
|
-
Yest =
|
|
821
|
+
Yest = Yprior
|
|
793
822
|
!$OMP PARALLEL DO PRIVATE(i) SHARED(Yest,indicesForEst) SCHEDULE(STATIC)
|
|
794
823
|
do i=1, NestIndices
|
|
795
|
-
Yest(indicesForEst(i)) = Yest_KRR(indicesForEst(i), alpha(:,1))
|
|
824
|
+
Yest(indicesForEst(i)) = Yprior + Yest_KRR(indicesForEst(i), alpha(:,1))
|
|
796
825
|
end do
|
|
797
826
|
!$OMP END PARALLEL DO
|
|
798
827
|
end if
|
|
@@ -918,7 +947,7 @@ recursive subroutine optLambdaLog2Grid(hyperOptDataPt, indicesCVoptSplitsPt)
|
|
|
918
947
|
|
|
919
948
|
else
|
|
920
949
|
! Train, i.e. calculate regression coefficients alpha
|
|
921
|
-
call getYtrain(Nsubtrain, indicesSubtrain, Nprops)
|
|
950
|
+
call getYtrain(Nsubtrain, indicesSubtrain, Nprops) ! Necessary to reset values if they are modified by prior
|
|
922
951
|
call calcAlpha(NtrTot, Nprops, K(1)%twoDrArr, Ytrain)
|
|
923
952
|
! Predict values using ML model
|
|
924
953
|
if (option%onTheFly) then
|
|
@@ -948,7 +977,7 @@ recursive subroutine optLambdaLog2Grid(hyperOptDataPt, indicesCVoptSplitsPt)
|
|
|
948
977
|
lambda = lambda_min
|
|
949
978
|
! Recalculate regression coefficients alpha
|
|
950
979
|
if (.not. option%CVopt) then
|
|
951
|
-
call getYtrain(Nsubtrain, indicesSubtrain, Nprops)
|
|
980
|
+
call getYtrain(Nsubtrain, indicesSubtrain, Nprops) ! Necessary to reset values if they are modified by prior
|
|
952
981
|
call calcAlpha(NtrTot, Nprops, K(1)%twoDrArr, Ytrain)
|
|
953
982
|
end if
|
|
954
983
|
|
|
@@ -1049,7 +1078,7 @@ recursive subroutine optLog2Grid(hyperparameter, hyperOptDataPt, indicesCVoptSpl
|
|
|
1049
1078
|
stsize = newsize
|
|
1050
1079
|
end do
|
|
1051
1080
|
call cleanUp_KRR()
|
|
1052
|
-
call getYtrain(Nsubtrain, indicesSubtrain, Nprops)
|
|
1081
|
+
call getYtrain(Nsubtrain, indicesSubtrain, Nprops) ! Necessary to reset values if they are modified by prior
|
|
1053
1082
|
allocate(K(1),stat=Error)
|
|
1054
1083
|
if(Error/=0)call stopMLatomF('Unable to allocate K')
|
|
1055
1084
|
allocate(K(1)%twoDrArr(1:NtrTot,1:NtrTot),stat=Error)
|
|
@@ -1087,7 +1116,7 @@ recursive subroutine optLog2Grid(hyperparameter, hyperOptDataPt, indicesCVoptSpl
|
|
|
1087
1116
|
|
|
1088
1117
|
else
|
|
1089
1118
|
! Calculate kernel matrix
|
|
1090
|
-
call getYtrain(Nsubtrain, indicesSubtrain, Nprops)
|
|
1119
|
+
call getYtrain(Nsubtrain, indicesSubtrain, Nprops) ! Necessary to reset values if they are modified by prior
|
|
1091
1120
|
call calcKernel(K(1)%twoDrArr)
|
|
1092
1121
|
if (.not. option%onTheFly) call calc_Kvalidate(Nsubtrain, indicesSubtrain, &
|
|
1093
1122
|
Nvalidate, indicesValidate, &
|
|
@@ -13,6 +13,7 @@ module A_KRR_kernel
|
|
|
13
13
|
implicit none
|
|
14
14
|
! Variables
|
|
15
15
|
real(kind=rprec), target :: sigma = 100.0_rprec ! Length-scale
|
|
16
|
+
real(kind=rprec), target :: sigmap = 100.0_rprec! Length-scale for the periodic part
|
|
16
17
|
integer, target :: lgSigmaPoints ! Number of points on a logarithmic grid for search optimal sigma
|
|
17
18
|
real(kind=rprec), target :: lgSigmaL ! The lowest value of log2(sigma) to try
|
|
18
19
|
real(kind=rprec), target :: lgSigmaH ! The highest value of log2(sigma) to try
|
|
@@ -25,6 +26,7 @@ module A_KRR_kernel
|
|
|
25
26
|
real(kind=rprec), target :: lgDL ! The lowest value of log2(d) to try
|
|
26
27
|
real(kind=rprec), target :: lgDH ! The highest value of log2(d) to try
|
|
27
28
|
integer, target :: nn = 2 ! n in the Matern kernel (nu = n + 1/2)
|
|
29
|
+
real(kind=rprec), target :: period = 1.0_rprec ! Period
|
|
28
30
|
integer :: NtrTot ! Total number of training points
|
|
29
31
|
integer :: NtrVal ! Number of training points with values
|
|
30
32
|
integer, allocatable :: itrval(:) ! Indices of training points with values
|
|
@@ -58,6 +60,20 @@ subroutine getSigma()
|
|
|
58
60
|
|
|
59
61
|
end subroutine getSigma
|
|
60
62
|
|
|
63
|
+
subroutine getPeriod()
|
|
64
|
+
implicit none
|
|
65
|
+
|
|
66
|
+
read(option%period,*) period
|
|
67
|
+
|
|
68
|
+
end subroutine getPeriod
|
|
69
|
+
|
|
70
|
+
subroutine getSigmaP()
|
|
71
|
+
implicit none
|
|
72
|
+
|
|
73
|
+
read(option%sigmap,*) sigmap
|
|
74
|
+
|
|
75
|
+
end subroutine getSigmaP
|
|
76
|
+
|
|
61
77
|
subroutine getC()
|
|
62
78
|
implicit none
|
|
63
79
|
|
|
@@ -464,6 +480,7 @@ function kernelFunction(Xi,Xj)
|
|
|
464
480
|
end function kernelFunction
|
|
465
481
|
|
|
466
482
|
function Kfunk(Xsize,Xi,Xj)
|
|
483
|
+
use constants, only : pi
|
|
467
484
|
use dataset, only : distance
|
|
468
485
|
use mathUtils, only : factorial_rprec
|
|
469
486
|
implicit none
|
|
@@ -483,7 +500,13 @@ function Kfunk(Xsize,Xi,Xj)
|
|
|
483
500
|
elseif (trim(option%kernel) == 'polynomial') then
|
|
484
501
|
Kfunk = (distance(Xsize,Xi,Xj) + c) ** d
|
|
485
502
|
elseif (trim(option%kernel) == 'Gaussian') then
|
|
486
|
-
|
|
503
|
+
if (option%decayKernel) then
|
|
504
|
+
Kfunk = exp(-1.0_rprec * distance(Xsize,Xi,Xj) / (2 * sigma ** 2) - 2.0_rprec * (sin(pi * sqrt(distance(Xsize,Xi,Xj)) / period))**2 / (sigmap ** 2))
|
|
505
|
+
elseif (option%periodKernel) then
|
|
506
|
+
Kfunk = exp(-2.0_rprec * (sin(pi * sqrt(distance(Xsize,Xi,Xj)) / period))**2 / (sigma ** 2))
|
|
507
|
+
else
|
|
508
|
+
Kfunk = exp(-1.0_rprec * distance(Xsize,Xi,Xj) / (2 * sigma ** 2))
|
|
509
|
+
end if
|
|
487
510
|
elseif (trim(option%kernel) == 'Laplacian') then
|
|
488
511
|
Kfunk = exp(-1.0_rprec * distance(Xsize,Xi,Xj) / sigma)
|
|
489
512
|
elseif (trim(option%kernel) == 'exponential') then
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
!---------------------------------------------------------------------------!
|
|
3
3
|
! !
|
|
4
4
|
! MLatom: a Package for Atomistic Simulations with Machine Learning !
|
|
5
|
-
!
|
|
5
|
+
! Version 2.1.2 !
|
|
6
6
|
! http://mlatom.com/ !
|
|
7
7
|
! !
|
|
8
|
-
! Copyright (c) 2013-
|
|
8
|
+
! Copyright (c) 2013-2022 Pavlo O. Dral !
|
|
9
9
|
! http://dr-dral.com/ !
|
|
10
10
|
! !
|
|
11
11
|
! All rights reserved. No part of MLatom may be used, published or !
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
! !
|
|
30
30
|
! Pavlo O. Dral, Bao-Xin Xue, Fuchun Ge, Yi-Fan Hou, !
|
|
31
31
|
! MLatom: A Package for Atomistic Simulations with Machine Learning !
|
|
32
|
-
! version 2.
|
|
32
|
+
! version 2.1.2, Xiamen University, Xiamen, China, 2013-2022 !
|
|
33
33
|
! !
|
|
34
34
|
!---------------------------------------------------------------------------!
|
|
35
35
|
|