Example #1
0
func main() {
	if len(os.Args) < 3 {
		fmt.Println("Usage: ", os.Args[0], "test.xyz template.xyz  \"indexes for test\"  \"indexes for template\" \n The indexes, given between quotations, are a list of integers separated by spaces which contains the atoms that will be used from each molecule to calculate the rotation matrix. If one or both indexes lists is empty (\"\"), the whole molecule will be used.")
		panic(":-)") //Not very subtle but oh well.
	}
	test, _ := chem.XYZFileRead(os.Args[1])
	templa, _ := chem.XYZFileRead(os.Args[2])
	testlist, _ := scu.IndexStringParse(os.Args[3])
	templalist, _ := scu.IndexStringParse(os.Args[4])
	test2, err := chem.Super(test.Coords[0], templa.Coords[0], testlist, templalist)
	if err != nil {
		panic(err)
	}
	chem.XYZFileWrite("superimposed.xyz", test2, test)
	rmsd, err := chem.RMSD(test2, templa.Coords[0])
	fmt.Println(rmsd)
}
Example #2
0
func main() {
	mol, err := chem.XYZFileRead(os.Args[1])
	if err != nil {
		panic(err.Error())
	}
	ndx, _ := scu.IndexStringParse(os.Args[2])
	fmt.Println(ndx)
	coord := mol.Coords[0]
	piv := coord.VecView(ndx[0])
	v1 := coord.VecView(ndx[1])
	v2 := coord.VecView(ndx[2])
	v1.Sub(v1, piv)
	v2.Sub(v2, piv)
	plane := v3.Zeros(1)
	plane.Cross(v1, v2)
	vfin := coord.VecView(ndx[3])
	vfin.Sub(vfin, piv)
	angle := chem.Angle(vfin, plane)
	fmt.Println(90-angle*chem.Rad2Deg, 90+angle*chem.Rad2Deg)
}
Example #3
0
func main() {
	//flag parsing
	//Lots of options, but the defaults are sane enough that you shouldnt need to use more than the filename and qm program.
	charge := flag.Int("charge", 0, "The charge of the system.")
	multi := flag.Int("multi", 1, "The multiplicity of the system.")
	filename := flag.String("file", "file.xyz", "The XYZ file containing the coordinates for the system.")
	functional := flag.String("func", "BP86", "The density functional used. TPSS and BP86 activate RI when possible.")
	program := flag.String("program", "nwchem", "The QM program used: qcmine, nwchem, or orca.")
	basis := flag.String("basis", "def2-SVP", "the basis set to use. Use Karlsruhe basis.")
	dielectric := flag.Float64("epsilon", -1, "The dielectric constant. -1 indicates no dielectric used.")
	optimize := flag.Bool("opt", true, "Wether to optimize or run an SP calculation.")
	fixed := flag.String("fixed", "", "Fixed atoms, counting from zero, separated by spaces.")
	flag.Parse()
	//We set the calculation to the values in the flags. Not big deal.
	mol, err := chem.XYZFileRead(*filename)
	if err != nil {
		panic(err.Error())
	}
	mol.SetMulti(*multi)
	mol.SetCharge(*charge)
	calc := new(qm.Calc)
	if strings.Contains("TPSS,BP86,PBE", *functional) {
		calc.RI = true
	}
	if *fixed != "" {
		calc.CConstraints, err = scu.IndexStringParse(*fixed)
		if err != nil {
			panic(err.Error())
		}
	}
	calc.Memory = 1000
	calc.Dielectric = *dielectric
	calc.Grid = 3
	if !strings.HasPrefix(*basis, "def2") {
		fmt.Println("Told ya to use Karlsruhe basis! RI cannot be activated. Happy now?")
		calc.RI = false
	}
	calc.Basis = *basis
	calc.Job.Opti = true //for the preeliminar calculation we always optimize, regarless of the user's input, because it's, well, a preoptimization.
	if calc.Job.Opti {
		calc.SCFTightness = 1
	}
	calc.Dispersion = "D3"
	//The preeliminar optimization will have a different name.
	namep := strings.Replace(*filename, ".xyz", "OPT", -1)
	name := strings.Replace(*filename, ".xyz", "", -1)
	pre := qm.NewMopacHandle()
	pre.SetName(namep)
	pre.BuildInput(mol.Coords[0], mol, calc)
	pre.Run(true)
	ncoords, err := pre.OptimizedGeometry(mol)
	if err != nil {
		panic(err.Error())
	}
	calc.Job.Opti = *optimize //here we optimize depending on what the user wants
	//MOPAC will overwrite the method, as it doesnt support DFT. This is why we set it AFTER the preeliminar calculations
	calc.Method = *functional
	var QM qmdef
	switch *program {
	default:
		QM = qmdef(qm.NewNWChemHandle())
	case "orca":
		QM = qmdef(qm.NewOrcaHandle())
		//		default:
		//			//There is a hicup with ChemShell since I have not implemented a few methods.
		//			//I should have an interface in goChem that does not require Energy() and OptimizedGeometry()
		//			CS:=qm.NewCSHandle()
		//			CS.SetDefaults()
		//			CS.SetName(name)
		//			CS.BuildInput(ncoords,mol,calc)
	}
	if QM != nil {
		QM.SetDefaults()
		QM.SetName(name)
		QM.BuildInput(ncoords, mol, calc)
	}
	newfilename := strings.Replace(*filename, ".xyz", "_preopt.xyz", 1)
	chem.XYZFileWrite(newfilename, ncoords, mol)
	fmt.Fprintln(os.Stderr, "Apparently, we made it :-)")
}