Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -556,10 +556,15 @@ <h4>Default Calculation Settings</h4>
</select>
<div class="preference-description">Default basis set for new calculations</div>
</div>
<div class="preference-item">
<label class="preference-label">Default reference:</label>
<select id="pref-reference" class="preference-select"></select>
<div class="preference-description">Reference (SCF) step added automatically for molecular calculations</div>
</div>
<div class="preference-item">
<label class="preference-label">Default method (molecule):</label>
<select id="pref-method-molecule" class="preference-select"></select>
<div class="preference-description">Default correlated method for molecular (geometry + basis) calculations. A DF-HF reference step is added automatically.</div>
<div class="preference-description">Default correlated method for molecular (geometry + basis) calculations. The default reference step is added automatically.</div>
</div>
<div class="preference-item">
<label class="preference-label">Default method (FCIDUMP):</label>
Expand Down
2 changes: 2 additions & 0 deletions js/elemco-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
18 changes: 13 additions & 5 deletions js/elemco.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -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) {
Expand Down Expand Up @@ -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 };
Expand Down Expand Up @@ -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();
});
Expand Down
16 changes: 16 additions & 0 deletions js/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const DEFAULT_PREFERENCES = {

// ElemCo.jl settings
defaultBasisSet: 'cc-pVDZ',
defaultReference: 'hf',
defaultMethodMolecule: 'ccsd_t',
defaultMethodFcidump: 'lambda_ccsd_t',
juliaCommand: 'julia',
Expand Down Expand Up @@ -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)');
Expand Down Expand Up @@ -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');
Expand Down
Loading