本文整理汇总了Golang中github.com/rmera/gochem/v3.Matrix.View方法的典型用法代码示例。如果您正苦于以下问题:Golang Matrix.View方法的具体用法?Golang Matrix.View怎么用?Golang Matrix.View使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/rmera/gochem/v3.Matrix
的用法示例。
在下文中一共展示了Matrix.View方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
//.........这里部分代码省略.........
} else {
calc.Basis = "def2-TZVP"
}
//We will use the default methods and basis sets of each program. In the case of MOPAC, that is currently PM6-D3H4.
var QM qm.Handle
switch qmprogram {
case "ORCA":
orca := qm.NewOrcaHandle()
orca.SetnCPU(runtime.NumCPU())
QM = qm.Handle(orca)
case "TURBOMOLE":
QM = qm.Handle(qm.NewTMHandle())
case "NWCHEM":
QM = qm.Handle(qm.NewNWChemHandle())
calc.SCFConvHelp = 1
default:
QM = qm.Handle(qm.NewMopacHandle())
}
QM.SetName(mainName)
QM.BuildInput(bigC, bigA, calc)
fmt.Fprint(os.Stderr, options.BoolOptions)
if options.BoolOptions[0][2] {
return //Dry run
}
if err2 := QM.Run(true); err != nil {
log.Fatal(err2.Error())
}
//Now we ran the calculation, we must retrive the geometry and divide the coordinates among the original selections.
var newBigC *v3.Matrix
info := new(chemjson.Info) //Contains the return info
var err2 error
if calc.Optimize {
newBigC, err2 = QM.OptimizedGeometry(bigA)
if err2 != nil {
log.Fatal(err2.Error())
}
if qmprogram == "NWCHEM" { //NWchem translates/rotates the system before optimizing so we need to superimpose with the original geometry in order for them to match.
newBigC, err2 = chem.Super(newBigC, bigC, bigFroz, bigFroz)
if err2 != nil {
log.Fatal(err2.Error())
}
}
info.Molecules = len(options.AtomsPerSel)
geooffset := 0
if options.BoolOptions[0][0] {
tmp := newBigC.View(geooffset, 0, len(sidelist), 3) //This is likely to change when we agree on a change for the gonum API!!!!
sidecoords.SetVecs(tmp, sidelist)
info.FramesPerMolecule = []int{1}
info.AtomsPerMolecule = []int{sidecoords.NVecs()}
//I DO NOT understand why the next line is += len(sidelist)-1 instead of len(sidelist), but it works. If a bug appears
//take a look at this line, and the equivalent in the for loop that follows.
geooffset += (len(sidelist) - 1)
}
for k, v := range bbcoords {
//Take a look here in case of bugs.
tmp := newBigC.View(geooffset, 0, len(bblist[k]), 3) //This is likely to change when we agree on a change for the gonum API!!!!
v.SetVecs(tmp, bblist[k])
info.FramesPerMolecule = append(info.FramesPerMolecule, 1)
info.AtomsPerMolecule = append(info.AtomsPerMolecule, v.NVecs())
geooffset += (len(bblist[k]) - 1)
}
// for k,v:=range(bbcoords){
// chem.XYZWrite(fmt.Sprintf("opti%d.xyz",k), , newcoords)
// }
} else {
//nothing here, the else part will get deleted after tests
}
energy, err2 := QM.Energy()
if err2 != nil {
log.Fatal(err2.Error())
}
//Start transfering data back
info.Energies = []float64{energy}
if err2 := info.Send(os.Stdout); err2 != nil {
fmt.Fprint(os.Stderr, err2)
log.Fatal(err2)
}
// fmt.Fprint(os.Stdout,mar)
// fmt.Fprint(os.Stdout,"\n")
// A loop again to transmit the info.
if options.BoolOptions[0][0] {
if err := chemjson.SendMolecule(nil, []*v3.Matrix{sidecoords}, nil, nil, os.Stdout); err2 != nil {
fmt.Fprint(os.Stderr, err)
log.Fatal(err)
}
}
for _, v := range bbcoords {
fmt.Fprintln(os.Stderr, "BB transmit!", v.NVecs())
if err := chemjson.SendMolecule(nil, []*v3.Matrix{v}, nil, nil, os.Stdout); err2 != nil {
fmt.Fprint(os.Stderr, err)
log.Fatal(err)
}
}
}