Skip to content

Commit 993acb9

Browse files
andyclaude
andcommitted
Gaussian 16/09: offer solvation (SCRF) for HF as well (#98)
Reported from a live session as "there's NO solvent option anywhere". It was not missing altogether -- it was gated by theory category, and the gating was wrong: Gaussian offered SCRF only for DFT and MP, so a plain HF job had none. Measured with tests/dialogs, which runs the real dialogs once per category and records every widget they build. Gaussian's SCRF works with HF -- "#p HF/6-31G* SCRF(PCM)" is an ordinary calculation, and for many people the first solvated job they would try. The generator side was never the blocker: ai.gauss{09,16}'s SCRFOptions is driven by UseSCRF/SCRF/Solvent, none of which is theory-specific. The box simply lived inside the DFT and MP branches. The block was duplicated verbatim in both branches, so it is now one addSolvationBox() method called from DFT, MP and SCF. The refactor was checked to be behaviour-neutral before SCF was added: DFT and MP built exactly the same widgets as before. CheckDependency()'s guard is extended to match, and says why it has to: naming a category that does not build the widgets dereferences attributes that do not exist and takes the whole dialog down -- which is precisely what ged03theory.py did, fixed earlier this week. Verified per category: SCF/DFT/MP now all build UseSCRF and Solvent with no construction error; CC and CI deliberately unchanged, since whether they should have it is a separate question left on #98. Not applied to ged03/ged98: both codes are disconnected from the New Calculation menu, so the same change there is unverifiable and pointless until they are reconnected. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFMUNbw2UpRPmgsqviAowb
1 parent f85eaae commit 993acb9

2 files changed

Lines changed: 215 additions & 338 deletions

File tree

‎scripts/codereg/ged09theory.py‎

Lines changed: 104 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -385,90 +385,11 @@ def __init__(self,parent,helpURL=""):
385385

386386
self.panelSizer.Add(dftSizer)
387387

388-
# Theory options solvation -CAO
389-
sovSizer = EcceBoxSizer(self,
390-
label = "Solvation",
391-
cols = 2)
392-
sovLeftSizer = EcceVBoxSizer()
393-
sovRightSizer = EcceVBoxSizer()
394-
395-
396-
# Use solvation
397-
self.useSCRF = EcceCheckBox(self, #useCosmo
398-
label = " Use SCRF",
399-
name = "ES.Theory.SCF.UseSCRF",
400-
default = False)
401-
sovLeftSizer.AddWidget(self.useSCRF,
402-
border = EcceGlobals.BorderDefault)
403-
# SCRF type
404-
scrfChoice = ["PCM",
405-
"CPCM",
406-
"IPCM",
407-
"SCIPCM",
408-
"SMD",
409-
"Dipole"]
410-
self.scrf = EcceComboBox(self,
411-
choices = scrfChoice,
412-
name = "ES.Theory.SCF.SCRF",
413-
label = "SCRF type:",
414-
default = 0)
415-
sovRightSizer.AddWidget(self.scrf,
416-
border = EcceGlobals.BorderDefault)
417-
# Solvent type
418-
solventChoice = ["Water",
419-
"Acetonitrile",
420-
"Methanol",
421-
"Ethanol",
422-
"Manual",
423-
"1,4-Dioxane",
424-
"methylcyclohexane",
425-
"Benzene",
426-
"Chloroform",
427-
"Diethylether",
428-
"Dichloromethane",
429-
"Dichloroethane",
430-
"Carbontetrachloride",
431-
"Toluene",
432-
"Chlorobenzene",
433-
"Nitromethane",
434-
"Heptane",
435-
"Aniline",
436-
"Acetone",
437-
"Tetrahydrofuran",
438-
"Dimethylsulfoxide",
439-
"Argon",
440-
"Krypton",
441-
"Xenon",
442-
"n-Octanol",
443-
"1-Butanol",
444-
"Cyclohexane",
445-
"Isoquinoline",
446-
"Quinoline",
447-
"n,n-dimethylformamide",
448-
]
449-
self.solvent = EcceComboBox(self,
450-
choices = solventChoice,
451-
name = "ES.Theory.SCF.Solvent",
452-
label = "Solvent:",
453-
default = 0)
454-
sovRightSizer.AddWidget(self.solvent,
455-
border = EcceGlobals.BorderDefault)
456-
457-
self.scrfDielec = EcceFloatInput(self,
458-
default = 78.4,
459-
name = "ES.Theory.SCF.Dielectric",
460-
label = "Dielectric Constant:",
461-
hardRange = "(0..)",
462-
unit = "Debye")
463-
sovRightSizer.AddWidget(self.scrfDielec,
464-
border = EcceGlobals.BorderDefault)
465-
466-
sovSizer.AddWidget(sovLeftSizer,
467-
flag = wx.ALL)
468-
sovSizer.AddWidget(sovRightSizer,
469-
flag = wx.ALL)
470-
self.panelSizer.Add(sovSizer)
471-
# End theory options solvation -CAO
388+
self.addSolvationBox()
389+
390+
# Solvation for plain HF as well (issue #98) -- see addSolvationBox.
391+
if EcceGlobals.Category == "SCF":
392+
self.addSolvationBox()
472393

473394
# THEORY OPTIONS MP
474395
if EcceGlobals.Category == "MP":
@@ -487,90 +408,7 @@ def __init__(self,parent,helpURL=""):
487408
label = "Computed:")
488409
mpSizer.AddWidget(self.mpOpt)
489410
self.panelSizer.Add(mpSizer)
490-
# Theory options solvation -CAO
491-
sovSizer = EcceBoxSizer(self,
492-
label = "Solvation",
493-
cols = 2)
494-
sovLeftSizer = EcceVBoxSizer()
495-
sovRightSizer = EcceVBoxSizer()
496-
497-
498-
# Use solvation
499-
self.useSCRF = EcceCheckBox(self, #useCosmo
500-
label = " Use SCRF",
501-
name = "ES.Theory.SCF.UseSCRF",
502-
default = False)
503-
sovLeftSizer.AddWidget(self.useSCRF,
504-
border = EcceGlobals.BorderDefault)
505-
# SCRF type
506-
scrfChoice = ["PCM",
507-
"CPCM",
508-
"IPCM",
509-
"SCIPCM",
510-
"SMD",
511-
"Dipole"]
512-
self.scrf = EcceComboBox(self,
513-
choices = scrfChoice,
514-
name = "ES.Theory.SCF.SCRF",
515-
label = "SCRF type:",
516-
default = 0)
517-
sovRightSizer.AddWidget(self.scrf,
518-
border = EcceGlobals.BorderDefault)
519-
# Solvent type
520-
solventChoice = ["Water",
521-
"Acetonitrile",
522-
"Methanol",
523-
"Ethanol",
524-
"Manual",
525-
"1,4-Dioxane",
526-
"methylcyclohexane",
527-
"Benzene",
528-
"Chloroform",
529-
"Diethylether",
530-
"Dichloromethane",
531-
"Dichloroethane",
532-
"Carbontetrachloride",
533-
"Toluene",
534-
"Chlorobenzene",
535-
"Nitromethane",
536-
"Heptane",
537-
"Aniline",
538-
"Acetone",
539-
"Tetrahydrofuran",
540-
"Dimethylsulfoxide",
541-
"Argon",
542-
"Krypton",
543-
"Xenon",
544-
"n-Octanol",
545-
"1-Butanol",
546-
"Cyclohexane",
547-
"Isoquinoline",
548-
"Quinoline",
549-
"n,n-dimethylformamide",
550-
]
551-
self.solvent = EcceComboBox(self,
552-
choices = solventChoice,
553-
name = "ES.Theory.SCF.Solvent",
554-
label = "Solvent:",
555-
default = 0)
556-
sovRightSizer.AddWidget(self.solvent,
557-
border = EcceGlobals.BorderDefault)
558-
559-
self.scrfDielec = EcceFloatInput(self,
560-
default = 78.4,
561-
name = "ES.Theory.SCF.Dielectric",
562-
label = "Dielectric Constant:",
563-
hardRange = "(0..)",
564-
unit = "Debye")
565-
sovRightSizer.AddWidget(self.scrfDielec,
566-
border = EcceGlobals.BorderDefault)
567-
568-
sovSizer.AddWidget(sovLeftSizer,
569-
flag = wx.ALL)
570-
sovSizer.AddWidget(sovRightSizer,
571-
flag = wx.ALL)
572-
self.panelSizer.Add(sovSizer)
573-
# End theory options solvation -CAO
411+
self.addSolvationBox()
574412
# THEORY OPTIONS CC
575413
if EcceGlobals.Category == "CC":
576414
ccSizer = EcceBoxSizer(self,
@@ -692,6 +530,100 @@ def __init__(self,parent,helpURL=""):
692530

693531
self.AddButtons()
694532

533+
534+
def addSolvationBox(self):
535+
"""Build the SCRF solvation box.
536+
537+
Duplicated verbatim in the DFT and MP branches and absent
538+
everywhere else, so a plain HF job had no solvation UI at all --
539+
even though Gaussian's SCRF works fine with HF and ai.gauss09's
540+
SCRFOptions is not theory-specific (issue #98).
541+
"""
542+
# Theory options solvation -CAO
543+
sovSizer = EcceBoxSizer(self,
544+
label = "Solvation",
545+
cols = 2)
546+
sovLeftSizer = EcceVBoxSizer()
547+
sovRightSizer = EcceVBoxSizer()
548+
549+
550+
# Use solvation
551+
self.useSCRF = EcceCheckBox(self, #useCosmo
552+
label = " Use SCRF",
553+
name = "ES.Theory.SCF.UseSCRF",
554+
default = False)
555+
sovLeftSizer.AddWidget(self.useSCRF,
556+
border = EcceGlobals.BorderDefault)
557+
# SCRF type
558+
scrfChoice = ["PCM",
559+
"CPCM",
560+
"IPCM",
561+
"SCIPCM",
562+
"SMD",
563+
"Dipole"]
564+
self.scrf = EcceComboBox(self,
565+
choices = scrfChoice,
566+
name = "ES.Theory.SCF.SCRF",
567+
label = "SCRF type:",
568+
default = 0)
569+
sovRightSizer.AddWidget(self.scrf,
570+
border = EcceGlobals.BorderDefault)
571+
# Solvent type
572+
solventChoice = ["Water",
573+
"Acetonitrile",
574+
"Methanol",
575+
"Ethanol",
576+
"Manual",
577+
"1,4-Dioxane",
578+
"methylcyclohexane",
579+
"Benzene",
580+
"Chloroform",
581+
"Diethylether",
582+
"Dichloromethane",
583+
"Dichloroethane",
584+
"Carbontetrachloride",
585+
"Toluene",
586+
"Chlorobenzene",
587+
"Nitromethane",
588+
"Heptane",
589+
"Aniline",
590+
"Acetone",
591+
"Tetrahydrofuran",
592+
"Dimethylsulfoxide",
593+
"Argon",
594+
"Krypton",
595+
"Xenon",
596+
"n-Octanol",
597+
"1-Butanol",
598+
"Cyclohexane",
599+
"Isoquinoline",
600+
"Quinoline",
601+
"n,n-dimethylformamide",
602+
]
603+
self.solvent = EcceComboBox(self,
604+
choices = solventChoice,
605+
name = "ES.Theory.SCF.Solvent",
606+
label = "Solvent:",
607+
default = 0)
608+
sovRightSizer.AddWidget(self.solvent,
609+
border = EcceGlobals.BorderDefault)
610+
611+
self.scrfDielec = EcceFloatInput(self,
612+
default = 78.4,
613+
name = "ES.Theory.SCF.Dielectric",
614+
label = "Dielectric Constant:",
615+
hardRange = "(0..)",
616+
unit = "Debye")
617+
sovRightSizer.AddWidget(self.scrfDielec,
618+
border = EcceGlobals.BorderDefault)
619+
620+
sovSizer.AddWidget(sovLeftSizer,
621+
flag = wx.ALL)
622+
sovSizer.AddWidget(sovRightSizer,
623+
flag = wx.ALL)
624+
self.panelSizer.Add(sovSizer)
625+
# End theory options solvation -CAO
626+
695627
def CheckDependency(self):
696628
try:
697629
self.memorySpin.Enable(self.memoryBox.GetValue())
@@ -712,7 +644,10 @@ def CheckDependency(self):
712644
self.corrFunc.Enable(not self.xcFunc.GetSelection())
713645

714646
# SCRF solvation -- CAO
715-
if EcceGlobals.Category == "DFT" or EcceGlobals.Category == "MP":
647+
# Must match exactly the categories that call addSolvationBox():
648+
# naming one that does not build the widgets takes the dialog down.
649+
if (EcceGlobals.Category == "DFT" or EcceGlobals.Category == "MP" or
650+
EcceGlobals.Category == "SCF"):
716651
self.solvent.Enable(self.useSCRF.GetValue())
717652
self.scrf.Enable(self.useSCRF.GetValue())
718653
self.scrfDielec.Enable(self.useSCRF.GetValue() and

0 commit comments

Comments
 (0)