Skip to content

Commit

Permalink
improved solvent handling (#15)
Browse files Browse the repository at this point in the history
    - added solvents dichloroethane and octane to solvents list
    - print clearer warning if solvent is not parameterized for the respective solvent model (and a replacement solvent is employed)
    - improved the automated SI generation (e.g. ALPB information)
    - improved the printout of the available density functionals in the tutorial option crenso -tutorial
    - added an option for the calculation of vapor_pressure in combination with crenso 1.0.4 and COSMO-RS

* vapor pressure calculation possible for COSMO-RS file same_solvents.json contains information on other needed solvent parameters
  e.g.
          {
          "same":{
            "cosmors": ["same", "same"],
            "dcosmors": [null, "thf"],
            "xtb": [null, "thf"],
            "cpcm": [null, null],
            "smd": [null, null],
            "DC": 7.8
          }
        }
  • Loading branch information
fabothch authored Jul 16, 2021
1 parent fb3958b commit d77ced5
Show file tree
Hide file tree
Showing 13 changed files with 270 additions and 112 deletions.
9 changes: 8 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Requirements:

* newest xtb (currently: https://github.com/grimme-lab/xtb/releases/tag/v6.4.0 )
* newest cefine https://github.com/grimme-lab/cefine/releases
* ORCA > version 4.1
* ORCA > version 4.1 and below 5.0.0 !!!


Further information (will be ordered later on):
Expand Down Expand Up @@ -166,6 +166,13 @@ holds for *maxcor* and/or *rpacor*.
$ echo "maxcor 4000" >> .cefinerc
$ echo "rpacor 4000" >> .cefinerc
For ORCA user:
--------------

CENSO currently does not work with the new ORCA 5.x release. In the new ORCA release
changes to the input have been introduced (e.g. DFT grids) and the input creation
inside CENSO has to be updated.

Available solvation models:
---------------------------

Expand Down
32 changes: 31 additions & 1 deletion censo_qm/cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os
import sys

__version__ = "1.1.0"
__version__ = "1.1.1"

DESCR = f"""
______________________________________________________________
Expand Down Expand Up @@ -833,6 +833,14 @@ def infos(self, request, prog=None):
"smd": ["DICHLOROMETHANE", "DICHLOROMETHANE"],
"DC": 9.1,
},
"dichloroethane": {
"cosmors": ["1,2-dichloroethane_c0", "1,2-dichloroethane_c0"],
"dcosmors": [None, "chcl3"],
"xtb": [None, "ch2cl2"],
"cpcm": [None, "CH2Cl2"],
"smd": ["1,2-DICHLOROETHANE", "1,2-DICHLOROETHANE"],
"DC": 10.125,
},
"dmso": {
"cosmors": ["dimethylsulfoxide_c0", "dimethylsulfoxide_c0"],
"dcosmors": ["dimethylsulfoxide", "dimethylsulfoxide"],
Expand Down Expand Up @@ -881,6 +889,14 @@ def infos(self, request, prog=None):
"smd": ["1-OCTANOL", "1-OCTANOL"],
"DC": 9.9,
},
"octane": {
"cosmors": ["octane_c0", "octane_c0"],
"dcosmors": [None, "octanol"],
"xtb": [None, "hexane"],
"cpcm": [None, "hexane"],
"smd": ["N-OCTANE", "N-OCTANE"],
"DC": 1.94,
},
"woctanol": {
"cosmors": [None, "woctanol"],
"dcosmors": ["wet-otcanol", "wet-octanol"],
Expand Down Expand Up @@ -4129,6 +4145,20 @@ def dict_to_NMRRef(self, dictionary):
r" year = {2015}",
r"}",
],
"alpb": [
r"@article{ALPB,",
r" author = {Ehlert, Sebastian and Stahn, Marcel and Spicher, Sebastian and Grimme, Stefan},",
r" title = {Robust and Efficient Implicit Solvation Model for Fast Semiempirical Methods},",
r" journal = {Journal of Chemical Theory and Computation},",
r" volume = {0},",
r" number = {0},",
r" pages = {null},",
r" year = {0},",
r" doi = {10.1021/acs.jctc.1c00471},",
r" note ={PMID: 34185531},",
r" URL = {https://doi.org/10.1021/acs.jctc.1c00471},",
r"}",
],
}

# qm_prepinfo: grid and scfconv settings for ORCA and TM
Expand Down
158 changes: 104 additions & 54 deletions censo_qm/inputhandling.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def cml(startup_description, options, argv=None):
"-solvent",
"--solvent",
dest="solvent",
choices=options.value_options["solvent"],
#choices=options.value_options["solvent"],
metavar="",
action="store",
required=False,
Expand Down Expand Up @@ -877,6 +877,16 @@ def cml(startup_description, options, argv=None):
metavar="",
help="scaling factor for frequencies (e.g. 1.0)",
)
group12 = parser.add_argument_group("SPECIAL PURPOSE")
group12.add_argument(
"--vapor_pressure",
"-vp",
dest="vapor_pressure",
choices=["on", "off"],
action="store",
help="Gsolv is evaluated for the input molecule in its solution (same). Only possible with COSMO-RS.",
)

group8 = parser.add_argument_group("CREATION/DELETION OF FILES")
group8.add_argument(
"--debug",
Expand Down Expand Up @@ -1564,7 +1574,7 @@ def __init__(self):
"opt_spearman": ["on", "off"],
"evaluate_rrho": ["on", "off"],
"consider_sym": ["on", "off"],
"prog_rrho": ["xtb", "prog"],
"prog_rrho": ["xtb",],
"part0_gfnv": self.impgfnv,
"part1_gfnv": self.impgfnv,
"part2_gfnv": self.impgfnv,
Expand Down Expand Up @@ -1786,6 +1796,8 @@ def __init__(self, path=os.getcwd(), *args, **kwargs):
self.func_or_scf = "r2scan-3c"
self.basis_or = "def2-SVPD"
self.freq_or = [589]
# special
self.vapor_pressure = False

# settings the program operates with updated to the defaults
for key in self.internal_defaults.keys():
Expand All @@ -1810,6 +1822,7 @@ def __init__(self, path=os.getcwd(), *args, **kwargs):
"run",
"configpath",
"fixed_temperature",
"vapor_pressure",
]
self.onlyread = False
self.fixed_temperature = None
Expand Down Expand Up @@ -2485,6 +2498,13 @@ def check_logic(self, error_logical=False, silent=False):
self.sm4_j = "gas-phase"
self.sm4_s = "gas-phase"
else:
if self.vapor_pressure:
self.save_errors.append(
f"{'INFORMATION:':{WARNLEN}}The vapor_pressure flag only affects "
f"settings for COSMO-RS!\n"
f"{'':{WARNLEN}}Information on solvents with properties similar "
f"to the input molecule must be provided for other solvent models!"
)
if self.part2:
# Handle sm2 --> solvent model in optimization:
exchange_sm = {
Expand Down Expand Up @@ -2701,6 +2721,7 @@ def check_logic(self, error_logical=False, silent=False):
check_for["cosmors"] = True
elif solventmodel in ("dcosmors",):
check_for["dcosmors"] = True
check_for["DC"] = True
elif solventmodel in ("cosmo",):
check_for["DC"] = True
elif solventmodel in ("cpcm",):
Expand All @@ -2720,67 +2741,81 @@ def check_logic(self, error_logical=False, silent=False):
# check if solvent in censo_solvent_db
if censo_solvent_db.get(self.solvent, "not_found") == "not_found":
self.save_errors.append(
f"{'ERROR:':{WARNLEN}}The solvent {self.solvent} is not found!"
f"{'ERROR:':{WARNLEN}}The solvent '{self.solvent}'' is not found in your file "
f"{os.path.expanduser(os.path.join('~/.censo_assets/', 'censo_solvents.json'))}!"
f"\n{'':{WARNLEN}}Check your input!"
)
error_logical = True
for key, value in check_for.items():
if value:
if (
censo_solvent_db[self.solvent].get(key, "nothing_found")
== "nothing_found"
):
self.save_errors.append(
f"{'ERROR:':{WARNLEN}}The solvent for solventmodel in "
"{key} is not found!"
)
error_logical = True
if key == "DC":
try:
if not (
float(
censo_solvent_db[self.solvent].get(
key, "nothing_found"
else:
for key, value in check_for.items():
if value:
if (
censo_solvent_db[self.solvent].get(key, "nothing_found")
== "nothing_found"
):
self.save_errors.append(
f"{'ERROR:':{WARNLEN}}The solvent for solventmodel in "
"{key} is not found!"
)
error_logical = True
if key == "DC":
try:
if censo_solvent_db[self.solvent].get(key, None) is not None:
_ = float(censo_solvent_db[self.solvent].get(key, None))
else:
self.save_errors.append(
f"{'ERROR:':{WARNLEN}}The dielectric constant for the solvent '{self.solvent}' "
f"is not provided for the solventmodel {'cosmo / dcosmors'}!"
)
error_logical = True
except ValueError:
self.save_errors.append(
f"{'ERROR:':{WARNLEN}}The dielectric constant can "
"not be converted."
)
> 0.0
and float(
censo_solvent_db[self.solvent].get(
key, "nothing_found"
)
error_logical = True
elif key in ("smd", "cpcm"):
if (censo_solvent_db[self.solvent].get(key, ['', 'nothing_found'])[1].lower()
not in getattr(self, lookup[key]) and
censo_solvent_db[self.solvent].get(key, ['', None])[1]):
self.save_errors.append(
f"{'WARNING:':{WARNLEN}}The solvent "
f"'{censo_solvent_db[self.solvent].get(key, 'nothing_found')[1]}'"
f" for solventmodel/program {key} can not be checked "
"but is used anyway."
)
< 150.0
else:
if (censo_solvent_db[self.solvent].get(key, ['', 'nothing_found'])[1]
not in getattr(self, lookup[key]) and
censo_solvent_db[self.solvent].get(key, ['', None])[1]):
self.save_errors.append(
f"{'WARNING:':{WARNLEN}}The solvent "
f"'{censo_solvent_db[self.solvent].get(key, 'nothing_found')[1]}' "
f"for solventmodel/program {key} can not be checked "
"but is used anyway."
)
if (key != "DC" and
censo_solvent_db[self.solvent].get(key, ["",""])[0] is None and
censo_solvent_db[self.solvent].get(key, "nothing_found") != "nothing_found"
):
if key == 'xtb':
tmp_sm = 'alpb'
else:
tmp_sm = key
if censo_solvent_db[self.solvent].get(key, ["",None])[1] is None:
self.save_errors.append(
f"{'ERROR:':{WARNLEN}}The dielectric constant "
"can not be converted."
f"{'ERROR:':{WARNLEN}}The solvent '{self.solvent}' "
f"is not parameterized for the solventmodel {tmp_sm}, and "
f"no replacement is available!!!"
)
error_logical = True
except ValueError:
self.save_errors.append(
f"{'ERROR:':{WARNLEN}}The dielectric constant can "
"not be converted."
)
error_logical = True
elif key in ("smd", "cpcm"):
if censo_solvent_db[self.solvent].get(key, "nothing_found")[
1
].lower() not in getattr(self, lookup[key]):
self.save_errors.append(
f"{'WARNING:':{WARNLEN}}The solvent "
f"{censo_solvent_db[self.solvent].get(key, 'nothing_found')[1]}"
f" for solventmodel/program {key} can not be checked "
"but is used anyway."
)
else:
if censo_solvent_db[self.solvent].get(key, "nothing_found")[
1
] not in getattr(self, lookup[key]):
self.save_errors.append(
f"{'WARNING:':{WARNLEN}}The solvent "
f"{censo_solvent_db[self.solvent].get(key, 'nothing_found')[1]} "
f"for solventmodel/program {key} can not be checked "
"but is used anyway."
)
else:
self.save_errors.append(
f"{'WARNING:':{WARNLEN}}The solvent '{self.solvent}' "
f"is not parameterized for the solventmodel {tmp_sm}, therefore"
f" '{censo_solvent_db[self.solvent].get(key, ['',''])[1]}' is used!!!"
)

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Handle optlevel2:
# sm2 needs to be set (not default!)
Expand Down Expand Up @@ -2935,6 +2970,14 @@ def print_parameters(self, cmlcall=None):
{True: "on"}.get(self.onlyread, self.onlyread),
]
)
if self.vapor_pressure in ("on", True):
info.append(
[
"printoption",
"vapor_pressure",
{True: "on"}.get(self.vapor_pressure, self.vapor_pressure),
]
)

if self.part0:
# PART0:
Expand Down Expand Up @@ -3445,6 +3488,13 @@ def create_SI(self, ensembledata):
out_bib.extend(si_bib.get(item, []))
if self.evaluate_rrho and self.bhess:
out_bib.extend(si_bib.get("sph", []))
if (self.solvent != 'gas' and
any(
[x in ('alpb', 'alpb_gsolv', 'gbsa', 'gbsa_gsolv')
for x in (self.sm_rrho, self.smgsolv1, self.smgsolv2, self.smgsolv3)]
)
):
out_bib.extend(si_bib.get("alpb", []))
print("\nBib entries:")
for line in out_bib:
print(line)
Expand Down
4 changes: 2 additions & 2 deletions censo_qm/nmrproperties.py
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ def part4(config, conformers, store_confs, ensembledata):
)
line = (
f"Coupling constant calculation {check[True]}"
f" for {last_folders(conf.job['workdir'], 2):>{pl}}: "
f" for {last_folders(conf.job['workdir'], 2):>{pl}}"
)
print(line)
calculate.append(prev_calculated.pop(prev_calculated.index(conf)))
Expand Down Expand Up @@ -1191,7 +1191,7 @@ def part4(config, conformers, store_confs, ensembledata):
)
line = (
f"Shielding constant calculation {check[True]}"
f" for {last_folders(conf.job['workdir'], 2):>{pl}}: "
f" for {last_folders(conf.job['workdir'], 2):>{pl}}"
)
print(line)
calculate.append(prev_calculated.pop(prev_calculated.index(conf)))
Expand Down
2 changes: 2 additions & 0 deletions censo_qm/optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,8 @@ def part2(config, conformers, store_confs, ensembledata):
"ctd-param": config.cosmorsparam,
"copymos": str(instruction_gsolv["func"]),
}
if config.vapor_pressure:
tmp["vapor_pressure"] = True
instruction_gsolv.update(tmp)
instruction_gsolv["method"], instruction_gsolv[
"method2"
Expand Down
2 changes: 1 addition & 1 deletion censo_qm/orca_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ def _xtbopt(self):
newcoord.write("$external\n")
newcoord.write(" orca input file= inp\n")
newcoord.write(
f" orca bin= {os.path.join(external_paths['orcapath'], 'orca')}"
f" orca bin= {os.path.join(external_paths['orcapath'], 'orca')} \n"
)
newcoord.write("$end")

Expand Down
2 changes: 2 additions & 0 deletions censo_qm/prescreening.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ def part1(config, conformers, store_confs, ensembledata):
"cosmothermversion": config.external_paths["cosmothermversion"],
"ctd-param": config.cosmorsparam,
}
if config.vapor_pressure:
tmp["vapor_pressure"] = True
instruction.update(tmp)
instruction["method"], instruction["method2"] = config.get_method_name(
"cosmors",
Expand Down
1 change: 1 addition & 0 deletions censo_qm/qm_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def reset_job_info(self):
#
"cosmorsparam": "", # normal/fine
"symnum": 1,
"vapor_pressure": False,
}

def _sp(self, silent=False):
Expand Down
2 changes: 2 additions & 0 deletions censo_qm/refinement.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ def part3(config, conformers, store_confs, ensembledata):
"cosmorsparam": exc_fine.get(config.smgsolv3, "normal"),
"ctd-param": config.cosmorsparam,
}
if config.vapor_pressure:
tmp["vapor_pressure"] = True
instruction.update(tmp)
instruction["method"], instruction["method2"] = config.get_method_name(
"cosmors",
Expand Down
Loading

0 comments on commit d77ced5

Please sign in to comment.