diff --git a/index.html b/index.html index 0f27c81..04a2637 100644 --- a/index.html +++ b/index.html @@ -556,10 +556,15 @@

Default Calculation Settings

Default basis set for new calculations
+
+ + +
Reference (SCF) step added automatically for molecular calculations
+
-
Default correlated method for molecular (geometry + basis) calculations. A DF-HF reference step is added automatically.
+
Default correlated method for molecular (geometry + basis) calculations. The default reference step is added automatically.
diff --git a/js/elemco-methods.js b/js/elemco-methods.js index 1ab5f5b..a50afc8 100644 --- a/js/elemco-methods.js +++ b/js/elemco-methods.js @@ -16,6 +16,8 @@ const ELEMCO_METHODS = { reference: [ { id: 'dfhf', label: 'DF-HF (RHF)', macro: '@dfhf', groups: ['scf', 'int'] }, { id: 'dfuhf', label: 'DF-UHF', macro: '@dfuhf', groups: ['scf', 'int'] }, + { id: 'hf', label: 'HF', macro: '@hf', groups: ['scf', 'int'] }, + { id: 'uhf', label: 'UHF', macro: '@uhf', groups: ['scf', 'int'] }, { id: 'dfmcscf', label: 'DF-MCSCF', macro: '@dfmcscf', groups: ['scf', 'wf'] }, { id: 'bohf', label: 'BO-HF (FCIDUMP)', macro: '@bohf', groups: ['scf'], advanced: true }, { id: 'bouhf', label: 'BO-UHF (FCIDUMP)', macro: '@bouhf', groups: ['scf'], advanced: true }, diff --git a/js/elemco.js b/js/elemco.js index 12b6d3a..4bfb349 100644 --- a/js/elemco.js +++ b/js/elemco.js @@ -311,8 +311,8 @@ function makeMethodStep(category, methodId) { return step; } // Default step list for a mode, from preferences. Molecule mode always starts -// with a DF-HF reference; FCIDUMP mode adds no reference when a correlated method -// is chosen. A method value of 'HF' means reference-only (no correlation step). +// with the preferred reference; FCIDUMP mode adds no reference when a correlated +// method is chosen. A method value of 'HF' means reference-only (no correlation step). function elcBuildDefaultSteps(mode) { const prefs = (typeof getPreferences === 'function') ? getPreferences() : {}; if (mode === 'fcidump') { @@ -321,10 +321,18 @@ function elcBuildDefaultSteps(mode) { return [makeMethodStep('correlation', m)]; } const m = prefs.defaultMethodMolecule || 'ccsd_t'; - const steps = [makeMethodStep('reference', 'dfhf')]; + const steps = [makeMethodStep('reference', elcDefaultReference())]; if (m && m !== 'HF') steps.push(makeMethodStep('correlation', m)); return steps; } +// The reference chosen in the preferences (default: exact-AO HF), validated +// against the registry so a stale stored id cannot break the step. +function elcDefaultReference() { + const prefs = (typeof getPreferences === 'function') ? getPreferences() : {}; + const id = prefs.defaultReference || 'hf'; + const known = ((typeof window !== 'undefined' && window.ELEMCO_METHODS) || {}).reference || []; + return known.some((r) => r.id === id) ? id : 'hf'; +} // Are the current steps still the untouched defaults for `mode`? (structural // comparison, ignoring ids). Used to decide whether a mode change may rebuild. function elcStepsMatchDefault(mode) { @@ -419,7 +427,7 @@ function syncElemCoBasisFromPrefs() { function addElemCoStep(type) { initElemCoState(); let step; - if (type === 'reference') step = makeMethodStep('reference', 'dfhf'); + if (type === 'reference') step = makeMethodStep('reference', elcDefaultReference()); else if (type === 'correlation') step = makeMethodStep('correlation', 'dcsd'); else if (type === 'export') step = { id: 's' + (elcStepSeq++), kind: 'export', filename: 'orbitals.molden' }; else if (type === 'macro') step = { id: 's' + (elcStepSeq++), kind: 'macro', macro: 'export_molden', args: '', options: {}, _optsOpen: false }; @@ -505,7 +513,7 @@ function renderElemCoSteps() { const b = elcEl('button', { type: 'button' }, 'Add reference'); b.addEventListener('click', () => { initElemCoState(); - elemcoState.steps.unshift(makeMethodStep('reference', 'dfhf')); + elemcoState.steps.unshift(makeMethodStep('reference', elcDefaultReference())); renderElemCoSteps(); updateElemCoInput(); }); diff --git a/js/preferences.js b/js/preferences.js index 282f8c6..c3a10de 100644 --- a/js/preferences.js +++ b/js/preferences.js @@ -27,6 +27,7 @@ const DEFAULT_PREFERENCES = { // ElemCo.jl settings defaultBasisSet: 'cc-pVDZ', + defaultReference: 'hf', defaultMethodMolecule: 'ccsd_t', defaultMethodFcidump: 'lambda_ccsd_t', juliaCommand: 'julia', @@ -217,6 +218,19 @@ function loadPreferencesIntoUI() { const basisSetSelect = document.getElementById('pref-basis-set'); if (basisSetSelect) basisSetSelect.value = prefs.defaultBasisSet || 'cc-pVDZ'; + const refSelect = document.getElementById('pref-reference'); + if (refSelect) { + refSelect.innerHTML = ''; + const refs = ((typeof window !== 'undefined' && window.ELEMCO_METHODS) || {}).reference || []; + refs.filter((r) => !r.advanced).forEach((r) => { + const o = document.createElement('option'); + o.value = r.id; + o.textContent = r.label; + refSelect.appendChild(o); + }); + refSelect.value = prefs.defaultReference || 'hf'; + } + const molMethodSelect = document.getElementById('pref-method-molecule'); const fciMethodSelect = document.getElementById('pref-method-fcidump'); elcPopulateMethodPrefSelect(molMethodSelect, 'HF (reference only)'); @@ -312,6 +326,8 @@ function savePreferencesFromUI() { const basisSetSelect = document.getElementById('pref-basis-set'); if (basisSetSelect) prefs.defaultBasisSet = basisSetSelect.value; + const refSelect = document.getElementById('pref-reference'); + if (refSelect) prefs.defaultReference = refSelect.value; const molMethodSelect = document.getElementById('pref-method-molecule'); if (molMethodSelect) prefs.defaultMethodMolecule = molMethodSelect.value; const fciMethodSelect = document.getElementById('pref-method-fcidump');