Skip to content

Instantly share code, notes, and snippets.

@ghutchis
Created March 14, 2026 16:13
Show Gist options
  • Select an option

  • Save ghutchis/fa4c91e4b50676fca5f7fc03e84db7c7 to your computer and use it in GitHub Desktop.

Select an option

Save ghutchis/fa4c91e4b50676fca5f7fc03e84db7c7 to your computer and use it in GitHub Desktop.
{
"highlightStyles": [
{
"style": "default",
"rules": [
{
"patterns": [
{ "string": "AIDER" },
{ "string": "AIGIN" },
{ "string": "AIGOUT" },
{ "string": "ALLBONDS" },
{ "string": "ALLVEC" },
{ "string": "ALT_A" },
{ "string": "ALT_R" },
{ "string": "AM1" },
{ "string": "AUTOSYM" },
{ "string": "AM1" },
{ "string": "BANANA" },
{ "string": "BAR" },
{ "string": "BCC" },
{ "string": "BIGCYCLES" },
{ "string": "BIRADICAL" },
{ "string": "BFGS" },
{ "string": "BONDS" },
{ "string": "BZ" },
{ "string": "CAMP" },
{ "string": "CARTAB" },
{ "string": "C.A.S." },
{ "string": "C.I.D." },
{ "string": "CHAINS" },
{ "string": "CHECK" },
{ "string": "CHARGE" },
{ "string": "CHARGES" },
{ "string": "CHARST" },
{ "string": "CIS" },
{ "string": "CISD" },
{ "string": "CISDT" },
{ "string": "COMPARE" },
{ "string": "COMPFG" },
{ "string": "COSCCH" },
{ "string": "COSWRT" },
{ "string": "CUTOFF" },
{ "string": "CUTOFS" },
{ "string": "CYCLES" },
{ "string": "CVB" },
{ "string": "DAMP" },
{ "string": "DATA" },
{ "string": "DCART" },
{ "string": "DDMAX" },
{ "string": "DDMIN" },
{ "string": "DEBUG" },
{ "string": "DEBUG DELAY" },
{ "string": "DENOUT" },
{ "string": "DENOUF" },
{ "string": "DENSITY" },
{ "string": "DERI1" },
{ "string": "DERI2" },
{ "string": "DERITR" },
{ "string": "DERIV" },
{ "string": "DERNVO" },
{ "string": "DFORCE" },
{ "string": "DFP" },
{ "string": "DIPOLE" },
{ "string": "DISEX" },
{ "string": "DISP" },
{ "string": "DMAX" },
{ "string": "DOUBLET" },
{ "string": "DRC" },
{ "string": "DUMP" },
{ "string": "ECHO" },
{ "string": "EF" },
{ "string": "EIGEN" },
{ "string": "EIGS" },
{ "string": "ENPART" },
{ "string": "EPS" },
{ "string": "ESP" },
{ "string": "ESPGRID" },
{ "string": "ESR" },
{ "string": "EXCITED" },
{ "string": "EXTERNAL" },
{ "string": "FIELD" },
{ "string": "FILL" },
{ "string": "FLEPO" },
{ "string": "FMAT" },
{ "string": "FOCK" },
{ "string": "FREQCY" },
{ "string": "FORCE" },
{ "string": "FORCETS" },
{ "string": "GEO-OK" },
{ "string": "GEO_DAT" },
{ "string": "GEO_REF" },
{ "string": "GNORM" },
{ "string": "GRADIENTS" },
{ "string": "GRAPH" },
{ "string": "GRAPHf" },
{ "string": "HCORE" },
{ "string": "HESSIAN" },
{ "string": "H-PRIORITY" },
{ "string": "HTML" },
{ "string": "HYPERFINE" },
{ "string": "INDO" },
{ "string": "INT" },
{ "string": "INVERT" },
{ "string": "IONIZE" },
{ "string": "IRC" },
{ "string": "ISOTOPE" },
{ "string": "ITER" },
{ "string": "ITRY" },
{ "string": "IUPD" },
{ "string": "KINETIC" },
{ "string": "KING" },
{ "string": "LARGE" },
{ "string": "LBFGS" },
{ "string": "LET" },
{ "string": "LEWIS" },
{ "string": "LINMIN" },
{ "string": "LOCAL" },
{ "string": "LOCATE-TS" },
{ "string": "LOG" },
{ "string": "MAXCI" },
{ "string": "MECI" },
{ "string": "MERS" },
{ "string": "METAL" },
{ "string": "MICROS" },
{ "string": "MINI" },
{ "string": "MINMEP" },
{ "string": "MMOK" },
{ "string": "MNDO" },
{ "string": "MNDOD" },
{ "string": "MODE" },
{ "string": "MOL_QMMM" },
{ "string": "MOLDAT" },
{ "string": "MOLSYM" },
{ "string": "MOPAC" },
{ "string": "MOZYME" },
{ "string": "MRCI" },
{ "string": "MRCI" },
{ "string": "MS" },
{ "string": "MULLIK" },
{ "string": "n**2" },
{ "string": "NEWPDB" },
{ "string": "NOANCI" },
{ "string": "NOCOMMENTS" },
{ "string": "NOGPU" },
{ "string": "NOLOG" },
{ "string": "NOMM" },
{ "string": "NONR" },
{ "string": "NOOPT" },
{ "string": "NOOPT-X" },
{ "string": "NOREOR" },
{ "string": "NORESEQ" },
{ "string": "NOSWAP" },
{ "string": "NOSYM" },
{ "string": "NOTER" },
{ "string": "NOTHIEL" },
{ "string": "NOTXT" },
{ "string": "NOXYZ" },
{ "string": "NSPA" },
{ "string": "NSURF" },
{ "string": "OCTET" },
{ "string": "OLDCAV" },
{ "string": "OLDENS" },
{ "string": "OLDFPC" },
{ "string": "OLDGEO" },
{ "string": "OMIN" },
{ "string": "OPEN" },
{ "string": "OPT" },
{ "string": "OPT-X" },
{ "string": "OUTPUT" },
{ "string": "P" },
{ "string": "PDB" },
{ "string": "PDBOUT" },
{ "string": "PECI" },
{ "string": "PI" },
{ "string": "pKa" },
{ "string": "PL" },
{ "string": "PM3" },
{ "string": "PM6" },
{ "string": "PM6-D3" },
{ "string": "PM6-DH+" },
{ "string": "PM6-DH2" },
{ "string": "PM6-DH2X" },
{ "string": "PM6-D3H4" },
{ "string": "PM6-D3H4X" },
{ "string": "PM6-ORG" },
{ "string": "PMEP" },
{ "string": "PM7" },
{ "string": "PM7-TS" },
{ "string": "PMEPR" },
{ "string": "POINT" },
{ "string": "POINT1" },
{ "string": "POINT2" },
{ "string": "POLAR" },
{ "string": "POTWRT" },
{ "string": "POWSQ" },
{ "string": "PRESSURE" },
{ "string": "PRNT" },
{ "string": "PRTCHAR" },
{ "string": "PRTINT" },
{ "string": "PRTMEP" },
{ "string": "PRTXYZ" },
{ "string": "PULAY" },
{ "string": "QMM" },
{ "string": "QPMEP" },
{ "string": "QUARTET" },
{ "string": "QUINTET" },
{ "string": "RABBIT" },
{ "string": "RAMA" },
{ "string": "RAPID" },
{ "string": "RECALC" },
{ "string": "RE-LOCAL" },
{ "string": "RELSCF" },
{ "string": "REORTHOG" },
{ "string": "RESEQ" },
{ "string": "RESIDUES" },
{ "string": "RESTART" },
{ "string": "RHF" },
{ "string": "RMAX" },
{ "string": "RMIN" },
{ "string": "ROOT" },
{ "string": "RSCAL" },
{ "string": "RSOLV" },
{ "string": "SADDLE" },
{ "string": "SCALE" },
{ "string": "SCFCRT" },
{ "string": "SCINCR" },
{ "string": "SEPTET" },
{ "string": "SETPI" },
{ "string": "SETUP" },
{ "string": "SEXTET" },
{ "string": "SHIFT" },
{ "string": "SHUT" },
{ "string": "SIGMA" },
{ "string": "SINGLET" },
{ "string": "SITE" },
{ "string": "SLOG" },
{ "string": "SLOPE" },
{ "string": "SMOOTH" },
{ "string": "SNAP" },
{ "string": "SPARKLE" },
{ "string": "SPIN" },
{ "string": "START_RES" },
{ "string": "STATIC" },
{ "string": "STEP" },
{ "string": "STEP1" },
{ "string": "STEP2" },
{ "string": "STO3G" },
{ "string": "SUPER" },
{ "string": "SYMAVG" },
{ "string": "SYMOIR" },
{ "string": "SYMTRZ" },
{ "string": "SYMMETRY" },
{ "string": "T" },
{ "string": "TDIP" },
{ "string": "THERMO" },
{ "string": "THREADS" },
{ "string": "TIMES" },
{ "string": "T-PRIORITY" },
{ "string": "TRANS" },
{ "string": "TRIPLET" },
{ "string": "TS" },
{ "string": "UHF" },
{ "string": "VDW" },
{ "string": "VDWM" },
{ "string": "VECTORS" },
{ "string": "VELOCITY" },
{ "string": "WRTCI" },
{ "string": "WRTCONF" },
{ "string": "WILLIAMS" },
{ "string": "X-PRIORITY" },
{ "string": "XENO" },
{ "string": "XYZ" },
{ "string": "Z" },
{ "string": "ZERO" },
{ "string": "0SCF" },
{ "string": "1ELECTRON" },
{ "string": "1SCF" }
],
"format": {
"preset": "keyword"
}
}
]
}
]
}
# SPDX-FileCopyrightText: 2026 Avogadro Project
# SPDX-License-Identifier: BSD 3-Clause
# ******************************************************************************
# This source file is part of the Avogadro project.
#
# This source code is released under the New BSD License, (the "License").
# ******************************************************************************
"""Input generation for MOPAC (https://openmopac.net/)."""
def generateInputFile(input_json: dict) -> tuple[str, list[str]]:
# Collect warning strings as we go
warnings = []
# Extract options:
opts = input_json['options']
title = opts['Title']
calculate = opts['Calculation Type']
theory = opts['Theory']
multiplicity = opts['Multiplicity']
charge = opts['Charge']
nCores = int(opts['Processor Cores'])
solvent = opts['Solvent']
optionaldielectric = opts['Other Solvent Dielectric']
hftype = opts['HF Type']
cosmo = opts['COSMO']
solventlist = {"Acetic acid": 6.15, "Acetone": 20.7, "Acetonitrile": 37.5,
"Anisole": 4.33, "Benzene": 2.27, "Bromobenzene": 5.17, "Carbon disulfide": 2.6,
"Carbon tetrachloride": 2.24, "Chlorobenzene": 5.62, "Chloroform": 4.81,
"Cyclohexane": 2.02, "Dibutyl ether": 3.1, "o-Dichlorobenzene": 9.93,
"1,2-Dichloroethane": 10.36, "Dichloromethane": 8.93, "Diethylamine": 3.6,
"Diethylether": 4.33, "1,2-Dimethoxyethane": 7.2, "N,N-Dimethylacetamide": 37.8,
"N,N-Dimethylformamide": 36.7, "Dimethylsulfoxide": 46.7, "1,4-Dioxane": 2.25,
"Ethanol": 24.5, "Ethyl acetate": 6.02, "Ethyl benzoate": 6.02, "Formamide": 111,
"Hexamethylphosphoramide": 30, "Isopropyl lcohol": 17.9, "Methanol": 32.7,
"2-Methyl-2-propanol": 10.9, "Nitrobenzene": 34.82, "Nitromethane": 35.87,
"Pyridine": 12.4, "Tetrahydrofuran": 7.58, "Toluene": 2.38, "Trichloroethylene": 3.4,
"Triethylamine": 2.42, "Trifluoroacetic acid": 8.55, "2,2,2-Trifluoroethanol": 8.55,
"Water": 80.1, "o-Xylene": 2.57}
generated_input = ''
# Multiplicity
multStr = ''
if multiplicity == 1:
multStr = 'SINGLET'
elif multiplicity == 2:
multStr = 'DOUBLET'
elif multiplicity == 3:
multStr = 'TRIPLET'
elif multiplicity == 4:
multStr = 'QUARTET'
elif multiplicity == 5:
multStr = 'QUINTET'
elif multiplicity == 6:
multStr = 'SEXTET'
else:
raise Exception('Unhandled multiplicity: %d' % multiplicity)
# Calculation type:
calcStr = ''
if calculate == 'Single Point':
calcStr = 'NOOPT'
elif calculate == 'Equilibrium Geometry':
pass
elif calculate == 'Frequencies':
calcStr = 'FORCE'
elif calculate == 'Transition State':
calcStr = 'SADDLE'
else:
raise Exception('Unhandled calculation type: %s' % calculate)
eps = ""
dielectric = ""
if solvent == "OTHER":
dielectric = optionaldielectric
else:
dielectric = str(solventlist[solvent])
if cosmo is True:
eps = "EPS=" + dielectric
if multiplicity > 1:
hftype = 'UHF'
# Charge, mult, calc type, theory:
generated_input += ' AUX LARGE CHARGE=%d %s %s %s %s PDBOUT THREADS=%d %s\n' %\
(charge, multStr, calcStr, theory, eps, nCores, hftype)
# Title
generated_input += '%s\n\n' % title
# Coordinates
if calculate == 'Single Point':
generated_input += '$$coords:Sx0y0z0$$\n'
else:
generated_input += '$$coords:Sx1y1z1$$\n'
return generated_input, warnings
def generateInput(input_json: dict, debug: bool) -> dict:
generated_input, warnings = generateInputFile(input_json)
filename = input_json['options']['Filename Base'] + '.mop'
result = {
'files': [
{'filename': filename,
'contents': generated_input,
'highlightStyles': ['default']}
],
'mainFile': filename,
}
if warnings:
result['warnings'] = warnings
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment