@@ -40,23 +40,38 @@ export class PlanewaveCutoffsContextProvider extends mix(ContextProvider).with(
40
40
return cutoffConfig [ this . application . name ] ;
41
41
}
42
42
43
+ /**
44
+ * @summary Find cutoff values corresponding to wavefunction or charge
45
+ * density with accuracy level in the pseudo method data
46
+ * @param data {Object}: the data object from pseudo method data
47
+ * @param cutoffEntity {String}: "wavefunction", or "density"
48
+ * @param accuracyLevel {String}: "standard", "high", or "low"
49
+ * @return {number }: if cutoff value present returns value else return 0
50
+ */
51
+ _cutoffFromPseudoData = ( data , cutoffEntity , accuracyLevel = "standard" ) => {
52
+ const cutoff = data ?. cutoffs ?. [ cutoffEntity ] || [ ] ;
53
+ return cutoff . find ( ( obj ) => obj . accuracy_level === accuracyLevel ) ?. value ?? 0 ;
54
+ } ;
55
+
56
+ /**
57
+ * @summary Set highest cutoff of all elements present, in case wavefunction
58
+ * cutoff is present but no charge density cutoff, set charge density cutoff
59
+ * to 4 or 8 times that of wavefunction cutoff
60
+ * @return {Array<number> }: tuple of wavefunction and density cutoffs
61
+ */
43
62
get _cutoffsFromPseudos ( ) {
44
- const pseudos = this . methodData ?. pseudo || [ ] ;
45
63
let ecutwfc = 0 ;
46
64
let ecutrho = 0 ;
65
+ const pseudos = this . methodData ?. pseudo || [ ] ;
47
66
48
67
pseudos . forEach ( ( data ) => {
49
- const wfcCutoff = data ?. cutoffs ?. wavefunction || [ ] ;
50
- const wfcCutoffStandardAccuracy =
51
- wfcCutoff . find ( ( obj ) => obj . accuracy_level === "standard" ) ?. value ?? 0 ;
68
+ const ecutwfcStandard = this . _cutoffFromPseudoData ( data , "wavefunction" ) ;
69
+ const ecutrhoStandard = this . _cutoffFromPseudoData ( data , "density" ) ;
52
70
// set the highest cutoff of all elements
53
- ecutwfc = Math . max ( ecutwfc , wfcCutoffStandardAccuracy ) ;
71
+ ecutwfc = Math . max ( ecutwfc , ecutwfcStandard ) ;
54
72
55
- const rhoCutoff = data ?. cutoffs ?. density || [ ] ;
56
- const rhoCutoffStandardAccuracy =
57
- rhoCutoff . find ( ( obj ) => obj . accuracy_level === "standard" ) ?. value ?? 0 ;
58
- if ( rhoCutoffStandardAccuracy > ecutrho ) {
59
- ecutrho = rhoCutoffStandardAccuracy ;
73
+ if ( ecutrhoStandard > ecutrho ) {
74
+ ecutrho = ecutrhoStandard ;
60
75
} else {
61
76
// if rho cutoff is not present, set it based on wfc cutoff
62
77
// if it is ultrasoft pseudopotential set rho cutoff 8 times
0 commit comments