qm

package
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2024 License: LGPL-2.1 Imports: 12 Imported by: 3

Documentation

Index

Constants

View Source
const (
	ErrProbableProblem = "goChem/QM: Probable problem with calculations" //this is never to be used for fatal errors
	ErrMissingCharges  = "goChem/QM: Missing charges or coordinates"
	ErrCantValue       = "goChem/QM: Can't obtain requested value" //for whatever doesn't match anything else
	ErrNoEnergy        = "goChem/QM: No energy in output"
	ErrNoFreeEnergy    = "goChem/QM: No free energy in output. Forces calculation might have not been performed"
	ErrNoCharges       = "goChem/QM: Unable to read charges from  output"
	ErrNoGeometry      = "gochem/QM: Unable to read geometry from output"
	ErrNotRunning      = "gochem/QM: Couldn't run calculation"
	ErrCantInput       = "goChem/QM: Can't build input file"
)
View Source
const (
	Orca      = "Orca"
	Mopac     = "Mopac"
	Turbomole = "Turbomole"
	NWChem    = "NWChem"
	Fermions  = "Fermions++"
	XTB       = "XTB" //this may go away if Orca starts supporting XTB.
)

Variables

This section is empty.

Functions

func ReasonableSetting added in v0.7.0

func ReasonableSetting(k string, Q *Calc) string

Types

type BuilderRunner

type BuilderRunner interface {
	InputBuilder
	Runner
}

Builds inputs and runs a QM calculations

type Calc

type Calc struct {
	Method       string
	Basis        string
	RI           bool
	RIJ          bool
	CartesianOpt bool   //Do the optimization in cartesian coordinates.
	BSSE         string //Correction for BSSE

	HighBasis    string //a bigger basis for certain atoms
	LowBasis     string //lower basis for certain atoms
	HBAtoms      []int
	LBAtoms      []int
	HBElements   []string
	LBElements   []string
	CConstraints []int //cartesian contraints
	IConstraints []*IConstraint
	ECPElements  []string //list of elements with ECP.
	//	IConstraints []IntConstraint //internal constraints
	Dielectric float64
	//	Solventmethod string
	Dispersion string //D2, D3, etc.
	Others     string //analysis methods, etc
	//	PCharges []PointCharge
	Guess string //initial guess
	Grid  int
	OldMO bool //Try to look for a file with MO.
	Job   *Job //NOTE: This should probably be a pointer: FIX!  NOTE2: Fixed it, but must check and fix whatever is now broken.
	//The following 3 are only for MD simulations, will be ignored in every other case.
	MDTime       int     //simulation time (whatever unit the program uses!)
	MDTemp       float64 //simulation temperature (K)
	MDPressure   int     //simulation pressure (whatever unit the program uses!)
	SCFTightness int     //1,2 and 3. 0 means the default
	OptTightness int
	SCFConvHelp  int
	ECP          string //The ECP to be used. It is the programmers responsibility to use a supported ECP (for instance, trying to use 10-electron core ECP for Carbon will fail)
	Gimic        bool
	Memory       int //Max memory to be used in MB (the effect depends on the QM program)
	// contains filtered or unexported fields
}

Calc is a structure for the general representation of a calculation mostly independent of the QM program (although, of course, some methods will not work in some programs)

func (*Calc) SetDefaults

func (Q *Calc) SetDefaults()

Utilities here

type EnergyGeo

type EnergyGeo interface {

	//Energy gets the last energy for a  calculation by parsing the
	//QM program's output file. Return error if fail. Also returns
	//Error ("Probable problem in calculation")
	//if there is a energy but the calculation didnt end properly.
	Energy() (float64, error)

	//OptimizedGeometry reads the optimized geometry from a calculation
	//output. Returns error if fail. Returns Error ("Probable problem
	//in calculation") if there is a geometry but the calculation didnt
	//end properly*
	OptimizedGeometry(atoms chem.Atomer) (*v3.Matrix, error)
}

Allows to recover energy and optimized geometries from a QM calculation

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error represents a decorable QM error.

func (Error) Code

func (err Error) Code() string

Code returns the name of the program that ran/was meant to run the calculation that caused the error.

func (Error) Critical

func (err Error) Critical() bool

Critical return whether the error is critical or it can be ifnored

func (Error) Decorate

func (err Error) Decorate(dec string) []string

Decorate will add the dec string to the decoration slice of strings of the error, and return the resulting slice.

func (Error) Error

func (err Error) Error() string

Error returns a string with an error message.

func (Error) InputName

func (err Error) InputName() string

InputName returns the name of the input file which processing caused the error

type FermionsHandle

type FermionsHandle struct {
	// contains filtered or unexported fields
}

A structure for handing FermiONs calculations Note that the default methods and basis vary with each program, and even for a given program they are NOT considered part of the API, so they can always change.

func NewFermionsHandle

func NewFermionsHandle() *FermionsHandle

NewFermionsHandle initializes and returns a FermionsHandle

func (*FermionsHandle) BuildInput

func (O *FermionsHandle) BuildInput(coords *v3.Matrix, atoms chem.AtomMultiCharger, Q *Calc) error

BuildInput builds an input for Fermions++ based int the data in atoms, coords and C. returns only error.

func (*FermionsHandle) Energy

func (O *FermionsHandle) Energy() (float64, error)

Energy the energy of a previously completed Fermions++ calculation. Returns error if problem, and also if the energy returned that is product of an abnormally-terminated Fermions++ calculation. (in this case error is "Probable problem in calculation")

func (*FermionsHandle) OptimizedGeometry

func (O *FermionsHandle) OptimizedGeometry(atoms chem.Atomer) (*v3.Matrix, error)

OptimizedGeometry does nothing and returns nil for both values. It is there for compatibility but it represents unimplemented functionality.

func (*FermionsHandle) Run

func (O *FermionsHandle) Run(wait bool) (err error)

Run runs the command given by the string O.command it waits or not for the result depending on wait. Not waiting for results works only for unix-compatible systems, as it uses bash and nohup.

func (*FermionsHandle) SetCommand

func (O *FermionsHandle) SetCommand(name string)

SetCommand sets the name and/or path of the FermiONs++ excecutable

func (*FermionsHandle) SetDefaults

func (O *FermionsHandle) SetDefaults()

Sets defaults for Fermions++ calculation. Default is a single-point at revPBE/def2-SVP

func (*FermionsHandle) SetGPU

func (O *FermionsHandle) SetGPU(rawname string)

SetGPU sets GPU usage. Alternatives are "cuda" or "opencl" (alias "ocl"). Anything else is ignored. GPU is off by default.

func (*FermionsHandle) SetName

func (O *FermionsHandle) SetName(name string)

SetName sets the name of the job, that will translate into the input and output files.

func (*FermionsHandle) SetWorkDir added in v0.6.3

func (O *FermionsHandle) SetWorkDir(d string)

SetWorkDir sets the name of the working directory for the Fermions calculations

type Handle

type Handle interface {
	BuilderRunner
	EnergyGeo
}

Handle is an interface for a mostly-full functionality QM program where "functionality" reflects it's degree of support in goChem

type IConstraint

type IConstraint struct {
	CAtoms []int
	Val    float64
	Class  byte // B: distance, A: angle, D: Dihedral
	UseVal bool //if false, don't add any value to the constraint (which should leave it at the value in the starting structure. This migth not work on every program, but it works in ORCA.
}

IConstraint is a container for a constraint to internal coordinates

type InputBuilder

type InputBuilder interface {
	//Sets the name for the job, used for input
	//and output files. The extentions will depend on the program.
	SetName(name string)

	//BuildInput builds an input for the QM program based int the data in
	//atoms, coords and C. returns only error.
	BuildInput(coords *v3.Matrix, atoms chem.AtomMultiCharger, Q *Calc) error
}

builds an input for a QM calculation

type Job

type Job struct {
	Opti    bool
	Forces  bool
	SP      bool
	MD      bool
	Charges bool
}

Job is a structure that define a type of calculations. The user should set one of these to true, and goChem will see that the proper actions are taken. If the user sets more than one of the fields to true, the priority will be Opti>Forces>SP (i.e. if Forces and SP are true, only the function handling forces will be called).

func (*Job) Do

func (J *Job) Do(plan jobChoose)

Do sets the job set to true in J, according to the corresponding function in plan. A "nil" plan means that the corresponding job is not supported by the QM handle and we will default to single point.

type MopacHandle

type MopacHandle struct {
	// contains filtered or unexported fields
}

MopacHandle represents a MOPAC calculations

func NewMopacHandle

func NewMopacHandle() *MopacHandle

NewMopacHandle creates and initializes a new MopacHandle, with values set to its defaults.

func (*MopacHandle) BuildInput

func (O *MopacHandle) BuildInput(coords *v3.Matrix, atoms chem.AtomMultiCharger, Q *Calc) error

BuildInput builds an input for ORCA based int the data in atoms, coords and C. returns only error.

func (*MopacHandle) Energy

func (O *MopacHandle) Energy() (float64, error)

Energy gets the last energy for a MOPAC2009/2012 calculation by parsing the mopac output file. Return error if fail. Also returns Error ("Probable problem in calculation") if there is a energy but the calculation didnt end properly

func (*MopacHandle) OptimizedGeometry

func (O *MopacHandle) OptimizedGeometry(atoms chem.Atomer) (*v3.Matrix, error)

OptimizeGeometry reads the optimized geometry from a MOPAC2009/2012 output. Return error if fail. Returns Error ("Probable problem in calculation") if there is a geometry but the calculation didnt end properly

func (*MopacHandle) Run

func (O *MopacHandle) Run(wait bool) (err error)

Run runs the command given by the string O.command it waits or not for the result depending on wait. Not waiting for results works only for unix-compatible systems, as it uses bash and nohup.

func (*MopacHandle) SetCommand

func (O *MopacHandle) SetCommand(name string)

SetCommand sets the command to run the MOPAC program.

func (*MopacHandle) SetDefaults

func (O *MopacHandle) SetDefaults()

Sets some defaults for MopacHandle. default is an optimization at

PM6-DH2X It tries to locate MOPAC2012 according to the
$MOPAC_LICENSE environment variable, which might only work in UNIX.
If other system or using MOPAC2009 the command Must be set with the
SetCommand function.

func (*MopacHandle) SetName

func (O *MopacHandle) SetName(name string)

SetName sets the name for the job, used for input and output files (ex. input will be name.inp).

func (*MopacHandle) SetWorkDir added in v0.6.3

func (O *MopacHandle) SetWorkDir(d string)

type NWChemHandle

type NWChemHandle struct {
	// contains filtered or unexported fields
}

NWChemHandle represents an NWChem calculation. Note that the default methods and basis vary with each program, and even for a given program they are NOT considered part of the API, so they can always change.

func NewNWChemHandle

func NewNWChemHandle() *NWChemHandle

Initializes and returns a NWChem handle

func (*NWChemHandle) BuildInput

func (O *NWChemHandle) BuildInput(coords *v3.Matrix, atoms chem.AtomMultiCharger, Q *Calc) error

BuildInput builds an input for NWChem based int the data in atoms, coords and C. returns only error.

func (*NWChemHandle) Charges added in v0.6.0

func (O *NWChemHandle) Charges() ([]float64, error)

Charges returns the RESP charges from a previous NWChem calculation.

func (*NWChemHandle) Energy

func (O *NWChemHandle) Energy() (float64, error)

Energy returns the energy of a previous NWChem calculation. Returns error if problem, and also if the energy returned that is product of an abnormally-terminated NWChem calculation. (in this case error is "Probable problem in calculation")

func (*NWChemHandle) OptimizedGeometry

func (O *NWChemHandle) OptimizedGeometry(atoms chem.Atomer) (*v3.Matrix, error)

OptimizedGeometry returns the latest geometry from an NWChem optimization. Returns the geometry or error. Returns the geometry AND error if the geometry read is not the product of a correctly ended NWChem calculation. In this case the error is "probable problem in calculation".

func (*NWChemHandle) Run

func (O *NWChemHandle) Run(wait bool) (err error)

Run runs the command given by the string O.command it waits or not for the result depending on wait. Not waiting for results works only for unix-compatible systems, as it uses bash and nohup.

func (*NWChemHandle) SetCommand

func (O *NWChemHandle) SetCommand(name string)

SetCommand sets the name/path of the MOPAC excecutable

func (*NWChemHandle) SetDefaults

func (O *NWChemHandle) SetDefaults()

SetDefaults sets the NWChem calculation to goChem's default values (_not_ considered part of the API!) As of now, default is a single-point at TPSS/def2-SVP with RI, and half the logical CPUs available (to account for the multithreading common on Intel CPUs)

func (*NWChemHandle) SetMOName

func (O *NWChemHandle) SetMOName(name string)

SetMOName sets the name of a file containing orbitals which will be used as a guess for this calculations

func (*NWChemHandle) SetName

func (O *NWChemHandle) SetName(name string)

SetName sets the name for the job, reflected in the input and output files.

func (*NWChemHandle) SetRestart

func (O *NWChemHandle) SetRestart(r bool)

SetRestart sets whether the calculation is a restart of a previous one.

func (*NWChemHandle) SetSmartCosmo

func (O *NWChemHandle) SetSmartCosmo(set bool)

SetsSmartCosmo sets the behaviour of NWChem regarding COSMO. For an optimization, a true value causes NBWChem to first calculate an SCF with do_gasphase True and use THAT density guess for the first optimization step. The optimization is done with do_gasphase False. for a SP, smartCosmo simply means do_gasphase False. Notice that SmartCosmo is not reallty too smart, for optimizations. In my tests, it doesn't really make things better. I keep it mostly just in case.

func (*NWChemHandle) SetWorkDir added in v0.6.3

func (O *NWChemHandle) SetWorkDir(d string)

SetWorkDir sets the working directory for the calculation

func (*NWChemHandle) SetnCPU added in v0.6.0

func (O *NWChemHandle) SetnCPU(cpu int)

SetnCPU sets the number of CPU to be used

type OrcaHandle

type OrcaHandle struct {
	// contains filtered or unexported fields
}

OrcaHandle represents an Orca calculation. Note that the default methods and basis vary with each program, and even for a given program they are NOT considered part of the API, so they can always change.

func NewOrcaHandle

func NewOrcaHandle() *OrcaHandle

NewOrcaHandle initializes and returns a new OrcaHandle.

func (*OrcaHandle) BuildInput

func (O *OrcaHandle) BuildInput(coords *v3.Matrix, atoms chem.AtomMultiCharger, Q *Calc) error

BuildInput builds an input for ORCA based int the data in atoms, coords and C. returns only error.

func (*OrcaHandle) Energy

func (O *OrcaHandle) Energy() (float64, error)

Energy returns the energy of a previous Orca calculations. Returns error if problem, and also if the energy returned that is product of an abnormally-terminated ORCA calculation. (in this case error is "Probable problem in calculation")

func (*OrcaHandle) OptimizedGeometry

func (O *OrcaHandle) OptimizedGeometry(atoms chem.Atomer) (*v3.Matrix, error)

OptimizedGeometry reads the latest geometry from an ORCA optimization. Returns the

geometry or error. Returns the geometry AND error if the geometry read
is not the product of a correctly ended ORCA calculation. In this case
the error is "probable problem in calculation"

func (*OrcaHandle) Run

func (O *OrcaHandle) Run(wait bool) (err error)

Run runs the command given by the string O.command it waits or not for the result depending on wait. Not waiting for results works only for unix-compatible systems, as it uses bash and nohup.

func (*OrcaHandle) SetCommand

func (O *OrcaHandle) SetCommand(name string)

SetCommand sets the name and path of the Orca excecutable

func (*OrcaHandle) SetDefaults

func (O *OrcaHandle) SetDefaults()

SetDefaults Sets defaults for ORCA calculation. The default is currently a single-point at revPBE/def2-SVP with RI, and all the available CPU with a max of 8. The ORCA command is set to $ORCA_PATH/orca, at least in unix. The default is _not_ part of the API, it can change as new methods appear.

func (*OrcaHandle) SetMOName

func (O *OrcaHandle) SetMOName(name string)

SetMOName sets the name of the file containing molecular orbitales (in the corresponding Orca format) to be used as initial guess.

func (*OrcaHandle) SetName

func (O *OrcaHandle) SetName(name string)

SetName sets the name of the job, which will reflect in the name fo the input and output files.

func (*OrcaHandle) SetOrca3

func (O *OrcaHandle) SetOrca3(b bool)

SetOrca3 sets the use of Orca3 to true or false. The default state is false, meaning that Orca4 is used.

func (*OrcaHandle) SetWorkDir added in v0.6.3

func (O *OrcaHandle) SetWorkDir(d string)

SetWorkDir sets the name of the working directory for the calculation

func (*OrcaHandle) SetnCPU

func (O *OrcaHandle) SetnCPU(cpu int)

SetnCPU sets the number of CPU to be used.

type PointCharge

type PointCharge struct {
	Charge float64
	Coords *v3.Matrix
}

PointCharge is a container for a point charge, such as those used in QM/MM calculations

type Runner

type Runner interface {
	//Run runs the QM program for a calculation previously set.
	//it waits or not for the result depending of the value of
	//wait.
	Run(wait bool) (err error)
}

Runs a QM calculation

type TMHandle

type TMHandle struct {
	// contains filtered or unexported fields
}

TMHandle is the representation of a Turbomole (TM) calculation This imlpementation supports only singlets and doublets.

func NewTMHandle

func NewTMHandle() *TMHandle

Creates and initializes a new instance of TMRuner, with values set to its defaults.

func (*TMHandle) AddToControl added in v0.7.0

func (O *TMHandle) AddToControl(toappend []string, before bool, where ...string) error

Adds the text strings given before or after the first line containing the where[0] string. By default the "target" is "$symmetry"

func (*TMHandle) BuildInput

func (O *TMHandle) BuildInput(coords *v3.Matrix, atoms chem.AtomMultiCharger, Q *Calc) error

BuildInput builds an input for TM based int the data in atoms, coords and C. returns only error. Note that at this point the interface does not support multiplicities different from 1 and 2. The number in atoms is simply ignored.

func (*TMHandle) Energy

func (O *TMHandle) Energy() (float64, error)

Energy returns the energy from the corresponding calculation, in kcal/mol.

func (*TMHandle) Name added in v0.7.0

func (O *TMHandle) Name(name ...string) string

SetName sets the name of the subdirectory, in the current directory where the calculation will be ran

func (*TMHandle) OptimizedGeometry

func (O *TMHandle) OptimizedGeometry(atoms chem.Atomer) (*v3.Matrix, error)

OptimizedGeometry returns the coordinates for the optimized structure.

func (*TMHandle) PreOpt added in v0.7.0

func (O *TMHandle) PreOpt(wait bool) error

func (*TMHandle) Run

func (O *TMHandle) Run(wait bool) error

Run runs the command given by the string O.command it waits or not for the result depending on wait. This is a Unix-only function.

func (*TMHandle) SetCommand

func (O *TMHandle) SetCommand(name string)

SetCommand doesn't do anything, and it is here only for compatibility. In TM the command is set according to the method. goChem assumes a normal TM installation.

func (*TMHandle) SetCosmoPrepCommand added in v0.7.0

func (O *TMHandle) SetCosmoPrepCommand(name string)

SetCommand doesn't do anything, and it is here only for compatibility. In TM the command is set according to the method. goChem assumes a normal TM installation.

func (*TMHandle) SetDefaults

func (O *TMHandle) SetDefaults()

SetDefaults sets default values for TMHandle. default is an optimization at

TPSS-D3 / def2-SVP

Defaults are not part of the API, they might change as new methods appear.

func (*TMHandle) SetDryRun

func (O *TMHandle) SetDryRun(dry bool)

SetDryRun sets the flag to see this is a dry run or if define will actually be run.

func (*TMHandle) SetMARIJ

func (O *TMHandle) SetMARIJ(state bool)

SetMARIJ sets the multipole acceleration

type XTBHandle

type XTBHandle struct {
	// contains filtered or unexported fields
}

XTBHandle represents an xtb calculation

func NewXTBHandle

func NewXTBHandle() *XTBHandle

NewXTBHandle initializes and returns an xtb handle with values set to their defaults. Defaults might change as new methods appear, so they are not part of the API.

func (*XTBHandle) BuildInput

func (O *XTBHandle) BuildInput(coords *v3.Matrix, atoms chem.AtomMultiCharger, Q *Calc) error

BuildInput builds an input for XTB. Right now it's very limited, only singlets are allowed and only unconstrained optimizations and single-points.

func (*XTBHandle) Command

func (O *XTBHandle) Command() string

Command returns the path and name for the xtb excecutable

func (*XTBHandle) Energy

func (O *XTBHandle) Energy() (float64, error)

Energy returns the energy of a previous XTB calculations, in kcal/mol. Returns error if problem, and also if the energy returned that is product of an abnormally-terminated ORCA calculation. (in this case error is "Probable problem in calculation")

func (*XTBHandle) FixImaginary added in v0.6.3

func (O *XTBHandle) FixImaginary(wait bool) error

FixImaginary prepares and runs a calculation on a geometry, produced by xtb on a previous Hessian calculation, which is distorted along the main imaginary mode found, if any. It such mode was not found, and thus the geometry was not produced by xtb, FixImaginary returns an error.

func (*XTBHandle) FreeEnergy added in v0.6.3

func (O *XTBHandle) FreeEnergy() (float64, error)

FreeEnergy returns the Gibbs free energy of a previous XTB calculations. A frequencies/solvation calculation is needed for this to work. FreeEnergy does _not_ check that the structure was at a minimum. You can check that with the LargestIm

func (*XTBHandle) LargestImaginary added in v0.6.3

func (O *XTBHandle) LargestImaginary() (float64, error)

LargestImaginary returns the absolute value of the wave number (in 1/cm) for the largest imaginary mode in the vibspectrum file produced by a forces calculation with xtb. Returns an error and -1 if unable to check.

func (*XTBHandle) MDAverageEnergy added in v0.6.3

func (O *XTBHandle) MDAverageEnergy(start, skip int) (float64, float64, error)

MDAverageEnergy gets the average potential and kinetic energy along a trajectory.

func (*XTBHandle) OptimizedGeometry

func (O *XTBHandle) OptimizedGeometry(atoms chem.Atomer) (*v3.Matrix, error)

OptimizedGeometry returns the latest geometry from an XTB optimization. It doesn't actually need the chem.Atomer but requires it so XTBHandle fits with the QM interface.

func (*XTBHandle) RelConstraints added in v0.6.3

func (O *XTBHandle) RelConstraints(force float64)

RelConstraints sets the use of relative contraints instead of absolute position restraints with the force force constant. If force is less than 0, the default value is employed.

func (*XTBHandle) Run

func (O *XTBHandle) Run(wait bool) (err error)

Run runs the command given by the string O.command it waits or not for the result depending on wait. Not waiting for results works only for unix-compatible systems, as it uses bash and nohup.

func (*XTBHandle) SetCommand

func (O *XTBHandle) SetCommand(name string)

SetCommand sets the path and name for the xtb excecutable

func (*XTBHandle) SetDefaults

func (O *XTBHandle) SetDefaults()

SetDefaults sets calculations parameters to their defaults. Defaults might change as new methods appear, so they are not part of the API.

func (*XTBHandle) SetName

func (O *XTBHandle) SetName(name string)

SetName sets the name for the calculations which is defines the input and output file names

func (*XTBHandle) SetWorkDir added in v0.6.3

func (O *XTBHandle) SetWorkDir(d string)

SetWorkDir sets the name of the working directory for the calculations

func (*XTBHandle) SetnCPU

func (O *XTBHandle) SetnCPU(cpu int)

SetnCPU sets the number of CPU to be used

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL