From 50aa20dd8c64c2127b3dfabe0a18710b3b65f6bc Mon Sep 17 00:00:00 2001 From: Daniel Kats Date: Tue, 25 Aug 2026 19:41:45 +0200 Subject: [PATCH 1/2] Add exact-AO HF/UHF to the reference selector ElemCo v0.16.0's @hf/@uhf (HF from exact non-DF AO integrals, issue #290) were in the regenerated macro catalog but missing from the hand-curated reference list, so they never appeared as a reference choice. Placed after the DF entries; option groups scf+int (int now carries the exact-AO options screen/ao_direct/df). Co-Authored-By: Claude Fable 5 --- js/elemco-methods.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/js/elemco-methods.js b/js/elemco-methods.js index 1ab5f5b..f90b1a1 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 (exact AO, RHF)', macro: '@hf', groups: ['scf', 'int'] }, + { id: 'uhf', label: 'UHF (exact AO)', 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 }, From 9ab920d999404802f5d7a9175ed6a2d39aaee94c Mon Sep 17 00:00:00 2001 From: Daniel Kats Date: Tue, 25 Aug 2026 19:46:09 +0200 Subject: [PATCH 2/2] Plain HF/UHF labels; default-reference preference (default: HF) - Reference labels are just 'HF'/'UHF' (the exact-AO route is the natural unmarked name; DF variants stay explicitly labeled). - New 'Default reference' setting: the reference step for molecular calculations is chosen in the preferences (populated from the registry, advanced FCIDUMP references excluded) and defaults to HF. All three reference-creation sites go through elcDefaultReference(), which validates the stored id against the registry. Co-Authored-By: Claude Fable 5 --- index.html | 7 ++++++- js/elemco-methods.js | 4 ++-- js/elemco.js | 18 +++++++++++++----- js/preferences.js | 16 ++++++++++++++++ 4 files changed, 37 insertions(+), 8 deletions(-) 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 f90b1a1..a50afc8 100644 --- a/js/elemco-methods.js +++ b/js/elemco-methods.js @@ -16,8 +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 (exact AO, RHF)', macro: '@hf', groups: ['scf', 'int'] }, - { id: 'uhf', label: 'UHF (exact AO)', macro: '@uhf', 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');