qm

package
Version: v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2021 License: LGPL-2.1 Imports: 11 Imported by: 2

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"
	ErrNoEnergy        = "goChem/QM: No energy in output"
	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

This section is empty.

Types

type BuilderRunner

type BuilderRunner interface {
	InputBuilder
	Runner
}

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. The
	Job   Job  //NOTE: This should probably be a pointer: FIX!
	//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
	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
}

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
}

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
}

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

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)

Gets the energy of a previous 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)

I don't have this implemented so far, sorry.

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)

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)

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)

type Handle

type Handle interface {
	BuilderRunner
	EnergyGeo
}

This allows to set QM calculations using different programs.

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.
}

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 IntConstraint

type IntConstraint struct {
	Kind  byte
	Atoms []int
}

type Job

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

This is what the user actually deasl with. 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 you set Forces and SP to 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
}

func NewMopacHandle

func NewMopacHandle() *MopacHandle

Creates and initialized a new instance of MopacRunner, 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)

Get Geometry 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)

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)

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

type NWChemHandle

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

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

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)

Gets 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) Energy

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

Gets 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)

Reads 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)

func (*NWChemHandle) SetDefaults

func (O *NWChemHandle) SetDefaults()

Sets defaults for NWChem calculation. Default is a single-point at TPSS/def2-SVP with RI, and all the available CPU with a max of unix.

func (*NWChemHandle) SetMOName

func (O *NWChemHandle) SetMOName(name string)

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)

func (*NWChemHandle) SetRestart

func (O *NWChemHandle) SetRestart(r bool)

func (*NWChemHandle) SetSmartCosmo

func (O *NWChemHandle) SetSmartCosmo(set bool)

For an optimization, 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 for further testing, and may never make it to the master branch. My tests indicate that just using do_gasphase False is good enough for optimizations.

func (*NWChemHandle) SetnCPU added in v0.6.0

func (O *NWChemHandle) SetnCPU(cpu int)

Sets the number of CPU to be used

type OrcaHandle

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

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

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)

Gets 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)

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)

func (*OrcaHandle) SetDefaults

func (O *OrcaHandle) SetDefaults()

Sets defaults for ORCA calculation. Default is 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.

func (*OrcaHandle) SetMOName

func (O *OrcaHandle) SetMOName(name string)

func (*OrcaHandle) SetName

func (O *OrcaHandle) SetName(name string)

func (*OrcaHandle) SetOrca3

func (O *OrcaHandle) SetOrca3(b bool)

As per the "zero value" of structures in Go, the default for goChem will be to use Orca 4

func (*OrcaHandle) SetnCPU

func (O *OrcaHandle) SetnCPU(cpu int)

Sets the number of CPU to be used

type PointCharge

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

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
}

This imlpementation supports only singlets and doublets.

func NewTMHandle

func NewTMHandle() *TMHandle

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

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) OptimizedGeometry

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

OptimizedGeometry returns the coordinates for the optimized structure.

func (*TMHandle) Run

func (O *TMHandle) 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. This is a Unix-only function.

func (*TMHandle) SetCommand

func (O *TMHandle) SetCommand(name string)

In TM the command is set according to the method. I just assume a normal installation. This method doesnt do anything.

func (*TMHandle) SetDefaults

func (O *TMHandle) SetDefaults()

Sets some defaults for TMHandle. default is an optimization at

TPSS-D3 / def2-SVP

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

func (*TMHandle) SetName

func (O *TMHandle) SetName(name string)

This set the name of the subdirectory, in the current directory where the calculation will be ran

type XTBHandle

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

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 NewXTBHandle

func NewXTBHandle() *XTBHandle

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

func (*XTBHandle) Energy

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

Gets the energy of a previous XTB 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 (*XTBHandle) OptimizedGeometry

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

Reads 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) 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)

func (*XTBHandle) SetDefaults

func (O *XTBHandle) SetDefaults()

func (*XTBHandle) SetName

func (O *XTBHandle) SetName(name string)

func (*XTBHandle) SetnCPU

func (O *XTBHandle) SetnCPU(cpu int)

Sets the number of CPU to be used

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL