diff -Nru bagel-1.2.0/debian/changelog bagel-1.2.2/debian/changelog --- bagel-1.2.0/debian/changelog 2018-12-24 04:09:23.000000000 +0000 +++ bagel-1.2.2/debian/changelog 2019-01-01 11:20:07.000000000 +0000 @@ -1,8 +1,9 @@ -bagel (1.2.0-5build1) disco; urgency=medium +bagel (1.2.2-1) unstable; urgency=medium - * No-change rebuild against libxc5 + * New upstream release. + * debian/patches/fix_dkhgrad.patch: Removed, no longer needed. - -- Steve Langasek Mon, 24 Dec 2018 04:09:23 +0000 + -- Michael Banck Tue, 01 Jan 2019 12:20:07 +0100 bagel (1.2.0-5) unstable; urgency=medium diff -Nru bagel-1.2.0/debian/control bagel-1.2.2/debian/control --- bagel-1.2.0/debian/control 2018-12-24 04:09:23.000000000 +0000 +++ bagel-1.2.2/debian/control 2018-02-09 16:16:35.000000000 +0000 @@ -1,8 +1,7 @@ Source: bagel Section: science Priority: optional -Maintainer: Ubuntu Developers -XSBC-Original-Maintainer: Debichem Team +Maintainer: Debichem Team Uploaders: Michael Banck , Graham Inggs Build-Depends: debhelper (>= 9), diff -Nru bagel-1.2.0/debian/patches/fix_dkhgrad.patch bagel-1.2.2/debian/patches/fix_dkhgrad.patch --- bagel-1.2.0/debian/patches/fix_dkhgrad.patch 2018-11-24 13:22:49.000000000 +0000 +++ bagel-1.2.2/debian/patches/fix_dkhgrad.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -From 9f130bffe5e52c0640865fa93a220c30d081b5af Mon Sep 17 00:00:00 2001 -From: Toru Shiozaki -Date: Tue, 30 Oct 2018 11:07:03 -0400 -Subject: [PATCH] Bug in Molecule::uncontract fixed. Resolves #138 - ---- - src/molecule/atom.cc | 2 +- - src/molecule/molecule.cc | 10 ++++++++++ - 2 files changed, 11 insertions(+), 1 deletion(-) - -diff --git a/src/molecule/atom.cc b/src/molecule/atom.cc -index a92c3200f..70ac9da55 100644 ---- a/src/molecule/atom.cc -+++ b/src/molecule/atom.cc -@@ -577,7 +577,7 @@ shared_ptr Atom::relativistic() const { - rshells.push_back(tmp); - } - auto atom = make_shared(*this); -- atom->shells_ = rshells; -+ atom->reset_shells(rshells); - return atom; - } - -diff --git a/src/molecule/molecule.cc b/src/molecule/molecule.cc -index e435422ad..681ce6bd0 100644 ---- a/src/molecule/molecule.cc -+++ b/src/molecule/molecule.cc -@@ -845,6 +845,16 @@ shared_ptr Molecule::uncontract() const { - atom.push_back(i->uncontract()->relativistic()); - - auto mol = make_shared(atom, aux_atoms_); -+ mol->spherical_ = spherical_; -+ mol->aux_merged_ = aux_merged_; -+ mol->basisfile_ = basisfile_; -+ mol->auxfile_ = auxfile_; -+ mol->nuclear_repulsion_ = nuclear_repulsion_; -+ mol->external_ = external_; -+ mol->magnetic_field_ = magnetic_field_; -+ mol->skip_self_interaction_ = skip_self_interaction_; -+ mol->cap_ = cap_; -+ - mol->common_init1(); - - return mol; diff -Nru bagel-1.2.0/debian/patches/series bagel-1.2.2/debian/patches/series --- bagel-1.2.0/debian/patches/series 2018-11-24 13:23:19.000000000 +0000 +++ bagel-1.2.2/debian/patches/series 2019-01-01 11:19:17.000000000 +0000 @@ -1,2 +1 @@ skip_failing_testcases.patch -fix_dkhgrad.patch diff -Nru bagel-1.2.0/docs/grad/force.html bagel-1.2.2/docs/grad/force.html --- bagel-1.2.0/docs/grad/force.html 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/docs/grad/force.html 2018-12-29 22:08:28.000000000 +0000 @@ -149,6 +149,14 @@
+

ciderivative

+
+
Description: Evaluate the CI derivative and full gradient in XMS-CASPT2. If false, only unrelaxed density will be calculated.
+
Datatype: bool
+
Default: true
+
+
+

export

Description: This option will export the nuclear gradient to a text file.
@@ -261,22 +269,22 @@ { "title" : "force", - "target" : 0, - "method" : [ { - "title" : "caspt2", - "smith" : { - "method" : "caspt2", - "ms" : "true", - "xms" : "true", - "sssr" : "true", - "shift" : 0.2, - "frozen" : true - }, - "nstate" : 2, - "nact" : 3, - "nclosed" : 46 - } ] - } + "target" : 0, + "method" : [ { + "title" : "caspt2", + "smith" : { + "method" : "caspt2", + "ms" : "true", + "xms" : "true", + "sssr" : "true", + "shift" : 0.2, + "frozen" : true + }, + "nstate" : 2, + "nact" : 3, + "nclosed" : 46 + } ] +}
@@ -284,48 +292,99 @@

Sample input: NACME and DGRAD

{
  "title" : "nacme",
-   "target" : 0,
-   "target2" : 1,
-   "method" : [ {
-     "title" : "caspt2",
-       "smith" : {
-         "method" : "caspt2",
-         "ms" : "true",
-         "xms" : "true",
-         "sssr" : "true",
-         "shift" : 0.2,
-         "frozen" : true
-     },
-     "nstate" : 3,
-     "nact" : 7,
-     "nclosed" : 44
-   } ]
- }
+ "target" : 0,
+ "target2" : 1,
+ "method" : [ {
+   "title" : "caspt2",
+   "smith" : {
+     "method" : "caspt2",
+     "ms" : "true",
+     "xms" : "true",
+     "sssr" : "true",
+     "shift" : 0.2,
+     "frozen" : true
+   },
+   "nstate" : 3,
+   "nact" : 7,
+   "nclosed" : 44
+ } ]
+}
 

Using the keyword forces, you can run multiple gradient or derivative coupling calculations without repeating the energy calculations. The example below evaluates the nuclear gradient of the energy of the ground state, the first excited state, and the interstate coupling vector (nacmtype is interstate) between these two states.

{
  "title" : "forces",
-   "grads" : [
-     { "title" : "force", "target" : 0 },
-     { "title" : "force", "target" : 1 },
-     { "title" : "nacme", "target" : 0, "target2" : 1, "nacmtype" : "interstate" }
-   ],
-   "method" : [ {
-     "title" : "caspt2",
-       "smith" : {
-         "method" : "caspt2",
-         "ms" : "true",
-         "xms" : "true",
-         "sssr" : "true",
-         "shift" : 0.2,
-         "frozen" : true
-     },
-     "nstate" : 3,
-     "nact" : 7,
-     "nclosed" : 44
-   } ]
- }
+ "grads" : [
+   { "title" : "force", "target" : 0 },
+   { "title" : "force", "target" : 1 },
+   { "title" : "nacme", "target" : 0, "target2" : 1, "nacmtype" : "interstate" }
+ ],
+ "method" : [ {
+   "title" : "caspt2",
+   "smith" : {
+     "method" : "caspt2",
+     "ms" : "true",
+     "xms" : "true",
+     "sssr" : "true",
+     "shift" : 0.2,
+     "frozen" : true
+   },
+   "nstate" : 3,
+   "nact" : 7,
+   "nclosed" : 44
+ } ]
+}
+
+
+ +
+

Sample input: Printing dipole moments

+

You can use the keyword dipole to compute the dipole moments for all the states, the transition dipole moments and oscillator strengths of all possible pairs of electronic states.

+
{
+ "title" : "forces",
+ "dipole" : "true",
+ "method" : [ {
+   "title" : "caspt2",
+   "smith" : {
+     "method" : "caspt2",
+     "ms" : "true",
+     "xms" : "true",
+     "sssr" : "true",
+     "shift" : 0.2,
+     "frozen" : true
+   },
+   "nstate" : 3,
+   "nact" : 7,
+   "nclosed" : 44
+ } ]
+}
+
+
+

Alternatively, for CASPT2, you can use the keyword "ciderivative" : "false" to evaluate the dipole moments, transition dipole moments and oscillator strengths of selected states, +without computing the CI derivative term and gradient. +The example below evaluates the dipole moments of state 0, state 1, and transition dipole moment of the state 0 – state 1 transition.

+
{
+ "title" : "forces",
+ "grads" : [
+   { "title" : "force", "target" : 0, "ciderivative" : "false" },
+   { "title" : "force", "target" : 1, "ciderivative" : "false" },
+   { "title" : "nacme", "target" : 0, "target2" : 1, "nacmtype" : "interstate", "ciderivative" : "false" }
+ ],
+ "method" : [ {
+   "title" : "caspt2",
+   "smith" : {
+     "method" : "caspt2",
+     "ms" : "true",
+     "xms" : "true",
+     "sssr" : "true",
+     "shift" : 0.2,
+     "frozen" : true
+   },
+   "nstate" : 3,
+   "nact" : 7,
+   "nclosed" : 44
+ } ]
+}
 
diff -Nru bagel-1.2.0/docs/searchindex.js bagel-1.2.2/docs/searchindex.js --- bagel-1.2.0/docs/searchindex.js 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/docs/searchindex.js 2018-12-29 22:08:28.000000000 +0000 @@ -1 +1 @@ -Search.setIndex({docnames:["asd/asd","asd/asd_dmrg","asd/asd_orbopt","asd/dimer","asd/dimer_asd","asd/multisite","author","ci/ci_methods","ci/fci","ci/rasci","ci/zfci","funding","grad/dynamics","grad/force","grad/grad","grad/hess","grad/methods","index","miscellaneous/localization","miscellaneous/misc","miscellaneous/molden","miscellaneous/moprint","miscellaneous/save_ref","molecule/molecule","molecule/molecule-toc","multi/casscf","multi/multi","multi/zcasscf","opt/optimize","pt2/caspt2","pt2/mp2","pt2/nevpt2","pt2/pt2","pt2/relcaspt2","quickstart/how_to_run_bagel","quickstart/installation_guide","quickstart/quickstart","scf/dhf","scf/hf","scf/scf","smith/caspt2","smith/mrci","smith/relcaspt2","smith/relmrci","smith/smith","supp_info/constants","supp_info/supp_info","user-manual"],envversion:54,filenames:["asd/asd.rst","asd/asd_dmrg.rst","asd/asd_orbopt.rst","asd/dimer.rst","asd/dimer_asd.rst","asd/multisite.rst","author.rst","ci/ci_methods.rst","ci/fci.rst","ci/rasci.rst","ci/zfci.rst","funding.rst","grad/dynamics.rst","grad/force.rst","grad/grad.rst","grad/hess.rst","grad/methods.rst","index.rst","miscellaneous/localization.rst","miscellaneous/misc.rst","miscellaneous/molden.rst","miscellaneous/moprint.rst","miscellaneous/save_ref.rst","molecule/molecule.rst","molecule/molecule-toc.rst","multi/casscf.rst","multi/multi.rst","multi/zcasscf.rst","opt/optimize.rst","pt2/caspt2.rst","pt2/mp2.rst","pt2/nevpt2.rst","pt2/pt2.rst","pt2/relcaspt2.rst","quickstart/how_to_run_bagel.rst","quickstart/installation_guide.rst","quickstart/quickstart.rst","scf/dhf.rst","scf/hf.rst","scf/scf.rst","smith/caspt2.rst","smith/mrci.rst","smith/relcaspt2.rst","smith/relmrci.rst","smith/smith.rst","supp_info/constants.rst","supp_info/supp_info.rst","user-manual.rst"],objects:{},objnames:{},objtypes:{},terms:{"0000e":41,"00e":[8,25,27],"01e":25,"02e":[8,27],"0380e":41,"03e":27,"04e":27,"06e":[25,27],"07e":27,"08e":27,"09e":[8,25],"10e":27,"10lf":12,"1101e":41,"1102e":41,"11e":[25,27],"12e":27,"13e":[8,25,27],"14e":25,"1714e":40,"17e":[25,27],"1865e":40,"18e":[25,27],"19e":[25,27],"1a1":9,"1b1":9,"20e":27,"2102e":41,"21e":[25,27],"21g":[23,38],"22222aa":10,"22222ab":10,"22222ba":10,"22222bb":10,"222a":9,"222a2b":8,"222ab2":8,"222b":9,"222b2a":8,"222ba2":8,"22a2a22":10,"22a2b22":10,"22ab":9,"22b2a22":10,"22b2b22":10,"22ba":9,"23e":[25,27],"24e":27,"25e":27,"2669e":40,"27e":27,"28e":[25,27],"29e":27,"2a1":9,"2a2a":9,"2a2b":9,"2b1":9,"2b2":9,"2b2a":9,"2b2b":9,"30e":27,"31e":[25,27],"31g":23,"32e":[25,27],"33e":25,"34e":27,"35e":27,"36e":27,"36th":[25,27],"37e":[25,27],"37th":[25,27],"38e":[25,27],"39e":27,"39th":[25,27],"3a1":9,"4045e":40,"40e":[10,25],"41e":25,"42e":27,"43e":27,"44e":27,"45e":27,"46e":27,"48e":[25,27],"49e":[25,27],"50e":8,"51e":10,"52e":27,"53e":25,"55e":8,"56e":[25,27],"57e":25,"58e":25,"59e":27,"60e":10,"61e":27,"62e":[8,25],"6360e":40,"63e":[25,27],"64e":[25,27],"64gb":40,"65e":25,"66e":27,"68e":[25,27],"69e":25,"70e":27,"71e":[8,10,27],"72e":[25,27],"73e":27,"74e":[25,27],"75e":[25,27],"76e":[8,25,27],"77e":27,"78e":27,"79e":[25,27],"8064e":40,"80e":8,"81e":25,"82e":[25,27],"83e":27,"84e":27,"86e":[8,25,27],"89e":[25,27],"90e":27,"9134e":41,"91e":[8,25,27],"92e":[25,27],"93e":27,"94e":27,"95e":27,"96e":[8,27],"97e":25,"98e":[25,27],"9968e":41,"99e":25,"break":28,"case":[13,16,18,28,37],"default":[1,2,3,4,5,8,9,10,12,13,15,18,20,21,22,23,25,27,28,30,31,34,37,38,40,41,42,43],"export":[34,35],"final":28,"function":[4,6,9,16,17,21,23,28,30,34,35,37,40,47],"gy\u0151rffi":[40,42],"import":[1,4,10,24,27,37],"int":[1,2,3,4,5,8,9,10,13,15,18,25,27,28,30,31,34,37,38,40,41,42,43],"m\u00f8ller":[13,23,32,47],"new":[15,22,23,38,41,43],"public":[11,17],"return":[10,27],"switch":13,"true":[4,8,9,10,12,13,15,16,18,20,21,22,23,25,27,28,30,31,37,38,40,41,42,43],"while":[6,10,16,27],Being:[30,34],For:[10,12,13,18,22,23,25,27,37,38,40,42],MOs:[19,21,47],Not:23,One:[16,20,35],PES:28,RAS:9,The:[2,3,4,5,6,8,9,10,12,13,15,16,17,18,20,21,22,23,24,25,27,28,30,31,34,35,37,38,40,41,42,43],There:[10,27],These:[7,9],Use:[1,2,8,9,10,12,18,21,23,27,28,35,40,42],Useful:24,Uses:[13,18],Using:[13,25,27,28,40,42],XMS:[6,12,13,21,28,40,41,42],abl:1,abov:23,absenc:37,absolut:35,academ:35,acc:28,acceler:[37,38],accomplish:23,accord:[12,28],accordingli:7,accuraci:23,acloc:35,activ:[1,2,3,4,6,7,13,15,17,21,22,23,26,28,37,40,41,42,43,47],active_first:3,adam:28,adapt:[8,10,27],add:[12,35],added:12,addit:[13,21,23,27,28,35,40],addition:12,adiabat:[13,28],adiabt:13,adjac:21,adjust:40,advanc:[11,23,28,38],after:[10,12,25,27,28,30,37,38],again:12,aggreg:[1,5],algorithm:[1,4,5,6,9,10,13,22,37,38,40,41,42,43],all:[6,8,9,10,13,21,23,25,27,35],allow:[4,13,15,16,27,28,35,38],along:[13,27,28],alpha:8,alreadi:23,also:[6,12,13,15,16,20,22,23,28,35,41,43],alter:23,altern:[23,35],amount:[8,10,27,40,41,42,43],analogu:[27,42,44],analys:6,analysi:[14,27,37,38,47],analyt:[13,14,28],andersson:[40,42],andr:[40,42],ang:31,angstrom:[1,4,8,9,10,12,13,15,22,27,28,30,31,34,37,38,41,42,43],angular:[23,27],anh:6,ani:[8,10,12,23],anisotropi:27,ano:23,anoth:[7,27],antibond:9,append:22,appli:[1,9,13,23,27,28,37],approach:35,appropri:[12,41],approxim:[8,27,28],arbitrari:27,archiv:[8,10,22,25,27,35,38],argument:23,arrai:[3,9,10,15,16,21,23,27,28,40],artifici:23,arxiv:27,ascend:12,asd:[0,5,6,35,47],asd_dmrg:1,asd_orbopt:2,ask:16,assembl:[30,31],assign:3,assist:25,associ:[8,10,23,25],assum:[10,27],atom:[1,3,4,8,9,10,12,13,15,18,21,22,24,25,27,28,30,31,34,35,37,38,40,41,42,43,45],atomno:12,attempt:3,aug:23,augment:25,author:[17,47],autoconf:35,autohead:35,automak:35,automat:[10,13,28,32,35,40,41,42,43,44],aux_basi:23,auxiliari:[24,30,31,34],avail:[6,7,8,10,13,23,27,34,35,40,41,42,43],averag:[13,15,25,27,28,40],avogadro:45,axes:[21,27],axi:21,back:[22,25,27],bagel:[1,4,7,8,9,10,12,14,15,16,17,18,20,21,22,23,25,28,30,32,45],bagel_num_thread:34,baker:28,balanc:[10,37],banerje:28,barbatti:12,base:[8,12,18,40],basi:[1,4,8,9,10,12,13,15,20,21,22,24,25,27,28,30,31,34,35,37,38,40,41,42,43],basic:[24,27],bate:[6,27],bearpark:28,becaus:23,been:[6,15,23,28],befor:38,begin:[37,38],being:[13,18],below:[8,9,10,13,15,16,21,23,25,27,36,38],benzen:[4,15,25],benzene_svp_mp2:35,benzophenon:[13,28],bess:6,beta:8,between:[2,12,13,21,23,27,28],bfg:[2,28],binari:[8,10,22,25,27],biomolecul:12,birkholz:28,bit:16,bla:35,block:[2,8,13,15,16,20,23,24,27,28,40,42],bohr:[12,13,15,21,23,27,28,45],bond:[8,13,28],bool:[2,3,4,8,10,12,13,18,20,21,22,23,25,27,28,30,31,37,38,40,41,42,43],boost:35,boost_1_64_0_gcc:35,boost_root:35,both:16,box:[21,38],bridg:[2,3],brilliantli:11,brunk:12,bse:23,build:[23,34,36],built:[13,28],c_3:28,c_4:28,calcul:[1,2,3,4,5,8,9,10,12,13,15,16,18,20,21,22,23,24,25,27,28,30,31,32,34,35,36,37,38,40,41,42,43],can:[2,3,4,8,10,11,12,13,15,16,17,18,20,21,22,23,25,27,28,32,34,35,37,38],cannot:[2,21,23],capabl:[6,22],carbon:[13,28],care:[10,27],cartesian:[1,3,4,15,20,21,23,28,38],cas:4,casa:[40,42],caspt2:[6,12,13,15,16,21,27,28,32,41,42,44,47],casscf:[6,8,9,10,12,13,15,16,21,22,26,27,28,47],casscf_:25,caution:9,cbla:35,celani:[40,42],center:27,central:15,cfmm:38,chang:[22,24,28],charg:[1,12,18,22,23,42,43,45],check:35,chem:[1,2,4,8,9,10,12,13,18,27,28,31,37,38,40,41,42,43],chemic:12,chemistri:[10,12,14,23,27,28,34,37,38],cherri:6,chosen:21,cimiraglia:31,citat:[17,47],clone:35,close:[7,8,10,25,27,38],cluster:35,cmake:12,cmakelist:12,cmbi:20,codata:45,code:[6,13,14,15,17,32,35,40,41,42,43,47],coeffici:[8,10,19,23,25,27,47],collect:38,com:[17,35],command:[21,22,36],commonli:27,commun:12,compat:22,compil:[35,36],complet:[4,8,9,13,22,23,26,37,40,41,42,43,47],complex:[21,27],compon:[12,21,28,37,38],compos:23,compress:[30,34],compris:[22,25,40],comput:[1,2,4,6,10,11,12,13,15,27,28,30,31,34,35,38,40,41,42,43,44],configur:[1,4,17,22,26,35,44,47],conic:6,consid:[28,35,38],consider:28,consist:[8,9,13,17,23,37,40,41,42,43,47],constant:[46,47],constrain:9,construct:[0,3,23],constructor:[3,5],construt:5,cont:23,contain:[9,12,20,23,28,35],content:24,continu:[12,25,27,37],contract:[31,40,41,42,43,44],contribut:[10,17,27,37,38,47],control:[34,38],converg:[1,2,4,8,10,13,22,23,25,27,30,34,37,38,40,41,42,43],convert:23,coordin:[3,21,22,23,27,28],copi:[10,25,27,34,37],core:[8,10,24,34,40,41,42,43],corner:21,correct:[40,41,43],correl:[8,10,30,31,32,44],correspond:23,could:[16,22],coulomb:[10,27,37,45],coupl:[6,10,12,14,21,28,40,47],cours:42,coval:[2,4],cpl:8,cpu:34,creat:35,cross:15,cub:[13,21],cube:[13,19,47],cuh2:23,current:[4,6,13,22,40],cutoff:[40,42],cxxflag:35,data:[19,23,40,41,42,43],dataty:4,datatyp:[1,2,3,4,5,8,9,10,12,13,15,18,20,21,22,23,25,27,28,30,31,37,38,40,41,42,43],davidson:[1,4,8,10,27,40,41,42,43],dcompile_j_orb:35,deactiv:35,deal:1,debug:[27,35],decid:28,deciu:15,decomposit:[1,2,4,17,47],decompot:4,decreas:40,def2:23,defin:[18,24],degener:10,degeneraci:[28,37],degre:15,deloc:28,delta:28,demonstr:16,denom:10,denomin:[10,40,41],densiti:[1,4,6,19,20,24,30,31,37,47],density_0:[13,21],density_1:13,density_2:13,density_3:13,density_filenam:13,density_print:21,depend:[8,23,37,38,40,41],deposit:28,deprec:27,deriv:[6,12,14,21,40,47],describ:32,descript:[0,14,19,23,26,32,39,44,47],descrit:38,design:[6,13],detail:[1,2,4,5,23],detect:[35,40,41],determin:[8,9,10,21,25,27,37],determinant:6,develop:6,df_basi:[1,4,8,9,10,12,13,15,20,21,22,25,27,28,30,31,34,37,38,40,41,42,43],dhf:[10,13,22,27,37,42,43],diag:[23,34],diagon:[1,4,8,10,27,40,42],diagop:27,differ:[2,7,10,13,15,22,23,28],differenti:6,difficult:23,dihydrogen:23,dii:[23,34,37,38],dimens:[21,38],dimer:[0,18,22,47],dimer_act:4,dioxid:10,dipol:[23,34,38],dirac:[6,10,13,23,27,39,47],direct:[12,14,21,28],directli:[12,27],directori:[22,35],disabl:35,discuss:7,displac:[3,8,12,13,15,28],dist:[8,25],distanc:[3,21,28],distant:38,distinct:0,distinguish:12,distribut:[23,35,38],ditchfield:23,dkh2:[6,23],dmrg:[0,5,35,47],dndebug:35,doe:[12,13,20,23,28],doi:11,done:[8,10,30,31,32,37],doubl:[1,2,3,4,8,10,13,15,21,23,25,27,28,37,38,40,41,42,43],doublet:[8,25],dougla:[6,23],download:36,due:[6,21,37,40],dummi:[21,24],dump:[8,10],duplic:[3,9],dyall:[10,23,40,42],dynam:[6,13,14,31,32,44,47],dzdot_return:35,e1331:11,each:[3,7,10,12,13,15,18,20,21,23,25,27,34,38],earlier:22,ecp10mdf:23,ecp28mdf:[23,38],ecp46mdf:23,ecp60mdf:23,ecp78mdf:23,ecp:[6,24,38],edg:21,effect:24,effici:[0,4,8,10,14,35],eigenst:[10,27],eigenvalu:[40,41],eigenvector:[15,20,28],either:[3,23,28],elaps:[8,10,30,34],electron:[9,10,11,13,21,23,25,27,28,30,32,34,37,38,41,45,47],electrostat:[12,23],element:[6,13,23,28,40],elementari:45,elong:8,embarassingli:15,embarrassingli:[13,15],embed:12,emploi:25,emsl:23,enabl:[6,14,35],end:[12,23,30,31],energi:[1,2,4,6,8,10,13,14,18,20,21,27,30,31,37,38,40,41,42,43],environ:36,epr:6,eps:[25,27],equal:34,equat:[6,13,28],equilibrium:6,error:[10,23,25,27,37,38],essenti:[23,35],etc:[8,25],etf:[13,28],evalu:[9,13,14,28,31,38,40,41,43],evangelisti:31,even:[25,27,37],everi:22,exact:[10,28,38],exactli:8,exampl:[0,14,19,24,26,32,34,35,39,44],except:[6,8,10,12,21,23],excess:[8,10],exchang:[23,37],excit:[9,12,13,25,28,41],exclud:[8,10],execut:12,exist:12,exit:13,expand:23,expans:[9,38],expect:[10,27,38],explicit:23,explicitli:[23,37],expon:23,extend:[6,27,40,42],extens:[6,22,35,37,41,43],extent:21,extern:[8,10,12,21,23,28,37],extract:[6,35],fact:12,factor:[13,27,28,45],faegri:10,fail:[25,35],fals:[1,2,3,4,8,10,12,13,15,18,20,21,22,23,25,27,28,34,37,38,40,41,42,43],far:38,fast:38,fatehi:28,fci:[6,7,9,10,25,47],featur:[16,17,22,24,47],field:[8,9,13,17,21,23,37,38,40,41,42,43,47],file:[8,10,13,15,19,23,27,28,34,35,37,47],filenam:[22,23,25,27],find:28,finit:[13,23],finlei:[40,42],first:[3,9,13,16,17,28,47],fit:[6,20,24,30,31,37],fix:[12,28],flexibl:16,flowchart:28,fmm:[6,23],fock:[3,5,6,8,9,10,13,21,23,25,31,34,39,40,47],follow:[1,4,12,20,22,23,28,30,34,38],followo:16,folow:34,forc:[12,16,21],force_:12,form:[12,23,27],format:[13,20,21,23,28],formul:31,found:[11,17,23],four:[21,37],fragment:[2,3,4,5],framework:[6,21,37],free:[6,31,35],freedom:15,freez:[8,10,27,30,40,41,42,43],freq:20,frequenc:[14,20,47],freshli:34,frisch:38,from:[2,3,6,8,9,10,15,20,21,22,23,25,27,28,31,34,35,37,38,40,41,42,43,45],frontier:[8,10,21],frozen:[13,15,16,21,23,28],full:[4,7,13,27,28,37,47],fulli:[40,41,42,43,44],fund:[17,47],fundament:45,further:23,furthermor:35,futur:22,gap:[13,28],gas:[12,28],gaug:[21,23],gaussian:[13,21,23],gener:[8,9,10,11,15,18,20,21,22,23,25,32,34,35,47],generate_guess:[10,27],geometri:[1,4,6,8,9,10,12,13,14,15,20,21,22,24,25,27,30,31,34,37,38,40,41,42,43,47],get:[28,34],giant:27,giao:[6,23,37],giebultowski:18,gill:38,git:35,github:[17,35],give:[10,22,27],given:[10,16,22,23,25,27],glibtool:35,gnu:[11,17,35],gonzalez:28,gordon:38,gov:23,grad:12,gradient:[2,6,12,15,16,17,21,28,34,40,41,42,43,47],granovski:[40,42],grei:[13,28],gridpoint:21,gromac:12,ground:[10,13,22,27,28,31],group:[1,6,18,35],guess:[4,8,10,22,23,25,27,37],guid:36,hai:6,hal:6,half:[10,27],hamiltonian:[4,6,8,10,23,27,37,40,42],handi:[8,10,25],harrison:[8,25],hartre:[3,5,6,8,9,10,12,13,21,23,25,28,34,39,47],has:[6,9,12,17,23,24,28,38],have:[7,12,15,22,23,28,30,31,34],hcore:34,head:38,header:35,heavi:23,heavili:16,heff:[40,42],helium:1,help:35,here:[1,4,13,45],hess:[6,23],hessian:[6,14,16,20,25,28,47],hf_write_mol_cart:23,high:[8,10,38],higher:[25,27],highli:25,hill:[15,23,38],histori:28,hole:[9,31],hop:12,host:17,how:[22,36],howev:[10,35],http:[11,17,23,35],hydrogen:[13,28],i_mpi_scalable_optim:34,ident:23,identifi:[37,38],imaginari:40,implement:[2,4,6,13,15,25,27,28,31,32,40,41,42,43,44],improv:6,inc_siz:13,includ:[2,6,8,10,12,13,21,22,23,25,27,28,32,35,37,38],inclus:[23,35],increas:[13,23,25,28,37],index:[9,10,25,27,30,31,34,38],indic:[8,10,21,23,27],individu:10,ineffici:6,inform:[4,8,12,13,15,17,20,23,24,27,28,40,47],infrar:[15,20],initi:[1,4,6,12,22,23,27,28],initio:27,inkoo:6,input:[2,5,14,23,24,27,36,47],insert:12,instal:[12,28,36],instanc:12,instead:37,institut:25,insuffici:[8,10,27,40,41,42,43],integ:[9,10,21,27],integr:[6,8,10,12,23,30,31,34,37,40,41],intel:[34,35],intens:[15,20],inter:38,interact:[1,4,17,23,27,37,38,44,47],interest:14,interfac:[6,8,10,13,14,27,28,35,47],intern:[40,41,42,43,44],intersect:6,interst:[13,28],introduc:23,introduct:[10,23,38],invalid:[10,27],invari:23,invers:[30,34],isotop:15,iter:[1,2,4,8,10,13,23,25,27,28,30,34,37,38,40,41,42,43],its:[12,16,22,27,40,42],itself:[41,43],jae:6,japan:25,jefferson:6,jensen:9,jeong:6,jheng:6,jkfit:[1,4,8,9,10,12,13,15,20,21,22,23,25,27,28,30,31,34,37,38,40,41,42,43],job:12,johnson:38,jop:10,jorgensen:9,journei:14,json:[34,35],just:35,jwp:6,keal:28,keep:1,kei:[1,4,16,28],kellei:[6,37],keyword:[0,7,14,19,24,26,32,39,44],kilogram:45,kim:[2,6],kind:23,kinet:[10,37],knowl:[8,10,25],kop:10,korchowiec:18,koslowski:28,kramer:37,kroll:[6,23],kurashig:[41,43],kutzelnigg:10,lamb:[25,27],lanl2dz:23,lapack:35,larg:[23,34],larger:[22,23,25,28],later:6,lcbla:35,ld_library_path:35,ldflag:35,least:21,leaven:34,left:3,leining:31,length:8,lett:[8,10,28,38,40,42],level:38,lib:35,librari:[11,23,35],libtool:35,libxc:35,licens:[11,17],lift:28,light:45,like:25,limit:[8,10,27,40,41,42,43],line:[15,23,44],linear:[37,38,40,41],link:[2,4],list:[8,23],load:[19,47],load_ref:[22,25,27],local:[1,2,4,13,19,28,35,47],localize_first:3,localz:18,log:[25,27,28,37],log_level:35,london:23,lone:[13,28],looser:23,lower:[8,10,25,27,40,41,42,43],lowest:[10,27,28,38],lying:27,machin:[34,35],macleod:[6,13,40,41,42,43],macroiter:[25,27],made:23,magnet:[21,23,27,37],mai:[6,7,10,35],make:[35,40],malmqvist:[40,42],malrieu:31,mani:[7,12,13],manner:35,manual:[6,17,30,31],map:27,mass:[28,45],matric:[27,31],matrix:[1,13,27,28,34,35,37,40,42],matthew:6,mavx:35,max:[40,41],max_hol:1,max_it:1,max_particl:1,maximium:9,maximum:[1,2,4,8,9,10,13,25,27,28,37,40,41,42,43],maxit:9,mcgraw:[15,23,38],mdci:28,mdlib:12,mean:[21,23,37,38],meant:35,mechan:28,meci:28,memori:[8,10,27,40,41,42,43],mention:[31,37,38,40,41,42,43],mep:28,messag:23,metal:27,meter:45,method:[7,8,9,10,12,14,16,17,21,22,23,27,30,34,37,38,41,43,44,47],metric:[10,27],mezei:18,microiter:[25,27],might:22,milli:38,min:[40,41],minim:35,minimum:1,minu:27,miscellan:[17,23,47],mix:[10,23,27,28],mizukami:[31,41,42,43],mkdir:35,mkl:35,mkl_num_thread:34,mkm:6,mode:[15,20,35],model:20,modern:[23,38,41,43],modif:22,modifi:28,modul:[6,21,22,23,25,27],mol:[11,12,13,23,45],molden:[8,15,19,21,22,23,28,47],molden_fil:[15,20],molecul:[0,1,2,3,4,8,9,10,12,13,14,15,17,20,21,22,25,27,28,30,31,34,37,38,40,41,42,43,47],molecular:[1,3,4,5,6,8,10,12,14,18,19,20,21,22,23,25,27,37,38,47],moment:[4,13,23,27,34,38],momentum:27,monom:3,mononuclear:27,moprint:[13,21],more:[1,4,6,8,13,15,20,23,28],most:[6,28,35],mp2:[6,13,21,23,28,31,32,47],mpi:[8,13,15,34,35],mpirun:34,mrci:[6,27,43,44,47],mrcisd:41,mulliken:18,multi:[0,6,12,13,22,26,40,42],multiconfigur:[17,40,47],multipass:40,multipl:[1,12,13],multiplet:10,multipli:[10,27,28],multirefer:[13,32,44,47],multisit:0,multist:[28,40,42],must:[9,10,16,23,27,28,38],mvapich:35,nacm:12,nacme_:12,nact:[10,12,13,15,16,21,22,28,31,40,41,42,43],name:[5,12,20,21,22,23,27,37],natur:[15,25,27],ncach:[30,31],nclose:[10,12,13,15,16,21,22,28,31,40,41,42,43],nearbi:23,necessari:40,need:[3,5,12,20,23,35],nest:16,netlib:35,nevertheless:23,nevpt2:[6,32,47],newer:35,newton:28,nguess:1,nil:6,node:[23,40],non:[6,7,10,13,22,26,27,28,37,39,42],nonadiabat:[12,28],nonzero:23,noopt:[25,27],nopen:12,normal:[15,20,25,27,34],note:[6,7,8,10,12,20,23,25,27,32,35],now:27,noweight:[13,28],nspin:[1,27],nstate:[9,10,12,13,15,16,21,27,28,40],nubakeri:[11,17,35],nucl:23,nuclear:[6,12,16,17,21,23,34,47],nucleu:23,number:[1,2,3,4,8,9,10,12,13,15,25,27,28,30,31,34,37,38,40,41,42,43],numer:[6,15,37],nvirt:[10,25,27],obit:3,obj:35,object:35,obtain:[3,4,5,8,9,10,22,23,25,27,31,40,41,42,43],occ:38,occasion:35,occup:[1,25,27],occurr:15,odd:37,off:34,often:[13,23,28],old:23,olsen:9,omp_num_thread:34,one:[3,7,8,9,10,12,13,15,21,23,24,27,28,31,35,38,40,41,42,43],onli:[13,15,22,23,27,40,41],open:[8,10,13,35,37,38],openmpi:35,oper:[10,27],opposit:28,opt:28,opt_histori:28,optim:[0,6,12,14,16,20,23,25,27,34,35,37,47],option:[2,3,5,12,16,22,24,25,27,35,38],orbit:[0,1,3,5,6,8,9,10,13,19,22,24,25,27,28,30,31,34,37,38,40,41,42,43,47],order:[6,12,23,24,25,27,28,30,32,34,38,41,43,44,47],org:[11,35],orient:27,origin:[30,31],orthog:34,orthogon:[18,40],ostlund:[23,38],other:[12,24,28,31],otherwis:[15,25,28,31,37,38,40,41,42,43],out:[4,15,25,28,34,38],output:[12,15,20,25,28,30,36],outsid:16,over:[13,15,28,40],overid:8,overlap:[3,34,37,38,40,41,42,43],owing:34,own:23,oxford:10,oxygen:[8,9,13,22,28],packag:[11,12,28],page:[32,35],pair:[13,28],parallel:[6,8,13,15,17,25,34,35],paramat:27,paramet:[6,10,16,21,24,27,28],park:[6,13,40],parker:[1,2,4,6],parser:12,part:6,particl:[9,12],particular:[13,23,28],particularli:[16,18,41,43],partit:2,pass:[12,40],path:[22,23,35],path_to_bagel:35,pcv5z:23,pcvdz:23,pcvqz:23,pcvtz:23,per:40,perform:[8,12,13,16,20,23,25,27,28,30,32,37],perman:[23,34],person:35,perturb:[13,17,23,44,47],peter:6,phase:[12,27,28],phase_ful:27,phenyl:[13,28],phy:[1,4,8,9,10,13,18,23,27,28,30,31,37,38,40,41,42,43],physic:45,pick:3,pilot:6,pipe:34,pipek:18,pleas:[8,11,23],plesset:[13,23,32,47],plot:21,plu:21,pnl:23,point:[23,28,40,42],popul:[27,37],portal:23,posit:[12,21,23],positron:27,possibl:[13,23,25],post:[10,23,27,34],potenti:[14,24,28],precis:[13,15,25,28,40,41,42,43],predefin:23,prep:[10,27,30,34],prepar:23,prerequisit:[1,2,4,36,44],press:10,previou:[10,15,23],prim:23,primari:27,primarili:10,primit:23,print:[4,8,10,15,19,20,25,27,37,38,41,43,47],print_oper:27,prior:25,problem:[25,34,35],procedur:[18,27],process:[8,13,15,19,23,25,28,34],produc:[10,22,27],product:28,program:[6,8,10,12,13,17,25,27,28,35,37,38],progress:28,project:[15,22,23,28],propag:12,properti:[10,19,23,27,37],provid:[5,22,23,28],psb:28,pseudospin:27,pulai:13,pv5z:23,pv6z:23,pvdz:[8,13,15,23,28,30],pvqz:23,pvtz:23,pwcv5z:23,pwcvdz:23,pwcvqz:23,pwcvtz:23,qm_bagel:12,qmmm:12,quantiti:12,quantiz:27,quantum:[10,12,14,23,27,28,34,37,38],quasi:28,quick:36,quit:16,qzvpp:23,radii:27,radiu:45,ram:35,rank:[27,38],raphson:28,ras:9,rasci:[1,4,7,47],rather:[22,28],ration:28,ratner:4,rcc:23,rdm:[31,40,41],rdr:6,reach:[25,27,37,38],reactant:28,read:[12,15,19,20,22,25,27,28],readabl:22,real:40,recent:35,recommend:[1,2,4,5,8,9,10,12,13,15,18,21,23,25,27,28,30,31,34,35,37,38,40,41,42,43],recompil:35,reconfigur:35,red:[13,28],reduc:[4,8,10,23,27,40,41,42,43],redun:28,redund:[22,40],ref:1,refer:[0,5,6,14,19,22,24,26,29,32,33,39,44],regardless:[10,27],region:[3,12,18],reiher:[27,37],reinsch:[41,43],reivew:11,relat:[7,8,17,47],relativist:[6,7,21,22,23,26,31,32,35,37,39,41,44,47],relcaspt2:[32,44,47],relcasscf:[23,26,42,43,47],releas:[6,35],relev:[16,23],relfci:[7,47],relmrci:[44,47],relsmith:[42,43],remov:37,renorm:1,repeat:13,replac:[6,27,28],repositori:35,repres:23,repuls:34,request:[15,16,28],requir:[24,30,31,34,35],res:[25,27],respect:[12,28],respons:6,restart:[15,20,22,23],restrict:[3,4,5,6,7,10,13,37,38,47],result:[20,23],retain:[8,10,27,40,41,42,43],retreat:6,rev:[12,30],revers:[10,27],review:13,reynold:[6,27,37],rfo:28,rhf:[13,23,34],right:3,ring:[13,28],rkb:37,rlmo:18,rmb:37,robb:28,robust:25,rohf:13,roo:[9,40,42],root:[37,38],rotat:[2,15,27,40,41,42],rothlisburg:12,run:[10,13,15,22,23,24,25,27,28,35,36,37,38],ryan:6,saddl:28,saitow:[41,43],same:[3,5,8,12,13,15,16,22,23,27,28,30,31],sampl:5,save:[5,19,28,34,38,47],save_ref:22,saveref:1,scalabl:34,scalapack:35,scalpack:35,scf:[23,25,30,34,37,38],scheme:[12,18,25,28,40,42],schlegel:28,schwarz:23,schwarz_thresh:38,sci:[11,12,13],scienc:[25,38],scratch:23,screen:23,scuseria:38,search:28,sec:[30,34],second:[6,9,13,22,23,25,27,28,30,32,43,44,47],section:[2,4,7,8,9,13,15,16,20,23,25,28],sector:27,see:[1,2,4,13,15,20,21,23,25,28,40,41,42,43],seideman:4,select:[8,9,10,13,28],selenium:10,self:[8,9,13,17,23,37,40,41,42,43,47],semi:[25,27],send:34,separ:[2,3,21,32,38,40],separated:38,serrano:[40,42],set:[1,2,3,5,9,13,16,18,20,21,22,24,25,27,28,30,31,34,35,37,38],sever:[16,27,35],shall:7,shane:6,shape:[21,28],shell:[13,37,38],shepard:28,shift:[13,15,16,21,27,28],shiozaki:[1,2,4,6,13,27,31,35,37,38,40,41,42,43],should:[2,3,10,12,27,28,30,34,37,40],show:22,shown:[15,25],sigma:[8,10],significantli:6,silva:18,similar:[7,35],simon:28,simpl:34,simplest:35,simpli:21,simul:[12,14],simulatan:9,simultan:[23,25],sinc:[6,16,28,30,34],singl:[1,5,8,12,13,23,28,40,41,42,43],singlet:[8,10,25,27],site:[0,1,5],sixth:27,size:[4,8,13,15],skip:23,slater:8,slightli:[2,22,40],slower:40,small:35,smith3:[6,17,29,32,33,35,40,41,42,43,47],smith:[13,15,16,21,28,35],smp:6,softwar:35,solut:10,solv:25,some:[10,12,17,22,23,35,38],sometim:23,sourc:[6,12,17,36],space:[2,3,6,7,8,13,17,22,23,26,28,37,40,41,42,43,47],span:[8,23],spatial:[3,21],specif:[6,17,28,31,35,38,47],specifi:[1,2,3,4,5,9,10,13,15,16,20,23,24,25,27,28,30,31,34,35,37,38],spectroscopi:15,speed:[23,45],spin:[1,4,6,8,10,21,25,27,31,38],spinor:37,split:27,squar:[37,38],sr1:28,src:[12,35],sssr:[13,15,28],stabil:37,stabl:[6,28],standard:[18,23,34,40,42],start:[2,3,4,5,8,10,15,24,25,27,28,36],startup:34,state:[1,4,6,8,12,13,22,25,28,32,40,41,42,43,47],statewis:12,statu:28,step:[12,13,15,17,20,25,27,28,47],stepsiz:28,steven:27,sto:[8,23,38],storag:[30,34],store:[22,30,34],store_matrix:4,strain:38,strand:6,stream:34,string:[1,2,3,4,8,13,18,20,21,22,23,25,27,28,30,31,40,42],strongli:[31,35],structur:[11,13,14,15,23,27,28,37,38,47],studi:18,subdirectori:28,subotnik:28,subsect:7,subsequ:16,subset:23,subspac:[0,1,2,3,4,9],substanti:[6,7],subval:[8,10,40,41,42,43],suit:35,sum:28,summari:12,supervis:6,supplementari:[17,47],suppli:[10,22,23,27],support:[14,35],surfac:[12,14,28],svp:[1,4,10,12,13,15,20,21,23,25,27,31,34,37,38,40,41,42,43],symbol:23,symmetr:[15,37],symmetri:[10,27],system:[8,10,23,24,38],szabo:[23,38],tabl:[23,45],take:14,taken:[28,45],takeshi:25,tar:35,tarbal:35,target2:12,target:[1,4,12,15,21],ten:44,term:[6,9],termin:[25,27,37,38],test:[35,36],testgrad:28,testsuit:35,text:[10,12,13,23,27,37,38],than:[1,8,10,22,23,25,27,28,40,41,42,43],thei:[23,25,27,38,45],theor:28,theori:[2,13,17,23,38,41,43,44,47],therefor:[10,20],thi:[6,7,8,9,10,12,13,14,16,21,22,23,24,27,28,34,35,40,41,42,43],thiel:28,third:[9,22],those:[8,10,27],thousand:44,thread:[34,35],three:[3,7,9,10,13,21,23,25,27,28,40],thresh:[9,13,22,27,28,31],thresh_fci:31,thresh_scf:31,threshold:[1,2,3,4,8,10,23,25,27,37,38,40,41,42,43],through:38,thrown:[25,27],tight:[40,42],tile:[40,41,42,43],time:[8,10,12,13,15,27,30,34],tinker1:28,tinker2:28,tinker:28,tinkin:28,titl:[1,2,3,4,8,9,10,12,15,16,18,20,21,22,23,24,25,27,30,31,34,37,38,40,41,42,43],tool:27,toru:6,total:[0,2,4,8,10,21,27,30,31],trajectori:12,tran:[10,27],transform:[8,10,25,27,30,31,40],transit:[6,13,28],translat:[4,13,15,28],transposit:35,treat:[3,10],trimer:[1,18],triplet:[8,10,22,25,27],turn:[10,23,27,30,31,35,37],two:[1,2,12,13,25,28,37,38,40,41],txt:12,type:[9,13,23,28,35],typic:[23,27],tzvpp:[9,10,22,23,38],uhf:13,under:[11,17],unit:[12,13,15,21,23,28,45],univers:10,unless:[15,21,23,31,37,38,40,41,42,43],unpair:[37,38],unrelax:13,unrestrict:[13,38],until:12,updat:[24,25,28],upper:28,use:[1,3,4,5,7,13,16,18,20,21,22,23,27,28,30,31,35,40],used:[4,6,8,9,10,12,13,15,16,18,21,22,23,25,27,28,30,31,34,35,37,38,40,41,42,43,45],useful:[16,18,23],user:[9,12,13,15,17,18,24,27,28,35],uses:22,using:[8,10,12,15,18,22,23,25,27,28,30,31,34,35,37,38],usr:35,usual:[10,27,37],util:6,valenc:[25,27,32,47],valu:[1,2,3,4,8,9,10,12,13,18,23,25,27,28,31,34,35,37,38,40,41,42,43,45],variabl:36,variant:[6,40,42],variou:[14,32],vch:[27,37],vector:[3,4,6,8,9,10,12,13,18,21,23,25,27,28,37,38,40,41,42,43],veri:[23,25,36],version:[12,22,35,40,42,43],vertic:[40,42],vibrat:[6,15],view:21,virtual:[40,41,42,43],visscher:23,vlaisavljevich:[6,13,40],wai:[8,16],wang:6,want:34,water:9,wave:4,wavefunct:[8,9,10,22,25,40,41],wcm:11,wei:6,weight:[13,15,28,40],weinheim:[27,37],well:[2,3,12,21,38],were:6,werner:[40,41,42,43],wget:35,when:[1,12,13,18,23,25,27,28,30,31,34],where:[10,12,16,23,27,35],whether:[2,3,4,21,37,38,40],which:[2,6,7,8,9,10,13,21,22,23,25,27,28,31,34,35,37,38,40,41,42,43],white:[13,28,38],who:6,whose:4,wilei:[27,37],wilson:15,wire:[11,12,13],wisconsin:6,within:[3,6,8,10,16,21,23,25,27,37],without:[13,22,25,27,28,30,34,35,37],wolf:[27,37],woo:6,work:[4,7,22,40],worth:10,would:18,write:[12,20,21,22,44],writer:12,written:[6,12,20,25,27],wrong:25,wrote:6,www:[11,20,35],xaxi:27,xmcqdpt2:42,xmcqdpt:40,xms:[13,15,28],xvf:35,xyz:[1,4,8,9,10,12,13,15,21,22,23,25,27,28,30,31,34,37,38,40,41,42,43],yanai:[25,27,41,43],yeonjun:6,yiqun:6,york:[15,23,38],you:[10,13,14,15,27,28,34,35],your:[15,22,25,34,36],zarrabian:[8,25],zaxi:27,zcasscf:[22,27,37,42,43],zcasscf_:27,zero:[8,10,23,27,40,41,42,43],zeroth:[40,41,42,43],zfci:10},titles:["Active space decomposition method","ASD-DMRG","ASD orbital optimization","Description","Dimer ASD","Description","Author contributions","Configuration interaction","Full configuration interaction (FCI)","Restricted active space configuration interaction (RASCI)","Relativistic full configuration interaction (RelFCI)","Funding and citation","Interface to dynamics codes","Nuclear gradient and derivative coupling","Nuclear gradients and related functionalities","Molecular Hessian and frequency analysis","Description of input structure","Brilliantly Advanced General Electronic-structure Library","Orbital localization","Miscellaneous features","MOLDEN","Printing orbital densities to cube files","Saving and loading MOs and CI coefficients","Required keywords","Molecule specification","Complete active space self-consistent field (CASSCF)","Multiconfiguration self-consistent field","Relativistic complete active space self-consistent field (RelCASSCF)","Molecular geometry optimization","Multireference second-order perturbation theory (CASPT2)","M\u00f8ller\u2013Plesset perturbation theory (MP2)","N-electron valence state perturbation theory (NEVPT2)","Perturbation theory","Relativistic multireference second-order perturbation theory (RelCASPT2)","How to run BAGEL","Installation","First steps with BAGEL","Dirac\u2013Hartree\u2013Fock","Hartree\u2013Fock","Self-consistent field","Multireference second-order perturbation theory (CASPT2)","Multireference configuration interaction (MRCI)","Relativistic multireference second-order perturbation theory (RelCASPT2)","Relativistic Multireference configuration interaction (RelMRCI)","SMITH3-generated code","Constants","Supplementary information","BAGEL user manual"],titleterms:{"export":[12,13],"function":14,"m\u00f8ller":30,MOs:22,Useful:23,activ:[0,5,8,9,10,18,25,27],active_thresh:3,adapt:28,advanc:17,algorithm:[2,8,18,25,27,28],analysi:15,angstrom:[3,21,23],aniso:27,asd:[1,2,4],atom:23,author:6,aux_basi:[30,31],auxiliari:23,bagel:[11,13,27,31,34,35,36,37,38,40,41,42,43,47],basi:23,basis_typ:23,batchsiz:9,block_diag_fock:[40,42],breit:[10,27,37],brilliantli:17,build:35,canon:[25,27],canonic:2,caspt2:[29,40],casscf:[25,40,41,42,43],cfmm:23,chang:23,charg:[4,8,10,25,27,37,38],cimaxchunk:40,citat:11,cite:11,code:[12,44],coeffici:22,command:34,common:3,complet:[25,27],configur:[7,8,9,10,41,43],conic:28,consist:[25,26,27,39],constant:45,construct:[1,2,4],continue_geom:22,contribut:6,conv_ignor:[25,27,37],converg:28,core:23,coupl:13,coval:3,criteria:28,cube:21,davidson_subspac:[4,8,10,27,40,41,42,43],decomposit:0,defin:23,densiti:[13,21,23],density_filenam:21,density_print:13,deriv:13,descript:[1,2,3,4,5,8,9,10,12,13,15,16,18,20,21,22,25,27,28,30,31,37,38,40,41,42,43],df_basi:23,dgrad:13,diis_start:[37,38],dimer:[2,3,4],dimer_act:3,dipol:[4,8,13],dirac:37,dkh:23,dma:38,dmrg:1,download:35,dummi:23,dynam:12,ecp:23,effect:23,electron:[17,31],energi:[12,28],energy_thresh:2,environ:34,exampl:[1,4,8,9,10,12,13,15,16,18,20,21,22,23,25,27,28,30,31,37,38,40,41,42,43],exchang:38,export_singl:[12,13],fci:[4,8],fci_algorithm:25,featur:[19,23],field:[25,26,27,39],file:[12,20,21,22],finite_nucleu:23,first:36,fit:23,fmm:38,fock:[37,38],forc:13,force_0:12,force_1:12,form:3,format:12,frequenc:15,frozen:[8,10,30,31,40,41,42,43],full:[8,10],fund:11,gaunt:[10,27,37],gener:[12,13,17,27,31,37,38,40,41,42,43,44],geometri:[23,28],grad:13,gradient:[13,14],gradient_thresh:2,hartre:[37,38],hcore_guess:27,hess_approx:28,hess_upd:28,hessian:15,how:[11,12,34],inc_siz:21,inform:46,input:[1,4,8,9,10,12,13,15,16,18,20,21,22,25,28,34,40,42],instal:35,interact:[7,8,9,10,41,43],interfac:12,intern:28,intersect:28,istat:31,keyword:[1,2,3,4,5,8,9,10,12,13,15,18,20,21,22,23,25,27,28,30,31,37,38,40,41,42,43],librari:17,link:3,lmax:38,lmax_exchang:38,load:22,local:[3,5,18],lowdin:18,magnetic_field:23,manual:47,mass:15,matrix:4,max_hol:9,max_it:4,max_particl:9,maxchang:28,maxdisp:28,maxgrad:28,maxit:[1,2,8,10,25,27,28,37,38,40,41,42,43],maxiter_fci:[8,10,25,27],maxiter_micro:[25,27],maxiter_scf:[37,38],maxstep:28,maxtil:[40,41,42,43],maxzit:[13,28],mdci_reference_geometri:28,mep_direct:28,method:[0,1,4,13,15,28,40,42],minimum:28,miscellan:19,mo_filenam:21,modifi:12,molden:20,molden_fil:23,molecul:[23,24],molecular:[15,28],mp2:30,mrci:41,multiconfigur:26,multipol:38,multirefer:[29,33,40,41,42,43],multisit:[1,5],nacm:13,nacme_0_1:12,nacmtyp:[13,28],nact:[25,27],natocc:[25,27],nclose:[25,27],ncore:[8,10,30,31,40,41,42,43],nevpt2:31,nfrozenvirt:[40,41,42,43],nguess:[4,8],non:3,nopen:38,norb:[8,10],nproc:[13,15],nspin:[4,8,25],nstate:[1,4,8,25],ntrunc:1,nuclear:[13,14],numer:[13,28],numerical_dx:28,occupi:18,only_electron:27,only_int:[8,10],optim:[2,28],option:[4,13,15,23,28],opttyp:28,orbit:[2,18,20,21,23],order:[29,33,40,42],orthogonal_basi:40,other:[15,23],out:12,output:34,pair:21,paramet:23,path:28,perturb:[1,29,30,31,32,33,40,42],perturb_min:1,perturb_thresh:1,plesset:30,pop:[27,37],potenti:23,prerequisit:[3,5,8,9,10,35,40,41],print:[13,21],print_info:4,print_thresh:[4,8,10,27],qmmm:28,qmmm_program:28,ras:[1,4],rasci:9,redund:28,ref:5,refer:[1,2,4,8,9,10,12,13,15,18,20,23,25,27,28,30,31,37,38,40,41,42,43],refgeom:28,region_s:[3,18],relat:14,relativist:[10,27,33,42,43],relax:[13,21],relcaspt2:[33,42],relcasscf:27,relfci:10,relmrci:43,requir:[2,4,13,15,23,28],restart:[8,10,38],restart_ca:[25,27],restrict:[1,9],rhf:38,robust:37,rohf:38,rotation_thresh:2,run:34,sampl:[1,4,8,9,10,12,13,15,18,20,21,22,25,28,40,42],save:22,scheme:3,schwarz_thresh:23,second:[29,33,40,42],self:[25,26,27,39],semi:2,set:23,shift:[40,42],shift_imag:40,skip_self_interact:23,smith3:44,smith:[40,41,42,43],softwar:12,soscf:38,sourc:[11,35],space:[0,1,4,9,25,27],specif:[23,24],spin_adapt:[10,27],sssr:[40,42],start_po:21,state:[10,27,31],step:36,store:4,structur:[16,17],supplementari:46,target2:[13,28],target:[13,28],tesla:23,test:34,theori:[29,30,31,32,33,40,42],thielc3:28,thielc4:28,thresh:[1,4,8,10,25,37,38,40,41,42,43],thresh_fci:[8,10,27],thresh_micro:25,thresh_overlap:[37,38,40,41,42,43],thresh_scf:37,titl:[13,28],translat:3,type:18,uhf:38,univers:28,updat:23,user:[23,47],valenc:31,variabl:34,version:6,vibrat:20,virtual:18,work:12,xms:[40,42]}}) \ No newline at end of file +Search.setIndex({docnames:["asd/asd","asd/asd_dmrg","asd/asd_orbopt","asd/dimer","asd/dimer_asd","asd/multisite","author","ci/ci_methods","ci/fci","ci/rasci","ci/zfci","funding","grad/dynamics","grad/force","grad/grad","grad/hess","grad/methods","index","miscellaneous/localization","miscellaneous/misc","miscellaneous/molden","miscellaneous/moprint","miscellaneous/save_ref","molecule/molecule","molecule/molecule-toc","multi/casscf","multi/multi","multi/zcasscf","opt/optimize","pt2/caspt2","pt2/mp2","pt2/nevpt2","pt2/pt2","pt2/relcaspt2","quickstart/how_to_run_bagel","quickstart/installation_guide","quickstart/quickstart","scf/dhf","scf/hf","scf/scf","smith/caspt2","smith/mrci","smith/relcaspt2","smith/relmrci","smith/smith","supp_info/constants","supp_info/supp_info","user-manual"],envversion:54,filenames:["asd/asd.rst","asd/asd_dmrg.rst","asd/asd_orbopt.rst","asd/dimer.rst","asd/dimer_asd.rst","asd/multisite.rst","author.rst","ci/ci_methods.rst","ci/fci.rst","ci/rasci.rst","ci/zfci.rst","funding.rst","grad/dynamics.rst","grad/force.rst","grad/grad.rst","grad/hess.rst","grad/methods.rst","index.rst","miscellaneous/localization.rst","miscellaneous/misc.rst","miscellaneous/molden.rst","miscellaneous/moprint.rst","miscellaneous/save_ref.rst","molecule/molecule.rst","molecule/molecule-toc.rst","multi/casscf.rst","multi/multi.rst","multi/zcasscf.rst","opt/optimize.rst","pt2/caspt2.rst","pt2/mp2.rst","pt2/nevpt2.rst","pt2/pt2.rst","pt2/relcaspt2.rst","quickstart/how_to_run_bagel.rst","quickstart/installation_guide.rst","quickstart/quickstart.rst","scf/dhf.rst","scf/hf.rst","scf/scf.rst","smith/caspt2.rst","smith/mrci.rst","smith/relcaspt2.rst","smith/relmrci.rst","smith/smith.rst","supp_info/constants.rst","supp_info/supp_info.rst","user-manual.rst"],objects:{},objnames:{},objtypes:{},terms:{"0000e":41,"00e":[8,25,27],"01e":25,"02e":[8,27],"0380e":41,"03e":27,"04e":27,"06e":[25,27],"07e":27,"08e":27,"09e":[8,25],"10e":27,"10lf":12,"1101e":41,"1102e":41,"11e":[25,27],"12e":27,"13e":[8,25,27],"14e":25,"1714e":40,"17e":[25,27],"1865e":40,"18e":[25,27],"19e":[25,27],"1a1":9,"1b1":9,"20e":27,"2102e":41,"21e":[25,27],"21g":[23,38],"22222aa":10,"22222ab":10,"22222ba":10,"22222bb":10,"222a":9,"222a2b":8,"222ab2":8,"222b":9,"222b2a":8,"222ba2":8,"22a2a22":10,"22a2b22":10,"22ab":9,"22b2a22":10,"22b2b22":10,"22ba":9,"23e":[25,27],"24e":27,"25e":27,"2669e":40,"27e":27,"28e":[25,27],"29e":27,"2a1":9,"2a2a":9,"2a2b":9,"2b1":9,"2b2":9,"2b2a":9,"2b2b":9,"30e":27,"31e":[25,27],"31g":23,"32e":[25,27],"33e":25,"34e":27,"35e":27,"36e":27,"36th":[25,27],"37e":[25,27],"37th":[25,27],"38e":[25,27],"39e":27,"39th":[25,27],"3a1":9,"4045e":40,"40e":[10,25],"41e":25,"42e":27,"43e":27,"44e":27,"45e":27,"46e":27,"48e":[25,27],"49e":[25,27],"50e":8,"51e":10,"52e":27,"53e":25,"55e":8,"56e":[25,27],"57e":25,"58e":25,"59e":27,"60e":10,"61e":27,"62e":[8,25],"6360e":40,"63e":[25,27],"64e":[25,27],"64gb":40,"65e":25,"66e":27,"68e":[25,27],"69e":25,"70e":27,"71e":[8,10,27],"72e":[25,27],"73e":27,"74e":[25,27],"75e":[25,27],"76e":[8,25,27],"77e":27,"78e":27,"79e":[25,27],"8064e":40,"80e":8,"81e":25,"82e":[25,27],"83e":27,"84e":27,"86e":[8,25,27],"89e":[25,27],"90e":27,"9134e":41,"91e":[8,25,27],"92e":[25,27],"93e":27,"94e":27,"95e":27,"96e":[8,27],"97e":25,"98e":[25,27],"9968e":41,"99e":25,"break":28,"case":[13,16,18,28,37],"default":[1,2,3,4,5,8,9,10,12,13,15,18,20,21,22,23,25,27,28,30,31,34,37,38,40,41,42,43],"export":[34,35],"final":28,"function":[4,6,9,16,17,21,23,28,30,34,35,37,40,47],"gy\u0151rffi":[40,42],"import":[1,4,10,24,27,37],"int":[1,2,3,4,5,8,9,10,13,15,18,25,27,28,30,31,34,37,38,40,41,42,43],"m\u00f8ller":[13,23,32,47],"new":[15,22,23,38,41,43],"public":[11,17],"return":[10,27],"switch":13,"true":[4,8,9,10,12,13,15,16,18,20,21,22,23,25,27,28,30,31,37,38,40,41,42,43],"while":[6,10,16,27],Being:[30,34],For:[10,12,13,18,22,23,25,27,37,38,40,42],MOs:[19,21,47],Not:23,One:[16,20,35],PES:28,RAS:9,The:[2,3,4,5,6,8,9,10,12,13,15,16,17,18,20,21,22,23,24,25,27,28,30,31,34,35,37,38,40,41,42,43],There:[10,27],These:[7,9],Use:[1,2,8,9,10,12,18,21,23,27,28,35,40,42],Useful:24,Uses:[13,18],Using:[13,25,27,28,40,42],XMS:[6,12,13,21,28,40,41,42],abl:1,abov:23,absenc:37,absolut:35,academ:35,acc:28,acceler:[37,38],accomplish:23,accord:[12,28],accordingli:7,accuraci:23,acloc:35,activ:[1,2,3,4,6,7,13,15,17,21,22,23,26,28,37,40,41,42,43,47],active_first:3,adam:28,adapt:[8,10,27],add:[12,35],added:12,addit:[13,21,23,27,28,35,40],addition:12,adiabat:[13,28],adiabt:13,adjac:21,adjust:40,advanc:[11,23,28,38],after:[10,12,25,27,28,30,37,38],again:12,aggreg:[1,5],algorithm:[1,4,5,6,9,10,13,22,37,38,40,41,42,43],all:[6,8,9,10,13,21,23,25,27,35],allow:[4,13,15,16,27,28,35,38],along:[13,27,28],alpha:8,alreadi:23,also:[6,12,13,15,16,20,22,23,28,35,41,43],alter:23,altern:[13,23,35],amount:[8,10,27,40,41,42,43],analogu:[27,42,44],analys:6,analysi:[14,27,37,38,47],analyt:[13,14,28],andersson:[40,42],andr:[40,42],ang:31,angstrom:[1,4,8,9,10,12,13,15,22,27,28,30,31,34,37,38,41,42,43],angular:[23,27],anh:6,ani:[8,10,12,23],anisotropi:27,ano:23,anoth:[7,27],antibond:9,append:22,appli:[1,9,13,23,27,28,37],approach:35,appropri:[12,41],approxim:[8,27,28],arbitrari:27,archiv:[8,10,22,25,27,35,38],argument:23,arrai:[3,9,10,15,16,21,23,27,28,40],artifici:23,arxiv:27,ascend:12,asd:[0,5,6,35,47],asd_dmrg:1,asd_orbopt:2,ask:16,assembl:[30,31],assign:3,assist:25,associ:[8,10,23,25],assum:[10,27],atom:[1,3,4,8,9,10,12,13,15,18,21,22,24,25,27,28,30,31,34,35,37,38,40,41,42,43,45],atomno:12,attempt:3,aug:23,augment:25,author:[17,47],autoconf:35,autohead:35,automak:35,automat:[10,13,28,32,35,40,41,42,43,44],aux_basi:23,auxiliari:[24,30,31,34],avail:[6,7,8,10,13,23,27,34,35,40,41,42,43],averag:[13,15,25,27,28,40],avogadro:45,axes:[21,27],axi:21,back:[22,25,27],bagel:[1,4,7,8,9,10,12,14,15,16,17,18,20,21,22,23,25,28,30,32,45],bagel_num_thread:34,baker:28,balanc:[10,37],banerje:28,barbatti:12,base:[8,12,18,40],basi:[1,4,8,9,10,12,13,15,20,21,22,24,25,27,28,30,31,34,35,37,38,40,41,42,43],basic:[24,27],bate:[6,27],bearpark:28,becaus:23,been:[6,15,23,28],befor:38,begin:[37,38],being:[13,18],below:[8,9,10,13,15,16,21,23,25,27,36,38],benzen:[4,15,25],benzene_svp_mp2:35,benzophenon:[13,28],bess:6,beta:8,between:[2,12,13,21,23,27,28],bfg:[2,28],binari:[8,10,22,25,27],biomolecul:12,birkholz:28,bit:16,bla:35,block:[2,8,13,15,16,20,23,24,27,28,40,42],bohr:[12,13,15,21,23,27,28,45],bond:[8,13,28],bool:[2,3,4,8,10,12,13,18,20,21,22,23,25,27,28,30,31,37,38,40,41,42,43],boost:35,boost_1_64_0_gcc:35,boost_root:35,both:16,box:[21,38],bridg:[2,3],brilliantli:11,brunk:12,bse:23,build:[23,34,36],built:[13,28],c_3:28,c_4:28,calcul:[1,2,3,4,5,8,9,10,12,13,15,16,18,20,21,22,23,24,25,27,28,30,31,32,34,35,36,37,38,40,41,42,43],can:[2,3,4,8,10,11,12,13,15,16,17,18,20,21,22,23,25,27,28,32,34,35,37,38],cannot:[2,21,23],capabl:[6,22],carbon:[13,28],care:[10,27],cartesian:[1,3,4,15,20,21,23,28,38],cas:4,casa:[40,42],caspt2:[6,12,13,15,16,21,27,28,32,41,42,44,47],casscf:[6,8,9,10,12,13,15,16,21,22,26,27,28,47],casscf_:25,caution:9,cbla:35,celani:[40,42],center:27,central:15,cfmm:38,chang:[22,24,28],charg:[1,12,18,22,23,42,43,45],check:35,chem:[1,2,4,8,9,10,12,13,18,27,28,31,37,38,40,41,42,43],chemic:12,chemistri:[10,12,14,23,27,28,34,37,38],cherri:6,chosen:21,cimiraglia:31,citat:[17,47],clone:35,close:[7,8,10,25,27,38],cluster:35,cmake:12,cmakelist:12,cmbi:20,codata:45,code:[6,13,14,15,17,32,35,40,41,42,43,47],coeffici:[8,10,19,23,25,27,47],collect:38,com:[17,35],command:[21,22,36],commonli:27,commun:12,compat:22,compil:[35,36],complet:[4,8,9,13,22,23,26,37,40,41,42,43,47],complex:[21,27],compon:[12,21,28,37,38],compos:23,compress:[30,34],compris:[22,25,40],comput:[1,2,4,6,10,11,12,13,15,27,28,30,31,34,35,38,40,41,42,43,44],configur:[1,4,17,22,26,35,44,47],conic:6,consid:[28,35,38],consider:28,consist:[8,9,13,17,23,37,40,41,42,43,47],constant:[46,47],constrain:9,construct:[0,3,23],constructor:[3,5],construt:5,cont:23,contain:[9,12,20,23,28,35],content:24,continu:[12,25,27,37],contract:[31,40,41,42,43,44],contribut:[10,17,27,37,38,47],control:[34,38],converg:[1,2,4,8,10,13,22,23,25,27,30,34,37,38,40,41,42,43],convert:23,coordin:[3,21,22,23,27,28],copi:[10,25,27,34,37],core:[8,10,24,34,40,41,42,43],corner:21,correct:[40,41,43],correl:[8,10,30,31,32,44],correspond:23,could:[16,22],coulomb:[10,27,37,45],coupl:[6,10,12,14,21,28,40,47],cours:42,coval:[2,4],cpl:8,cpu:34,creat:35,cross:15,cub:[13,21],cube:[13,19,47],cuh2:23,current:[4,6,13,22,40],cutoff:[40,42],cxxflag:35,data:[19,23,40,41,42,43],dataty:4,datatyp:[1,2,3,4,5,8,9,10,12,13,15,18,20,21,22,23,25,27,28,30,31,37,38,40,41,42,43],davidson:[1,4,8,10,27,40,41,42,43],dcompile_j_orb:35,deactiv:35,deal:1,debug:[27,35],decid:28,deciu:15,decomposit:[1,2,4,17,47],decompot:4,decreas:40,def2:23,defin:[18,24],degener:10,degeneraci:[28,37],degre:15,deloc:28,delta:28,demonstr:16,denom:10,denomin:[10,40,41],densiti:[1,4,6,19,20,24,30,31,37,47],density_0:[13,21],density_1:13,density_2:13,density_3:13,density_filenam:13,density_print:21,depend:[8,23,37,38,40,41],deposit:28,deprec:27,deriv:[6,12,14,21,40,47],describ:32,descript:[0,14,19,23,26,32,39,44,47],descrit:38,design:[6,13],detail:[1,2,4,5,23],detect:[35,40,41],determin:[8,9,10,21,25,27,37],determinant:6,develop:6,df_basi:[1,4,8,9,10,12,13,15,20,21,22,25,27,28,30,31,34,37,38,40,41,42,43],dhf:[10,13,22,27,37,42,43],diag:[23,34],diagon:[1,4,8,10,27,40,42],diagop:27,differ:[2,7,10,13,15,22,23,28],differenti:6,difficult:23,dihydrogen:23,dii:[23,34,37,38],dimens:[21,38],dimer:[0,18,22,47],dimer_act:4,dioxid:10,dipol:[23,34,38],dirac:[6,10,13,23,27,39,47],direct:[12,14,21,28],directli:[12,27],directori:[22,35],disabl:35,discuss:7,displac:[3,8,12,13,15,28],dist:[8,25],distanc:[3,21,28],distant:38,distinct:0,distinguish:12,distribut:[23,35,38],ditchfield:23,dkh2:[6,23],dmrg:[0,5,35,47],dndebug:35,doe:[12,13,20,23,28],doi:11,done:[8,10,30,31,32,37],doubl:[1,2,3,4,8,10,13,15,21,23,25,27,28,37,38,40,41,42,43],doublet:[8,25],dougla:[6,23],download:36,due:[6,21,37,40],dummi:[21,24],dump:[8,10],duplic:[3,9],dyall:[10,23,40,42],dynam:[6,13,14,31,32,44,47],dzdot_return:35,e1331:11,each:[3,7,10,12,13,15,18,20,21,23,25,27,34,38],earlier:22,ecp10mdf:23,ecp28mdf:[23,38],ecp46mdf:23,ecp60mdf:23,ecp78mdf:23,ecp:[6,24,38],edg:21,effect:24,effici:[0,4,8,10,14,35],eigenst:[10,27],eigenvalu:[40,41],eigenvector:[15,20,28],either:[3,23,28],elaps:[8,10,30,34],electron:[9,10,11,13,21,23,25,27,28,30,32,34,37,38,41,45,47],electrostat:[12,23],element:[6,13,23,28,40],elementari:45,elong:8,embarassingli:15,embarrassingli:[13,15],embed:12,emploi:25,emsl:23,enabl:[6,14,35],end:[12,23,30,31],energi:[1,2,4,6,8,10,13,14,18,20,21,27,30,31,37,38,40,41,42,43],environ:36,epr:6,eps:[25,27],equal:34,equat:[6,13,28],equilibrium:6,error:[10,23,25,27,37,38],essenti:[23,35],etc:[8,25],etf:[13,28],evalu:[9,13,14,28,31,38,40,41,43],evangelisti:31,even:[25,27,37],everi:22,exact:[10,28,38],exactli:8,exampl:[0,14,19,24,26,32,34,35,39,44],except:[6,8,10,12,21,23],excess:[8,10],exchang:[23,37],excit:[9,12,13,25,28,41],exclud:[8,10],execut:12,exist:12,exit:13,expand:23,expans:[9,38],expect:[10,27,38],explicit:23,explicitli:[23,37],expon:23,extend:[6,27,40,42],extens:[6,22,35,37,41,43],extent:21,extern:[8,10,12,21,23,28,37],extract:[6,35],fact:12,factor:[13,27,28,45],faegri:10,fail:[25,35],fals:[1,2,3,4,8,10,12,13,15,18,20,21,22,23,25,27,28,34,37,38,40,41,42,43],far:38,fast:38,fatehi:28,fci:[6,7,9,10,25,47],featur:[16,17,22,24,47],field:[8,9,13,17,21,23,37,38,40,41,42,43,47],file:[8,10,13,15,19,23,27,28,34,35,37,47],filenam:[22,23,25,27],find:28,finit:[13,23],finlei:[40,42],first:[3,9,13,16,17,28,47],fit:[6,20,24,30,31,37],fix:[12,28],flexibl:16,flowchart:28,fmm:[6,23],fock:[3,5,6,8,9,10,13,21,23,25,31,34,39,40,47],follow:[1,4,12,20,22,23,28,30,34,38],followo:16,folow:34,forc:[12,16,21],force_:12,form:[12,23,27],format:[13,20,21,23,28],formul:31,found:[11,17,23],four:[21,37],fragment:[2,3,4,5],framework:[6,21,37],free:[6,31,35],freedom:15,freez:[8,10,27,30,40,41,42,43],freq:20,frequenc:[14,20,47],freshli:34,frisch:38,from:[2,3,6,8,9,10,15,20,21,22,23,25,27,28,31,34,35,37,38,40,41,42,43,45],frontier:[8,10,21],frozen:[13,15,16,21,23,28],full:[4,7,13,27,28,37,47],fulli:[40,41,42,43,44],fund:[17,47],fundament:45,further:23,furthermor:35,futur:22,gap:[13,28],gas:[12,28],gaug:[21,23],gaussian:[13,21,23],gener:[8,9,10,11,15,18,20,21,22,23,25,32,34,35,47],generate_guess:[10,27],geometri:[1,4,6,8,9,10,12,13,14,15,20,21,22,24,25,27,30,31,34,37,38,40,41,42,43,47],get:[28,34],giant:27,giao:[6,23,37],giebultowski:18,gill:38,git:35,github:[17,35],give:[10,22,27],given:[10,16,22,23,25,27],glibtool:35,gnu:[11,17,35],gonzalez:28,gordon:38,gov:23,grad:12,gradient:[2,6,12,15,16,17,21,28,34,40,41,42,43,47],granovski:[40,42],grei:[13,28],gridpoint:21,gromac:12,ground:[10,13,22,27,28,31],group:[1,6,18,35],guess:[4,8,10,22,23,25,27,37],guid:36,hai:6,hal:6,half:[10,27],hamiltonian:[4,6,8,10,23,27,37,40,42],handi:[8,10,25],harrison:[8,25],hartre:[3,5,6,8,9,10,12,13,21,23,25,28,34,39,47],has:[6,9,12,17,23,24,28,38],have:[7,12,15,22,23,28,30,31,34],hcore:34,head:38,header:35,heavi:23,heavili:16,heff:[40,42],helium:1,help:35,here:[1,4,13,45],hess:[6,23],hessian:[6,14,16,20,25,28,47],hf_write_mol_cart:23,high:[8,10,38],higher:[25,27],highli:25,hill:[15,23,38],histori:28,hole:[9,31],hop:12,host:17,how:[22,36],howev:[10,35],http:[11,17,23,35],hydrogen:[13,28],i_mpi_scalable_optim:34,ident:23,identifi:[37,38],imaginari:40,implement:[2,4,6,13,15,25,27,28,31,32,40,41,42,43,44],improv:6,inc_siz:13,includ:[2,6,8,10,12,13,21,22,23,25,27,28,32,35,37,38],inclus:[23,35],increas:[13,23,25,28,37],index:[9,10,25,27,30,31,34,38],indic:[8,10,21,23,27],individu:10,ineffici:6,inform:[4,8,12,13,15,17,20,23,24,27,28,40,47],infrar:[15,20],initi:[1,4,6,12,22,23,27,28],initio:27,inkoo:6,input:[2,5,14,23,24,27,36,47],insert:12,instal:[12,28,36],instanc:12,instead:37,institut:25,insuffici:[8,10,27,40,41,42,43],integ:[9,10,21,27],integr:[6,8,10,12,23,30,31,34,37,40,41],intel:[34,35],intens:[15,20],inter:38,interact:[1,4,17,23,27,37,38,44,47],interest:14,interfac:[6,8,10,13,14,27,28,35,47],intern:[40,41,42,43,44],intersect:6,interst:[13,28],introduc:23,introduct:[10,23,38],invalid:[10,27],invari:23,invers:[30,34],isotop:15,iter:[1,2,4,8,10,13,23,25,27,28,30,34,37,38,40,41,42,43],its:[12,16,22,27,40,42],itself:[41,43],jae:6,japan:25,jefferson:6,jensen:9,jeong:6,jheng:6,jkfit:[1,4,8,9,10,12,13,15,20,21,22,23,25,27,28,30,31,34,37,38,40,41,42,43],job:12,johnson:38,jop:10,jorgensen:9,journei:14,json:[34,35],just:35,jwp:6,keal:28,keep:1,kei:[1,4,16,28],kellei:[6,37],keyword:[0,7,14,19,24,26,32,39,44],kilogram:45,kim:[2,6],kind:23,kinet:[10,37],knowl:[8,10,25],kop:10,korchowiec:18,koslowski:28,kramer:37,kroll:[6,23],kurashig:[41,43],kutzelnigg:10,lamb:[25,27],lanl2dz:23,lapack:35,larg:[23,34],larger:[22,23,25,28],later:6,lcbla:35,ld_library_path:35,ldflag:35,least:21,leaven:34,left:3,leining:31,length:8,lett:[8,10,28,38,40,42],level:38,lib:35,librari:[11,23,35],libtool:35,libxc:35,licens:[11,17],lift:28,light:45,like:25,limit:[8,10,27,40,41,42,43],line:[15,23,44],linear:[37,38,40,41],link:[2,4],list:[8,23],load:[19,47],load_ref:[22,25,27],local:[1,2,4,13,19,28,35,47],localize_first:3,localz:18,log:[25,27,28,37],log_level:35,london:23,lone:[13,28],looser:23,lower:[8,10,25,27,40,41,42,43],lowest:[10,27,28,38],lying:27,machin:[34,35],macleod:[6,13,40,41,42,43],macroiter:[25,27],made:23,magnet:[21,23,27,37],mai:[6,7,10,35],make:[35,40],malmqvist:[40,42],malrieu:31,mani:[7,12,13],manner:35,manual:[6,17,30,31],map:27,mass:[28,45],matric:[27,31],matrix:[1,13,27,28,34,35,37,40,42],matthew:6,mavx:35,max:[40,41],max_hol:1,max_it:1,max_particl:1,maximium:9,maximum:[1,2,4,8,9,10,13,25,27,28,37,40,41,42,43],maxit:9,mcgraw:[15,23,38],mdci:28,mdlib:12,mean:[21,23,37,38],meant:35,mechan:28,meci:28,memori:[8,10,27,40,41,42,43],mention:[31,37,38,40,41,42,43],mep:28,messag:23,metal:27,meter:45,method:[7,8,9,10,12,14,16,17,21,22,23,27,30,34,37,38,41,43,44,47],metric:[10,27],mezei:18,microiter:[25,27],might:22,milli:38,min:[40,41],minim:35,minimum:1,minu:27,miscellan:[17,23,47],mix:[10,23,27,28],mizukami:[31,41,42,43],mkdir:35,mkl:35,mkl_num_thread:34,mkm:6,mode:[15,20,35],model:20,modern:[23,38,41,43],modif:22,modifi:28,modul:[6,21,22,23,25,27],mol:[11,12,13,23,45],molden:[8,15,19,21,22,23,28,47],molden_fil:[15,20],molecul:[0,1,2,3,4,8,9,10,12,13,14,15,17,20,21,22,25,27,28,30,31,34,37,38,40,41,42,43,47],molecular:[1,3,4,5,6,8,10,12,14,18,19,20,21,22,23,25,27,37,38,47],moment:[4,23,27,34,38],momentum:27,monom:3,mononuclear:27,moprint:[13,21],more:[1,4,6,8,13,15,20,23,28],most:[6,28,35],mp2:[6,13,21,23,28,31,32,47],mpi:[8,13,15,34,35],mpirun:34,mrci:[6,27,43,44,47],mrcisd:41,mulliken:18,multi:[0,6,12,13,22,26,40,42],multiconfigur:[17,40,47],multipass:40,multipl:[1,12,13],multiplet:10,multipli:[10,27,28],multirefer:[13,32,44,47],multisit:0,multist:[28,40,42],must:[9,10,16,23,27,28,38],mvapich:35,nacm:12,nacme_:12,nact:[10,12,13,15,16,21,22,28,31,40,41,42,43],name:[5,12,20,21,22,23,27,37],natur:[15,25,27],ncach:[30,31],nclose:[10,12,13,15,16,21,22,28,31,40,41,42,43],nearbi:23,necessari:40,need:[3,5,12,20,23,35],nest:16,netlib:35,nevertheless:23,nevpt2:[6,32,47],newer:35,newton:28,nguess:1,nil:6,node:[23,40],non:[6,7,10,13,22,26,27,28,37,39,42],nonadiabat:[12,28],nonzero:23,noopt:[25,27],nopen:12,normal:[15,20,25,27,34],note:[6,7,8,10,12,20,23,25,27,32,35],now:27,noweight:[13,28],nspin:[1,27],nstate:[9,10,12,13,15,16,21,27,28,40],nubakeri:[11,17,35],nucl:23,nuclear:[6,12,16,17,21,23,34,47],nucleu:23,number:[1,2,3,4,8,9,10,12,13,15,25,27,28,30,31,34,37,38,40,41,42,43],numer:[6,15,37],nvirt:[10,25,27],obit:3,obj:35,object:35,obtain:[3,4,5,8,9,10,22,23,25,27,31,40,41,42,43],occ:38,occasion:35,occup:[1,25,27],occurr:15,odd:37,off:34,often:[13,23,28],old:23,olsen:9,omp_num_thread:34,one:[3,7,8,9,10,12,13,15,21,23,24,27,28,31,35,38,40,41,42,43],onli:[13,15,22,23,27,40,41],open:[8,10,13,35,37,38],openmpi:35,oper:[10,27],opposit:28,opt:28,opt_histori:28,optim:[0,6,12,14,16,20,23,25,27,34,35,37,47],option:[2,3,5,12,16,22,24,25,27,35,38],orbit:[0,1,3,5,6,8,9,10,13,19,22,24,25,27,28,30,31,34,37,38,40,41,42,43,47],order:[6,12,23,24,25,27,28,30,32,34,38,41,43,44,47],org:[11,35],orient:27,origin:[30,31],orthog:34,orthogon:[18,40],oscil:13,ostlund:[23,38],other:[12,24,28,31],otherwis:[15,25,28,31,37,38,40,41,42,43],out:[4,15,25,28,34,38],output:[12,15,20,25,28,30,36],outsid:16,over:[13,15,28,40],overid:8,overlap:[3,34,37,38,40,41,42,43],owing:34,own:23,oxford:10,oxygen:[8,9,13,22,28],packag:[11,12,28],page:[32,35],pair:[13,28],parallel:[6,8,13,15,17,25,34,35],paramat:27,paramet:[6,10,16,21,24,27,28],park:[6,13,40],parker:[1,2,4,6],parser:12,part:6,particl:[9,12],particular:[13,23,28],particularli:[16,18,41,43],partit:2,pass:[12,40],path:[22,23,35],path_to_bagel:35,pcv5z:23,pcvdz:23,pcvqz:23,pcvtz:23,per:40,perform:[8,12,13,16,20,23,25,27,28,30,32,37],perman:[23,34],person:35,perturb:[13,17,23,44,47],peter:6,phase:[12,27,28],phase_ful:27,phenyl:[13,28],phy:[1,4,8,9,10,13,18,23,27,28,30,31,37,38,40,41,42,43],physic:45,pick:3,pilot:6,pipe:34,pipek:18,pleas:[8,11,23],plesset:[13,23,32,47],plot:21,plu:21,pnl:23,point:[23,28,40,42],popul:[27,37],portal:23,posit:[12,21,23],positron:27,possibl:[13,23,25],post:[10,23,27,34],potenti:[14,24,28],precis:[13,15,25,28,40,41,42,43],predefin:23,prep:[10,27,30,34],prepar:23,prerequisit:[1,2,4,36,44],press:10,previou:[10,15,23],prim:23,primari:27,primarili:10,primit:23,print:[4,8,10,15,19,20,25,27,37,38,41,43,47],print_oper:27,prior:25,problem:[25,34,35],procedur:[18,27],process:[8,13,15,19,23,25,28,34],produc:[10,22,27],product:28,program:[6,8,10,12,13,17,25,27,28,35,37,38],progress:28,project:[15,22,23,28],propag:12,properti:[10,19,23,27,37],provid:[5,22,23,28],psb:28,pseudospin:27,pulai:13,pv5z:23,pv6z:23,pvdz:[8,13,15,23,28,30],pvqz:23,pvtz:23,pwcv5z:23,pwcvdz:23,pwcvqz:23,pwcvtz:23,qm_bagel:12,qmmm:12,quantiti:12,quantiz:27,quantum:[10,12,14,23,27,28,34,37,38],quasi:28,quick:36,quit:16,qzvpp:23,radii:27,radiu:45,ram:35,rank:[27,38],raphson:28,ras:9,rasci:[1,4,7,47],rather:[22,28],ration:28,ratner:4,rcc:23,rdm:[31,40,41],rdr:6,reach:[25,27,37,38],reactant:28,read:[12,15,19,20,22,25,27,28],readabl:22,real:40,recent:35,recommend:[1,2,4,5,8,9,10,12,13,15,18,21,23,25,27,28,30,31,34,35,37,38,40,41,42,43],recompil:35,reconfigur:35,red:[13,28],reduc:[4,8,10,23,27,40,41,42,43],redun:28,redund:[22,40],ref:1,refer:[0,5,6,14,19,22,24,26,29,32,33,39,44],regardless:[10,27],region:[3,12,18],reiher:[27,37],reinsch:[41,43],reivew:11,relat:[7,8,17,47],relativist:[6,7,21,22,23,26,31,32,35,37,39,41,44,47],relcaspt2:[32,44,47],relcasscf:[23,26,42,43,47],releas:[6,35],relev:[16,23],relfci:[7,47],relmrci:[44,47],relsmith:[42,43],remov:37,renorm:1,repeat:13,replac:[6,27,28],repositori:35,repres:23,repuls:34,request:[15,16,28],requir:[24,30,31,34,35],res:[25,27],respect:[12,28],respons:6,restart:[15,20,22,23],restrict:[3,4,5,6,7,10,13,37,38,47],result:[20,23],retain:[8,10,27,40,41,42,43],retreat:6,rev:[12,30],revers:[10,27],review:13,reynold:[6,27,37],rfo:28,rhf:[13,23,34],right:3,ring:[13,28],rkb:37,rlmo:18,rmb:37,robb:28,robust:25,rohf:13,roo:[9,40,42],root:[37,38],rotat:[2,15,27,40,41,42],rothlisburg:12,run:[10,13,15,22,23,24,25,27,28,35,36,37,38],ryan:6,saddl:28,saitow:[41,43],same:[3,5,8,12,13,15,16,22,23,27,28,30,31],sampl:5,save:[5,19,28,34,38,47],save_ref:22,saveref:1,scalabl:34,scalapack:35,scalpack:35,scf:[23,25,30,34,37,38],scheme:[12,18,25,28,40,42],schlegel:28,schwarz:23,schwarz_thresh:38,sci:[11,12,13],scienc:[25,38],scratch:23,screen:23,scuseria:38,search:28,sec:[30,34],second:[6,9,13,22,23,25,27,28,30,32,43,44,47],section:[2,4,7,8,9,13,15,16,20,23,25,28],sector:27,see:[1,2,4,13,15,20,21,23,25,28,40,41,42,43],seideman:4,select:[8,9,10,13,28],selenium:10,self:[8,9,13,17,23,37,40,41,42,43,47],semi:[25,27],send:34,separ:[2,3,21,32,38,40],separated:38,serrano:[40,42],set:[1,2,3,5,9,13,16,18,20,21,22,24,25,27,28,30,31,34,35,37,38],sever:[16,27,35],shall:7,shane:6,shape:[21,28],shell:[13,37,38],shepard:28,shift:[13,15,16,21,27,28],shiozaki:[1,2,4,6,13,27,31,35,37,38,40,41,42,43],should:[2,3,10,12,27,28,30,34,37,40],show:22,shown:[15,25],sigma:[8,10],significantli:6,silva:18,similar:[7,35],simon:28,simpl:34,simplest:35,simpli:21,simul:[12,14],simulatan:9,simultan:[23,25],sinc:[6,16,28,30,34],singl:[1,5,8,12,13,23,28,40,41,42,43],singlet:[8,10,25,27],site:[0,1,5],sixth:27,size:[4,8,13,15],skip:23,slater:8,slightli:[2,22,40],slower:40,small:35,smith3:[6,17,29,32,33,35,40,41,42,43,47],smith:[13,15,16,21,28,35],smp:6,softwar:35,solut:10,solv:25,some:[10,12,17,22,23,35,38],sometim:23,sourc:[6,12,17,36],space:[2,3,6,7,8,13,17,22,23,26,28,37,40,41,42,43,47],span:[8,23],spatial:[3,21],specif:[6,17,28,31,35,38,47],specifi:[1,2,3,4,5,9,10,13,15,16,20,23,24,25,27,28,30,31,34,35,37,38],spectroscopi:15,speed:[23,45],spin:[1,4,6,8,10,21,25,27,31,38],spinor:37,split:27,squar:[37,38],sr1:28,src:[12,35],sssr:[13,15,28],stabil:37,stabl:[6,28],standard:[18,23,34,40,42],start:[2,3,4,5,8,10,15,24,25,27,28,36],startup:34,state:[1,4,6,8,12,13,22,25,28,32,40,41,42,43,47],statewis:12,statu:28,step:[12,13,15,17,20,25,27,28,47],stepsiz:28,steven:27,sto:[8,23,38],storag:[30,34],store:[22,30,34],store_matrix:4,strain:38,strand:6,stream:34,strength:13,string:[1,2,3,4,8,13,18,20,21,22,23,25,27,28,30,31,40,42],strongli:[31,35],structur:[11,13,14,15,23,27,28,37,38,47],studi:18,subdirectori:28,subotnik:28,subsect:7,subsequ:16,subset:23,subspac:[0,1,2,3,4,9],substanti:[6,7],subval:[8,10,40,41,42,43],suit:35,sum:28,summari:12,supervis:6,supplementari:[17,47],suppli:[10,22,23,27],support:[14,35],surfac:[12,14,28],svp:[1,4,10,12,13,15,20,21,23,25,27,31,34,37,38,40,41,42,43],symbol:23,symmetr:[15,37],symmetri:[10,27],system:[8,10,23,24,38],szabo:[23,38],tabl:[23,45],take:14,taken:[28,45],takeshi:25,tar:35,tarbal:35,target2:12,target:[1,4,12,15,21],ten:44,term:[6,9,13],termin:[25,27,37,38],test:[35,36],testgrad:28,testsuit:35,text:[10,12,13,23,27,37,38],than:[1,8,10,22,23,25,27,28,40,41,42,43],thei:[23,25,27,38,45],theor:28,theori:[2,13,17,23,38,41,43,44,47],therefor:[10,20],thi:[6,7,8,9,10,12,13,14,16,21,22,23,24,27,28,34,35,40,41,42,43],thiel:28,third:[9,22],those:[8,10,27],thousand:44,thread:[34,35],three:[3,7,9,10,13,21,23,25,27,28,40],thresh:[9,13,22,27,28,31],thresh_fci:31,thresh_scf:31,threshold:[1,2,3,4,8,10,23,25,27,37,38,40,41,42,43],through:38,thrown:[25,27],tight:[40,42],tile:[40,41,42,43],time:[8,10,12,13,15,27,30,34],tinker1:28,tinker2:28,tinker:28,tinkin:28,titl:[1,2,3,4,8,9,10,12,15,16,18,20,21,22,23,24,25,27,30,31,34,37,38,40,41,42,43],tool:27,toru:6,total:[0,2,4,8,10,21,27,30,31],trajectori:12,tran:[10,27],transform:[8,10,25,27,30,31,40],transit:[6,13,28],translat:[4,13,15,28],transposit:35,treat:[3,10],trimer:[1,18],triplet:[8,10,22,25,27],turn:[10,23,27,30,31,35,37],two:[1,2,12,13,25,28,37,38,40,41],txt:12,type:[9,13,23,28,35],typic:[23,27],tzvpp:[9,10,22,23,38],uhf:13,under:[11,17],unit:[12,13,15,21,23,28,45],univers:10,unless:[15,21,23,31,37,38,40,41,42,43],unpair:[37,38],unrelax:13,unrestrict:[13,38],until:12,updat:[24,25,28],upper:28,use:[1,3,4,5,7,13,16,18,20,21,22,23,27,28,30,31,35,40],used:[4,6,8,9,10,12,13,15,16,18,21,22,23,25,27,28,30,31,34,35,37,38,40,41,42,43,45],useful:[16,18,23],user:[9,12,13,15,17,18,24,27,28,35],uses:22,using:[8,10,12,15,18,22,23,25,27,28,30,31,34,35,37,38],usr:35,usual:[10,27,37],util:6,valenc:[25,27,32,47],valu:[1,2,3,4,8,9,10,12,13,18,23,25,27,28,31,34,35,37,38,40,41,42,43,45],variabl:36,variant:[6,40,42],variou:[14,32],vch:[27,37],vector:[3,4,6,8,9,10,12,13,18,21,23,25,27,28,37,38,40,41,42,43],veri:[23,25,36],version:[12,22,35,40,42,43],vertic:[40,42],vibrat:[6,15],view:21,virtual:[40,41,42,43],visscher:23,vlaisavljevich:[6,13,40],wai:[8,16],wang:6,want:34,water:9,wave:4,wavefunct:[8,9,10,22,25,40,41],wcm:11,wei:6,weight:[13,15,28,40],weinheim:[27,37],well:[2,3,12,21,38],were:6,werner:[40,41,42,43],wget:35,when:[1,12,13,18,23,25,27,28,30,31,34],where:[10,12,16,23,27,35],whether:[2,3,4,21,37,38,40],which:[2,6,7,8,9,10,13,21,22,23,25,27,28,31,34,35,37,38,40,41,42,43],white:[13,28,38],who:6,whose:4,wilei:[27,37],wilson:15,wire:[11,12,13],wisconsin:6,within:[3,6,8,10,16,21,23,25,27,37],without:[13,22,25,27,28,30,34,35,37],wolf:[27,37],woo:6,work:[4,7,22,40],worth:10,would:18,write:[12,20,21,22,44],writer:12,written:[6,12,20,25,27],wrong:25,wrote:6,www:[11,20,35],xaxi:27,xmcqdpt2:42,xmcqdpt:40,xms:[13,15,28],xvf:35,xyz:[1,4,8,9,10,12,13,15,21,22,23,25,27,28,30,31,34,37,38,40,41,42,43],yanai:[25,27,41,43],yeonjun:6,yiqun:6,york:[15,23,38],you:[10,13,14,15,27,28,34,35],your:[15,22,25,34,36],zarrabian:[8,25],zaxi:27,zcasscf:[22,27,37,42,43],zcasscf_:27,zero:[8,10,23,27,40,41,42,43],zeroth:[40,41,42,43],zfci:10},titles:["Active space decomposition method","ASD-DMRG","ASD orbital optimization","Description","Dimer ASD","Description","Author contributions","Configuration interaction","Full configuration interaction (FCI)","Restricted active space configuration interaction (RASCI)","Relativistic full configuration interaction (RelFCI)","Funding and citation","Interface to dynamics codes","Nuclear gradient and derivative coupling","Nuclear gradients and related functionalities","Molecular Hessian and frequency analysis","Description of input structure","Brilliantly Advanced General Electronic-structure Library","Orbital localization","Miscellaneous features","MOLDEN","Printing orbital densities to cube files","Saving and loading MOs and CI coefficients","Required keywords","Molecule specification","Complete active space self-consistent field (CASSCF)","Multiconfiguration self-consistent field","Relativistic complete active space self-consistent field (RelCASSCF)","Molecular geometry optimization","Multireference second-order perturbation theory (CASPT2)","M\u00f8ller\u2013Plesset perturbation theory (MP2)","N-electron valence state perturbation theory (NEVPT2)","Perturbation theory","Relativistic multireference second-order perturbation theory (RelCASPT2)","How to run BAGEL","Installation","First steps with BAGEL","Dirac\u2013Hartree\u2013Fock","Hartree\u2013Fock","Self-consistent field","Multireference second-order perturbation theory (CASPT2)","Multireference configuration interaction (MRCI)","Relativistic multireference second-order perturbation theory (RelCASPT2)","Relativistic Multireference configuration interaction (RelMRCI)","SMITH3-generated code","Constants","Supplementary information","BAGEL user manual"],titleterms:{"export":[12,13],"function":14,"m\u00f8ller":30,MOs:22,Useful:23,activ:[0,5,8,9,10,18,25,27],active_thresh:3,adapt:28,advanc:17,algorithm:[2,8,18,25,27,28],analysi:15,angstrom:[3,21,23],aniso:27,asd:[1,2,4],atom:23,author:6,aux_basi:[30,31],auxiliari:23,bagel:[11,13,27,31,34,35,36,37,38,40,41,42,43,47],basi:23,basis_typ:23,batchsiz:9,block_diag_fock:[40,42],breit:[10,27,37],brilliantli:17,build:35,canon:[25,27],canonic:2,caspt2:[29,40],casscf:[25,40,41,42,43],cfmm:23,chang:23,charg:[4,8,10,25,27,37,38],cideriv:13,cimaxchunk:40,citat:11,cite:11,code:[12,44],coeffici:22,command:34,common:3,complet:[25,27],configur:[7,8,9,10,41,43],conic:28,consist:[25,26,27,39],constant:45,construct:[1,2,4],continue_geom:22,contribut:6,conv_ignor:[25,27,37],converg:28,core:23,coupl:13,coval:3,criteria:28,cube:21,davidson_subspac:[4,8,10,27,40,41,42,43],decomposit:0,defin:23,densiti:[13,21,23],density_filenam:21,density_print:13,deriv:13,descript:[1,2,3,4,5,8,9,10,12,13,15,16,18,20,21,22,25,27,28,30,31,37,38,40,41,42,43],df_basi:23,dgrad:13,diis_start:[37,38],dimer:[2,3,4],dimer_act:3,dipol:[4,8,13],dirac:37,dkh:23,dma:38,dmrg:1,download:35,dummi:23,dynam:12,ecp:23,effect:23,electron:[17,31],energi:[12,28],energy_thresh:2,environ:34,exampl:[1,4,8,9,10,12,13,15,16,18,20,21,22,23,25,27,28,30,31,37,38,40,41,42,43],exchang:38,export_singl:[12,13],fci:[4,8],fci_algorithm:25,featur:[19,23],field:[25,26,27,39],file:[12,20,21,22],finite_nucleu:23,first:36,fit:23,fmm:38,fock:[37,38],forc:13,force_0:12,force_1:12,form:3,format:12,frequenc:15,frozen:[8,10,30,31,40,41,42,43],full:[8,10],fund:11,gaunt:[10,27,37],gener:[12,13,17,27,31,37,38,40,41,42,43,44],geometri:[23,28],grad:13,gradient:[13,14],gradient_thresh:2,hartre:[37,38],hcore_guess:27,hess_approx:28,hess_upd:28,hessian:15,how:[11,12,34],inc_siz:21,inform:46,input:[1,4,8,9,10,12,13,15,16,18,20,21,22,25,28,34,40,42],instal:35,interact:[7,8,9,10,41,43],interfac:12,intern:28,intersect:28,istat:31,keyword:[1,2,3,4,5,8,9,10,12,13,15,18,20,21,22,23,25,27,28,30,31,37,38,40,41,42,43],librari:17,link:3,lmax:38,lmax_exchang:38,load:22,local:[3,5,18],lowdin:18,magnetic_field:23,manual:47,mass:15,matrix:4,max_hol:9,max_it:4,max_particl:9,maxchang:28,maxdisp:28,maxgrad:28,maxit:[1,2,8,10,25,27,28,37,38,40,41,42,43],maxiter_fci:[8,10,25,27],maxiter_micro:[25,27],maxiter_scf:[37,38],maxstep:28,maxtil:[40,41,42,43],maxzit:[13,28],mdci_reference_geometri:28,mep_direct:28,method:[0,1,4,13,15,28,40,42],minimum:28,miscellan:19,mo_filenam:21,modifi:12,molden:20,molden_fil:23,molecul:[23,24],molecular:[15,28],moment:13,mp2:30,mrci:41,multiconfigur:26,multipol:38,multirefer:[29,33,40,41,42,43],multisit:[1,5],nacm:13,nacme_0_1:12,nacmtyp:[13,28],nact:[25,27],natocc:[25,27],nclose:[25,27],ncore:[8,10,30,31,40,41,42,43],nevpt2:31,nfrozenvirt:[40,41,42,43],nguess:[4,8],non:3,nopen:38,norb:[8,10],nproc:[13,15],nspin:[4,8,25],nstate:[1,4,8,25],ntrunc:1,nuclear:[13,14],numer:[13,28],numerical_dx:28,occupi:18,only_electron:27,only_int:[8,10],optim:[2,28],option:[4,13,15,23,28],opttyp:28,orbit:[2,18,20,21,23],order:[29,33,40,42],orthogonal_basi:40,other:[15,23],out:12,output:34,pair:21,paramet:23,path:28,perturb:[1,29,30,31,32,33,40,42],perturb_min:1,perturb_thresh:1,plesset:30,pop:[27,37],potenti:23,prerequisit:[3,5,8,9,10,35,40,41],print:[13,21],print_info:4,print_thresh:[4,8,10,27],qmmm:28,qmmm_program:28,ras:[1,4],rasci:9,redund:28,ref:5,refer:[1,2,4,8,9,10,12,13,15,18,20,23,25,27,28,30,31,37,38,40,41,42,43],refgeom:28,region_s:[3,18],relat:14,relativist:[10,27,33,42,43],relax:[13,21],relcaspt2:[33,42],relcasscf:27,relfci:10,relmrci:43,requir:[2,4,13,15,23,28],restart:[8,10,38],restart_ca:[25,27],restrict:[1,9],rhf:38,robust:37,rohf:38,rotation_thresh:2,run:34,sampl:[1,4,8,9,10,12,13,15,18,20,21,22,25,28,40,42],save:22,scheme:3,schwarz_thresh:23,second:[29,33,40,42],self:[25,26,27,39],semi:2,set:23,shift:[40,42],shift_imag:40,skip_self_interact:23,smith3:44,smith:[40,41,42,43],softwar:12,soscf:38,sourc:[11,35],space:[0,1,4,9,25,27],specif:[23,24],spin_adapt:[10,27],sssr:[40,42],start_po:21,state:[10,27,31],step:36,store:4,structur:[16,17],supplementari:46,target2:[13,28],target:[13,28],tesla:23,test:34,theori:[29,30,31,32,33,40,42],thielc3:28,thielc4:28,thresh:[1,4,8,10,25,37,38,40,41,42,43],thresh_fci:[8,10,27],thresh_micro:25,thresh_overlap:[37,38,40,41,42,43],thresh_scf:37,titl:[13,28],translat:3,type:18,uhf:38,univers:28,updat:23,user:[23,47],valenc:31,variabl:34,version:6,vibrat:20,virtual:18,work:12,xms:[40,42]}}) \ No newline at end of file diff -Nru bagel-1.2.0/docs/_sources/grad/force.rst.txt bagel-1.2.2/docs/_sources/grad/force.rst.txt --- bagel-1.2.0/docs/_sources/grad/force.rst.txt 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/docs/_sources/grad/force.rst.txt 2018-12-29 22:08:28.000000000 +0000 @@ -86,6 +86,12 @@ | **Datatype:** bool | **Default:** false +.. topic:: ``ciderivative`` + + | **Description:** Evaluate the CI derivative and full gradient in XMS-CASPT2. If false, only unrelaxed density will be calculated. + | **Datatype:** bool + | **Default:** true + .. topic:: ``export`` | **Description:** This option will export the nuclear gradient to a text file. @@ -198,22 +204,22 @@ { "title" : "force", - "target" : 0, - "method" : [ { - "title" : "caspt2", - "smith" : { - "method" : "caspt2", - "ms" : "true", - "xms" : "true", - "sssr" : "true", - "shift" : 0.2, - "frozen" : true - }, - "nstate" : 2, - "nact" : 3, - "nclosed" : 46 - } ] - } + "target" : 0, + "method" : [ { + "title" : "caspt2", + "smith" : { + "method" : "caspt2", + "ms" : "true", + "xms" : "true", + "sssr" : "true", + "shift" : 0.2, + "frozen" : true + }, + "nstate" : 2, + "nact" : 3, + "nclosed" : 46 + } ] + } Sample input: NACME and DGRAD ----------------------------- @@ -222,23 +228,23 @@ { "title" : "nacme", - "target" : 0, - "target2" : 1, - "method" : [ { - "title" : "caspt2", - "smith" : { - "method" : "caspt2", - "ms" : "true", - "xms" : "true", - "sssr" : "true", - "shift" : 0.2, - "frozen" : true - }, - "nstate" : 3, - "nact" : 7, - "nclosed" : 44 - } ] - } + "target" : 0, + "target2" : 1, + "method" : [ { + "title" : "caspt2", + "smith" : { + "method" : "caspt2", + "ms" : "true", + "xms" : "true", + "sssr" : "true", + "shift" : 0.2, + "frozen" : true + }, + "nstate" : 3, + "nact" : 7, + "nclosed" : 44 + } ] + } Using the keyword ``forces``, you can run multiple gradient or derivative coupling calculations without repeating the energy calculations. The example below evaluates the nuclear gradient of the energy of the ground state, the first excited state, and the interstate coupling vector (``nacmtype`` is ``interstate``) between these two states. @@ -246,26 +252,82 @@ { "title" : "forces", - "grads" : [ - { "title" : "force", "target" : 0 }, - { "title" : "force", "target" : 1 }, - { "title" : "nacme", "target" : 0, "target2" : 1, "nacmtype" : "interstate" } - ], - "method" : [ { - "title" : "caspt2", - "smith" : { - "method" : "caspt2", - "ms" : "true", - "xms" : "true", - "sssr" : "true", - "shift" : 0.2, - "frozen" : true - }, - "nstate" : 3, - "nact" : 7, - "nclosed" : 44 - } ] - } + "grads" : [ + { "title" : "force", "target" : 0 }, + { "title" : "force", "target" : 1 }, + { "title" : "nacme", "target" : 0, "target2" : 1, "nacmtype" : "interstate" } + ], + "method" : [ { + "title" : "caspt2", + "smith" : { + "method" : "caspt2", + "ms" : "true", + "xms" : "true", + "sssr" : "true", + "shift" : 0.2, + "frozen" : true + }, + "nstate" : 3, + "nact" : 7, + "nclosed" : 44 + } ] + } + +Sample input: Printing dipole moments +------------------------------------- + +You can use the keyword ``dipole`` to compute the dipole moments for all the states, the transition dipole moments and oscillator strengths of all possible pairs of electronic states. + +.. code-block:: javascript + + { + "title" : "forces", + "dipole" : "true", + "method" : [ { + "title" : "caspt2", + "smith" : { + "method" : "caspt2", + "ms" : "true", + "xms" : "true", + "sssr" : "true", + "shift" : 0.2, + "frozen" : true + }, + "nstate" : 3, + "nact" : 7, + "nclosed" : 44 + } ] + } + +Alternatively, for CASPT2, you can use the keyword ``"ciderivative" : "false"`` to evaluate the dipole moments, transition dipole moments and oscillator strengths of selected states, +without computing the CI derivative term and gradient. +The example below evaluates the dipole moments of state 0, state 1, and transition dipole moment of the state 0 -- state 1 transition. + +.. code-block:: javascript + + { + "title" : "forces", + "grads" : [ + { "title" : "force", "target" : 0, "ciderivative" : "false" }, + { "title" : "force", "target" : 1, "ciderivative" : "false" }, + { "title" : "nacme", "target" : 0, "target2" : 1, "nacmtype" : "interstate", "ciderivative" : "false" } + ], + "method" : [ { + "title" : "caspt2", + "smith" : { + "method" : "caspt2", + "ms" : "true", + "xms" : "true", + "sssr" : "true", + "shift" : 0.2, + "frozen" : true + }, + "nstate" : 3, + "nact" : 7, + "nclosed" : 44 + } ] + } + Sample input: Printing relaxed density -------------------------------------- diff -Nru bagel-1.2.0/src/asd/dimer/dimer_scf.cc bagel-1.2.2/src/asd/dimer/dimer_scf.cc --- bagel-1.2.0/src/asd/dimer/dimer_scf.cc 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/src/asd/dimer/dimer_scf.cc 2018-12-29 22:08:28.000000000 +0000 @@ -313,7 +313,7 @@ } nvirt_ = {nexternA - nactA, nexternB - nactB}; - sref_ = make_shared(sgeom_, make_shared(*out_coeff), nclosed, nact, nexternA+nexternB - (nclosed+nact)); + sref_ = make_shared(sgeom_, make_shared(*out_coeff), nclosed, nact, nexternA+nexternB - nact); } diff -Nru bagel-1.2.0/src/ci/fci/fci_rdm.cc bagel-1.2.2/src/ci/fci/fci_rdm.cc --- bagel-1.2.0/src/ci/fci/fci_rdm.cc 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/src/ci/fci/fci_rdm.cc 2018-12-29 22:08:28.000000000 +0000 @@ -125,7 +125,6 @@ FCI::compute_rdm12_last_step(shared_ptr dbra, shared_ptr dket, shared_ptr cibra) const { const int nri = cibra->asize()*cibra->lenb(); - const int ij = norb_*norb_; // 1RDM c^dagger // 2RDM \sum_I <0|\hat{E}|I> @@ -135,20 +134,13 @@ auto cibra_data = make_shared(nri); copy_n(cibra->data(), nri, cibra_data->data()); - auto dket_data = make_shared(nri, ij); - for (int i = 0; i != ij; ++i) - copy_n(dket->data(i)->data(), nri, dket_data->element_ptr(0, i)); + auto dketv = btas::group(*dket,0,2); auto rdm1t = btas::group(*rdm1,0,2); - btas::contract(1.0, *dket_data, {0,1}, *cibra_data, {0}, 0.0, rdm1t, {1}); + btas::contract(1.0, dketv, {0,1}, *cibra_data, {0}, 0.0, rdm1t, {1}); - auto dbra_data = dket_data; - if (dbra != dket) { - dbra_data = make_shared(nri, ij); - for (int i = 0; i != ij; ++i) - copy_n(dbra->data(i)->data(), nri, dbra_data->element_ptr(0, i)); - } + auto dbrav = btas::group(*dbra,0,2); auto rdm2t = group(group(*rdm2, 2,4), 0,2); - btas::contract(1.0, *dbra_data, {1,0}, *dket_data, {1,2}, 0.0, rdm2t, {0,2}); + btas::contract(1.0, dbrav, {1,0}, dketv, {1,2}, 0.0, rdm2t, {0,2}); } // sorting... a bit stupid but cheap anyway diff -Nru bagel-1.2.0/src/grad/gradinfo.h bagel-1.2.2/src/grad/gradinfo.h --- bagel-1.2.0/src/grad/gradinfo.h 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/src/grad/gradinfo.h 2018-12-29 22:08:28.000000000 +0000 @@ -36,16 +36,18 @@ int target_state2_; int maxziter_; bool density_print_; + bool cider_eval_; std::shared_ptr nacmtype_; std::shared_ptr moprint_info_; public: - GradInfo() : target_state_(0), target_state2_(1), maxziter_(100), density_print_(false), nacmtype_(std::make_shared("full")), moprint_info_(std::make_shared()) { } + GradInfo() : target_state_(0), target_state2_(1), maxziter_(100), density_print_(false), cider_eval_(true), nacmtype_(std::make_shared("full")), moprint_info_(std::make_shared()) { } GradInfo(std::shared_ptr o, const int target) { target_state_ = target; target_state2_ = -1; maxziter_ = o->maxziter(); density_print_ = o->density_print(); + cider_eval_ = o->cider_eval(); nacmtype_ = o->nacmtype(); moprint_info_ = o->moprint_info(); } @@ -55,6 +57,7 @@ target_state2_ = idat->get("target2", 1); maxziter_ = idat->get("maxziter", 100); density_print_ = idat->get("density_print", false); + cider_eval_ = idat->get("ciderivative", true); moprint_info_ = idat->get_child_optional("moprint"); if (!moprint_info_) moprint_info_ = std::make_shared(); } @@ -63,6 +66,7 @@ int target_state2() const { return target_state2_; } int maxziter() const { return maxziter_; } bool density_print() const { return density_print_; } + bool cider_eval() const { return cider_eval_; } std::shared_ptr nacmtype() const { return nacmtype_; } std::shared_ptr moprint_info() const { return moprint_info_; } diff -Nru bagel-1.2.0/src/main.cc bagel-1.2.2/src/main.cc --- bagel-1.2.0/src/main.cc 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/src/main.cc 2018-12-29 22:08:28.000000000 +0000 @@ -35,13 +35,15 @@ int main(int argc, char** argv) { try { - const bool input_provided = argc == 2; - if (!input_provided) + if (argc == 2) { + const string input = argv[1]; + run_bagel_from_input(input); + } else if (argc == 3 && string(argv[1]) == "-i") { + const string input = argv[2]; + run_bagel_from_json(input); + } else { throw runtime_error("no input file provided"); - const string input = argv[1]; - - // this is the main driver - bagel::run_bagel_from_input(input); + } } catch (const Termination& e) { cout << " -- Termination requested --" << endl; cout << " message: " << e.what() << endl; diff -Nru bagel-1.2.0/src/molecule/atom.cc bagel-1.2.2/src/molecule/atom.cc --- bagel-1.2.0/src/molecule/atom.cc 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/src/molecule/atom.cc 2018-12-29 22:08:28.000000000 +0000 @@ -577,7 +577,7 @@ rshells.push_back(tmp); } auto atom = make_shared(*this); - atom->shells_ = rshells; + atom->reset_shells(rshells); return atom; } diff -Nru bagel-1.2.0/src/molecule/molecule.cc bagel-1.2.2/src/molecule/molecule.cc --- bagel-1.2.0/src/molecule/molecule.cc 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/src/molecule/molecule.cc 2018-12-29 22:08:28.000000000 +0000 @@ -845,6 +845,16 @@ atom.push_back(i->uncontract()->relativistic()); auto mol = make_shared(atom, aux_atoms_); + mol->spherical_ = spherical_; + mol->aux_merged_ = aux_merged_; + mol->basisfile_ = basisfile_; + mol->auxfile_ = auxfile_; + mol->nuclear_repulsion_ = nuclear_repulsion_; + mol->external_ = external_; + mol->magnetic_field_ = magnetic_field_; + mol->skip_self_interaction_ = skip_self_interaction_; + mol->cap_ = cap_; + mol->common_init1(); return mol; diff -Nru bagel-1.2.0/src/multi/casscf/casnoopt.h bagel-1.2.2/src/multi/casscf/casnoopt.h --- bagel-1.2.0/src/multi/casscf/casnoopt.h 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/src/multi/casscf/casnoopt.h 2018-12-29 22:08:28.000000000 +0000 @@ -53,8 +53,12 @@ energy_ = ref_->energy(); } - if (canonical_) - coeff_ = semi_canonical_orb(); + if (canonical_) { + auto tmp = semi_canonical_orb(); + coeff_ = std::get<0>(tmp); + eig_ = std::get<1>(tmp); + occup_ = std::get<2>(tmp); + } if (do_hyperfine_ && !geom_->external() && nstate_ == 1 && external_rdm_.empty()) { HyperFine hfcc(geom_, spin_density(), fci_->det()->nspin(), "CASSCF"); @@ -63,12 +67,16 @@ } std::shared_ptr conv_to_ref() const override { + std::shared_ptr out; if (nact_) { - return std::make_shared(geom_, coeff_, nclosed_, nact_, nvirt_, energy_, - fci_->rdm1(), fci_->rdm2(), fci_->rdm1_av(), fci_->rdm2_av(), fci_->conv_to_ciwfn()); + out = std::make_shared(geom_, coeff_, nclosed_, nact_, nvirt_, energy_, + fci_->rdm1(), fci_->rdm2(), fci_->rdm1_av(), fci_->rdm2_av(), fci_->conv_to_ciwfn()); } else { - return std::make_shared(geom_, coeff_, nclosed_, nact_, nvirt_, energy_); + out = std::make_shared(geom_, coeff_, nclosed_, nact_, nvirt_, energy_); } + out->set_eig(eig_); + out->set_occup(occup_); + return out; } }; diff -Nru bagel-1.2.0/src/multi/casscf/casscf.cc bagel-1.2.2/src/multi/casscf/casscf.cc --- bagel-1.2.0/src/multi/casscf/casscf.cc 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/src/multi/casscf/casscf.cc 2018-12-29 22:08:28.000000000 +0000 @@ -225,7 +225,7 @@ } -shared_ptr CASSCF::semi_canonical_orb() const { +tuple,VectorB,VectorB> CASSCF::semi_canonical_orb() const { auto rdm1mat = make_shared(nact_, nact_); if (nact_) { copy_n(fci_->rdm1_av()->data(), rdm1mat->size(), rdm1mat->data()); @@ -236,29 +236,49 @@ auto acoeff = coeff_->slice(nclosed_, nocc_); auto vcoeff = coeff_->slice(nocc_, nmo_); - VectorB eig(coeff_->mdim()); Fock<1> fock; if (nact_) fock = Fock<1>(geom_, fci_->jop()->core_fock(), nullptr, acoeff * *rdm1mat, false, /*rhf*/true); else fock = Fock<1>(geom_, ref_->hcore(), nullptr, coeff_->slice_copy(0, nclosed_), false, /*rhf*/true); + VectorB eig(coeff_->mdim()); + VectorB occup(coeff_->mdim()); + // calculate the transformation matrix to (semi-)canonical orbitals Matrix trans(nmo_, nmo_); trans.unit(); if (nclosed_) { Matrix ofock = ocoeff % fock * ocoeff; - ofock.diagonalize(eig); + VectorB tmp(nclosed_); + ofock.diagonalize(tmp); trans.copy_block(0, 0, nclosed_, nclosed_, ofock); + copy_n(tmp.data(), nclosed_, eig.data()); + fill_n(occup.data(), nclosed_, 2.0); } if (nact_ && canonical_) { Matrix afock = acoeff % fock * acoeff; - afock.diagonalize(eig); + VectorB tmp(nact_); + afock.diagonalize(tmp); trans.copy_block(nclosed_, nclosed_, nact_, nact_, afock); + copy_n(tmp.data(), nact_, eig.data()+nclosed_); + } + { + Matrix vfock = vcoeff % fock * vcoeff; + VectorB tmp(nvirt_); + vfock.diagonalize(tmp); + trans.copy_block(nocc_, nocc_, nvirt_, nvirt_, vfock); + copy_n(tmp.data(), nvirt_, eig.data()+nclosed_+nact_); } - Matrix vfock = vcoeff % fock * vcoeff; - vfock.diagonalize(eig); - trans.copy_block(nocc_, nocc_, nvirt_, nvirt_, vfock); - return make_shared(*coeff_ * trans); + // finally calculate the occupation numbers for active orbitals (diagonal elements of transformed 1RDM) + { + shared_ptr atrans = trans.get_submatrix(nclosed_, nclosed_, nact_, nact_); + const Matrix transrdm = *atrans * *rdm1mat ^ *atrans; + for (int i = 0; i != nact_; ++i) + occup[i+nclosed_] = transrdm(i, i); + } + + auto coeffout = make_shared(*coeff_ * trans); + return make_tuple(coeffout, move(eig), move(occup)); } @@ -282,7 +302,10 @@ shared_ptr CASSCF::conv_to_ref() const { const bool noci = !nact_ || external_rdm_ == "noref"; - return noci ? make_shared(geom_, coeff_, nclosed_, nact_, nvirt_, energy_) - : make_shared(geom_, coeff_, nclosed_, nact_, nvirt_, energy_, - fci_->rdm1(), fci_->rdm2(), fci_->rdm1_av(), fci_->rdm2_av(), fci_->conv_to_ciwfn()); + auto ref = noci ? make_shared(geom_, coeff_, nclosed_, nact_, nvirt_, energy_) + : make_shared(geom_, coeff_, nclosed_, nact_, nvirt_, energy_, + fci_->rdm1(), fci_->rdm2(), fci_->rdm1_av(), fci_->rdm2_av(), fci_->conv_to_ciwfn()); + ref->set_eig(eig_); + ref->set_occup(occup_); + return ref; } diff -Nru bagel-1.2.0/src/multi/casscf/casscf.h bagel-1.2.2/src/multi/casscf/casscf.h --- bagel-1.2.0/src/multi/casscf/casscf.h 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/src/multi/casscf/casscf.h 2018-12-29 22:08:28.000000000 +0000 @@ -102,9 +102,13 @@ const std::shared_ptr hcore_; - std::shared_ptr semi_canonical_orb() const; + std::tuple,VectorB,VectorB> semi_canonical_orb() const; std::shared_ptr spin_density() const; + // orbital eigenvalues and occupations + VectorB eig_; + VectorB occup_; + // energy std::vector energy_; double rms_grad_; diff -Nru bagel-1.2.0/src/multi/casscf/cassecond.cc bagel-1.2.2/src/multi/casscf/cassecond.cc --- bagel-1.2.0/src/multi/casscf/cassecond.cc 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/src/multi/casscf/cassecond.cc 2018-12-29 22:08:28.000000000 +0000 @@ -146,8 +146,12 @@ muffle_->unmute(); // block diagonalize coeff_ in nclosed and nvirt - if (max_iter_ > 0) - coeff_ = semi_canonical_orb(); + if (max_iter_ > 0) { + auto tmp = semi_canonical_orb(); + coeff_ = get<0>(tmp); + eig_ = get<1>(tmp); + occup_ = get<2>(tmp); + } // this is not needed for energy, but for consistency we want to have this... // update construct Jop from scratch @@ -238,7 +242,8 @@ Matrix tmp(nao, nao); for (int i = 0; i != nclosed_; ++i) { dgemv_("T", nri, nao*nao, 1.0, geom_->df()->block(0)->data(), nri, vgcc->block(0)->data()+nri*(i+nclosed_*i), 1, 0.0, tmp.data(), 1); - tmp.allreduce(); + if (!vgcc->serial()) + tmp.allreduce(); Matrix tmp0 = vcoeff % tmp * vcoeff; blas::ax_plus_y_n(-4.0, tmp0.diag().data(), nvirt_, denom->ptr_vc()+nvirt_*i); } @@ -250,7 +255,8 @@ Matrix tmp(nao, nao); for (int i = 0; i != nact_; ++i) { dgemv_("T", nri, nao*nao, 1.0, geom_->df()->block(0)->data(), nri, vgaa->block(0)->data()+nri*(i+nact_*i), 1, 0.0, tmp.data(), 1); - tmp.allreduce(); + if (!vgaa->serial()) + tmp.allreduce(); Matrix tmp0 = vcoeff % tmp * vcoeff; blas::ax_plus_y_n(2.0, tmp0.diag().data(), nvirt_, denom->ptr_va()+nvirt_*i); if (nclosed_) { @@ -292,7 +298,8 @@ vgaa->ax_plus_y(-1.0, vaa); for (int i = 0; i != nact_; ++i) { dgemv_("T", nri, nao*nao, 1.0, geom_->df()->block(0)->data(), nri, vgaa->block(0)->data()+nri*(i+nact_*i), 1, 0.0, tmp.data(), 1); - tmp.allreduce(); + if (!vgaa->serial()) + tmp.allreduce(); Matrix tmp0 = ccoeff % tmp * ccoeff; blas::ax_plus_y_n(4.0, tmp0.diag().data(), nclosed_, denom->ptr_ca()+nclosed_*i); } diff -Nru bagel-1.2.0/src/smith/caspt2/MSCASPT2.cc bagel-1.2.2/src/smith/caspt2/MSCASPT2.cc --- bagel-1.2.0/src/smith/caspt2/MSCASPT2.cc 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/src/smith/caspt2/MSCASPT2.cc 2018-12-29 22:08:28.000000000 +0000 @@ -283,7 +283,7 @@ add_total(lnhJI); } - if ((!info_->sssr() || (mst == lst && nst == lst)) && !info_->orthogonal_basis()) { + if ((!info_->sssr() || (mst == lst && nst == lst)) && !info_->shift_imag()) { e0_ = 2.0*info_->shift(); l2 = t2all_[lst]->at(nst); t2 = t2all_[lst]->at(mst); @@ -365,17 +365,18 @@ stringstream ss; ss << "CI derivative evaluation (" << setw(2) << mst+1 << " /" << setw(2) << nstates << ")"; timer.tick_print(ss.str()); } + } - // If we have imaginary shift, construct additional density due to the shift - if (info_->shift_imag() && info_->shift() != 0.0) { - shared_ptr dshift; - tie(dshift, etensor1_, etensor2_, etensor3_, etensor4_, nimag_) = make_d2_imag(); - *den2_ += *dshift; - timer.tick_print("dshift"); - } + // If we have imaginary shift, construct additional density due to the shift + if (info_->shift_imag() && info_->shift() != 0.0) { + shared_ptr dshift; + tie(dshift, etensor1_, etensor2_, etensor3_, etensor4_, nimag_) = make_d2_imag(); + *den2_ += *dshift; + timer.tick_print("dshift"); + } - if (info_->nact()) - do_rdm_deriv(1.0); + if (!nocider && info_->nact()) { + do_rdm_deriv(1.0); timer.tick_print("CI derivative contraction"); } } diff -Nru bagel-1.2.0/src/smith/caspt2/MSCASPT2_shift.cc bagel-1.2.2/src/smith/caspt2/MSCASPT2_shift.cc --- bagel-1.2.0/src/smith/caspt2/MSCASPT2_shift.cc 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/src/smith/caspt2/MSCASPT2_shift.cc 2018-12-29 22:08:28.000000000 +0000 @@ -185,20 +185,36 @@ const double shift2 = info_->shift() * info_->shift(); for (int iext = Excitations::arbs; iext != Excitations::total; ++iext) { - const size_t interm_size = (iext == Excitations::aibj) ? 1 : t_orthogonal_->shalf(iext)->ndim(); - auto smallz = make_shared(interm_size, interm_size); - auto largey = make_shared(interm_size, interm_size); - auto largex = make_shared(interm_size, interm_size); - auto largeq = make_shared(interm_size, interm_size); + auto smallzall = make_shared>(); + auto largexall = make_shared>(); + auto largeyall = make_shared>(); + auto largeqall = make_shared>(); + + for (int istate = 0; istate != nstates; ++istate) { + if (!info_->sssr() && istate != 0) continue; // if ms-mr, only one needed + const size_t interm_size = (iext != Excitations::aibj) ? t_orthogonal_->shalf(iext, istate).ndim() : 1; + auto temp = make_shared(interm_size, interm_size); + smallzall->emplace(istate, temp->copy()); + largexall->emplace(istate, temp->copy()); + largeyall->emplace(istate, temp->copy()); + largeqall->emplace(istate, temp->copy()); + } + switch (iext) { case Excitations::arbs: for (int istate = 0; istate != nstates; ++istate) { // state of T const shared_ptr> l = l_orthogonal_->data(istate)->at(iext); const shared_ptr> t = t_orthogonal_->data(istate)->at(iext); const shared_ptr> d = t_orthogonal_->denom(istate)->at(iext); + + const size_t dataindex = info_->sssr() ? iext + istate * Excitations::total : iext; + shared_ptr smallz = info_->sssr() ? smallzall->at(istate) : smallzall->at(0); + shared_ptr largey = info_->sssr() ? largeyall->at(istate) : largeyall->at(0); + shared_ptr largeq = info_->sssr() ? largeqall->at(istate) : largeqall->at(0); + for (auto& i3 : t_orthogonal_->virt()) for (auto& i1 : t_orthogonal_->virt()) - for (auto& i0o : t_orthogonal_->interm(iext)) { + for (auto& i0o : t_orthogonal_->interm(dataindex)) { if (!t->is_local(i0o, i1, i3)) continue; const unique_ptr amplitude = t->get_block(i0o, i1, i3); const unique_ptr lambda = l->get_block(i0o, i1, i3); @@ -216,7 +232,7 @@ } } } - for (auto& i1o : t_orthogonal_->interm(iext)) { + for (auto& i1o : t_orthogonal_->interm(dataindex)) { const unique_ptr amplitudek = t->get_block(i1o, i1, i3); const unique_ptr lambdak = l->get_block(i1o, i1, i3); const unique_ptr denomk = d->get_block(i1o, i1, i3); @@ -236,23 +252,39 @@ } } } - smallz->allreduce(); - largey->allreduce(); - largeq->allreduce(); - for (size_t j0o = 0; j0o != interm_size; ++j0o) { - for (size_t j1o = 0; j1o != interm_size; ++j1o) { - if (j1o == j0o) continue; - const double fdiff = t_orthogonal_->phi(iext, j1o) - t_orthogonal_->phi(iext, j0o); - smallz->element(j1o, j0o) = fabs(fdiff) > 1.0e-12 ? -0.5 * (largey->element(j1o, j0o) - largey->element(j0o, j1o)) / fdiff : 0.0; + for (int istate = 0; istate != nstates; ++istate) { + if (!info_->sssr() && istate != 0) continue; + smallzall->at(istate)->allreduce(); + largeyall->at(istate)->allreduce(); + largeqall->at(istate)->allreduce(); + + shared_ptr smallz = info_->sssr() ? smallzall->at(istate) : smallzall->at(0); + shared_ptr largex = info_->sssr() ? largexall->at(istate) : largexall->at(0); + shared_ptr largey = info_->sssr() ? largeyall->at(istate) : largeyall->at(0); + + const size_t interm_size = t_orthogonal_->shalf(iext, istate).ndim(); + + for (size_t j0o = 0; j0o != interm_size; ++j0o) { + for (size_t j1o = 0; j1o != interm_size; ++j1o) { + if (j1o == j0o) continue; + const double fdiff = t_orthogonal_->phi(iext, istate, j1o) - t_orthogonal_->phi(iext, istate, j0o); + smallz->element(j1o, j0o) = fabs(fdiff) > 1.0e-12 ? -0.5 * (largey->element(j1o, j0o) - largey->element(j0o, j1o)) / fdiff : 0.0; + } } - } - for (size_t j0o = 0; j0o != interm_size; ++j0o) { - for (size_t j1o = 0; j1o != interm_size; ++j1o) { - largex->element(j1o, j0o) = 0.25 * (largey->element(j1o, j0o) + 2.0 * smallz->element(j1o, j0o) * t_orthogonal_->phi(iext, j1o)) - + 0.25 * (largey->element(j0o, j1o) + 2.0 * smallz->element(j0o, j1o) * t_orthogonal_->phi(iext, j0o)); + for (size_t j0o = 0; j0o != interm_size; ++j0o) { + for (size_t j1o = 0; j1o != interm_size; ++j1o) { + largex->element(j1o, j0o) = 0.25 * (largey->element(j1o, j0o) + 2.0 * smallz->element(j1o, j0o) * t_orthogonal_->phi(iext, istate, j1o)) + + 0.25 * (largey->element(j0o, j1o) + 2.0 * smallz->element(j0o, j1o) * t_orthogonal_->phi(iext, istate, j0o)); + } } } + for (size_t is = 0; is != nstates; ++is) { + shared_ptr smallz = info_->sssr() ? smallzall->at(is) : smallzall->at(0); + shared_ptr largey = info_->sssr() ? largeyall->at(is) : largeyall->at(0); + shared_ptr largeq = info_->sssr() ? largeqall->at(is) : largeqall->at(0); + shared_ptr largex = info_->sssr() ? largexall->at(is) : largexall->at(0); + const size_t interm_size = t_orthogonal_->shalf(iext, is).ndim(); for (size_t js = 0; js != nstates; ++js) { if (info_->sssr() && is != js) continue; shared_ptr> rdm1; @@ -261,9 +293,10 @@ shared_ptr> rdm4; tie(rdm1, rdm2, rdm3, rdm4) = feed_rdm(js, is); { - shared_ptr Vmat = t_orthogonal_->shalf(iext)->get_submatrix(0, is * nact * nact, interm_size, nact * nact); - auto Qmat = make_shared((*smallz) % (*Vmat)); - auto Pmat = make_shared((-2.0 * (*largex) + (*largeq)) % (*Vmat)); + MatView VmatI = t_orthogonal_->shalf(iext, is); + MatView VmatJ = t_orthogonal_->shalf(iext, js); + auto Qmat = make_shared((*smallz) % VmatI); + auto Pmat = make_shared((-2.0 * (*largex) + (*largeq)) % VmatI); auto Rmat = make_shared>(nact); // (2) form R_{tv,uw} = Q^U_{tv} V^{U}_{uw} for (size_t j0 = 0; j0 != nact; ++j0) { @@ -273,7 +306,7 @@ for (size_t j2 = 0; j2 != nact; ++j2) { for (size_t j3 = 0; j3 != nact; ++j3) { for (size_t j0o = 0; j0o != interm_size; ++j0o) { - const double VrsO = t_orthogonal_->shalf(iext)->element(j0o, j2 + j3 * nact + js * nact * nact); + const double VrsO = VmatJ.element(j0o, j2 + j3 * nact); Rmat->element(j0, j1, j2, j3) += Qmat->element(j0o, j0 + j1 * nact) * VrsO; e2->at(js, is)->element(j0, j2, j1, j3) += Pmat->element(j0o, j0 + j1 * nact) * VrsO; } @@ -308,10 +341,16 @@ const shared_ptr> l = l_orthogonal_->data(istate)->at(iext); const shared_ptr> t = t_orthogonal_->data(istate)->at(iext); const shared_ptr> d = t_orthogonal_->denom(istate)->at(iext); + + const size_t dataindex = info_->sssr() ? iext + istate * Excitations::total : iext; + shared_ptr smallz = info_->sssr() ? smallzall->at(istate) : smallzall->at(0); + shared_ptr largey = info_->sssr() ? largeyall->at(istate) : largeyall->at(0); + shared_ptr largeq = info_->sssr() ? largeqall->at(istate) : largeqall->at(0); + for (auto& i3 : t_orthogonal_->virt()) for (auto& i2 : t_orthogonal_->closed()) for (auto& i1 : t_orthogonal_->virt()) - for (auto& i0o : t_orthogonal_->interm(iext)) { + for (auto& i0o : t_orthogonal_->interm(dataindex)) { if (!t->is_local(i0o, i1, i2, i3)) continue; const unique_ptr amplitude = t->get_block(i0o, i1, i2, i3); const unique_ptr lambda = l->get_block(i0o, i1, i2, i3); @@ -341,7 +380,7 @@ } } } - for (auto& i1o : t_orthogonal_->interm(iext)) { + for (auto& i1o : t_orthogonal_->interm(dataindex)) { const unique_ptr amplitudek = t->get_block(i1o, i1, i2, i3); const unique_ptr lambdak = l->get_block(i1o, i1, i2, i3); const unique_ptr denomk = d->get_block(i1o, i1, i2, i3); @@ -363,23 +402,38 @@ } } } - smallz->allreduce(); - largey->allreduce(); - largeq->allreduce(); - for (size_t j0o = 0; j0o != interm_size; ++j0o) { - for (size_t j1o = 0; j1o != interm_size; ++j1o) { - if (j1o == j0o) continue; - const double fdiff = t_orthogonal_->phi(iext, j1o) - t_orthogonal_->phi(iext, j0o); - smallz->element(j1o, j0o) = fabs(fdiff) > 1.0e-12 ? -0.5 * (largey->element(j1o, j0o) - largey->element(j0o, j1o)) / fdiff : 0.0; + for (int istate = 0; istate != nstates; ++istate) { + if (!info_->sssr() && istate != 0) continue; + smallzall->at(istate)->allreduce(); + largeyall->at(istate)->allreduce(); + largeqall->at(istate)->allreduce(); + + shared_ptr smallz = info_->sssr() ? smallzall->at(istate) : smallzall->at(0); + shared_ptr largex = info_->sssr() ? largexall->at(istate) : largexall->at(0); + shared_ptr largey = info_->sssr() ? largeyall->at(istate) : largeyall->at(0); + + const size_t interm_size = t_orthogonal_->shalf(iext, istate).ndim(); + + for (size_t j0o = 0; j0o != interm_size; ++j0o) { + for (size_t j1o = 0; j1o != interm_size; ++j1o) { + if (j1o == j0o) continue; + const double fdiff = t_orthogonal_->phi(iext, istate, j1o) - t_orthogonal_->phi(iext, istate, j0o); + smallz->element(j1o, j0o) = fabs(fdiff) > 1.0e-12 ? -0.5 * (largey->element(j1o, j0o) - largey->element(j0o, j1o)) / fdiff : 0.0; + } } - } - for (size_t j0o = 0; j0o != interm_size; ++j0o) { - for (size_t j1o = 0; j1o != interm_size; ++j1o) { - largex->element(j1o, j0o) = 0.25 * (largey->element(j1o, j0o) + 2.0 * smallz->element(j1o, j0o) * t_orthogonal_->phi(iext, j1o)) - + 0.25 * (largey->element(j0o, j1o) + 2.0 * smallz->element(j0o, j1o) * t_orthogonal_->phi(iext, j0o)); + for (size_t j0o = 0; j0o != interm_size; ++j0o) { + for (size_t j1o = 0; j1o != interm_size; ++j1o) { + largex->element(j1o, j0o) = 0.25 * (largey->element(j1o, j0o) + 2.0 * smallz->element(j1o, j0o) * t_orthogonal_->phi(iext, istate, j1o)) + + 0.25 * (largey->element(j0o, j1o) + 2.0 * smallz->element(j0o, j1o) * t_orthogonal_->phi(iext, istate, j0o)); + } } } for (size_t is = 0; is != nstates; ++is) { + shared_ptr smallz = info_->sssr() ? smallzall->at(is) : smallzall->at(0); + shared_ptr largey = info_->sssr() ? largeyall->at(is) : largeyall->at(0); + shared_ptr largeq = info_->sssr() ? largeqall->at(is) : largeqall->at(0); + shared_ptr largex = info_->sssr() ? largexall->at(is) : largexall->at(0); + const size_t interm_size = t_orthogonal_->shalf(iext, is).ndim(); for (size_t js = 0; js != nstates; ++js) { if (info_->sssr() && is != js) continue; shared_ptr> rdm1; @@ -388,9 +442,10 @@ shared_ptr> rdm4; tie(rdm1, rdm2, rdm3, rdm4) = feed_rdm(js, is); { - shared_ptr Vmat = t_orthogonal_->shalf(iext)->get_submatrix(0, is * nact, interm_size, nact); - auto Qmat = make_shared((*smallz) % (*Vmat)); - auto Pmat = make_shared((-2.0 * (*largex) + (*largeq)) % (*Vmat)); + MatView VmatI = t_orthogonal_->shalf(iext, is); + MatView VmatJ = t_orthogonal_->shalf(iext, js); + auto Qmat = make_shared((*smallz) % VmatI); + auto Pmat = make_shared((-2.0 * (*largex) + (*largeq)) % VmatI); auto Rmat = make_shared>(nact); // (2) form R_{tv,uw} = Q^U_{tv} V^{U}_{uw} for (size_t j0 = 0; j0 != nact; ++j0) { @@ -398,7 +453,7 @@ const int jall = j1 + nact * j0; if (jall % mpi__->size() != mpi__->rank()) continue; for (size_t j0o = 0; j0o != interm_size; ++j0o) { - const double VrO = t_orthogonal_->shalf(iext)->element(j0o, j1 + js * nact); + const double VrO = VmatJ.element(j0o, j1); Rmat->element(j0, j1) += Qmat->element(j0o, j0) * VrO; e1->at(js, is)->element(j0, j1) += Pmat->element(j0o, j0) * VrO; } @@ -429,10 +484,16 @@ const shared_ptr> l = l_orthogonal_->data(istate)->at(iext); const shared_ptr> t = t_orthogonal_->data(istate)->at(iext); const shared_ptr> d = t_orthogonal_->denom(istate)->at(iext); + + const size_t dataindex = info_->sssr() ? iext + istate * Excitations::total : iext; + shared_ptr smallz = info_->sssr() ? smallzall->at(istate) : smallzall->at(0); + shared_ptr largey = info_->sssr() ? largeyall->at(istate) : largeyall->at(0); + shared_ptr largeq = info_->sssr() ? largeqall->at(istate) : largeqall->at(0); + for (auto& i2 : t_orthogonal_->closed()) for (auto& i1 : t_orthogonal_->virt()) for (auto& i0 : t_orthogonal_->closed()) - for (auto& i0o : t_orthogonal_->interm(iext)) { + for (auto& i0o : t_orthogonal_->interm(dataindex)) { if (!t->is_local(i0o, i0, i1, i2)) continue; const unique_ptr amplitude = t->get_block(i0o, i0, i1, i2); const unique_ptr lambda = l->get_block(i0o, i0, i1, i2); @@ -462,7 +523,7 @@ } } } - for (auto& i1o : t_orthogonal_->interm(iext)) { + for (auto& i1o : t_orthogonal_->interm(dataindex)) { const unique_ptr amplitudek = t->get_block(i1o, i0, i1, i2); const unique_ptr lambdak = l->get_block(i1o, i0, i1, i2); const unique_ptr denomk = d->get_block(i1o, i0, i1, i2); @@ -484,23 +545,38 @@ } } } - smallz->allreduce(); - largey->allreduce(); - largeq->allreduce(); - for (size_t j0o = 0; j0o != interm_size; ++j0o) { - for (size_t j1o = 0; j1o != interm_size; ++j1o) { - if (j1o == j0o) continue; - const double fdiff = t_orthogonal_->phi(iext, j1o) - t_orthogonal_->phi(iext, j0o); - smallz->element(j1o, j0o) = fabs(fdiff) > 1.0e-12 ? -0.5 * (largey->element(j1o, j0o) - largey->element(j0o, j1o)) / fdiff : 0.0; + for (int istate = 0; istate != nstates; ++istate) { + if (!info_->sssr() && istate != 0) continue; + smallzall->at(istate)->allreduce(); + largeyall->at(istate)->allreduce(); + largeqall->at(istate)->allreduce(); + + shared_ptr smallz = info_->sssr() ? smallzall->at(istate) : smallzall->at(0); + shared_ptr largex = info_->sssr() ? largexall->at(istate) : largexall->at(0); + shared_ptr largey = info_->sssr() ? largeyall->at(istate) : largeyall->at(0); + + const size_t interm_size = t_orthogonal_->shalf(iext, istate).ndim(); + + for (size_t j0o = 0; j0o != interm_size; ++j0o) { + for (size_t j1o = 0; j1o != interm_size; ++j1o) { + if (j1o == j0o) continue; + const double fdiff = t_orthogonal_->phi(iext, istate, j1o) - t_orthogonal_->phi(iext, istate, j0o); + smallz->element(j1o, j0o) = fabs(fdiff) > 1.0e-12 ? -0.5 * (largey->element(j1o, j0o) - largey->element(j0o, j1o)) / fdiff : 0.0; + } } - } - for (size_t j0o = 0; j0o != interm_size; ++j0o) { - for (size_t j1o = 0; j1o != interm_size; ++j1o) { - largex->element(j1o, j0o) = 0.25 * (largey->element(j1o, j0o) + 2.0 * smallz->element(j1o, j0o) * t_orthogonal_->phi(iext, j1o)) - + 0.25 * (largey->element(j0o, j1o) + 2.0 * smallz->element(j0o, j1o) * t_orthogonal_->phi(iext, j0o)); + for (size_t j0o = 0; j0o != interm_size; ++j0o) { + for (size_t j1o = 0; j1o != interm_size; ++j1o) { + largex->element(j1o, j0o) = 0.25 * (largey->element(j1o, j0o) + 2.0 * smallz->element(j1o, j0o) * t_orthogonal_->phi(iext, istate, j1o)) + + 0.25 * (largey->element(j0o, j1o) + 2.0 * smallz->element(j0o, j1o) * t_orthogonal_->phi(iext, istate, j0o)); + } } } for (size_t is = 0; is != nstates; ++is) { + shared_ptr smallz = info_->sssr() ? smallzall->at(is) : smallzall->at(0); + shared_ptr largey = info_->sssr() ? largeyall->at(is) : largeyall->at(0); + shared_ptr largeq = info_->sssr() ? largeqall->at(is) : largeqall->at(0); + shared_ptr largex = info_->sssr() ? largexall->at(is) : largexall->at(0); + const size_t interm_size = t_orthogonal_->shalf(iext, is).ndim(); for (size_t js = 0; js != nstates; ++js) { if (info_->sssr() && is != js) continue; shared_ptr> rdm1; @@ -509,9 +585,10 @@ shared_ptr> rdm4; tie(rdm1, rdm2, rdm3, rdm4) = feed_rdm(js, is); { - shared_ptr Vmat = t_orthogonal_->shalf(iext)->get_submatrix(0, is * nact, interm_size, nact); - auto Qmat = make_shared((*smallz) % (*Vmat)); - auto Pmat = make_shared((-2.0 * (*largex) + (*largeq)) % (*Vmat)); + MatView VmatI = t_orthogonal_->shalf(iext, is); + MatView VmatJ = t_orthogonal_->shalf(iext, js); + auto Qmat = make_shared((*smallz) % VmatI); + auto Pmat = make_shared((-2.0 * (*largex) + (*largeq)) % VmatI); auto Rmat = make_shared>(nact); // (2) form R_{tv,uw} = Q^U_{tv} V^{U}_{uw} for (size_t j0 = 0; j0 != nact; ++j0) { @@ -519,7 +596,7 @@ const int jall = j1 + nact * j0; if (jall % mpi__->size() != mpi__->rank()) continue; for (size_t j0o = 0; j0o != interm_size; ++j0o) { - const double VrO = t_orthogonal_->shalf(iext)->element(j0o, j1 + js * nact); + const double VrO = VmatJ.element(j0o, j1); Rmat->element(j0, j1) += Qmat->element(j0o, j0) * VrO; e1->at(js, is)->element(j0, j1) += -Pmat->element(j0o, j0) * VrO; } @@ -557,9 +634,15 @@ const shared_ptr> l = l_orthogonal_->data(istate)->at(iext); const shared_ptr> t = t_orthogonal_->data(istate)->at(iext); const shared_ptr> d = t_orthogonal_->denom(istate)->at(iext); + + const size_t dataindex = info_->sssr() ? iext + istate * Excitations::total : iext; + shared_ptr smallz = info_->sssr() ? smallzall->at(istate) : smallzall->at(0); + shared_ptr largey = info_->sssr() ? largeyall->at(istate) : largeyall->at(0); + shared_ptr largeq = info_->sssr() ? largeqall->at(istate) : largeqall->at(0); + for (auto& i2 : t_orthogonal_->closed()) for (auto& i0 : t_orthogonal_->closed()) - for (auto& i0o : t_orthogonal_->interm(iext)) { + for (auto& i0o : t_orthogonal_->interm(dataindex)) { if (!t->is_local(i0o, i0, i2)) continue; const unique_ptr amplitude = t->get_block(i0o, i0, i2); const unique_ptr lambda = l->get_block(i0o, i0, i2); @@ -577,7 +660,7 @@ } } } - for (auto& i1o : t_orthogonal_->interm(iext)) { + for (auto& i1o : t_orthogonal_->interm(dataindex)) { const unique_ptr amplitudek = t->get_block(i1o, i0, i2); const unique_ptr lambdak = l->get_block(i1o, i0, i2); const unique_ptr denomk = d->get_block(i1o, i0, i2); @@ -597,23 +680,38 @@ } } } - smallz->allreduce(); - largey->allreduce(); - largeq->allreduce(); - for (size_t j0o = 0; j0o != interm_size; ++j0o) { - for (size_t j1o = 0; j1o != interm_size; ++j1o) { - if (j1o == j0o) continue; - const double fdiff = t_orthogonal_->phi(iext, j1o) - t_orthogonal_->phi(iext, j0o); - smallz->element(j1o, j0o) = fabs(fdiff) > 1.0e-12 ? -0.5 * (largey->element(j1o, j0o) - largey->element(j0o, j1o)) / fdiff : 0.0; + for (int istate = 0; istate != nstates; ++istate) { + if (!info_->sssr() && istate != 0) continue; + smallzall->at(istate)->allreduce(); + largeyall->at(istate)->allreduce(); + largeqall->at(istate)->allreduce(); + + shared_ptr smallz = info_->sssr() ? smallzall->at(istate) : smallzall->at(0); + shared_ptr largex = info_->sssr() ? largexall->at(istate) : largexall->at(0); + shared_ptr largey = info_->sssr() ? largeyall->at(istate) : largeyall->at(0); + + const size_t interm_size = t_orthogonal_->shalf(iext, istate).ndim(); + + for (size_t j0o = 0; j0o != interm_size; ++j0o) { + for (size_t j1o = 0; j1o != interm_size; ++j1o) { + if (j1o == j0o) continue; + const double fdiff = t_orthogonal_->phi(iext, istate, j1o) - t_orthogonal_->phi(iext, istate, j0o); + smallz->element(j1o, j0o) = fabs(fdiff) > 1.0e-12 ? -0.5 * (largey->element(j1o, j0o) - largey->element(j0o, j1o)) / fdiff : 0.0; + } } - } - for (size_t j0o = 0; j0o != interm_size; ++j0o) { - for (size_t j1o = 0; j1o != interm_size; ++j1o) { - largex->element(j1o, j0o) = 0.25 * (largey->element(j1o, j0o) + 2.0 * smallz->element(j1o, j0o) * t_orthogonal_->phi(iext, j1o)) - + 0.25 * (largey->element(j0o, j1o) + 2.0 * smallz->element(j0o, j1o) * t_orthogonal_->phi(iext, j0o)); + for (size_t j0o = 0; j0o != interm_size; ++j0o) { + for (size_t j1o = 0; j1o != interm_size; ++j1o) { + largex->element(j1o, j0o) = 0.25 * (largey->element(j1o, j0o) + 2.0 * smallz->element(j1o, j0o) * t_orthogonal_->phi(iext, istate, j1o)) + + 0.25 * (largey->element(j0o, j1o) + 2.0 * smallz->element(j0o, j1o) * t_orthogonal_->phi(iext, istate, j0o)); + } } } for (size_t is = 0; is != nstates; ++is) { + shared_ptr smallz = info_->sssr() ? smallzall->at(is) : smallzall->at(0); + shared_ptr largey = info_->sssr() ? largeyall->at(is) : largeyall->at(0); + shared_ptr largeq = info_->sssr() ? largeqall->at(is) : largeqall->at(0); + shared_ptr largex = info_->sssr() ? largexall->at(is) : largexall->at(0); + const size_t interm_size = t_orthogonal_->shalf(iext, is).ndim(); for (size_t js = 0; js != nstates; ++js) { if (info_->sssr() && is != js) continue; shared_ptr> rdm1; @@ -622,9 +720,10 @@ shared_ptr> rdm4; tie(rdm1, rdm2, rdm3, rdm4) = feed_rdm(js, is); { - shared_ptr Vmat = t_orthogonal_->shalf(iext)->get_submatrix(0, is * nact * nact, interm_size, nact * nact); - auto Qmat = make_shared((*smallz) % (*Vmat)); - auto Pmat = make_shared((-2.0 * (*largex) + (*largeq)) % (*Vmat)); + MatView VmatI = t_orthogonal_->shalf(iext, is); + MatView VmatJ = t_orthogonal_->shalf(iext, js); + auto Qmat = make_shared((*smallz) % VmatI); + auto Pmat = make_shared((-2.0 * (*largex) + (*largeq)) % VmatI); auto Rmat = make_shared>(nact); // (2) form R_{tv,uw} = Q^U_{tv} V^{U}_{uw} for (size_t j0 = 0; j0 != nact; ++j0) { @@ -634,13 +733,13 @@ for (size_t j2 = 0; j2 != nact; ++j2) { for (size_t j3 = 0; j3 != nact; ++j3) { for (size_t j0o = 0; j0o != interm_size; ++j0o) { - const double VrsO = t_orthogonal_->shalf(iext)->element(j0o, j2 + j3 * nact + js * nact * nact); + const double VrsO = VmatJ.element(j0o, j2 + j3 * nact); Rmat->element(j0, j2, j1, j3) += Qmat->element(j0o, j0 + j1 * nact) * VrsO; e2->at(js, is)->element(j0, j2, j1, j3) += Pmat->element(j0o, j0 + j1 * nact) * VrsO; - if (j2 == j1) e1->at(js, is)->element(j0, j3) += 1.0 * Pmat->element(j0o, j0 + j1 * nact) * VrsO; - if (j1 == j3) e1->at(js, is)->element(j0, j2) += -2.0 * Pmat->element(j0o, j0 + j1 * nact) * VrsO; - if (j0 == j2) e1->at(js, is)->element(j1, j3) += -2.0 * Pmat->element(j0o, j0 + j1 * nact) * VrsO; - if (j0 == j3) e1->at(js, is)->element(j1, j2) += 1.0 * Pmat->element(j0o, j0 + j1 * nact) * VrsO; + if (j2 == j1) e1->at(js, is)->element(j0, j3) += 1.0 * Pmat->element(j0o, j0 + j1 * nact) * VrsO; + if (j1 == j3) e1->at(js, is)->element(j0, j2) += -2.0 * Pmat->element(j0o, j0 + j1 * nact) * VrsO; + if (j0 == j2) e1->at(js, is)->element(j1, j3) += -2.0 * Pmat->element(j0o, j0 + j1 * nact) * VrsO; + if (j0 == j3) e1->at(js, is)->element(j1, j2) += 1.0 * Pmat->element(j0o, j0 + j1 * nact) * VrsO; } } } @@ -722,9 +821,15 @@ const shared_ptr> l = l_orthogonal_->data(istate)->at(iext); const shared_ptr> t = t_orthogonal_->data(istate)->at(iext); const shared_ptr> d = t_orthogonal_->denom(istate)->at(iext); + + const size_t dataindex = info_->sssr() ? iext + istate * Excitations::total : iext; + shared_ptr smallz = info_->sssr() ? smallzall->at(istate) : smallzall->at(0); + shared_ptr largey = info_->sssr() ? largeyall->at(istate) : largeyall->at(0); + shared_ptr largeq = info_->sssr() ? largeqall->at(istate) : largeqall->at(0); + for (auto& i1 : t_orthogonal_->virt()) for (auto& i0 : t_orthogonal_->closed()) - for (auto& i0o : t_orthogonal_->interm(iext)) { + for (auto& i0o : t_orthogonal_->interm(dataindex)) { if (!t->is_local(i0o, i0, i1)) continue; const unique_ptr amplitude = t->get_block(i0o, i0, i1); const unique_ptr lambda = l->get_block(i0o, i0, i1); @@ -742,7 +847,7 @@ } } } - for (auto& i1o : t_orthogonal_->interm(iext)) { + for (auto& i1o : t_orthogonal_->interm(dataindex)) { const unique_ptr amplitudek = t->get_block(i1o, i0, i1); const unique_ptr lambdak = l->get_block(i1o, i0, i1); const unique_ptr denomk = d->get_block(i1o, i0, i1); @@ -762,23 +867,38 @@ } } } - smallz->allreduce(); - largey->allreduce(); - largeq->allreduce(); - for (size_t j0o = 0; j0o != interm_size; ++j0o) { - for (size_t j1o = 0; j1o != interm_size; ++j1o) { - if (j1o == j0o) continue; - const double fdiff = t_orthogonal_->phi(iext, j1o) - t_orthogonal_->phi(iext, j0o); - smallz->element(j1o, j0o) = fabs(fdiff) > 1.0e-12 ? -0.5 * (largey->element(j1o, j0o) - largey->element(j0o, j1o)) / fdiff : 0.0; + for (int istate = 0; istate != nstates; ++istate) { + if (!info_->sssr() && istate != 0) continue; + smallzall->at(istate)->allreduce(); + largeyall->at(istate)->allreduce(); + largeqall->at(istate)->allreduce(); + + shared_ptr smallz = info_->sssr() ? smallzall->at(istate) : smallzall->at(0); + shared_ptr largex = info_->sssr() ? largexall->at(istate) : largexall->at(0); + shared_ptr largey = info_->sssr() ? largeyall->at(istate) : largeyall->at(0); + + const size_t interm_size = t_orthogonal_->shalf(iext, istate).ndim(); + + for (size_t j0o = 0; j0o != interm_size; ++j0o) { + for (size_t j1o = 0; j1o != interm_size; ++j1o) { + if (j1o == j0o) continue; + const double fdiff = t_orthogonal_->phi(iext, istate, j1o) - t_orthogonal_->phi(iext, istate, j0o); + smallz->element(j1o, j0o) = fabs(fdiff) > 1.0e-12 ? -0.5 * (largey->element(j1o, j0o) - largey->element(j0o, j1o)) / fdiff : 0.0; + } } - } - for (size_t j0o = 0; j0o != interm_size; ++j0o) { - for (size_t j1o = 0; j1o != interm_size; ++j1o) { - largex->element(j1o, j0o) = 0.25 * (largey->element(j1o, j0o) + 2.0 * smallz->element(j1o, j0o) * t_orthogonal_->phi(iext, j1o)) - + 0.25 * (largey->element(j0o, j1o) + 2.0 * smallz->element(j0o, j1o) * t_orthogonal_->phi(iext, j0o)); + for (size_t j0o = 0; j0o != interm_size; ++j0o) { + for (size_t j1o = 0; j1o != interm_size; ++j1o) { + largex->element(j1o, j0o) = 0.25 * (largey->element(j1o, j0o) + 2.0 * smallz->element(j1o, j0o) * t_orthogonal_->phi(iext, istate, j1o)) + + 0.25 * (largey->element(j0o, j1o) + 2.0 * smallz->element(j0o, j1o) * t_orthogonal_->phi(iext, istate, j0o)); + } } } for (size_t is = 0; is != nstates; ++is) { + shared_ptr smallz = info_->sssr() ? smallzall->at(is) : smallzall->at(0); + shared_ptr largey = info_->sssr() ? largeyall->at(is) : largeyall->at(0); + shared_ptr largeq = info_->sssr() ? largeqall->at(is) : largeqall->at(0); + shared_ptr largex = info_->sssr() ? largexall->at(is) : largexall->at(0); + const size_t interm_size = t_orthogonal_->shalf(iext, is).ndim(); for (size_t js = 0; js != nstates; ++js) { if (info_->sssr() && is != js) continue; shared_ptr> rdm1; @@ -792,14 +912,22 @@ shared_ptr> rdm4c; tie(rdm1c, rdm2c, rdm3c, rdm4c) = feed_rdm(is, js); { - shared_ptr VmatA = t_orthogonal_->shalf(iext)->get_submatrix(0, (2 * is + 0) * nact * nact, interm_size, nact * nact); - shared_ptr VmatB = t_orthogonal_->shalf(iext)->get_submatrix(0, (2 * is + 1) * nact * nact, interm_size, nact * nact); - auto QmatA = make_shared(*smallz % (2.0 * (*VmatA) - (*VmatB))); - auto QmatB = make_shared(*smallz % (-1.0 * (*VmatA))); - auto QmatC = make_shared(*smallz % (*VmatB)); - auto PmatA = make_shared((-2.0 * (*largex) + (*largeq)) % (2.0 * (*VmatA) - (*VmatB))); - auto PmatB = make_shared((-2.0 * (*largex) + (*largeq)) % (-1.0 * (*VmatA))); - auto PmatC = make_shared((-2.0 * (*largex) + (*largeq)) % (*VmatB)); + shared_ptr VmatAI, VmatBI; + shared_ptr VmatAJ, VmatBJ; + { + auto VmatI = make_shared(t_orthogonal_->shalf(iext, is)); + VmatAI = VmatI->get_submatrix(0, 0, interm_size, nact * nact); + VmatBI = VmatI->get_submatrix(0, nact * nact, interm_size, nact * nact); + auto VmatJ = make_shared(t_orthogonal_->shalf(iext, js)); + VmatAJ = VmatJ->get_submatrix(0, 0, interm_size, nact * nact); + VmatBJ = VmatJ->get_submatrix(0, nact * nact, interm_size, nact * nact); + } + auto QmatA = make_shared(*smallz % (2.0 * (*VmatAI) - (*VmatBI))); + auto QmatB = make_shared(*smallz % (-1.0 * (*VmatAI))); + auto QmatC = make_shared(*smallz % (*VmatBI)); + auto PmatA = make_shared((-2.0 * (*largex) + (*largeq)) % (2.0 * (*VmatAI) - (*VmatBI))); + auto PmatB = make_shared((-2.0 * (*largex) + (*largeq)) % (-1.0 * (*VmatAI))); + auto PmatC = make_shared((-2.0 * (*largex) + (*largeq)) % (*VmatBI)); auto RmatA = make_shared>(nact); auto RmatC = make_shared>(nact); // (2) form R_{tv,uw} = Q^U_{tv} V^{U}_{uw} @@ -810,8 +938,8 @@ for (size_t j2 = 0; j2 != nact; ++j2) { for (size_t j3 = 0; j3 != nact; ++j3) { for (size_t j0o = 0; j0o != interm_size; ++j0o) { - const double VrsO = t_orthogonal_->shalf(iext)->element(j0o, j2 + j3 * nact + (2 * js + 0) * nact * nact); - const double VrsS = t_orthogonal_->shalf(iext)->element(j0o, j2 + j3 * nact + (2 * js + 1) * nact * nact); + const double VrsO = VmatAJ->element(j0o, j2 + j3 * nact); + const double VrsS = VmatBJ->element(j0o, j2 + j3 * nact); RmatA->element(j0, j1, j3, j2) += QmatA->element(j0o, j0 + j1 * nact) * VrsO + QmatB->element(j0o, j0 + j1 * nact) * VrsS; RmatC->element(j0, j1, j3, j2) += QmatC->element(j0o, j0 + j1 * nact) * VrsS; e2->at(js, is)->element(j0, j1, j3, j2) += (PmatA->element(j0o, j0 + j1 * nact) * VrsO + PmatB->element(j0o, j0 + j1 * nact) * VrsS); @@ -869,8 +997,14 @@ const shared_ptr> l = l_orthogonal_->data(istate)->at(iext); const shared_ptr> t = t_orthogonal_->data(istate)->at(iext); const shared_ptr> d = t_orthogonal_->denom(istate)->at(iext); + + const size_t dataindex = info_->sssr() ? iext + istate * Excitations::total : iext; + shared_ptr smallz = info_->sssr() ? smallzall->at(istate) : smallzall->at(0); + shared_ptr largey = info_->sssr() ? largeyall->at(istate) : largeyall->at(0); + shared_ptr largeq = info_->sssr() ? largeqall->at(istate) : largeqall->at(0); + for (auto& i0 : t_orthogonal_->virt()) - for (auto& i0o : t_orthogonal_->interm(iext)) { + for (auto& i0o : t_orthogonal_->interm(dataindex)) { if (!t->is_local(i0o, i0)) continue; const unique_ptr amplitude = t->get_block(i0o, i0); const unique_ptr lambda = l->get_block(i0o, i0); @@ -884,7 +1018,7 @@ nimag[istate] -= Lambda; } } - for (auto& i1o : t_orthogonal_->interm(iext)) { + for (auto& i1o : t_orthogonal_->interm(dataindex)) { const unique_ptr amplitudek = t->get_block(i1o, i0); const unique_ptr lambdak = l->get_block(i1o, i0); const unique_ptr denomk = d->get_block(i1o, i0); @@ -902,23 +1036,38 @@ } } } - smallz->allreduce(); - largey->allreduce(); - largeq->allreduce(); - for (size_t j0o = 0; j0o != interm_size; ++j0o) { - for (size_t j1o = 0; j1o != interm_size; ++j1o) { - if (j1o == j0o) continue; - const double fdiff = t_orthogonal_->phi(iext, j1o) - t_orthogonal_->phi(iext, j0o); - smallz->element(j1o, j0o) = fabs(fdiff) > 1.0e-12 ? -0.5 * (largey->element(j1o, j0o) - largey->element(j0o, j1o)) / fdiff : 0.0; + for (int istate = 0; istate != nstates; ++istate) { + if (!info_->sssr() && istate != 0) continue; + smallzall->at(istate)->allreduce(); + largeyall->at(istate)->allreduce(); + largeqall->at(istate)->allreduce(); + + shared_ptr smallz = info_->sssr() ? smallzall->at(istate) : smallzall->at(0); + shared_ptr largex = info_->sssr() ? largexall->at(istate) : largexall->at(0); + shared_ptr largey = info_->sssr() ? largeyall->at(istate) : largeyall->at(0); + + const size_t interm_size = t_orthogonal_->shalf(iext, istate).ndim(); + + for (size_t j0o = 0; j0o != interm_size; ++j0o) { + for (size_t j1o = 0; j1o != interm_size; ++j1o) { + if (j1o == j0o) continue; + const double fdiff = t_orthogonal_->phi(iext, istate, j1o) - t_orthogonal_->phi(iext, istate, j0o); + smallz->element(j1o, j0o) = fabs(fdiff) > 1.0e-12 ? -0.5 * (largey->element(j1o, j0o) - largey->element(j0o, j1o)) / fdiff : 0.0; + } } - } - for (size_t j0o = 0; j0o != interm_size; ++j0o) { - for (size_t j1o = 0; j1o != interm_size; ++j1o) { - largex->element(j1o, j0o) = 0.25 * (largey->element(j1o, j0o) + 2.0 * smallz->element(j1o, j0o) * t_orthogonal_->phi(iext, j1o)) - + 0.25 * (largey->element(j0o, j1o) + 2.0 * smallz->element(j0o, j1o) * t_orthogonal_->phi(iext, j0o)); + for (size_t j0o = 0; j0o != interm_size; ++j0o) { + for (size_t j1o = 0; j1o != interm_size; ++j1o) { + largex->element(j1o, j0o) = 0.25 * (largey->element(j1o, j0o) + 2.0 * smallz->element(j1o, j0o) * t_orthogonal_->phi(iext, istate, j1o)) + + 0.25 * (largey->element(j0o, j1o) + 2.0 * smallz->element(j0o, j1o) * t_orthogonal_->phi(iext, istate, j0o)); + } } } for (size_t is = 0; is != nstates; ++is) { + shared_ptr smallz = info_->sssr() ? smallzall->at(is) : smallzall->at(0); + shared_ptr largey = info_->sssr() ? largeyall->at(is) : largeyall->at(0); + shared_ptr largeq = info_->sssr() ? largeqall->at(is) : largeqall->at(0); + shared_ptr largex = info_->sssr() ? largexall->at(is) : largexall->at(0); + const size_t interm_size = t_orthogonal_->shalf(iext, is).ndim(); for (size_t js = 0; js != nstates; ++js) { if (info_->sssr() && is != js) continue; shared_ptr> rdm1; @@ -927,9 +1076,10 @@ shared_ptr> rdm4; tie(rdm1, rdm2, rdm3, rdm4) = feed_rdm(js, is); { - shared_ptr Vmat = t_orthogonal_->shalf(iext)->get_submatrix(0, is * nact * nact * nact, interm_size, nact * nact * nact); - auto Qmat = make_shared((*smallz) % (*Vmat)); - auto Pmat = make_shared((-2.0 * (*largex) + (*largeq)) % (*Vmat)); + MatView VmatI = t_orthogonal_->shalf(iext, is); + MatView VmatJ = t_orthogonal_->shalf(iext, js); + auto Qmat = make_shared((*smallz) % VmatI); + auto Pmat = make_shared((-2.0 * (*largex) + (*largeq)) % VmatI); auto Rmat = make_shared>(nact); for (size_t j0 = 0; j0 != nact; ++j0) { for (size_t j1 = 0; j1 != nact; ++j1) { @@ -940,7 +1090,7 @@ for (size_t j4 = 0; j4 != nact; ++j4) { for (size_t j5 = 0; j5 != nact; ++j5) { for (size_t j0o = 0; j0o != interm_size; ++j0o) { - const double VrstO = t_orthogonal_->shalf(iext)->element(j0o, j3 + nact * (j4 + nact * j5) + js * nact * nact * nact); + const double VrstO = VmatJ.element(j0o, j3 + nact * (j4 + nact * j5)); Rmat->element(j1, j2, j5, j4, j0, j3) += Qmat->element(j0o, j0 + nact * (j1 + nact * j2)) * VrstO; e3->at(js, is)->element(j0, j1, j5, j4, j2, j3) += Pmat->element(j0o, j2 + nact * (j0 + nact * j1)) * VrstO; if (j1 == j5) e2->at(js, is)->element(j0, j4, j2, j3) += Pmat->element(j0o, j2 + nact * (j0 + nact * j1)) * VrstO; @@ -988,8 +1138,14 @@ const shared_ptr> l = l_orthogonal_->data(istate)->at(iext); const shared_ptr> t = t_orthogonal_->data(istate)->at(iext); const shared_ptr> d = t_orthogonal_->denom(istate)->at(iext); + + const size_t dataindex = info_->sssr() ? iext + istate * Excitations::total : iext; + shared_ptr smallz = info_->sssr() ? smallzall->at(istate) : smallzall->at(0); + shared_ptr largey = info_->sssr() ? largeyall->at(istate) : largeyall->at(0); + shared_ptr largeq = info_->sssr() ? largeqall->at(istate) : largeqall->at(0); + for (auto& i0 : t_orthogonal_->closed()) - for (auto& i0o : t_orthogonal_->interm(iext)) { + for (auto& i0o : t_orthogonal_->interm(dataindex)) { if (!t->is_local(i0o, i0)) continue; const unique_ptr amplitude = t->get_block(i0o, i0); const unique_ptr lambda = l->get_block(i0o, i0); @@ -1003,7 +1159,7 @@ nimag[istate] -= Lambda; } } - for (auto& i1o : t_orthogonal_->interm(iext)) { + for (auto& i1o : t_orthogonal_->interm(dataindex)) { const unique_ptr amplitudek = t->get_block(i1o, i0); const unique_ptr lambdak = l->get_block(i1o, i0); const unique_ptr denomk = d->get_block(i1o, i0); @@ -1021,23 +1177,38 @@ } } } - smallz->allreduce(); - largey->allreduce(); - largeq->allreduce(); - for (size_t j0o = 0; j0o != interm_size; ++j0o) { - for (size_t j1o = 0; j1o != interm_size; ++j1o) { - if (j1o == j0o) continue; - const double fdiff = t_orthogonal_->phi(iext, j1o) - t_orthogonal_->phi(iext, j0o); - smallz->element(j1o, j0o) = fabs(fdiff) > 1.0e-12 ? -0.5 * (largey->element(j1o, j0o) - largey->element(j0o, j1o)) / fdiff : 0.0; + for (int istate = 0; istate != nstates; ++istate) { + if (!info_->sssr() && istate != 0) continue; + smallzall->at(istate)->allreduce(); + largeyall->at(istate)->allreduce(); + largeqall->at(istate)->allreduce(); + + shared_ptr smallz = info_->sssr() ? smallzall->at(istate) : smallzall->at(0); + shared_ptr largex = info_->sssr() ? largexall->at(istate) : largexall->at(0); + shared_ptr largey = info_->sssr() ? largeyall->at(istate) : largeyall->at(0); + + const size_t interm_size = t_orthogonal_->shalf(iext, istate).ndim(); + + for (size_t j0o = 0; j0o != interm_size; ++j0o) { + for (size_t j1o = 0; j1o != interm_size; ++j1o) { + if (j1o == j0o) continue; + const double fdiff = t_orthogonal_->phi(iext, istate, j1o) - t_orthogonal_->phi(iext, istate, j0o); + smallz->element(j1o, j0o) = fabs(fdiff) > 1.0e-12 ? -0.5 * (largey->element(j1o, j0o) - largey->element(j0o, j1o)) / fdiff : 0.0; + } } - } - for (size_t j0o = 0; j0o != interm_size; ++j0o) { - for (size_t j1o = 0; j1o != interm_size; ++j1o) { - largex->element(j1o, j0o) = 0.25 * (largey->element(j1o, j0o) + 2.0 * smallz->element(j1o, j0o) * t_orthogonal_->phi(iext, j1o)) - + 0.25 * (largey->element(j0o, j1o) + 2.0 * smallz->element(j0o, j1o) * t_orthogonal_->phi(iext, j0o)); + for (size_t j0o = 0; j0o != interm_size; ++j0o) { + for (size_t j1o = 0; j1o != interm_size; ++j1o) { + largex->element(j1o, j0o) = 0.25 * (largey->element(j1o, j0o) + 2.0 * smallz->element(j1o, j0o) * t_orthogonal_->phi(iext, istate, j1o)) + + 0.25 * (largey->element(j0o, j1o) + 2.0 * smallz->element(j0o, j1o) * t_orthogonal_->phi(iext, istate, j0o)); + } } } for (size_t is = 0; is != nstates; ++is) { + shared_ptr smallz = info_->sssr() ? smallzall->at(is) : smallzall->at(0); + shared_ptr largey = info_->sssr() ? largeyall->at(is) : largeyall->at(0); + shared_ptr largeq = info_->sssr() ? largeqall->at(is) : largeqall->at(0); + shared_ptr largex = info_->sssr() ? largexall->at(is) : largexall->at(0); + const size_t interm_size = t_orthogonal_->shalf(iext, is).ndim(); for (size_t js = 0; js != nstates; ++js) { if (info_->sssr() && is != js) continue; shared_ptr> rdm1; @@ -1046,9 +1217,10 @@ shared_ptr> rdm4; tie(rdm1, rdm2, rdm3, rdm4) = feed_rdm(js, is); { - shared_ptr Vmat = t_orthogonal_->shalf(iext)->get_submatrix(0, is * nact * nact * nact, interm_size, nact * nact * nact); - auto Qmat = make_shared((*smallz) % (*Vmat)); - auto Pmat = make_shared((-2.0 * (*largex) + (*largeq)) % (*Vmat)); + MatView VmatI = t_orthogonal_->shalf(iext, is); + MatView VmatJ = t_orthogonal_->shalf(iext, js); + auto Qmat = make_shared((*smallz) % VmatI); + auto Pmat = make_shared((-2.0 * (*largex) + (*largeq)) % VmatI); auto Rmat = make_shared>(nact); for (size_t j0 = 0; j0 != nact; ++j0) { for (size_t j1 = 0; j1 != nact; ++j1) { @@ -1059,7 +1231,7 @@ for (size_t j4 = 0; j4 != nact; ++j4) { for (size_t j5 = 0; j5 != nact; ++j5) { for (size_t j0o = 0; j0o != interm_size; ++j0o) { - const double VrstO = t_orthogonal_->shalf(iext)->element(j0o, j3 + nact * (j4 + nact * j5) + js * nact * nact * nact); + const double VrstO = VmatJ.element(j0o, j3 + nact * (j4 + nact * j5)); Rmat->element(j0, j1, j5, j2, j4, j3) += Qmat->element(j0o, j0 + nact * (j1 + nact * j2)) * VrstO; e3->at(js, is)->element(j0, j1, j5, j2, j4, j3) += -1.0 * Pmat->element(j0o, j0 + nact * (j1 + nact * j2)) * VrstO; if (j2 == j4) e2->at(js, is)->element(j0, j1, j5, j3) += -1.0 * Pmat->element(j0o, j0 + nact * (j1 + nact * j2)) * VrstO; diff -Nru bagel-1.2.0/src/smith/caspt2grad.cc bagel-1.2.2/src/smith/caspt2grad.cc --- bagel-1.2.0/src/smith/caspt2grad.cc 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/src/smith/caspt2grad.cc 2018-12-29 22:08:28.000000000 +0000 @@ -275,12 +275,9 @@ shared_ptr GradEval::compute(const string jobtitle, shared_ptr gradinfo) { #ifdef COMPILE_SMITH const int istate = gradinfo->target_state(); - const int jstate = gradinfo->target_state2(); + const int jstate = (jobtitle == "nacme") ? gradinfo->target_state2() : istate; - if (jobtitle == "nacme") - task_->compute_gradient(istate, jstate, gradinfo->nacmtype()); - else - task_->compute_gradient(istate, istate); + task_->compute_gradient(istate, jstate, gradinfo->nacmtype(), !gradinfo->cider_eval()); Timer timer; @@ -334,6 +331,10 @@ dipole.compute(); } + if (!gradinfo->cider_eval()) { + return make_shared(geom_->natom()); + } + // compute Yrs shared_ptr half = ref->geom()->df()->compute_half_transform(ocoeff); shared_ptr halfj = half->apply_J(); diff -Nru bagel-1.2.0/src/smith/denom.cc bagel-1.2.2/src/smith/denom.cc --- bagel-1.2.0/src/smith/denom.cc 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/src/smith/denom.cc 2018-12-29 22:08:28.000000000 +0000 @@ -34,504 +34,586 @@ using namespace btas; template -Denom::Denom(shared_ptr fock, const int nstates, const double th) : fock_(fock), thresh_(th) { +Denom::Denom(shared_ptr fock, const int nstates, const double th) : fock_(fock), thresh_(th), nstates_(nstates) { const size_t ndim = fock->mdim() * nstates; const size_t ndim2 = fock->mdim() * ndim; const size_t ndim3 = fock->mdim() * ndim2; const int fac2 = is_same::value ? 2 : 1; - shalf_x_ = make_shared(ndim, ndim); - shalf_h_ = make_shared(ndim, ndim); - shalf_xx_ = make_shared(ndim2, ndim2); - shalf_hh_ = make_shared(ndim2, ndim2); - shalf_xh_ = make_shared(ndim2*fac2, ndim2*fac2); - shalf_xxh_ = make_shared(ndim3, ndim3); - shalf_xhh_ = make_shared(ndim3, ndim3); - - work_x_ = make_shared(ndim, ndim); - work_h_ = make_shared(ndim, ndim); - work_xx_ = make_shared(ndim2, ndim2); - work_hh_ = make_shared(ndim2, ndim2); - work_xh_ = make_shared(ndim2*fac2, ndim2*fac2); - work_xxh_ = make_shared(ndim3, ndim3); - work_xhh_ = make_shared(ndim3, ndim3); - - denom_x_ = VectorB(ndim); - denom_h_ = VectorB(ndim); - denom_xx_ = VectorB(ndim2); - denom_hh_ = VectorB(ndim2); - denom_xh_ = VectorB(ndim2*fac2); - denom_xxh_ = VectorB(ndim3); - denom_xhh_ = VectorB(ndim3); + dim_["x"] = ndim/nstates; + dim_["h"] = ndim/nstates; + dim_["xx"] = ndim2/nstates; + dim_["hh"] = ndim2/nstates; + dim_["xh"] = ndim2*fac2/nstates; + dim_["xxh"] = ndim3/nstates; + dim_["xhh"] = ndim3/nstates; } - template -void Denom::append(const int jst, const int ist, shared_ptr> rdm1, shared_ptr> rdm2, - shared_ptr> rdm3, shared_ptr> rdm4f) { - init_x_(jst, ist, rdm1, rdm2, rdm3, rdm4f); - init_h_(jst, ist, rdm1, rdm2, rdm3, rdm4f); - init_xx_(jst, ist, rdm1, rdm2, rdm3, rdm4f); - init_hh_(jst, ist, rdm1, rdm2, rdm3, rdm4f); - init_xh_(jst, ist, rdm1, rdm2, rdm3, rdm4f); - init_xxh_(jst, ist, rdm1, rdm2, rdm3, rdm4f); - init_xhh_(jst, ist, rdm1, rdm2, rdm3, rdm4f); -} - - -template -void Denom::compute() { - // TODO in principle, we can use smaller dimension (i.e., use canonical orthogonalization for shalf_x_) - { - shalf_x_->inverse_half(thresh_); - MatType tmp(*shalf_x_ % *work_x_ * *shalf_x_); - tmp.diagonalize(denom_x_); - shalf_x_ = make_shared(tmp % *shalf_x_); - } - { - shalf_h_->inverse_half(thresh_); - MatType tmp(*shalf_h_ % *work_h_ * *shalf_h_); - tmp.diagonalize(denom_h_); - shalf_h_ = make_shared(tmp % *shalf_h_); - } - { - shalf_xx_->inverse_half(thresh_); - MatType tmp(*shalf_xx_ % *work_xx_ * *shalf_xx_); - tmp.diagonalize(denom_xx_); - shalf_xx_ = make_shared(tmp % *shalf_xx_); - } - { - shalf_hh_->inverse_half(thresh_); - MatType tmp(*shalf_hh_ % *work_hh_ * *shalf_hh_); - tmp.diagonalize(denom_hh_); - shalf_hh_ = make_shared(tmp % *shalf_hh_); - } - { - shalf_xh_->inverse_half(thresh_); - MatType tmp(*shalf_xh_ % *work_xh_ * *shalf_xh_); - tmp.diagonalize(denom_xh_); - shalf_xh_ = make_shared(tmp % *shalf_xh_); - } - { - shalf_xxh_->inverse_half(thresh_); - MatType tmp(*shalf_xxh_ % *work_xxh_ * *shalf_xxh_); - tmp.diagonalize(denom_xxh_); - shalf_xxh_ = make_shared(tmp % *shalf_xxh_); - } - { - shalf_xhh_->inverse_half(thresh_); - MatType tmp(*shalf_xhh_ % *work_xhh_ * *shalf_xhh_); - tmp.diagonalize(denom_xhh_); - shalf_xhh_ = make_shared(tmp % *shalf_xhh_); +Denom_SSSR::Denom_SSSR(shared_ptr fock, const int nstates, const double th) : Denom(fock, nstates, th) { + denom_["x"] = vector(); + denom_["h"] = vector(); + denom_["xx"] = vector(); + denom_["hh"] = vector(); + denom_["xh"] = vector(); + denom_["xxh"] = vector(); + denom_["xhh"] = vector(); + + shalf_["x"] = vector>(); + shalf_["h"] = vector>(); + shalf_["xx"] = vector>(); + shalf_["hh"] = vector>(); + shalf_["xh"] = vector>(); + shalf_["xxh"] = vector>(); + shalf_["xhh"] = vector>(); + + work_["x"] = vector>(); + work_["h"] = vector>(); + work_["xx"] = vector>(); + work_["hh"] = vector>(); + work_["xh"] = vector>(); + work_["xxh"] = vector>(); + work_["xhh"] = vector>(); + + for (int i = 0; i != nstates; ++i) { + denom_["x"].emplace_back(dim_.at("x")); + denom_["h"].emplace_back(dim_.at("h")); + denom_["xx"].emplace_back(dim_.at("xx")); + denom_["hh"].emplace_back(dim_.at("hh")); + denom_["xh"].emplace_back(dim_.at("xh")); + denom_["xxh"].emplace_back(dim_.at("xxh")); + denom_["xhh"].emplace_back(dim_.at("xhh")); + + shalf_["x"].push_back(make_shared(dim_.at("x"), dim_.at("x"))); + shalf_["h"].push_back(make_shared(dim_.at("h"), dim_.at("h"))); + shalf_["xx"].push_back(make_shared(dim_.at("xx"), dim_.at("xx"))); + shalf_["hh"].push_back(make_shared(dim_.at("hh"), dim_.at("hh"))); + shalf_["xh"].push_back(make_shared(dim_.at("xh"), dim_.at("xh"))); + shalf_["xxh"].push_back(make_shared(dim_.at("xxh"), dim_.at("xxh"))); + shalf_["xhh"].push_back(make_shared(dim_.at("xhh"), dim_.at("xhh"))); + + work_["x"].push_back(make_shared(dim_.at("x"), dim_.at("x"))); + work_["h"].push_back(make_shared(dim_.at("h"), dim_.at("h"))); + work_["xx"].push_back(make_shared(dim_.at("xx"), dim_.at("xx"))); + work_["hh"].push_back(make_shared(dim_.at("hh"), dim_.at("hh"))); + work_["xh"].push_back(make_shared(dim_.at("xh"), dim_.at("xh"))); + work_["xxh"].push_back(make_shared(dim_.at("xxh"), dim_.at("xxh"))); + work_["xhh"].push_back(make_shared(dim_.at("xhh"), dim_.at("xhh"))); } } template -void Denom::init_x_(const int jst, const int ist, shared_ptr> rdm1, shared_ptr> rdm2, - shared_ptr> rdm3, shared_ptr> rdm4f) { - const size_t nact = rdm1->norb(); - const size_t dim = nact; - - shalf_x_->copy_block(dim*jst, dim*ist, dim, dim, rdm1); +Denom_MSMR::Denom_MSMR(shared_ptr fock, const int nstates, const double th) : Denom(fock, nstates, th) { + const size_t ndim = fock->mdim() * nstates; + const size_t ndim2 = fock->mdim() * ndim; + const size_t ndim3 = fock->mdim() * ndim2; + const int fac2 = is_same::value ? 2 : 1; - MatType work2(dim, dim); - auto rdm2v = group(group(*rdm2, 2,4),0,2); - auto workv = group(work2, 0,2); - contract(1.0, rdm2v, {0,1}, group(*fock_,0,2), {1}, 0.0, workv, {0}); - work_x_->copy_block(dim*jst, dim*ist, dim, dim, work2); + denom_["x"] = VectorB(ndim); + denom_["h"] = VectorB(ndim); + denom_["xx"] = VectorB(ndim2); + denom_["hh"] = VectorB(ndim2); + denom_["xh"] = VectorB(ndim2*fac2); + denom_["xxh"] = VectorB(ndim3); + denom_["xhh"] = VectorB(ndim3); + + shalf_["x"] = make_shared(ndim, ndim); + shalf_["h"] = make_shared(ndim, ndim); + shalf_["xx"] = make_shared(ndim2, ndim2); + shalf_["hh"] = make_shared(ndim2, ndim2); + shalf_["xh"] = make_shared(ndim2*fac2, ndim2*fac2); + shalf_["xxh"] = make_shared(ndim3, ndim3); + shalf_["xhh"] = make_shared(ndim3, ndim3); + + work_["x"] = make_shared(ndim, ndim); + work_["h"] = make_shared(ndim, ndim); + work_["xx"] = make_shared(ndim2, ndim2); + work_["hh"] = make_shared(ndim2, ndim2); + work_["xh"] = make_shared(ndim2*fac2, ndim2*fac2); + work_["xxh"] = make_shared(ndim3, ndim3); + work_["xhh"] = make_shared(ndim3, ndim3); } template -void Denom::init_h_(const int jst, const int ist, shared_ptr> rdm1, shared_ptr> rdm2, - shared_ptr> rdm3, shared_ptr> rdm4f) { +void Denom::append(const int jst, const int ist, shared_ptr> rdm1, shared_ptr> rdm2, + shared_ptr> rdm3, shared_ptr> rdm4f) { const size_t nact = rdm1->norb(); - const size_t dim = nact; - auto shalf = make_shared(dim, dim); - const double fac2 = is_same::value ? 2.0 : 1.0; - if (jst == ist) { - copy_n(rdm1->data(), rdm1->size(), shalf->data()); - if (is_same>::value) - shalf = shalf->get_conjg(); - shalf->scale(-1.0); - shalf->add_diag(fac2); //.. making hole 1RDM - } else { - blas::transpose(rdm1->data(), dim, dim, shalf->data()); - shalf->scale(-1.0); - } - shalf_h_->copy_block(dim*jst, dim*ist, dim, dim, shalf); - - shared_ptr> ovl = rdm2->clone(); - sort_indices<1,0,2,0,1,-1,1>(rdm2->data(), ovl->data(), nact, nact, nact*nact); - - for (int i = 0; i != nact; ++i) - for (int j = 0; j != nact; ++j) - for (int k = 0; k != nact; ++k) { - // see Celani eq. A7 - ovl->element(k, i, j, i) += shalf->element(k,j); - ovl->element(i, k, i, j) += -1.0 * rdm1->element(k,j); - ovl->element(i, i, k, j) += fac2 * rdm1->element(k,j); - } - MatType work2(dim, dim); - auto ovlv = group(group(*ovl,2,4),0,2); - auto workv = group(work2, 0,2); - contract(1.0, ovlv, {0,1}, group(*fock_,0,2), {1}, 0.0, workv, {0}); - work_h_->copy_block(dim*jst, dim*ist, dim, dim, work2); -} - + { // x + const size_t dim = dim_.at("x"); + this->set_sblock("x", jst, ist, *rdm1); + + MatType work2(dim, dim); + auto rdm2v = group(group(*rdm2, 2,4),0,2); + auto workv = group(work2, 0,2); + contract(1.0, rdm2v, {0,1}, group(*fock_,0,2), {1}, 0.0, workv, {0}); + this->set_wblock("x", jst, ist, work2); + + } { // h + const size_t dim = dim_.at("h"); + auto shalf = make_shared(dim, dim); + const double fac2 = is_same::value ? 2.0 : 1.0; + if (jst == ist) { + copy_n(rdm1->data(), rdm1->size(), shalf->data()); + if (is_same>::value) + shalf = shalf->get_conjg(); + shalf->scale(-1.0); + shalf->add_diag(fac2); //.. making hole 1RDM + } else { + blas::transpose(rdm1->data(), dim, dim, shalf->data()); + shalf->scale(-1.0); + } + this->set_sblock("h", jst, ist, *shalf); + shared_ptr> ovl = rdm2->clone(); + sort_indices<1,0,2,0,1,-1,1>(rdm2->data(), ovl->data(), nact, nact, nact*nact); -template -void Denom::init_xx_(const int jst, const int ist, shared_ptr> rdm1, shared_ptr> rdm2, - shared_ptr> rdm3, shared_ptr> rdm4f) { - const size_t nact = rdm1->norb(); - const size_t dim = nact*nact; - auto shalf = make_shared(dim, dim); - sort_indices<0,2,1,3,0,1,1,1>(rdm2->data(), shalf->data(), nact, nact, nact, nact); - shalf_xx_->copy_block(dim*jst, dim*ist, dim, dim, shalf); - - auto work2 = make_shared(dim, dim); - auto workv = group(*work2, 0,2); - auto rdm3v = group(group(*rdm3,4,6),0,4); - contract(1.0, rdm3v, {0,1}, group(*fock_,0,2), {1}, 0.0, workv, {0}); - auto work = make_shared(dim, dim); - sort_indices<0,2,1,3,0,1,1,1>(work2->data(), work->data(), nact, nact, nact, nact); - work_xx_->copy_block(dim*jst, dim*ist, dim, dim, work); -} - + for (int i = 0; i != nact; ++i) + for (int j = 0; j != nact; ++j) + for (int k = 0; k != nact; ++k) { + // see Celani eq. A7 + ovl->element(k, i, j, i) += shalf->element(k,j); + ovl->element(i, k, i, j) += -1.0 * rdm1->element(k,j); + ovl->element(i, i, k, j) += fac2 * rdm1->element(k,j); + } + MatType work2(dim, dim); + auto ovlv = group(group(*ovl,2,4),0,2); + auto workv = group(work2, 0,2); + contract(1.0, ovlv, {0,1}, group(*fock_,0,2), {1}, 0.0, workv, {0}); + this->set_wblock("h", jst, ist, work2); + + } { // "xx" + const size_t dim = dim_.at("xx"); + auto shalf = make_shared(dim, dim); + sort_indices<0,2,1,3,0,1,1,1>(rdm2->data(), shalf->data(), nact, nact, nact, nact); + this->set_sblock("xx", jst, ist, *shalf); -template -void Denom::init_hh_(const int jst, const int ist, shared_ptr> rdm1, shared_ptr> rdm2, - shared_ptr> rdm3, shared_ptr> rdm4f) { - const size_t nact = rdm1->norb(); - const size_t dim = nact*nact; - shared_ptr> shalf = rdm2->clone(); - sort_indices<1,3,0,2,0,1,1,1>(rdm2->data(), shalf->data(), nact, nact, nact, nact); - const double fac = jst == ist ? 1.0 : 0.0; - const double fac2 = is_same::value ? 2.0 : 1.0; - const double fac4 = is_same::value ? 4.0 : 1.0; - for (int i2 = 0; i2 != nact; ++i2) - for (int i1 = 0; i1 != nact; ++i1) { - shalf->element(i2, i1, i2, i1) += fac4 * fac; - shalf->element(i2, i1, i1, i2) += -fac2 * fac; - for (int i0 = 0; i0 != nact; ++i0) { - shalf->element(i0, i1, i1, i2) += rdm1->element(i2, i0); - shalf->element(i0, i1, i2, i1) += -fac2 * rdm1->element(i2, i0); - shalf->element(i1, i0, i1, i2) += -fac2 * rdm1->element(i2, i0); - shalf->element(i1, i0, i2, i1) += rdm1->element(i2, i0); + auto work2 = make_shared(dim, dim); + auto workv = group(*work2, 0,2); + auto rdm3v = group(group(*rdm3,4,6),0,4); + contract(1.0, rdm3v, {0,1}, group(*fock_,0,2), {1}, 0.0, workv, {0}); + auto work = make_shared(dim, dim); + sort_indices<0,2,1,3,0,1,1,1>(work2->data(), work->data(), nact, nact, nact, nact); + this->set_wblock("xx", jst, ist, *work); + + } { // "hh" + const size_t dim = dim_.at("hh"); + shared_ptr> shalf = rdm2->clone(); + sort_indices<1,3,0,2,0,1,1,1>(rdm2->data(), shalf->data(), nact, nact, nact, nact); + const double fac = jst == ist ? 1.0 : 0.0; + const double fac2 = is_same::value ? 2.0 : 1.0; + const double fac4 = is_same::value ? 4.0 : 1.0; + for (int i2 = 0; i2 != nact; ++i2) + for (int i1 = 0; i1 != nact; ++i1) { + shalf->element(i2, i1, i2, i1) += fac4 * fac; + shalf->element(i2, i1, i1, i2) += -fac2 * fac; + for (int i0 = 0; i0 != nact; ++i0) { + shalf->element(i0, i1, i1, i2) += rdm1->element(i2, i0); + shalf->element(i0, i1, i2, i1) += -fac2 * rdm1->element(i2, i0); + shalf->element(i1, i0, i1, i2) += -fac2 * rdm1->element(i2, i0); + shalf->element(i1, i0, i2, i1) += rdm1->element(i2, i0); + } } - } - auto sview = group(group(*shalf, 2,4),0,2); - shalf_hh_->copy_block(dim*jst, dim*ist, dim, dim, sview); + auto sview = group(group(*shalf, 2,4),0,2); + this->set_sblock("hh", jst, ist, sview); - shared_ptr> r3 = rdm3->clone(); - sort_indices<1,3,0,2,4,0,1,1,1>(rdm3->data(), r3->data(), nact, nact, nact, nact, nact*nact); - for (int i2 = 0; i2 != nact; ++i2) - for (int i3 = 0; i3 != nact; ++i3) - for (int i4 = 0; i4 != nact; ++i4) { - r3->element(i4, i2, i4, i3, i2, i3) += fac4 * fac; - r3->element(i4, i2, i3, i4, i2, i3) += -fac2 * fac; - r3->element(i4, i2, i2, i3, i4, i3) += -fac2 * fac; - r3->element(i4, i2, i3, i2, i4, i3) += fac4 * fac; - for (int i1 = 0; i1 != nact; ++i1) { - r3->element(i1, i4, i4, i3, i2, i3) += rdm1->element(i2, i1); - r3->element(i1, i4, i3, i4, i2, i3) += -fac2 * rdm1->element(i2, i1); - r3->element(i1, i4, i3, i2, i4, i3) += rdm1->element(i2, i1); - r3->element(i1, i4, i2, i3, i4, i3) += -fac2 * rdm1->element(i2, i1); - r3->element(i1, i4, i1, i3, i2, i3) += -fac2 * rdm1->element(i2, i4); - r3->element(i1, i2, i1, i4, i2, i3) += -fac2 * rdm1->element(i4, i3); - r3->element(i4, i1, i3, i4, i2, i3) += rdm1->element(i2, i1); - r3->element(i4, i1, i2, i4, i1, i3) += rdm1->element(i2, i3); - r3->element(i2, i1, i3, i4, i2, i3) += -fac2 * rdm1->element(i4, i1); - r3->element(i2, i1, i4, i3, i2, i3) += rdm1->element(i4, i1); - r3->element(i2, i1, i1, i4, i2, i3) += rdm1->element(i4, i3); - r3->element(i2, i1, i4, i1, i2, i3) += -fac2 * rdm1->element(i4, i3); - r3->element(i4, i1, i4, i1, i2, i3) += fac4 * rdm1->element(i2, i3); - r3->element(i4, i1, i1, i4, i2, i3) += -fac2 * rdm1->element(i2, i3); - for (int i0 = 0; i0 != nact; ++i0) { - r3->element(i0, i1, i3, i4, i2, i3) += rdm2->element(i2, i0, i4, i1); - r3->element(i0, i1, i4, i3, i2, i3) += rdm2->element(i4, i0, i2, i1); - r3->element(i0, i1, i1, i4, i2, i3) += rdm2->element(i4, i0, i2, i3); - r3->element(i0, i1, i4, i1, i2, i3) += -fac2 * rdm2->element(i4, i0, i2, i3); - r3->element(i0, i1, i2, i4, i1, i3) += rdm2->element(i2, i0, i4, i3); - r3->element(i1, i0, i1, i4, i2, i3) += -fac2 * rdm2->element(i4, i0, i2, i3); - r3->element(i1, i0, i4, i1, i2, i3) += rdm2->element(i4, i0, i2, i3); - r3->element(i1, i0, i2, i4, i1, i3) += rdm2->element(i4, i0, i2, i3); + shared_ptr> r3 = rdm3->clone(); + sort_indices<1,3,0,2,4,0,1,1,1>(rdm3->data(), r3->data(), nact, nact, nact, nact, nact*nact); + for (int i2 = 0; i2 != nact; ++i2) + for (int i3 = 0; i3 != nact; ++i3) + for (int i4 = 0; i4 != nact; ++i4) { + r3->element(i4, i2, i4, i3, i2, i3) += fac4 * fac; + r3->element(i4, i2, i3, i4, i2, i3) += -fac2 * fac; + r3->element(i4, i2, i2, i3, i4, i3) += -fac2 * fac; + r3->element(i4, i2, i3, i2, i4, i3) += fac4 * fac; + for (int i1 = 0; i1 != nact; ++i1) { + r3->element(i1, i4, i4, i3, i2, i3) += rdm1->element(i2, i1); + r3->element(i1, i4, i3, i4, i2, i3) += -fac2 * rdm1->element(i2, i1); + r3->element(i1, i4, i3, i2, i4, i3) += rdm1->element(i2, i1); + r3->element(i1, i4, i2, i3, i4, i3) += -fac2 * rdm1->element(i2, i1); + r3->element(i1, i4, i1, i3, i2, i3) += -fac2 * rdm1->element(i2, i4); + r3->element(i1, i2, i1, i4, i2, i3) += -fac2 * rdm1->element(i4, i3); + r3->element(i4, i1, i3, i4, i2, i3) += rdm1->element(i2, i1); + r3->element(i4, i1, i2, i4, i1, i3) += rdm1->element(i2, i3); + r3->element(i2, i1, i3, i4, i2, i3) += -fac2 * rdm1->element(i4, i1); + r3->element(i2, i1, i4, i3, i2, i3) += rdm1->element(i4, i1); + r3->element(i2, i1, i1, i4, i2, i3) += rdm1->element(i4, i3); + r3->element(i2, i1, i4, i1, i2, i3) += -fac2 * rdm1->element(i4, i3); + r3->element(i4, i1, i4, i1, i2, i3) += fac4 * rdm1->element(i2, i3); + r3->element(i4, i1, i1, i4, i2, i3) += -fac2 * rdm1->element(i2, i3); + for (int i0 = 0; i0 != nact; ++i0) { + r3->element(i0, i1, i3, i4, i2, i3) += rdm2->element(i2, i0, i4, i1); + r3->element(i0, i1, i4, i3, i2, i3) += rdm2->element(i4, i0, i2, i1); + r3->element(i0, i1, i1, i4, i2, i3) += rdm2->element(i4, i0, i2, i3); + r3->element(i0, i1, i4, i1, i2, i3) += -fac2 * rdm2->element(i4, i0, i2, i3); + r3->element(i0, i1, i2, i4, i1, i3) += rdm2->element(i2, i0, i4, i3); + r3->element(i1, i0, i1, i4, i2, i3) += -fac2 * rdm2->element(i4, i0, i2, i3); + r3->element(i1, i0, i4, i1, i2, i3) += rdm2->element(i4, i0, i2, i3); + r3->element(i1, i0, i2, i4, i1, i3) += rdm2->element(i4, i0, i2, i3); + } } } - } - - auto work2 = make_shared(dim, dim); - auto r3v = group(group(*r3, 4,6),0,4); - auto workv = group(*work2, 0,2); - contract(1.0, r3v, {0,1}, group(*fock_,0,2), {1}, 0.0, workv, {0}); - work_hh_->copy_block(dim*jst, dim*ist, dim, dim, work2); -} + auto work2 = make_shared(dim, dim); + auto r3v = group(group(*r3, 4,6),0,4); + auto workv = group(*work2, 0,2); + contract(1.0, r3v, {0,1}, group(*fock_,0,2), {1}, 0.0, workv, {0}); + this->set_wblock("hh", jst, ist, *work2); + + } { // xh + const size_t dim = dim_.at("xh"); + const size_t nsq = nact*nact; + RDM<2,DataType> ovl1 = *rdm2; + RDM<2,DataType> ovl4 = *rdm2; + ovl1.scale(-1.0); + + const double fac2 = is_same::value ? 2.0 : 1.0; + for (int i = 0; i != nact; ++i) + for (int j = 0; j != nact; ++j) + for (int k = 0; k != nact; ++k) { + ovl1.element(i, i, k, j) += fac2 * rdm1->element(k, j); + ovl4.element(k, i, i, j) += rdm1->element(k, j); + } -template -void Denom::init_xh_(const int jst, const int ist, shared_ptr> rdm1, shared_ptr> rdm2, - shared_ptr> rdm3, shared_ptr> rdm4f) { - const size_t nact = rdm1->norb(); - const size_t dim = nact*nact; - auto shalf = make_shared(dim*2, dim*2); - RDM<2,DataType> ovl1 = *rdm2; - RDM<2,DataType> ovl4 = *rdm2; - ovl1.scale(-1.0); - - const double fac2 = is_same::value ? 2.0 : 1.0; - for (int i = 0; i != nact; ++i) - for (int j = 0; j != nact; ++j) - for (int k = 0; k != nact; ++k) { - ovl1.element(i, i, k, j) += fac2 * rdm1->element(k, j); - ovl4.element(k, i, i, j) += rdm1->element(k, j); - } + MatType work(nsq, nsq); + sort_indices<2,1,3,0,0,1,1,1>(ovl1.data(), work.data(), nact, nact, nact, nact); - MatType work(dim, dim); - sort_indices<2,1,3,0,0,1,1,1>(ovl1.data(), work.data(), nact, nact, nact, nact); + if (is_same::value) { + auto shalf = make_shared(dim, dim); + shalf->add_block(1.0, nsq, nsq, nsq, nsq, work); + + sort_indices<0,1,3,2,0,1,1,1>(ovl4.data(), work.data(), nact, nact, nact, nact); + shalf->add_block(fac2, 0, 0, nsq, nsq, work); + + shalf->add_block(-1.0, nsq, 0, nsq, nsq, work); + shalf->add_block(-1.0, 0, nsq, nsq, nsq, work); + + this->set_sblock("xh", jst, ist, *shalf); + } else { + this->set_sblock("xh", jst, ist, work); + } - if (is_same::value) { - shalf->add_block(1.0, dim, dim, dim, dim, work); + shared_ptr> d0 = rdm3->copy(); + shared_ptr> d3 = is_same::value ? rdm3->copy() : nullptr; + d0->scale(-1.0); + for (int i5 = 0; i5 != nact; ++i5) + for (int i4 = 0; i4 != nact; ++i4) + for (int i3 = 0; i3 != nact; ++i3) { + if (is_same::value) { + blas::ax_plus_y_n(1.0, rdm2->element_ptr(0,0, i4, i5), nact*nact, d3->element_ptr(0,0, i3, i5, i4, i3)); + blas::ax_plus_y_n(1.0, rdm1->element_ptr(0, i5), nact, d3->element_ptr(0, i4, i3, i5, i4, i3)); + } + for (int i2 = 0; i2 != nact; ++i2) { + if (is_same::value) { + blas::ax_plus_y_n(1.0, rdm2->element_ptr(0, i5, i2, i3), nact, d3->element_ptr(0, i4, i4, i5, i2, i3)); + blas::ax_plus_y_n(1.0, rdm2->element_ptr(0, i3, i4, i5), nact, d3->element_ptr(0, i2, i4, i5, i2, i3)); + } + d0->element(i3, i2, i4, i5, i2, i3) += fac2 * rdm1->element(i4, i5); + blas::ax_plus_y_n(-1.0, rdm2->element_ptr(0, i3, i2, i5), nact, d0->element_ptr(0, i4, i2, i5, i4, i3)); + for (int i1 = 0; i1 != nact; ++i1) { + d0->element(i3, i1, i4, i5, i2, i3) += -1.0 * rdm2->element(i2, i1, i4, i5); + d0->element(i1, i1, i4, i5, i2, i3) += fac2 * rdm2->element(i2, i3, i4, i5); + } + } + } - sort_indices<0,1,3,2,0,1,1,1>(ovl4.data(), work.data(), nact, nact, nact, nact); - shalf->add_block(fac2, 0, 0, dim, dim, work); + MatType work2(nsq, nsq); - shalf->add_block(-1.0, dim, 0, dim, dim, work); - shalf->add_block(-1.0, 0, dim, dim, dim, work); + auto d0v = group(group(*d0, 4,6),0,4); + auto work2v = group(work2, 0,2); + contract(1.0, d0v, {0,1}, group(*fock_,0,2), {1}, 0.0, work2v, {0}); + sort_indices<2,1,3,0,0,1,1,1>(work2.data(), work.data(), nact, nact, nact, nact); + + if (is_same::value) { + auto num = make_shared(dim, dim); + num->add_block(1.0, nsq, nsq, nsq, nsq, work); + + auto d3v = group(group(*d3, 4,6),0,4); + contract(1.0, d3v, {0,1}, group(*fock_,0,2), {1}, 0.0, work2v, {0}); + sort_indices<0,1,3,2,0,1,1,1>(work2.data(), work.data(), nact, nact, nact, nact); + num->add_block(fac2, 0, 0, nsq, nsq, work); + + num->add_block(-1.0, nsq, 0, nsq, nsq, work); + num->add_block(-1.0, 0, nsq, nsq, nsq, work); + + this->set_wblock("xh", jst, ist, *num); + } else { + this->set_wblock("xh", jst, ist, work); + } - shalf_xh_->copy_block(dim*jst*2, dim*ist*2, dim*2, dim*2, shalf); - } else { - shalf_xh_->copy_block(dim*jst, dim*ist, dim, dim, work); - } + } { // xxh + const size_t dim = dim_.at("xxh"); + shared_ptr> ovl = rdm3->copy(); + for (int i5 = 0; i5 != nact; ++i5) + for (int i0 = 0; i0 != nact; ++i0) + for (int i4 = 0; i4 != nact; ++i4) + for (int i3 = 0; i3 != nact; ++i3) + blas::ax_plus_y_n(1.0, rdm2->element_ptr(0, i4, i0, i5), nact, ovl->element_ptr(0, i3, i3, i4, i0, i5)); + auto shalf = make_shared(dim, dim); + sort_indices<4,0,1,5,3,2,0,1,1,1>(ovl->data(), shalf->data(), nact, nact, nact, nact, nact, nact); + this->set_sblock("xxh", jst, ist, *shalf); - shared_ptr> d0 = rdm3->copy(); - shared_ptr> d3 = is_same::value ? rdm3->copy() : nullptr; - d0->scale(-1.0); - for (int i5 = 0; i5 != nact; ++i5) + // TODO a littile of duplication. Maybe should merge with xhh below + shared_ptr> fr4 = rdm4f->copy(); for (int i4 = 0; i4 != nact; ++i4) for (int i3 = 0; i3 != nact; ++i3) { - if (is_same::value) { - blas::ax_plus_y_n(1.0, rdm2->element_ptr(0,0, i4, i5), nact*nact, d3->element_ptr(0,0, i3, i5, i4, i3)); - blas::ax_plus_y_n(1.0, rdm1->element_ptr(0, i5), nact, d3->element_ptr(0, i4, i3, i5, i4, i3)); - } + const DataType f = fock_->element(i3, i4); + for (int i7 = 0; i7 != nact; ++i7) + for (int i0 = 0; i0 != nact; ++i0) + for (int i6 = 0; i6 != nact; ++i6) + blas::ax_plus_y_n(f, rdm2->element_ptr(0, i6, i0, i7), nact, fr4->element_ptr(0, i3, i4, i6, i0, i7)); + } + // terms with frdm3(....) = rdm3(....ij) * f(i,j) + { + shared_ptr> frdm3 = rdm2->clone(); + auto rdm3v = group(group(*rdm3,4,6),0,4); + auto frdm3v = group(*frdm3,0,4); + btas::contract(1.0, rdm3v, {0,1}, group(*fock_,0,2), {1}, 0.0, frdm3v, {0}); + for (int i7 = 0; i7 != nact; ++i7) + for (int i0 = 0; i0 != nact; ++i0) + for (int i6 = 0; i6 != nact; ++i6) + for (int i5 = 0; i5 != nact; ++i5) + blas::ax_plus_y_n(1.0, frdm3->element_ptr(0, i6, i0, i7), nact, fr4->element_ptr(0, i5, i5, i6, i0, i7)); + } + // terms with grdm3(.....i) = rdm3(.....j) * f(i,j) + { + shared_ptr> grdm3 = rdm3->clone(); + auto grdm3v = group(*grdm3,0,5); + btas::contract(1.0, group(*rdm3,0,5), {0,1}, *fock_, {2,1}, 0.0, grdm3v, {0,2}); + sort_indices<1,0,1,1,1,1>(grdm3->data(), fr4->data(), nact*nact*nact*nact, nact*nact); + } + // terms with hrdm3(j.....) = rdm3(i.....) * f(i,j) + { + shared_ptr> hrdm3 = rdm3->clone(); + auto hrdm3v = group(*hrdm3,1,6); + btas::contract(1.0, group(*rdm3,1,6), {0,1}, *fock_, {0,2}, 0.0, hrdm3v, {2,1}); + sort_indices<1,0,2,1,1,1,1>(hrdm3->data(), fr4->data(), nact*nact, nact*nact, nact*nact); + } + auto fss = make_shared(dim, dim); + sort_indices<4,0,1,5,3,2,0,1,1,1>(fr4->data(), fss->data(), nact, nact, nact, nact, nact, nact); + this->set_wblock("xxh", jst, ist, *fss); + + } { // xhh + const size_t dim = dim_.at("xhh"); + shared_ptr> ovl = rdm3->copy(); + ovl->scale(-1.0); + const double fac2 = is_same::value ? 2.0 : 1.0; + for (int i5 = 0; i5 != nact; ++i5) + for (int i4 = 0; i4 != nact; ++i4) { + blas::ax_plus_y_n(-1.0, rdm2->element_ptr(0,0,0, i5), nact*nact*nact, ovl->element_ptr(0,0,0, i4, i4, i5)); for (int i2 = 0; i2 != nact; ++i2) { - if (is_same::value) { - blas::ax_plus_y_n(1.0, rdm2->element_ptr(0, i5, i2, i3), nact, d3->element_ptr(0, i4, i4, i5, i2, i3)); - blas::ax_plus_y_n(1.0, rdm2->element_ptr(0, i3, i4, i5), nact, d3->element_ptr(0, i2, i4, i5, i2, i3)); - } - d0->element(i3, i2, i4, i5, i2, i3) += fac2 * rdm1->element(i4, i5); - blas::ax_plus_y_n(-1.0, rdm2->element_ptr(0, i3, i2, i5), nact, d0->element_ptr(0, i4, i2, i5, i4, i3)); - for (int i1 = 0; i1 != nact; ++i1) { - d0->element(i3, i1, i4, i5, i2, i3) += -1.0 * rdm2->element(i2, i1, i4, i5); - d0->element(i1, i1, i4, i5, i2, i3) += fac2 * rdm2->element(i2, i3, i4, i5); + blas::ax_plus_y_n(fac2, rdm2->element_ptr(0,0, i4, i5), nact*nact, ovl->element_ptr(0,0, i2, i2, i4, i5)); + blas::ax_plus_y_n(fac2, rdm1->element_ptr(0, i5), nact, ovl->element_ptr(0, i4, i2, i2, i4, i5)); + blas::ax_plus_y_n(-1.0, rdm1->element_ptr(0, i5), nact, ovl->element_ptr(0, i2, i2, i4, i4, i5)); + for (int i3 = 0; i3 != nact; ++i3) { + blas::ax_plus_y_n(-1.0, rdm2->element_ptr(0, i5, i3, i2), nact, ovl->element_ptr(0, i4, i3, i2, i4, i5)); + blas::ax_plus_y_n(-1.0, rdm2->element_ptr(0, i2, i4, i5), nact, ovl->element_ptr(0, i3, i3, i2, i4, i5)); } } } + auto shalf = make_shared(dim, dim); + sort_indices<0,2,4,3,1,0,1,1,1>(ovl->data(), shalf->data(), nact*nact, nact, nact, nact, nact); + this->set_sblock("xhh", jst, ist, *shalf); + + shared_ptr> fr4 = rdm4f->copy(); + fr4->scale(-1.0); + + // terms with 1 or 2RDM intermediates + { + shared_ptr> frdm3 = rdm2->clone(); + auto rdm3v = group(group(*rdm3,4,6),0,4); + auto frdm3v = group(*frdm3,0,4); + btas::contract(1.0, rdm3v, {0,1}, group(*fock_,0,2), {1}, 0.0, frdm3v, {0}); + + shared_ptr> frdm2 = rdm1->clone(); + auto rdm2v = group(group(*rdm2,2,4),0,2); + auto frdm2v = group(*frdm2,0,2); + btas::contract(1.0, rdm2v, {0,1}, group(*fock_,0,2), {1}, 0.0, frdm2v, {0}); + + shared_ptr> grdm2 = rdm2->clone(); + shared_ptr> grdm2t = rdm2->clone(); + auto grdm2v = group(*grdm2,0,3); + btas::contract(1.0, group(*rdm2,0,3), {0,1}, *fock_, {2,1}, 0.0, grdm2v, {0,2}); + sort_indices<1,0,0,1,1,1>(grdm2->data(), grdm2t->data(), nact*nact, nact*nact); + + shared_ptr> hrdm2 = rdm2->clone(); + shared_ptr> hrdm2t = rdm2->clone(); + auto hrdm2v = group(*hrdm2,1,4); + btas::contract(1.0, group(*rdm2,1,4), {0,1}, *fock_, {0,2}, 0.0, hrdm2v, {2,1}); + sort_indices<1,0,0,1,1,1>(hrdm2->data(), hrdm2t->data(), nact*nact, nact*nact); - MatType work2(dim, dim); + for (int i7 = 0; i7 != nact; ++i7) { + for (int i6 = 0; i6 != nact; ++i6) { + blas::ax_plus_y_n(-1.0, grdm2t->element_ptr(0,0,0, i7), nact*nact*nact, fr4->element_ptr(0,0,0, i6, i6, i7)); + blas::ax_plus_y_n(-1.0, hrdm2t->element_ptr(0,0,0, i7), nact*nact*nact, fr4->element_ptr(0,0,0, i6, i6, i7)); + for (int i2 = 0; i2 != nact; ++i2) { + blas::ax_plus_y_n(-1.0, frdm3->element_ptr(0,0, i6, i7), nact*nact, fr4->element_ptr(0,0, i6, i2, i2, i7)); + blas::ax_plus_y_n(fac2, frdm3->element_ptr(0,0, i6, i7), nact*nact, fr4->element_ptr(0,0, i2, i2, i6, i7)); + blas::ax_plus_y_n(fac2, frdm2->element_ptr(0, i7), nact, fr4->element_ptr(0, i6, i2, i2, i6, i7)); + blas::ax_plus_y_n(-1.0, frdm2->element_ptr(0, i7), nact, fr4->element_ptr(0, i2, i2, i6, i6, i7)); + blas::ax_plus_y_n(fac2, grdm2t->element_ptr(0,0, i6, i7), nact*nact, fr4->element_ptr(0,0, i2, i2, i6, i7)); + blas::ax_plus_y_n(fac2, hrdm2t->element_ptr(0,0, i6, i7), nact*nact, fr4->element_ptr(0,0, i2, i2, i6, i7)); + for (int i5 = 0; i5 != nact; ++i5) { + blas::ax_plus_y_n(-1.0, frdm3->element_ptr(0, i7, i5, i2), nact, fr4->element_ptr(0, i6, i5, i2, i6, i7)); + blas::ax_plus_y_n(-1.0, frdm3->element_ptr(0, i2, i6, i7), nact, fr4->element_ptr(0, i5, i5, i2, i6, i7)); + blas::ax_plus_y_n(-1.0, grdm2->element_ptr(0, i7, i2, i5), nact, fr4->element_ptr(0, i6, i2, i5, i6, i7)); + blas::ax_plus_y_n(-1.0, grdm2t->element_ptr(0, i5, i6, i7), nact, fr4->element_ptr(0, i2, i2, i5, i6, i7)); + blas::ax_plus_y_n(-1.0, hrdm2t->element_ptr(0, i7, i5, i2), nact, fr4->element_ptr(0, i6, i5, i2, i6, i7)); + blas::ax_plus_y_n(-1.0, hrdm2t->element_ptr(0, i2, i5, i7), nact, fr4->element_ptr(0, i6, i6, i2, i5, i7)); + } + } + } + } + } + // terms with grdm3(.....i) = rdm3(.....j) * f(i,j) + { + shared_ptr> grdm3 = rdm3->clone(); + auto grdm3v = group(*grdm3,0,5); + btas::contract(1.0, group(*rdm3,0,5), {0,1}, *fock_, {2,1}, 0.0, grdm3v, {0,2}); + sort_indices<1,0,1,1,-1,1>(grdm3->data(), fr4->data(), nact*nact*nact*nact, nact*nact); + sort_indices<0,2,1,1,1,-1,1>(grdm3->data(), fr4->data(), nact*nact, nact*nact, nact*nact); + } + // terms with hrdm3(j.....) = rdm3(i.....) * f(i,j) + { + shared_ptr> hrdm3 = rdm3->clone(); + auto hrdm3v = group(*hrdm3,1,6); + btas::contract(1.0, group(*rdm3,1,6), {0,1}, *fock_, {0,2}, 0.0, hrdm3v, {2,1}); + sort_indices<1,0,1,1,-1,1>(hrdm3->data(), fr4->data(), nact*nact, nact*nact*nact*nact); + sort_indices<1,0,2,1,1,-1,1>(hrdm3->data(), fr4->data(), nact*nact, nact*nact, nact*nact); + } - auto d0v = group(group(*d0, 4,6),0,4); - auto work2v = group(work2, 0,2); - contract(1.0, d0v, {0,1}, group(*fock_,0,2), {1}, 0.0, work2v, {0}); - sort_indices<2,1,3,0,0,1,1,1>(work2.data(), work.data(), nact, nact, nact, nact); - auto num = make_shared(dim*2, dim*2); - - if (is_same::value) { - num->add_block(1.0, dim, dim, dim, dim, work); - - auto d3v = group(group(*d3, 4,6),0,4); - contract(1.0, d3v, {0,1}, group(*fock_,0,2), {1}, 0.0, work2v, {0}); - sort_indices<0,1,3,2,0,1,1,1>(work2.data(), work.data(), nact, nact, nact, nact); - num->add_block(fac2, 0, 0, dim, dim, work); - - num->add_block(-1.0, dim, 0, dim, dim, work); - num->add_block(-1.0, 0, dim, dim, dim, work); - - work_xh_->copy_block(dim*jst*2, dim*ist*2, dim*2, dim*2, num); - } else { - work_xh_->copy_block(dim*jst, dim*ist, dim, dim, work); + for (int i4 = 0; i4 != nact; ++i4) + for (int i3 = 0; i3 != nact; ++i3) { + const DataType f = fock_->element(i3, i4); + const DataType f2 = f * fac2; + for (int i7 = 0; i7 != nact; ++i7) { + blas::ax_plus_y_n(-f, rdm2->element_ptr(0,0,0, i7), nact*nact*nact, fr4->element_ptr(0,0,0, i3, i4, i7)); + for (int i6 = 0; i6 != nact; ++i6) { + blas::ax_plus_y_n(f2, rdm2->element_ptr(0,0, i6, i7), nact*nact, fr4->element_ptr(0,0, i4, i3, i6, i7)); + blas::ax_plus_y_n(f2, rdm1->element_ptr(0, i7), nact, fr4->element_ptr(0, i6, i4, i3, i6, i7)); + blas::ax_plus_y_n(-f, rdm1->element_ptr(0, i7), nact, fr4->element_ptr(0, i6, i6, i3, i4, i7)); + blas::ax_plus_y_n(-f, rdm1->element_ptr(0, i7), nact, fr4->element_ptr(0, i3, i4, i6, i6, i7)); + blas::ax_plus_y_n(f2, rdm1->element_ptr(0, i7), nact, fr4->element_ptr(0, i3, i6, i6, i4, i7)); + for (int i2 = 0; i2 != nact; ++i2) { + blas::ax_plus_y_n(-f, rdm2->element_ptr(0, i7, i6, i2), nact, fr4->element_ptr(0, i3, i6, i2, i4, i7)); + blas::ax_plus_y_n(-f, rdm2->element_ptr(0, i2, i6, i7), nact, fr4->element_ptr(0, i3, i4, i2, i6, i7)); + } + } + } + } + auto fss = make_shared(dim, dim); + sort_indices<0,2,4,3,1,0,1,1,1>(fr4->data(), fss->data(), nact*nact, nact, nact, nact, nact); + this->set_wblock("xhh", jst, ist, *fss); } } template -void Denom::init_xxh_(const int jst, const int ist, shared_ptr> rdm1, shared_ptr> rdm2, - shared_ptr> rdm3, shared_ptr> rdm4f) { - const size_t nact = rdm1->norb(); - const size_t dim = nact*nact*nact; - shared_ptr> ovl = rdm3->copy(); - for (int i5 = 0; i5 != nact; ++i5) - for (int i0 = 0; i0 != nact; ++i0) - for (int i4 = 0; i4 != nact; ++i4) - for (int i3 = 0; i3 != nact; ++i3) - blas::ax_plus_y_n(1.0, rdm2->element_ptr(0, i4, i0, i5), nact, ovl->element_ptr(0, i3, i3, i4, i0, i5)); - auto shalf = make_shared(dim, dim); - sort_indices<4,0,1,5,3,2,0,1,1,1>(ovl->data(), shalf->data(), nact, nact, nact, nact, nact, nact); - shalf_xxh_->copy_block(dim*jst, dim*ist, dim, dim, shalf); - - // TODO a littile of duplication. Maybe should merge with xhh below - shared_ptr> fr4 = rdm4f->copy(); - for (int i4 = 0; i4 != nact; ++i4) - for (int i3 = 0; i3 != nact; ++i3) { - const DataType f = fock_->element(i3, i4); - for (int i7 = 0; i7 != nact; ++i7) - for (int i0 = 0; i0 != nact; ++i0) - for (int i6 = 0; i6 != nact; ++i6) - blas::ax_plus_y_n(f, rdm2->element_ptr(0, i6, i0, i7), nact, fr4->element_ptr(0, i3, i4, i6, i0, i7)); - } - // terms with frdm3(....) = rdm3(....ij) * f(i,j) +void Denom_MSMR::compute() { { - shared_ptr> frdm3 = rdm2->clone(); - auto rdm3v = group(group(*rdm3,4,6),0,4); - auto frdm3v = group(*frdm3,0,4); - btas::contract(1.0, rdm3v, {0,1}, group(*fock_,0,2), {1}, 0.0, frdm3v, {0}); - for (int i7 = 0; i7 != nact; ++i7) - for (int i0 = 0; i0 != nact; ++i0) - for (int i6 = 0; i6 != nact; ++i6) - for (int i5 = 0; i5 != nact; ++i5) - blas::ax_plus_y_n(1.0, frdm3->element_ptr(0, i6, i0, i7), nact, fr4->element_ptr(0, i5, i5, i6, i0, i7)); + shalf_["x"]->inverse_half(thresh_); + MatType tmp(*shalf_["x"] % *work_["x"] * *shalf_["x"]); + tmp.diagonalize(denom_["x"]); + shalf_["x"] = make_shared(tmp % *shalf_["x"]); } - // terms with grdm3(.....i) = rdm3(.....j) * f(i,j) { - shared_ptr> grdm3 = rdm3->clone(); - auto grdm3v = group(*grdm3,0,5); - btas::contract(1.0, group(*rdm3,0,5), {0,1}, *fock_, {2,1}, 0.0, grdm3v, {0,2}); - sort_indices<1,0,1,1,1,1>(grdm3->data(), fr4->data(), nact*nact*nact*nact, nact*nact); + shalf_["h"]->inverse_half(thresh_); + MatType tmp(*shalf_["h"] % *work_["h"] * *shalf_["h"]); + tmp.diagonalize(denom_["h"]); + shalf_["h"] = make_shared(tmp % *shalf_["h"]); } - // terms with hrdm3(j.....) = rdm3(i.....) * f(i,j) { - shared_ptr> hrdm3 = rdm3->clone(); - auto hrdm3v = group(*hrdm3,1,6); - btas::contract(1.0, group(*rdm3,1,6), {0,1}, *fock_, {0,2}, 0.0, hrdm3v, {2,1}); - sort_indices<1,0,2,1,1,1,1>(hrdm3->data(), fr4->data(), nact*nact, nact*nact, nact*nact); - } - auto fss = make_shared(dim, dim); - sort_indices<4,0,1,5,3,2,0,1,1,1>(fr4->data(), fss->data(), nact, nact, nact, nact, nact, nact); - work_xxh_->copy_block(dim*jst, dim*ist, dim, dim, fss); -} - - -template -void Denom::init_xhh_(const int jst, const int ist, shared_ptr> rdm1, shared_ptr> rdm2, - shared_ptr> rdm3, shared_ptr> rdm4f) { - const size_t nact = rdm1->norb(); - const size_t dim = nact*nact*nact; - shared_ptr> ovl = rdm3->copy(); - ovl->scale(-1.0); - const double fac2 = is_same::value ? 2.0 : 1.0; - for (int i5 = 0; i5 != nact; ++i5) - for (int i4 = 0; i4 != nact; ++i4) { - blas::ax_plus_y_n(-1.0, rdm2->element_ptr(0,0,0, i5), nact*nact*nact, ovl->element_ptr(0,0,0, i4, i4, i5)); - for (int i2 = 0; i2 != nact; ++i2) { - blas::ax_plus_y_n(fac2, rdm2->element_ptr(0,0, i4, i5), nact*nact, ovl->element_ptr(0,0, i2, i2, i4, i5)); - blas::ax_plus_y_n(fac2, rdm1->element_ptr(0, i5), nact, ovl->element_ptr(0, i4, i2, i2, i4, i5)); - blas::ax_plus_y_n(-1.0, rdm1->element_ptr(0, i5), nact, ovl->element_ptr(0, i2, i2, i4, i4, i5)); - for (int i3 = 0; i3 != nact; ++i3) { - blas::ax_plus_y_n(-1.0, rdm2->element_ptr(0, i5, i3, i2), nact, ovl->element_ptr(0, i4, i3, i2, i4, i5)); - blas::ax_plus_y_n(-1.0, rdm2->element_ptr(0, i2, i4, i5), nact, ovl->element_ptr(0, i3, i3, i2, i4, i5)); - } - } - } - auto shalf = make_shared(dim, dim); - sort_indices<0,2,4,3,1,0,1,1,1>(ovl->data(), shalf->data(), nact*nact, nact, nact, nact, nact); - shalf_xhh_->copy_block(dim*jst, dim*ist, dim, dim, shalf); - - shared_ptr> fr4 = rdm4f->copy(); - fr4->scale(-1.0); - - // terms with 1 or 2RDM intermediates + shalf_["xx"]->inverse_half(thresh_); + MatType tmp(*shalf_["xx"] % *work_["xx"] * *shalf_["xx"]); + tmp.diagonalize(denom_["xx"]); + shalf_["xx"] = make_shared(tmp % *shalf_["xx"]); + } { - shared_ptr> frdm3 = rdm2->clone(); - auto rdm3v = group(group(*rdm3,4,6),0,4); - auto frdm3v = group(*frdm3,0,4); - btas::contract(1.0, rdm3v, {0,1}, group(*fock_,0,2), {1}, 0.0, frdm3v, {0}); - - shared_ptr> frdm2 = rdm1->clone(); - auto rdm2v = group(group(*rdm2,2,4),0,2); - auto frdm2v = group(*frdm2,0,2); - btas::contract(1.0, rdm2v, {0,1}, group(*fock_,0,2), {1}, 0.0, frdm2v, {0}); - - shared_ptr> grdm2 = rdm2->clone(); - shared_ptr> grdm2t = rdm2->clone(); - auto grdm2v = group(*grdm2,0,3); - btas::contract(1.0, group(*rdm2,0,3), {0,1}, *fock_, {2,1}, 0.0, grdm2v, {0,2}); - sort_indices<1,0,0,1,1,1>(grdm2->data(), grdm2t->data(), nact*nact, nact*nact); - - shared_ptr> hrdm2 = rdm2->clone(); - shared_ptr> hrdm2t = rdm2->clone(); - auto hrdm2v = group(*hrdm2,1,4); - btas::contract(1.0, group(*rdm2,1,4), {0,1}, *fock_, {0,2}, 0.0, hrdm2v, {2,1}); - sort_indices<1,0,0,1,1,1>(hrdm2->data(), hrdm2t->data(), nact*nact, nact*nact); - - for (int i7 = 0; i7 != nact; ++i7) { - for (int i6 = 0; i6 != nact; ++i6) { - blas::ax_plus_y_n(-1.0, grdm2t->element_ptr(0,0,0, i7), nact*nact*nact, fr4->element_ptr(0,0,0, i6, i6, i7)); - blas::ax_plus_y_n(-1.0, hrdm2t->element_ptr(0,0,0, i7), nact*nact*nact, fr4->element_ptr(0,0,0, i6, i6, i7)); - for (int i2 = 0; i2 != nact; ++i2) { - blas::ax_plus_y_n(-1.0, frdm3->element_ptr(0,0, i6, i7), nact*nact, fr4->element_ptr(0,0, i6, i2, i2, i7)); - blas::ax_plus_y_n(fac2, frdm3->element_ptr(0,0, i6, i7), nact*nact, fr4->element_ptr(0,0, i2, i2, i6, i7)); - blas::ax_plus_y_n(fac2, frdm2->element_ptr(0, i7), nact, fr4->element_ptr(0, i6, i2, i2, i6, i7)); - blas::ax_plus_y_n(-1.0, frdm2->element_ptr(0, i7), nact, fr4->element_ptr(0, i2, i2, i6, i6, i7)); - blas::ax_plus_y_n(fac2, grdm2t->element_ptr(0,0, i6, i7), nact*nact, fr4->element_ptr(0,0, i2, i2, i6, i7)); - blas::ax_plus_y_n(fac2, hrdm2t->element_ptr(0,0, i6, i7), nact*nact, fr4->element_ptr(0,0, i2, i2, i6, i7)); - for (int i5 = 0; i5 != nact; ++i5) { - blas::ax_plus_y_n(-1.0, frdm3->element_ptr(0, i7, i5, i2), nact, fr4->element_ptr(0, i6, i5, i2, i6, i7)); - blas::ax_plus_y_n(-1.0, frdm3->element_ptr(0, i2, i6, i7), nact, fr4->element_ptr(0, i5, i5, i2, i6, i7)); - blas::ax_plus_y_n(-1.0, grdm2->element_ptr(0, i7, i2, i5), nact, fr4->element_ptr(0, i6, i2, i5, i6, i7)); - blas::ax_plus_y_n(-1.0, grdm2t->element_ptr(0, i5, i6, i7), nact, fr4->element_ptr(0, i2, i2, i5, i6, i7)); - blas::ax_plus_y_n(-1.0, hrdm2t->element_ptr(0, i7, i5, i2), nact, fr4->element_ptr(0, i6, i5, i2, i6, i7)); - blas::ax_plus_y_n(-1.0, hrdm2t->element_ptr(0, i2, i5, i7), nact, fr4->element_ptr(0, i6, i6, i2, i5, i7)); - } - } - } - } + shalf_["hh"]->inverse_half(thresh_); + MatType tmp(*shalf_["hh"] % *work_["hh"] * *shalf_["hh"]); + tmp.diagonalize(denom_["hh"]); + shalf_["hh"] = make_shared(tmp % *shalf_["hh"]); + } + { + shalf_["xh"]->inverse_half(thresh_); + MatType tmp(*shalf_["xh"] % *work_["xh"] * *shalf_["xh"]); + tmp.diagonalize(denom_["xh"]); + shalf_["xh"] = make_shared(tmp % *shalf_["xh"]); } - // terms with grdm3(.....i) = rdm3(.....j) * f(i,j) { - shared_ptr> grdm3 = rdm3->clone(); - auto grdm3v = group(*grdm3,0,5); - btas::contract(1.0, group(*rdm3,0,5), {0,1}, *fock_, {2,1}, 0.0, grdm3v, {0,2}); - sort_indices<1,0,1,1,-1,1>(grdm3->data(), fr4->data(), nact*nact*nact*nact, nact*nact); - sort_indices<0,2,1,1,1,-1,1>(grdm3->data(), fr4->data(), nact*nact, nact*nact, nact*nact); + shalf_["xxh"]->inverse_half(thresh_); + MatType tmp(*shalf_["xxh"] % *work_["xxh"] * *shalf_["xxh"]); + tmp.diagonalize(denom_["xxh"]); + shalf_["xxh"] = make_shared(tmp % *shalf_["xxh"]); } - // terms with hrdm3(j.....) = rdm3(i.....) * f(i,j) { - shared_ptr> hrdm3 = rdm3->clone(); - auto hrdm3v = group(*hrdm3,1,6); - btas::contract(1.0, group(*rdm3,1,6), {0,1}, *fock_, {0,2}, 0.0, hrdm3v, {2,1}); - sort_indices<1,0,1,1,-1,1>(hrdm3->data(), fr4->data(), nact*nact, nact*nact*nact*nact); - sort_indices<1,0,2,1,1,-1,1>(hrdm3->data(), fr4->data(), nact*nact, nact*nact, nact*nact); + shalf_["xhh"]->inverse_half(thresh_); + MatType tmp(*shalf_["xhh"] % *work_["xhh"] * *shalf_["xhh"]); + tmp.diagonalize(denom_["xhh"]); + shalf_["xhh"] = make_shared(tmp % *shalf_["xhh"]); } + work_ = decltype(work_)(); +} - for (int i4 = 0; i4 != nact; ++i4) - for (int i3 = 0; i3 != nact; ++i3) { - const DataType f = fock_->element(i3, i4); - const DataType f2 = f * fac2; - for (int i7 = 0; i7 != nact; ++i7) { - blas::ax_plus_y_n(-f, rdm2->element_ptr(0,0,0, i7), nact*nact*nact, fr4->element_ptr(0,0,0, i3, i4, i7)); - for (int i6 = 0; i6 != nact; ++i6) { - blas::ax_plus_y_n(f2, rdm2->element_ptr(0,0, i6, i7), nact*nact, fr4->element_ptr(0,0, i4, i3, i6, i7)); - blas::ax_plus_y_n(f2, rdm1->element_ptr(0, i7), nact, fr4->element_ptr(0, i6, i4, i3, i6, i7)); - blas::ax_plus_y_n(-f, rdm1->element_ptr(0, i7), nact, fr4->element_ptr(0, i6, i6, i3, i4, i7)); - blas::ax_plus_y_n(-f, rdm1->element_ptr(0, i7), nact, fr4->element_ptr(0, i3, i4, i6, i6, i7)); - blas::ax_plus_y_n(f2, rdm1->element_ptr(0, i7), nact, fr4->element_ptr(0, i3, i6, i6, i4, i7)); - for (int i2 = 0; i2 != nact; ++i2) { - blas::ax_plus_y_n(-f, rdm2->element_ptr(0, i7, i6, i2), nact, fr4->element_ptr(0, i3, i6, i2, i4, i7)); - blas::ax_plus_y_n(-f, rdm2->element_ptr(0, i2, i6, i7), nact, fr4->element_ptr(0, i3, i4, i2, i6, i7)); - } - } - } - } - auto fss = make_shared(dim, dim); - sort_indices<0,2,4,3,1,0,1,1,1>(fr4->data(), fss->data(), nact*nact, nact, nact, nact, nact); - work_xhh_->copy_block(dim*jst, dim*ist, dim, dim, fss); + + +template +void Denom_SSSR::compute() { + for (int ist = 0; ist != nstates_; ++ist) { + shalf_["x"][ist]->inverse_half(thresh_); + MatType tmp(*shalf_["x"][ist] % *work_["x"][ist] * *shalf_["x"][ist]); + tmp.diagonalize(denom_["x"][ist]); + shalf_["x"][ist] = make_shared(tmp % *shalf_["x"][ist]); + } + for (int ist = 0; ist != nstates_; ++ist) { + shalf_["h"][ist]->inverse_half(thresh_); + MatType tmp(*shalf_["h"][ist] % *work_["h"][ist] * *shalf_["h"][ist]); + tmp.diagonalize(denom_["h"][ist]); + shalf_["h"][ist] = make_shared(tmp % *shalf_["h"][ist]); + } + for (int ist = 0; ist != nstates_; ++ist) { + shalf_["xx"][ist]->inverse_half(thresh_); + MatType tmp(*shalf_["xx"][ist] % *work_["xx"][ist] * *shalf_["xx"][ist]); + tmp.diagonalize(denom_["xx"][ist]); + shalf_["xx"][ist] = make_shared(tmp % *shalf_["xx"][ist]); + } + for (int ist = 0; ist != nstates_; ++ist) { + shalf_["hh"][ist]->inverse_half(thresh_); + MatType tmp(*shalf_["hh"][ist] % *work_["hh"][ist] * *shalf_["hh"][ist]); + tmp.diagonalize(denom_["hh"][ist]); + shalf_["hh"][ist] = make_shared(tmp % *shalf_["hh"][ist]); + } + for (int ist = 0; ist != nstates_; ++ist) { + shalf_["xh"][ist]->inverse_half(thresh_); + MatType tmp(*shalf_["xh"][ist] % *work_["xh"][ist] * *shalf_["xh"][ist]); + tmp.diagonalize(denom_["xh"][ist]); + shalf_["xh"][ist] = make_shared(tmp % *shalf_["xh"][ist]); + } + for (int ist = 0; ist != nstates_; ++ist) { + shalf_["xxh"][ist]->inverse_half(thresh_); + MatType tmp(*shalf_["xxh"][ist] % *work_["xxh"][ist] * *shalf_["xxh"][ist]); + tmp.diagonalize(denom_["xxh"][ist]); + shalf_["xxh"][ist] = make_shared(tmp % *shalf_["xxh"][ist]); + } + for (int ist = 0; ist != nstates_; ++ist) { + shalf_["xhh"][ist]->inverse_half(thresh_); + MatType tmp(*shalf_["xhh"][ist] % *work_["xhh"][ist] * *shalf_["xhh"][ist]); + tmp.diagonalize(denom_["xhh"][ist]); + shalf_["xhh"][ist] = make_shared(tmp % *shalf_["xhh"][ist]); + } + work_ = decltype(work_)(); } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // explict instantiation at the end of the file template class bagel::SMITH::Denom; template class bagel::SMITH::Denom>; +template class bagel::SMITH::Denom_MSMR; +template class bagel::SMITH::Denom_MSMR>; +template class bagel::SMITH::Denom_SSSR; +template class bagel::SMITH::Denom_SSSR>; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #endif diff -Nru bagel-1.2.0/src/smith/denom.h bagel-1.2.2/src/smith/denom.h --- bagel-1.2.0/src/smith/denom.h 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/src/smith/denom.h 2018-12-29 22:08:28.000000000 +0000 @@ -35,50 +35,20 @@ class Denom { protected: using MatType = typename std::conditional::value,Matrix,ZMatrix>::type; + using ViewType = typename std::conditional::value,MatView,ZMatView>::type; protected: std::shared_ptr fock_; const double thresh_; - - std::shared_ptr shalf_x_; - std::shared_ptr shalf_h_; - std::shared_ptr shalf_xx_; - std::shared_ptr shalf_hh_; - std::shared_ptr shalf_xh_; - std::shared_ptr shalf_xhh_; - std::shared_ptr shalf_xxh_; - - std::shared_ptr work_x_; - std::shared_ptr work_h_; - std::shared_ptr work_xx_; - std::shared_ptr work_hh_; - std::shared_ptr work_xh_; - std::shared_ptr work_xhh_; - std::shared_ptr work_xxh_; - - VectorB denom_x_; - VectorB denom_h_; - VectorB denom_xx_; - VectorB denom_hh_; - VectorB denom_xh_; - VectorB denom_xhh_; - VectorB denom_xxh_; + const size_t nstates_; + std::map dim_; // init functions - void init_x_(const int, const int, std::shared_ptr>, std::shared_ptr>, - std::shared_ptr>, std::shared_ptr>); - void init_h_(const int, const int, std::shared_ptr>, std::shared_ptr>, - std::shared_ptr>, std::shared_ptr>); - void init_xx_(const int, const int, std::shared_ptr>, std::shared_ptr>, - std::shared_ptr>, std::shared_ptr>); - void init_hh_(const int, const int, std::shared_ptr>, std::shared_ptr>, - std::shared_ptr>, std::shared_ptr>); - void init_xh_(const int, const int, std::shared_ptr>, std::shared_ptr>, - std::shared_ptr>, std::shared_ptr>); - void init_xhh_(const int, const int, std::shared_ptr>, std::shared_ptr>, - std::shared_ptr>, std::shared_ptr>); - void init_xxh_(const int, const int, std::shared_ptr>, std::shared_ptr>, - std::shared_ptr>, std::shared_ptr>); + void init_(const std::string& tag, const int, const int, + std::shared_ptr>, std::shared_ptr>, + std::shared_ptr>, std::shared_ptr>); + virtual void set_sblock(const std::string tag, const int, const int, const btas::TensorView2 data) = 0; + virtual void set_wblock(const std::string tag, const int, const int, const btas::TensorView2 data) = 0; public: Denom(std::shared_ptr fock, const int nstates, const double thresh_overlap); @@ -87,32 +57,78 @@ void append(const int jst, const int ist, std::shared_ptr>, std::shared_ptr>, std::shared_ptr>, std::shared_ptr>); // diagonalize and set to shalf and denom - void compute(); + virtual void compute() = 0; + + virtual const ViewType shalf(const std::string, const int) const = 0; + virtual double denom(const std::string& tag, const int ist, const size_t i) const = 0; +}; + + +template +class Denom_SSSR : public Denom { + protected: + using Denom::thresh_; + using Denom::nstates_; + using Denom::dim_; + using Denom::fock_; + using MatType = typename std::conditional::value,Matrix,ZMatrix>::type; + using ViewType = typename std::conditional::value,MatView,ZMatView>::type; + + protected: + std::map>> shalf_; + std::map>> work_; + std::map> denom_; + + void set_sblock(const std::string tag, const int jst, const int ist, const btas::TensorView2 o) override { + assert(jst == ist && o.size() == shalf_.at(tag)[ist]->size()); + std::copy_n(&*o.begin(), o.size(), shalf_.at(tag)[ist]->data()); + } + void set_wblock(const std::string tag, const int jst, const int ist, const btas::TensorView2 o) override { + assert(jst == ist && o.size() == work_.at(tag)[ist]->size()); + std::copy_n(&*o.begin(), o.size(), work_.at(tag)[ist]->data()); + } + + public: + Denom_SSSR(std::shared_ptr fock, const int nstates, const double thresh_overlap); + + const ViewType shalf(const std::string tag, const int ist) const { return *(shalf_.at(tag)[ist]); } + void compute() override; + double denom(const std::string& tag, const int ist, const size_t i) const override { return denom_.at(tag)[ist](i); } +}; + + +template +class Denom_MSMR : public Denom { + protected: + using Denom::thresh_; + using Denom::dim_; + using Denom::fock_; + using MatType = typename std::conditional::value,Matrix,ZMatrix>::type; + using ViewType = typename std::conditional::value,MatView,ZMatView>::type; - std::shared_ptr shalf_x() const { return shalf_x_; } - std::shared_ptr shalf_h() const { return shalf_h_; } - std::shared_ptr shalf_xx() const { return shalf_xx_; } - std::shared_ptr shalf_hh() const { return shalf_hh_; } - std::shared_ptr shalf_xh() const { return shalf_xh_; } - std::shared_ptr shalf_xhh() const { return shalf_xhh_; } - std::shared_ptr shalf_xxh() const { return shalf_xxh_; } - - VectorB denom_x() const { return denom_x_; } - VectorB denom_h() const { return denom_h_; } - VectorB denom_xx() const { return denom_xx_; } - VectorB denom_hh() const { return denom_hh_; } - VectorB denom_xh() const { return denom_xh_; } - VectorB denom_xhh() const { return denom_xhh_; } - VectorB denom_xxh() const { return denom_xxh_; } - - const double& denom_x(const size_t i) const { return denom_x_(i); } - const double& denom_h(const size_t i) const { return denom_h_(i); } - const double& denom_xx(const size_t i) const { return denom_xx_(i); } - const double& denom_hh(const size_t i) const { return denom_hh_(i); } - const double& denom_xh(const size_t i) const { return denom_xh_(i); } - const double& denom_xhh(const size_t i) const { return denom_xhh_(i); } - const double& denom_xxh(const size_t i) const { return denom_xxh_(i); } + protected: + std::map> shalf_; + std::map> work_; + std::map denom_; + + void set_sblock(const std::string tag, const int jst, const int ist, const btas::TensorView2 o) override { + const size_t dim = dim_.at(tag); + shalf_.at(tag)->copy_block(jst*dim, ist*dim, dim, dim, o); + } + void set_wblock(const std::string tag, const int jst, const int ist, const btas::TensorView2 o) override { + const size_t dim = dim_.at(tag); + work_.at(tag)->copy_block(jst*dim, ist*dim, dim, dim, o); + } + + public: + Denom_MSMR(std::shared_ptr fock, const int nstates, const double thresh_overlap); + const ViewType shalf(const std::string tag, const int ist) const { + const size_t dim = dim_.at(tag); + return shalf_.at(tag)->slice(ist*dim, (ist+1)*dim); + } + void compute() override; + double denom(const std::string& tag, const int ist, const size_t i) const override { return denom_.at(tag)(i); } }; extern template class Denom; diff -Nru bagel-1.2.0/src/smith/orthogonal.cc bagel-1.2.2/src/smith/orthogonal.cc --- bagel-1.2.0/src/smith/orthogonal.cc 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/src/smith/orthogonal.cc 2018-12-29 22:08:28.000000000 +0000 @@ -44,35 +44,62 @@ norb_ = nocc_ + nvirt_; nstates_ = info->ciwfn()->nstates(); + d_ = d; + fockact_ = fact->copy(); sssr_ = info->sssr(); imag_ = info->shift_imag(); shift_ = info->shift(); - set_shalf(d); + to_denom_[Excitations::arbs] = "xx"; + to_denom_[Excitations::arbi] = "x"; + to_denom_[Excitations::airj] = "h"; + to_denom_[Excitations::risj] = "hh"; + to_denom_[Excitations::airs] = "xh"; + to_denom_[Excitations::arst] = "xxh"; + to_denom_[Excitations::rist] = "xhh"; + to_denom_[Excitations::aibj] = ""; int keyoffset = closed_.nblock() + active_.nblock() + virt_.nblock(); - for (int iext = Excitations::arbs; iext != Excitations::aibj; ++iext) { - // should have < 256 blocks. - const int maxtile = max(((int)(shalf_[iext]->ndim() / 255) + 1), info->maxtile()); - interm_.push_back(IndexRange(shalf_[iext]->ndim(), maxtile, keyoffset)); - keyoffset += interm_[iext].nblock(); + + // Now we have interms + // sssr ---- state 0 0 1 2 3 4 5 6 7 + // state 1 0 1 2 3 4 5 6 7 + // state 2 0 1 2 3 4 5 6 7 ... + // msmr ---- 0 1 2 3 4 5 6 7(0) 7(1) 7(2) + if (sssr_) { + for (int istate = 0; istate != nstates_; ++istate) { + for (int iext = Excitations::arbs; iext != Excitations::aibj; ++iext) { + const size_t ndim = d->shalf(to_denom_.at(iext), istate).ndim(); + const int maxtile = max(((int)(ndim / 255) + 1), info->maxtile()); + interm_.push_back(IndexRange(ndim, maxtile, keyoffset)); + keyoffset += interm_[iext].nblock(); + } + interm_.push_back(IndexRange(0)); + } + } else { + for (int iext = Excitations::arbs; iext != Excitations::aibj; ++iext) { + const size_t ndim = d->shalf(to_denom_.at(iext), 0).ndim(); + const int maxtile = max(((int)(ndim / 255) + 1), info->maxtile()); + interm_.push_back(IndexRange(ndim, maxtile, keyoffset)); + keyoffset += interm_[iext].nblock(); + } + interm_.push_back(IndexRange(0)); } - interm_.push_back(IndexRange(0)); for (int istate = 0; istate != nstates_; ++istate) { auto tmp = make_shared>(Excitations::total + (sssr_ ? 0 : nstates_-1)); for (int iext = Excitations::arbs; iext != Excitations::aibj; ++iext) { - (*tmp)[iext] = init_data(iext); + (*tmp)[iext] = init_data(iext, istate); } // aibj depends on whether sssr or msmr if (sssr_) { const int pos = Excitations::aibj; - (*tmp)[pos] = init_data(Excitations::aibj); + (*tmp)[pos] = init_data(Excitations::aibj, istate); } else { for (int ist = 0; ist != nstates_; ++ist) { const int pos = Excitations::aibj + ist; - (*tmp)[pos] = init_data(Excitations::aibj); + (*tmp)[pos] = init_data(Excitations::aibj, istate); } } @@ -90,6 +117,8 @@ Orthogonal_Basis::Orthogonal_Basis(const Orthogonal_Basis& o, const bool clone, const bool residual) { + to_denom_ = o.to_denom_; + closed_ = o.closed_; active_ = o.active_; virt_ = o.virt_; @@ -106,16 +135,13 @@ norb_ = o.norb_; nstates_ = o.nstates_; + d_ = o.d_; + sssr_ = o.sssr_; imag_ = o.imag_; shift_ = o.shift_; - shalf_.resize(Excitations::total); - for (int i = 0; i != Excitations::total; ++i) - shalf_[i] = o.shalf_[i]; - interm_ = o.interm_; - phi_ = o.phi_; data_.resize(nstates_); for (int i = 0; i != nstates_; ++i) { @@ -135,80 +161,61 @@ } -void Orthogonal_Basis::set_shalf(shared_ptr> d) { - shalf_.push_back(d->shalf_xx()->copy()); - shalf_.push_back(d->shalf_x()->copy()); - shalf_.push_back(d->shalf_h()->copy()); - shalf_.push_back(d->shalf_hh()->copy()); - shalf_.push_back(d->shalf_xh()->copy()); - shalf_.push_back(d->shalf_xxh()->copy()); - shalf_.push_back(d->shalf_xhh()->copy()); - shalf_.push_back(make_shared()); - - phi_.push_back(d->denom_xx()); - phi_.push_back(d->denom_x()); - phi_.push_back(d->denom_h()); - phi_.push_back(d->denom_hh()); - phi_.push_back(d->denom_xh()); - phi_.push_back(d->denom_xxh()); - phi_.push_back(d->denom_xhh()); -} - - -shared_ptr> Orthogonal_Basis::init_data(const int iext) { +shared_ptr> Orthogonal_Basis::init_data(const int iext, const int istate) { // Now we use intermediate indices instead of orbital, and is somewhat complicated... // Interm always runs faster. unordered_set sparse; shared_ptr> out; + const int dataindex = sssr_ ? iext + istate * Excitations::total : iext; switch(iext) { case Excitations::arbs: for (auto& i3 : virt_) for (auto& i1 : virt_) - for (auto& i0o : interm_[iext]) + for (auto& i0o : interm_[dataindex]) sparse.insert(generate_hash_key(i0o, i1, i3)); - out = make_shared>(vector{interm_[iext], virt_, virt_}, /*kramers=*/false, sparse, /*alloc=*/true); + out = make_shared>(vector{interm_[dataindex], virt_, virt_}, /*kramers=*/false, sparse, /*alloc=*/true); break; case Excitations::arbi: for (auto& i3 : virt_) for (auto& i2 : closed_) for (auto& i1 : virt_) - for (auto& i0o : interm_[iext]) + for (auto& i0o : interm_[dataindex]) sparse.insert(generate_hash_key(i0o, i1, i2, i3)); - out = make_shared>(vector{interm_[iext], virt_, closed_, virt_}, /*kramers=*/false, sparse, /*alloc=*/true); + out = make_shared>(vector{interm_[dataindex], virt_, closed_, virt_}, /*kramers=*/false, sparse, /*alloc=*/true); break; case Excitations::airj: for (auto& i2 : closed_) for (auto& i1 : virt_) for (auto& i0 : closed_) - for (auto& i0o : interm_[iext]) + for (auto& i0o : interm_[dataindex]) sparse.insert(generate_hash_key(i0o, i0, i1, i2)); - out = make_shared>(vector{interm_[iext], closed_, virt_, closed_}, /*kramers=*/false, sparse, /*alloc=*/true); + out = make_shared>(vector{interm_[dataindex], closed_, virt_, closed_}, /*kramers=*/false, sparse, /*alloc=*/true); break; case Excitations::risj: for (auto& i2 : closed_) for (auto& i0 : closed_) - for (auto& i0o : interm_[iext]) + for (auto& i0o : interm_[dataindex]) sparse.insert(generate_hash_key(i0o, i0, i2)); - out = make_shared>(vector{interm_[iext], closed_, closed_}, /*kramers=*/false, sparse, /*alloc=*/true); + out = make_shared>(vector{interm_[dataindex], closed_, closed_}, /*kramers=*/false, sparse, /*alloc=*/true); break; case Excitations::airs: for (auto& i1 : virt_) for (auto& i0 : closed_) - for (auto& i0o : interm_[iext]) + for (auto& i0o : interm_[dataindex]) sparse.insert(generate_hash_key(i0o, i0, i1)); - out = make_shared>(vector{interm_[iext], closed_, virt_}, /*kramers=*/false, sparse, /*alloc=*/true); + out = make_shared>(vector{interm_[dataindex], closed_, virt_}, /*kramers=*/false, sparse, /*alloc=*/true); break; case Excitations::arst: for (auto& i1 : virt_) - for (auto& i0o : interm_[iext]) + for (auto& i0o : interm_[dataindex]) sparse.insert(generate_hash_key(i0o, i1)); - out = make_shared>(vector{interm_[iext], virt_}, /*kramers=*/false, sparse, /*alloc=*/true); + out = make_shared>(vector{interm_[dataindex], virt_}, /*kramers=*/false, sparse, /*alloc=*/true); break; case Excitations::rist: for (auto& i0 : closed_) - for (auto& i0o : interm_[iext]) + for (auto& i0o : interm_[dataindex]) sparse.insert(generate_hash_key(i0o, i0)); - out = make_shared>(vector{interm_[iext], closed_}, /*kramers=*/false, sparse, /*alloc=*/true); + out = make_shared>(vector{interm_[dataindex], closed_}, /*kramers=*/false, sparse, /*alloc=*/true); break; case Excitations::aibj: for (auto& i3 : virt_) @@ -226,6 +233,7 @@ shared_ptr> Orthogonal_Basis::weight_by_denom(const int istate, shared_ptr> original) const { auto out = make_shared>(Excitations::total + (sssr_ ? 0 : nstates_-1)); for (int iext = Excitations::arbs; iext != Excitations::total; ++iext) { + const int dataindex = sssr_ ? iext + istate * Excitations::total : iext; const shared_ptr> dtensor = denom_[istate]->at(iext); shared_ptr> ttensor = original->at(iext); switch(iext) { @@ -233,7 +241,7 @@ out->at(iext) = ttensor->clone(); for (auto& i3 : virt_) for (auto& i1 : virt_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!dtensor->is_local(i0o, i1, i3)) continue; const unique_ptr ddata = dtensor->get_block(i0o, i1, i3); unique_ptr tdata = ttensor->get_block(i0o, i1, i3); @@ -249,7 +257,7 @@ for (auto& i3 : virt_) for (auto& i2 : closed_) for (auto& i1 : virt_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!dtensor->is_local(i0o, i1, i2, i3)) continue; const unique_ptr ddata = dtensor->get_block(i0o, i1, i2, i3); unique_ptr tdata = ttensor->get_block(i0o, i1, i2, i3); @@ -265,7 +273,7 @@ for (auto& i2 : closed_) for (auto& i1 : virt_) for (auto& i0 : closed_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!dtensor->is_local(i0o, i0, i1, i2)) continue; const unique_ptr ddata = dtensor->get_block(i0o, i0, i1, i2); unique_ptr tdata = ttensor->get_block(i0o, i0, i1, i2); @@ -280,7 +288,7 @@ out->at(iext) = ttensor->clone(); for (auto& i2 : closed_) for (auto& i0 : closed_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!dtensor->is_local(i0o, i0, i2)) continue; const unique_ptr ddata = dtensor->get_block(i0o, i0, i2); unique_ptr tdata = ttensor->get_block(i0o, i0, i2); @@ -295,7 +303,7 @@ out->at(iext) = ttensor->clone(); for (auto& i1 : virt_) for (auto& i0 : closed_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!dtensor->is_local(i0o, i0, i1)) continue; const unique_ptr ddata = dtensor->get_block(i0o, i0, i1); unique_ptr tdata = ttensor->get_block(i0o, i0, i1); @@ -309,7 +317,7 @@ case Excitations::arst: out->at(iext) = ttensor->clone(); for (auto& i1 : virt_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!dtensor->is_local(i0o, i1)) continue; const unique_ptr ddata = dtensor->get_block(i0o, i1); unique_ptr tdata = ttensor->get_block(i0o, i1); @@ -323,7 +331,7 @@ case Excitations::rist: out->at(iext) = ttensor->clone(); for (auto& i0 : closed_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!dtensor->is_local(i0o, i0)) continue; const unique_ptr ddata = dtensor->get_block(i0o, i0); unique_ptr tdata = ttensor->get_block(i0o, i0); @@ -365,6 +373,7 @@ shared_ptr> Orthogonal_Basis::get_contravariant(const int istate, const bool weight) const { auto out = make_shared>(Excitations::total + (sssr_ ? 0 : nstates_-1)); for (int iext = Excitations::arbs; iext != Excitations::total; ++iext) { + const int dataindex = sssr_ ? iext + istate * Excitations::total : iext; const shared_ptr> dtensor = data_[istate]->at(iext); switch(iext) { case Excitations::arbs: @@ -375,7 +384,7 @@ for (auto& i3 : virt_) for (auto& i2 : closed_) for (auto& i1 : virt_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!dtensor->is_local(i0o, i1, i2, i3)) continue; unique_ptr data0 = dtensor->get_block(i0o, i1, i2, i3); unique_ptr data1 = dtensor->get_block(i0o, i3, i2, i1); @@ -388,7 +397,7 @@ for (auto& i2 : closed_) for (auto& i1 : virt_) for (auto& i0 : closed_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!dtensor->is_local(i0o, i0, i1, i2)) continue; unique_ptr data0 = dtensor->get_block(i0o, i0, i1, i2); unique_ptr data1 = dtensor->get_block(i0o, i2, i1, i0); @@ -442,19 +451,20 @@ for (int istate = 0; istate != nstates_; ++istate) { e0_ = e0all_[istate]; for (int iext = Excitations::arbs; iext != Excitations::total; ++iext) { + const int dataindex = sssr_ ? iext + istate * Excitations::total : iext; const shared_ptr> dtensor = denom_[istate]->at(iext); switch(iext) { case Excitations::arbs: for (auto& i3 : virt_) for (auto& i1 : virt_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!dtensor->is_local(i0o, i1, i3)) continue; unique_ptr data0(new double[dtensor->get_size(i0o, i1, i3)]); size_t iall = 0; for (int j3 = i3.offset(); j3 != i3.offset()+i3.size(); ++j3) for (int j1 = i1.offset(); j1 != i1.offset()+i1.size(); ++j1) for (int j0o = i0o.offset(); j0o != i0o.offset()+i0o.size(); ++j0o, ++iall) - data0[iall] = eig_[j3] + eig_[j1] + d->denom_xx(j0o) - e0_; + data0[iall] = eig_[j3] + eig_[j1] + d->denom(to_denom_.at(iext), istate, j0o) - e0_; denom_[istate]->at(iext)->put_block(data0, i0o, i1, i3); } break; @@ -462,7 +472,7 @@ for (auto& i3 : virt_) for (auto& i2 : closed_) for (auto& i1 : virt_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!dtensor->is_local(i0o, i1, i2, i3)) continue; unique_ptr data0(new double[dtensor->get_size(i0o, i1, i2, i3)]); size_t iall = 0; @@ -470,7 +480,7 @@ for (int j2 = i2.offset(); j2 != i2.offset()+i2.size(); ++j2) for (int j1 = i1.offset(); j1 != i1.offset()+i1.size(); ++j1) for (int j0o = i0o.offset(); j0o != i0o.offset()+i0o.size(); ++j0o, ++iall) - data0[iall] = eig_[j3] - eig_[j2] + eig_[j1] + d->denom_x(j0o) - e0_; + data0[iall] = eig_[j3] - eig_[j2] + eig_[j1] + d->denom(to_denom_.at(iext), istate, j0o) - e0_; denom_[istate]->at(iext)->put_block(data0, i0o, i1, i2, i3); } break; @@ -478,7 +488,7 @@ for (auto& i2 : closed_) for (auto& i1 : virt_) for (auto& i0 : closed_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!dtensor->is_local(i0o, i0, i1, i2)) continue; unique_ptr data0(new double[dtensor->get_size(i0o, i0, i1, i2)]); size_t iall = 0; @@ -486,59 +496,59 @@ for (int j1 = i1.offset(); j1 != i1.offset()+i1.size(); ++j1) for (int j0 = i0.offset(); j0 != i0.offset()+i0.size(); ++j0) for (int j0o = i0o.offset(); j0o != i0o.offset()+i0o.size(); ++j0o, ++iall) - data0[iall] = - eig_[j2] + eig_[j1] - eig_[j0] + d->denom_h(j0o) - e0_; + data0[iall] = - eig_[j2] + eig_[j1] - eig_[j0] + d->denom(to_denom_.at(iext), istate, j0o) - e0_; denom_[istate]->at(iext)->put_block(data0, i0o, i0, i1, i2); } break; case Excitations::risj: for (auto& i2 : closed_) for (auto& i0 : closed_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!dtensor->is_local(i0o, i0, i2)) continue; unique_ptr data0(new double[dtensor->get_size(i0o, i0, i2)]); size_t iall = 0; for (int j2 = i2.offset(); j2 != i2.offset()+i2.size(); ++j2) for (int j0 = i0.offset(); j0 != i0.offset()+i0.size(); ++j0) for (int j0o = i0o.offset(); j0o != i0o.offset()+i0o.size(); ++j0o, ++iall) - data0[iall] = - eig_[j2] - eig_[j0] + d->denom_hh(j0o) - e0_; + data0[iall] = - eig_[j2] - eig_[j0] + d->denom(to_denom_.at(iext), istate, j0o) - e0_; denom_[istate]->at(iext)->put_block(data0, i0o, i0, i2); } break; case Excitations::airs: for (auto& i1 : virt_) for (auto& i0 : closed_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!dtensor->is_local(i0o, i0, i1)) continue; unique_ptr data0(new double[dtensor->get_size(i0o, i0, i1)]); size_t iall = 0; for (int j1 = i1.offset(); j1 != i1.offset()+i1.size(); ++j1) for (int j0 = i0.offset(); j0 != i0.offset()+i0.size(); ++j0) for (int j0o = i0o.offset(); j0o != i0o.offset()+i0o.size(); ++j0o, ++iall) - data0[iall] = eig_[j1] - eig_[j0] + d->denom_xh(j0o) - e0_; + data0[iall] = eig_[j1] - eig_[j0] + d->denom(to_denom_.at(iext), istate, j0o) - e0_; denom_[istate]->at(iext)->put_block(data0, i0o, i0, i1); } break; case Excitations::arst: for (auto& i1 : virt_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!dtensor->is_local(i0o, i1)) continue; unique_ptr data0(new double[dtensor->get_size(i0o, i1)]); size_t iall = 0; for (int j1 = i1.offset(); j1 != i1.offset()+i1.size(); ++j1) for (int j0o = i0o.offset(); j0o != i0o.offset()+i0o.size(); ++j0o, ++iall) - data0[iall] = eig_[j1] + d->denom_xxh(j0o) - e0_; + data0[iall] = eig_[j1] + d->denom(to_denom_.at(iext), istate, j0o) - e0_; denom_[istate]->at(iext)->put_block(data0, i0o, i1); } break; case Excitations::rist: for (auto& i0 : closed_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!dtensor->is_local(i0o, i0)) continue; unique_ptr data0(new double[dtensor->get_size(i0o, i0)]); size_t iall = 0; for (int j0 = i0.offset(); j0 != i0.offset()+i0.size(); ++j0) for (int j0o = i0o.offset(); j0o != i0o.offset()+i0o.size(); ++j0o, ++iall) - data0[iall] = - eig_[j0] + d->denom_xhh(j0o) - e0_; + data0[iall] = - eig_[j0] + d->denom(to_denom_.at(iext), istate, j0o) - e0_; denom_[istate]->at(iext)->put_block(data0, i0o, i0); } break; @@ -577,21 +587,23 @@ for (int ist = 0; ist != nstates_; ++ist) { if (!t->at(ist)) continue; for (int iext = Excitations::arbs; iext != Excitations::total; ++iext) { + const int dataindex = sssr_ ? iext + istate * Excitations::total : iext; shared_ptr> tensor = t->at(ist); + const MatView ishalf = (iext != Excitations::aibj) ? shalf(iext, ist) : shalf(0, ist); switch(iext) { case Excitations::arbs: for (auto& i2 : active_) for (auto& i0 : active_) { - auto create_transp = [&iext, this](const int i, const Index& I0, const Index& I2, const Index& I0o) { + auto create_transp = [this](const MatView shalf, const Index& I0, const Index& I2, const Index& I0o) { unique_ptr out(new double[I0.size()*I2.size()*I0o.size()]); for (int j2 = I2.offset(), k = 0; j2 != I2.offset()+I2.size(); ++j2) for (int j0 = I0.offset(); j0 != I0.offset()+I0.size(); ++j0, ++k) - copy_n(shalf_[iext]->element_ptr(I0o.offset(),(j0-nclosed_)+(j2-nclosed_)*nact_ + i*nact_*nact_), + copy_n(shalf.element_ptr(I0o.offset(),(j0-nclosed_)+(j2-nclosed_)*nact_), I0o.size(), out.get()+I0o.size()*k); return move(out); }; - for (auto& i0o : interm_[iext]) { - unique_ptr transp = create_transp(ist, i0, i2, i0o); + for (auto& i0o : interm_[dataindex]) { + unique_ptr transp = create_transp(ishalf, i0, i2, i0o); for (auto& i3 : virt_) for (auto& i1 : virt_) { if (!data_[istate]->at(iext)->is_local(i0o, i1, i3)) continue; @@ -610,14 +622,14 @@ break; case Excitations::arbi: for (auto& i0 : active_) { - auto create_transp = [&iext, this](const int i, const Index& I0, const Index& I0o) { + auto create_transp = [this](const MatView shalf, const Index& I0, const Index& I0o) { unique_ptr out(new double[I0.size()*I0o.size()]); for (int j0 = I0.offset(), k = 0; j0 != I0.offset()+I0.size(); ++j0, ++k) - copy_n(shalf_[iext]->element_ptr(I0o.offset(), j0-nclosed_ + i*nact_), I0o.size(), out.get()+I0o.size()*k); + copy_n(shalf.element_ptr(I0o.offset(), j0-nclosed_), I0o.size(), out.get()+I0o.size()*k); return move(out); }; - for (auto& i0o : interm_[iext]) { - unique_ptr transp = create_transp(ist, i0, i0o); + for (auto& i0o : interm_[dataindex]) { + unique_ptr transp = create_transp(ishalf, i0, i0o); for (auto& i3 : virt_) for (auto& i2 : closed_) for (auto& i1 : virt_) { @@ -639,14 +651,14 @@ break; case Excitations::airj: for (auto& i3 : active_) { - auto create_transp = [&iext, this](const int i, const Index& I3, const Index& I0o) { + auto create_transp = [this](const MatView shalf, const Index& I3, const Index& I0o) { unique_ptr out(new double[I3.size()*I0o.size()]); for (int j3 = I3.offset(), k = 0; j3 != I3.offset()+I3.size(); ++j3, ++k) - copy_n(shalf_[iext]->element_ptr(I0o.offset(),j3-nclosed_ + i*nact_), I0o.size(), out.get()+I0o.size()*k); + copy_n(shalf.element_ptr(I0o.offset(),j3-nclosed_), I0o.size(), out.get()+I0o.size()*k); return move(out); }; - for (auto& i0o : interm_[iext]) { - unique_ptr transp = create_transp(ist, i3, i0o); + for (auto& i0o : interm_[dataindex]) { + unique_ptr transp = create_transp(ishalf, i3, i0o); for (auto& i2 : closed_) for (auto& i1 : virt_) for (auto& i0 : closed_) { @@ -669,16 +681,16 @@ case Excitations::risj: for (auto& i3 : active_) for (auto& i1 : active_) { - auto create_transp = [&iext, this](const int i, const Index& I1, const Index& I3, const Index& I0o) { + auto create_transp = [this](const MatView shalf, const Index& I1, const Index& I3, const Index& I0o) { unique_ptr out(new double[I1.size()*I3.size()*I0o.size()]); for (int j3 = I3.offset(), k = 0; j3 != I3.offset()+I3.size(); ++j3) for (int j1 = I1.offset(); j1 != I1.offset()+I1.size(); ++j1, ++k) - copy_n(shalf_[iext]->element_ptr(I0o.offset(),(j1-nclosed_)+(j3-nclosed_)*nact_ + i*nact_*nact_), + copy_n(shalf.element_ptr(I0o.offset(),(j1-nclosed_)+(j3-nclosed_)*nact_), I0o.size(), out.get()+I0o.size()*k); return move(out); }; - for (auto& i0o : interm_[iext]) { - unique_ptr transp = create_transp(ist, i1, i3, i0o); + for (auto& i0o : interm_[dataindex]) { + unique_ptr transp = create_transp(ishalf, i1, i3, i0o); for (auto& i2 : closed_) for (auto& i0 : closed_) { if (!data_[istate]->at(iext)->is_local(i0o, i0, i2)) continue; @@ -698,19 +710,19 @@ case Excitations::airs: for (auto& i3 : active_) for (auto& i2 : active_) { - auto create_transp = [&iext, this](const int i, const Index& I2, const Index& I3, const Index& I0o) { + auto create_transp = [this](const MatView shalf, const Index& I2, const Index& I3, const Index& I0o) { unique_ptr out(new double[I2.size()*I3.size()*I0o.size()*2]); for (int j3 = I3.offset(), k = 0; j3 != I3.offset()+I3.size(); ++j3) for (int j2 = I2.offset(); j2 != I2.offset()+I2.size(); ++j2, ++k) { - copy_n(shalf_[iext]->element_ptr(I0o.offset(), (j2-nclosed_)+(j3-nclosed_)*nact_ + 2*i*nact_*nact_), + copy_n(shalf.element_ptr(I0o.offset(), (j2-nclosed_)+(j3-nclosed_)*nact_), I0o.size(), out.get()+I0o.size()*k); - copy_n(shalf_[iext]->element_ptr(I0o.offset(), (j2-nclosed_)+(j3-nclosed_)*nact_ + (2*i+1)*nact_*nact_), + copy_n(shalf.element_ptr(I0o.offset(), (j2-nclosed_)+(j3-nclosed_)*nact_ + nact_*nact_), I0o.size(), out.get()+I0o.size()*(k+I2.size()*I3.size())); } return move(out); }; - for (auto& i0o : interm_[iext]) { - unique_ptr transp = create_transp(ist, i2, i3, i0o); + for (auto& i0o : interm_[dataindex]) { + unique_ptr transp = create_transp(ishalf, i2, i3, i0o); for (auto& i1 : virt_) for (auto& i0 : closed_) { if (!data_[istate]->at(iext)->is_local(i0o, i0, i1)) continue; @@ -735,17 +747,17 @@ for (auto& i3 : active_) for (auto& i2 : active_) for (auto& i0 : active_) { - auto create_transp = [&iext, this](const int i, const Index& I0, const Index& I2, const Index& I3, const Index& I0o) { + auto create_transp = [this](const MatView shalf, const Index& I0, const Index& I2, const Index& I3, const Index& I0o) { unique_ptr out(new double[I0.size()*I2.size()*I3.size()*I0o.size()]); for (int j3 = I3.offset(), k = 0; j3 != I3.offset()+I3.size(); ++j3) for (int j2 = I2.offset(); j2 != I2.offset()+I2.size(); ++j2) for (int j0 = I0.offset(); j0 != I0.offset()+I0.size(); ++j0, ++k) - copy_n(shalf_[iext]->element_ptr(I0o.offset(),j0-nclosed_+nact_*(j2-nclosed_+nact_*(j3-nclosed_)) + i*nact_*nact_*nact_), + copy_n(shalf.element_ptr(I0o.offset(),j0-nclosed_+nact_*(j2-nclosed_+nact_*(j3-nclosed_))), I0o.size(), out.get()+I0o.size()*k); return move(out); }; - for (auto& i0o : interm_[iext]) { - unique_ptr transp = create_transp(ist, i0, i2, i3, i0o); + for (auto& i0o : interm_[dataindex]) { + unique_ptr transp = create_transp(ishalf, i0, i2, i3, i0o); for (auto& i1 : virt_) { if (!data_[istate]->at(iext)->is_local(i0o, i1)) continue; const size_t blocksize = tensor->get_size(i2, i3, i0, i1); @@ -765,17 +777,17 @@ for (auto& i3 : active_) for (auto& i1 : active_) for (auto& i0 : active_) { - auto create_transp = [&iext, this](const int i, const Index& I0, const Index& I1, const Index& I3, const Index& I0o) { + auto create_transp = [this](const MatView shalf, const Index& I0, const Index& I1, const Index& I3, const Index& I0o) { unique_ptr out(new double[I0.size()*I1.size()*I3.size()*I0o.size()]); for (int j3 = I3.offset(), k = 0; j3 != I3.offset()+I3.size(); ++j3) for (int j1 = I1.offset(); j1 != I1.offset()+I1.size(); ++j1) for (int j0 = I0.offset(); j0 != I0.offset()+I0.size(); ++j0, ++k) - copy_n(shalf_[iext]->element_ptr(I0o.offset(),j0-nclosed_+nact_*(j1-nclosed_+nact_*(j3-nclosed_)) + i*nact_*nact_*nact_), + copy_n(shalf.element_ptr(I0o.offset(),j0-nclosed_+nact_*(j1-nclosed_+nact_*(j3-nclosed_))), I0o.size(), out.get()+I0o.size()*k); return move(out); }; - for (auto& i0o : interm_[iext]) { - unique_ptr transp = create_transp(ist, i0, i1, i3, i0o); + for (auto& i0o : interm_[dataindex]) { + unique_ptr transp = create_transp(ishalf, i0, i1, i3, i0o); for (auto& i2 : closed_) { if (!data_[istate]->at(iext)->is_local(i0o, i2)) continue; const size_t blocksize = tensor->get_size(i2, i3, i0, i1); @@ -798,7 +810,7 @@ for (auto& i2 : closed_) for (auto& i1 : virt_) for (auto& i0 : closed_) { - if (!data_[istate]->at(iext)->is_local(i0, i1, i2, i3)) continue; + if (!data_[istate]->at(pos)->is_local(i0, i1, i2, i3)) continue; unique_ptr data0 = t->at(ist)->get_block(i0, i1, i2, i3); const unique_ptr data1 = t->at(ist)->get_block(i0, i3, i2, i1); sort_indices<0,3,2,1,2,12,1,12>(data1, data0, i0.size(), i3.size(), i2.size(), i1.size()); @@ -816,284 +828,284 @@ shared_ptr> Orthogonal_Basis::transform_to_redundant(const int istate) const { // we put the transformed data in out. auto out = make_shared>(nstates_); - for (int ist = 0; ist != nstates_; ++ist) { - if (!sssr_ || ist == istate) { - (*out)[ist] = init_amplitude(); - for (int iext = Excitations::arbs; iext != Excitations::total; ++iext) { - shared_ptr> tensor = out->at(ist); - shared_ptr> dtensor = data_[istate]->at(iext); - switch(iext) { - case Excitations::arbs: - for (auto& i2 : active_) - for (auto& i0 : active_) { - auto create_transp = [&iext, this](const int i, const Index& I0, const Index& I2, const Index& I0o) { - unique_ptr out(new double[I0.size()*I2.size()*I0o.size()]); - for (int j2 = I2.offset(), k = 0; j2 != I2.offset()+I2.size(); ++j2) - for (int j0 = I0.offset(); j0 != I0.offset()+I0.size(); ++j0, ++k) - copy_n(shalf_[iext]->element_ptr(I0o.offset(),(j0-nclosed_)+(j2-nclosed_)*nact_ + i*nact_*nact_), - I0o.size(), out.get()+I0o.size()*k); - return move(out); - }; - for (auto& i0o : interm_[iext]) { - unique_ptr transp = create_transp(ist, i0, i2, i0o); - for (auto& i3 : virt_) - for (auto& i1 : virt_) { - if (!tensor->is_local(i0, i1, i2, i3)) continue; - const size_t blocksize = tensor->get_size(i0, i1, i2, i3); - unique_ptr interm = dtensor->get_block(i0o, i1, i3); - const size_t interm_size = dtensor->get_size(i0o, i1, i3); - if (imag_) { - const unique_ptr denom = denom_[istate]->at(iext)->get_block(i0o, i1, i3); - for (size_t i = 0; i != interm_size; ++i) { - interm[i] *= denom[i]; - } - } - unique_ptr data0(new double[blocksize]); - btas::gemm_impl::call(CblasColMajor, CblasConjTrans, CblasNoTrans, i0.size()*i2.size(), i1.size()*i3.size(), i0o.size(), - sqrt(0.5), transp.get(), i0o.size(), interm.get(), i0o.size(), 0.0, data0.get(), i0.size()*i2.size()); - unique_ptr data1(new double[blocksize]); - sort_indices<0,2,1,3,0,1,1,1>(data0.get(), data1.get(), i0.size(), i2.size(), i1.size(), i3.size()); - tensor->add_block(data1, i0, i1, i2, i3); - } - } - } - break; - case Excitations::arbi: + if (sssr_ && istate != ist) continue; + (*out)[ist] = init_amplitude(); + for (int iext = Excitations::arbs; iext != Excitations::total; ++iext) { + const int dataindex = sssr_ ? iext + istate * Excitations::total : iext; + shared_ptr> tensor = out->at(ist); + shared_ptr> dtensor = data_[istate]->at(iext); + const MatView ishalf = (iext != Excitations::aibj) ? shalf(iext, ist) : shalf(0, ist); + switch(iext) { + case Excitations::arbs: + for (auto& i2 : active_) for (auto& i0 : active_) { - auto create_transp = [&iext, this](const int i, const Index& I0, const Index& I0o) { - unique_ptr out(new double[I0.size()*I0o.size()]); - for (int j0 = I0.offset(), k = 0; j0 != I0.offset()+I0.size(); ++j0, ++k) - copy_n(shalf_[iext]->element_ptr(I0o.offset(), j0-nclosed_ + i*nact_), I0o.size(), out.get()+I0o.size()*k); + auto create_transp = [this](const MatView shalf, const Index& I0, const Index& I2, const Index& I0o) { + unique_ptr out(new double[I0.size()*I2.size()*I0o.size()]); + for (int j2 = I2.offset(), k = 0; j2 != I2.offset()+I2.size(); ++j2) + for (int j0 = I0.offset(); j0 != I0.offset()+I0.size(); ++j0, ++k) + copy_n(shalf.element_ptr(I0o.offset(),(j0-nclosed_)+(j2-nclosed_)*nact_), + I0o.size(), out.get()+I0o.size()*k); return move(out); }; - for (auto& i0o : interm_[iext]) { - unique_ptr transp = create_transp(ist, i0, i0o); + for (auto& i0o : interm_[dataindex]) { + unique_ptr transp = create_transp(ishalf, i0, i2, i0o); for (auto& i3 : virt_) - for (auto& i2 : closed_) - for (auto& i1 : virt_) { - if (!tensor->is_local(i0, i1, i2, i3)) continue; - const size_t blocksize = tensor->get_size(i0, i1, i2, i3); - unique_ptr interm = dtensor->get_block(i0o, i1, i2, i3); - const size_t interm_size = dtensor->get_size(i0o, i1, i2, i3); - if (imag_) { - const unique_ptr denom = denom_[istate]->at(iext)->get_block(i0o, i1, i2, i3); - for (size_t i = 0; i != interm_size; ++i) { - interm[i] *= denom[i]; - } + for (auto& i1 : virt_) { + if (!tensor->is_local(i0, i1, i2, i3)) continue; + const size_t blocksize = tensor->get_size(i0, i1, i2, i3); + unique_ptr interm = dtensor->get_block(i0o, i1, i3); + const size_t interm_size = dtensor->get_size(i0o, i1, i3); + if (imag_) { + const unique_ptr denom = denom_[istate]->at(iext)->get_block(i0o, i1, i3); + for (size_t i = 0; i != interm_size; ++i) { + interm[i] *= denom[i]; } - unique_ptr data0(new double[blocksize]); - btas::gemm_impl::call(CblasColMajor, CblasConjTrans, CblasNoTrans, i0.size(), i1.size()*i2.size()*i3.size(), i0o.size(), - 1.0, transp.get(), i0o.size(), interm.get(), i0o.size(), 0.0, data0.get(), i0.size()); - tensor->add_block(data0, i0, i1, i2, i3); } + unique_ptr data0(new double[blocksize]); + btas::gemm_impl::call(CblasColMajor, CblasConjTrans, CblasNoTrans, i0.size()*i2.size(), i1.size()*i3.size(), i0o.size(), + sqrt(0.5), transp.get(), i0o.size(), interm.get(), i0o.size(), 0.0, data0.get(), i0.size()*i2.size()); + unique_ptr data1(new double[blocksize]); + sort_indices<0,2,1,3,0,1,1,1>(data0.get(), data1.get(), i0.size(), i2.size(), i1.size(), i3.size()); + tensor->add_block(data1, i0, i1, i2, i3); + } } } - break; - case Excitations::airj: - for (auto& i3 : active_) { - auto create_transp = [&iext, this](const int i, const Index& I3, const Index& I0o) { - unique_ptr out(new double[I3.size()*I0o.size()]); - for (int j3 = I3.offset(), k = 0; j3 != I3.offset()+I3.size(); ++j3, ++k) - copy_n(shalf_[iext]->element_ptr(I0o.offset(),j3-nclosed_ + i*nact_), I0o.size(), out.get()+I0o.size()*k); + break; + case Excitations::arbi: + for (auto& i0 : active_) { + auto create_transp = [this](const MatView shalf, const Index& I0, const Index& I0o) { + unique_ptr out(new double[I0.size()*I0o.size()]); + for (int j0 = I0.offset(), k = 0; j0 != I0.offset()+I0.size(); ++j0, ++k) + copy_n(shalf.element_ptr(I0o.offset(), j0-nclosed_), I0o.size(), out.get()+I0o.size()*k); + return move(out); + }; + for (auto& i0o : interm_[dataindex]) { + unique_ptr transp = create_transp(ishalf, i0, i0o); + for (auto& i3 : virt_) + for (auto& i2 : closed_) + for (auto& i1 : virt_) { + if (!tensor->is_local(i0, i1, i2, i3)) continue; + const size_t blocksize = tensor->get_size(i0, i1, i2, i3); + unique_ptr interm = dtensor->get_block(i0o, i1, i2, i3); + const size_t interm_size = dtensor->get_size(i0o, i1, i2, i3); + if (imag_) { + const unique_ptr denom = denom_[istate]->at(iext)->get_block(i0o, i1, i2, i3); + for (size_t i = 0; i != interm_size; ++i) { + interm[i] *= denom[i]; + } + } + unique_ptr data0(new double[blocksize]); + btas::gemm_impl::call(CblasColMajor, CblasConjTrans, CblasNoTrans, i0.size(), i1.size()*i2.size()*i3.size(), i0o.size(), + 1.0, transp.get(), i0o.size(), interm.get(), i0o.size(), 0.0, data0.get(), i0.size()); + tensor->add_block(data0, i0, i1, i2, i3); + } + } + } + break; + case Excitations::airj: + for (auto& i3 : active_) { + auto create_transp = [this](const MatView shalf, const Index& I3, const Index& I0o) { + unique_ptr out(new double[I3.size()*I0o.size()]); + for (int j3 = I3.offset(), k = 0; j3 != I3.offset()+I3.size(); ++j3, ++k) + copy_n(shalf.element_ptr(I0o.offset(),j3-nclosed_), I0o.size(), out.get()+I0o.size()*k); + return move(out); + }; + for (auto& i0o : interm_[dataindex]) { + unique_ptr transp = create_transp(ishalf, i3, i0o); + for (auto& i2 : closed_) + for (auto& i1 : virt_) + for (auto& i0 : closed_) { + if (!dtensor->is_local(i0o, i0, i1, i2)) continue; + const size_t blocksize = tensor->get_size(i0, i1, i2, i3); + unique_ptr interm = dtensor->get_block(i0o, i0, i1, i2); + const size_t interm_size = dtensor->get_size(i0o, i0, i1, i2); + if (imag_) { + const unique_ptr denom = denom_[istate]->at(iext)->get_block(i0o,i0, i1, i2); + for (size_t i = 0; i != interm_size; ++i) { + interm[i] *= denom[i]; + } + } + unique_ptr interm2(new double[interm_size]); + sort_indices<1,2,3,0,0,1,1,1>(interm.get(), interm2.get(), i0o.size(), i0.size(), i1.size(), i2.size()); + unique_ptr data0(new double[blocksize]); + btas::gemm_impl::call(CblasColMajor, CblasNoTrans, CblasNoTrans, i0.size()*i1.size()*i2.size(), i3.size(), i0o.size(), + 1.0, interm2.get(), i0.size()*i1.size()*i2.size(), transp.get(), i0o.size(), 0.0, data0.get(), i0.size()*i1.size()*i2.size()); + tensor->add_block(data0, i0, i1, i2, i3); + } + } + } + break; + case Excitations::risj: + for (auto& i3 : active_) + for (auto& i1 : active_) { + auto create_transp = [this](const MatView shalf, const Index& I1, const Index& I3, const Index& I0o) { + unique_ptr out(new double[I1.size()*I3.size()*I0o.size()]); + for (int j3 = I3.offset(), k = 0; j3 != I3.offset()+I3.size(); ++j3) + for (int j1 = I1.offset(); j1 != I1.offset()+I1.size(); ++j1, ++k) + copy_n(shalf.element_ptr(I0o.offset(),(j1-nclosed_)+(j3-nclosed_)*nact_), + I0o.size(), out.get()+I0o.size()*k); return move(out); }; - for (auto& i0o : interm_[iext]) { - unique_ptr transp = create_transp(ist, i3, i0o); + for (auto& i0o : interm_[dataindex]) { + unique_ptr transp = create_transp(ishalf, i1, i3, i0o); for (auto& i2 : closed_) - for (auto& i1 : virt_) - for (auto& i0 : closed_) { - if (!dtensor->is_local(i0o, i0, i1, i2)) continue; - const size_t blocksize = tensor->get_size(i0, i1, i2, i3); - unique_ptr interm = dtensor->get_block(i0o, i0, i1, i2); - const size_t interm_size = dtensor->get_size(i0o, i0, i1, i2); - if (imag_) { - const unique_ptr denom = denom_[istate]->at(iext)->get_block(i0o,i0, i1, i2); - for (size_t i = 0; i != interm_size; ++i) { - interm[i] *= denom[i]; - } + for (auto& i0 : closed_) { + if (!tensor->is_local(i0, i1, i2, i3)) continue; + const size_t blocksize = tensor->get_size(i0, i1, i2, i3); + unique_ptr interm = dtensor->get_block(i0o, i0, i2); + const size_t interm_size = dtensor->get_size(i0o, i0, i2); + if (imag_) { + const unique_ptr denom = denom_[istate]->at(iext)->get_block(i0o, i0, i2); + for (size_t i = 0; i != interm_size; ++i) { + interm[i] *= denom[i]; + } + } + unique_ptr interm2(new double[interm_size]); + sort_indices<1,2,0,0,1,1,1>(interm.get(), interm2.get(), i0o.size(), i0.size(), i2.size()); + unique_ptr data0(new double[blocksize]); + btas::gemm_impl::call(CblasColMajor, CblasNoTrans, CblasNoTrans, i0.size()*i2.size(), i1.size()*i3.size(), i0o.size(), + sqrt(0.5), interm2.get(), i0.size()*i2.size(), transp.get(), i0o.size(), 0.0, data0.get(), i0.size()*i2.size()); + unique_ptr data1(new double[blocksize]); + sort_indices<0,2,1,3,0,1,1,1>(data0, data1, i0.size(), i2.size(), i1.size(), i3.size()); + tensor->add_block(data1, i0, i1, i2, i3); + } + } + } + break; + case Excitations::airs: + for (auto& i3 : active_) + for (auto& i2 : active_) { + auto create_transp = [this](const MatView shalf, const Index& I2, const Index& I3, const Index& I0o) { + unique_ptr out(new double[I2.size()*I3.size()*I0o.size()*2]); + for (int j3 = I3.offset(), k = 0; j3 != I3.offset()+I3.size(); ++j3) + for (int j2 = I2.offset(); j2 != I2.offset()+I2.size(); ++j2, ++k) { + copy_n(shalf.element_ptr(I0o.offset(), (j2-nclosed_)+(j3-nclosed_)*nact_), + I0o.size(), out.get()+I0o.size()*k); + copy_n(shalf.element_ptr(I0o.offset(), (j2-nclosed_)+(j3-nclosed_)*nact_ + nact_*nact_), + I0o.size(), out.get()+I0o.size()*(k+I2.size()*I3.size())); + } + return move(out); + }; + for (auto& i0o : interm_[dataindex]) { + unique_ptr transp = create_transp(ishalf, i2, i3, i0o); + for (auto& i1 : virt_) + for (auto& i0 : closed_) { + if (!tensor->is_local(i0, i1, i2, i3)) continue; + const size_t blocksize = tensor->get_size(i0, i1, i2, i3); + unique_ptr interm = dtensor->get_block(i0o, i0, i1); + const size_t interm_size = dtensor->get_size(i0o, i0, i1); + if (imag_) { + const unique_ptr denom = denom_[istate]->at(iext)->get_block(i0o, i0, i1); + for (size_t i = 0; i != interm_size; ++i) { + interm[i] *= denom[i]; } - unique_ptr interm2(new double[interm_size]); - sort_indices<1,2,3,0,0,1,1,1>(interm.get(), interm2.get(), i0o.size(), i0.size(), i1.size(), i2.size()); - unique_ptr data0(new double[blocksize]); - btas::gemm_impl::call(CblasColMajor, CblasNoTrans, CblasNoTrans, i0.size()*i1.size()*i2.size(), i3.size(), i0o.size(), - 1.0, interm2.get(), i0.size()*i1.size()*i2.size(), transp.get(), i0o.size(), 0.0, data0.get(), i0.size()*i1.size()*i2.size()); - tensor->add_block(data0, i0, i1, i2, i3); } + unique_ptr interm2(new double[dtensor->get_size(i0o, i0, i1)]); + sort_indices<1,2,0,0,1,1,1>(interm.get(), interm2.get(), i0o.size(), i0.size(), i1.size()); + unique_ptr data0(new double[blocksize*2]); + btas::gemm_impl::call(CblasColMajor, CblasNoTrans, CblasNoTrans, i0.size()*i1.size(), i2.size()*i3.size()*2, i0o.size(), + 1.0, interm2.get(), i0.size()*i1.size(), transp.get(), i0o.size(), 0.0, data0.get(), i0.size()*i1.size()); + unique_ptr data1(new double[blocksize]); + unique_ptr data2(new double[blocksize]); + copy_n(data0.get(), blocksize, data1.get()); + sort_indices<2,1,0,3,0,1,1,1>(data0.get()+blocksize, data2.get(), i0.size(), i1.size(), i2.size(), i3.size()); + tensor->add_block(data1, i0, i1, i2, i3); + tensor->add_block(data2, i2, i1, i0, i3); + } } } - break; - case Excitations::risj: - for (auto& i3 : active_) - for (auto& i1 : active_) { - auto create_transp = [&iext, this](const int i, const Index& I1, const Index& I3, const Index& I0o) { - unique_ptr out(new double[I1.size()*I3.size()*I0o.size()]); + break; + case Excitations::arst: + for (auto& i3 : active_) + for (auto& i2 : active_) + for (auto& i0 : active_) { + auto create_transp = [this](const MatView shalf, const Index& I0, const Index& I2, const Index& I3, const Index& I0o) { + unique_ptr out(new double[I0.size()*I2.size()*I3.size()*I0o.size()]); for (int j3 = I3.offset(), k = 0; j3 != I3.offset()+I3.size(); ++j3) - for (int j1 = I1.offset(); j1 != I1.offset()+I1.size(); ++j1, ++k) - copy_n(shalf_[iext]->element_ptr(I0o.offset(),(j1-nclosed_)+(j3-nclosed_)*nact_ + i*nact_*nact_), - I0o.size(), out.get()+I0o.size()*k); + for (int j2 = I2.offset(); j2 != I2.offset()+I2.size(); ++j2) + for (int j0 = I0.offset(); j0 != I0.offset()+I0.size(); ++j0, ++k) + copy_n(shalf.element_ptr(I0o.offset(),j0-nclosed_+nact_*(j2-nclosed_+nact_*(j3-nclosed_))), + I0o.size(), out.get()+I0o.size()*k); return move(out); }; - for (auto& i0o : interm_[iext]) { - unique_ptr transp = create_transp(ist, i1, i3, i0o); - for (auto& i2 : closed_) - for (auto& i0 : closed_) { - if (!tensor->is_local(i0, i1, i2, i3)) continue; - const size_t blocksize = tensor->get_size(i0, i1, i2, i3); - unique_ptr interm = dtensor->get_block(i0o, i0, i2); - const size_t interm_size = dtensor->get_size(i0o, i0, i2); - if (imag_) { - const unique_ptr denom = denom_[istate]->at(iext)->get_block(i0o, i0, i2); - for (size_t i = 0; i != interm_size; ++i) { - interm[i] *= denom[i]; - } + for (auto& i0o : interm_[dataindex]) { + unique_ptr transp = create_transp(ishalf, i0, i2, i3, i0o); + for (auto& i1 : virt_) { + if (!tensor->is_local(i0, i1, i2, i3)) continue; + const size_t blocksize = tensor->get_size(i0, i1, i2, i3); + unique_ptr interm = dtensor->get_block(i0o, i1); + const size_t interm_size = dtensor->get_size(i0o, i1); + if (imag_) { + const unique_ptr denom = denom_[istate]->at(iext)->get_block(i0o, i1); + for (size_t i = 0; i != interm_size; ++i) { + interm[i] *= denom[i]; } - unique_ptr interm2(new double[interm_size]); - sort_indices<1,2,0,0,1,1,1>(interm.get(), interm2.get(), i0o.size(), i0.size(), i2.size()); - unique_ptr data0(new double[blocksize]); - btas::gemm_impl::call(CblasColMajor, CblasNoTrans, CblasNoTrans, i0.size()*i2.size(), i1.size()*i3.size(), i0o.size(), - sqrt(0.5), interm2.get(), i0.size()*i2.size(), transp.get(), i0o.size(), 0.0, data0.get(), i0.size()*i2.size()); - unique_ptr data1(new double[blocksize]); - sort_indices<0,2,1,3,0,1,1,1>(data0, data1, i0.size(), i2.size(), i1.size(), i3.size()); - tensor->add_block(data1, i0, i1, i2, i3); } + unique_ptr data0(new double[blocksize]); + btas::gemm_impl::call(CblasColMajor, CblasConjTrans, CblasNoTrans, i0.size()*i2.size()*i3.size(), i1.size(), i0o.size(), + 1.0, transp.get(), i0o.size(), interm.get(), i0o.size(), 0.0, data0.get(), i0.size()*i2.size()*i3.size()); + unique_ptr data1(new double[blocksize]); + sort_indices<0,3,1,2,0,1,1,1>(data0.get(), data1.get(), i0.size(), i2.size(), i3.size(), i1.size()); + tensor->add_block(data1, i0, i1, i2, i3); + } } } - break; - case Excitations::airs: - for (auto& i3 : active_) - for (auto& i2 : active_) { - auto create_transp = [&iext, this](const int i, const Index& I2, const Index& I3, const Index& I0o) { - unique_ptr out(new double[I2.size()*I3.size()*I0o.size()*2]); + break; + case Excitations::rist: + for (auto& i3 : active_) + for (auto& i1 : active_) + for (auto& i0 : active_) { + auto create_transp = [this](const MatView shalf, const Index& I0, const Index& I1, const Index& I3, const Index& I0o) { + unique_ptr out(new double[I0.size()*I1.size()*I3.size()*I0o.size()]); for (int j3 = I3.offset(), k = 0; j3 != I3.offset()+I3.size(); ++j3) - for (int j2 = I2.offset(); j2 != I2.offset()+I2.size(); ++j2, ++k) { - copy_n(shalf_[iext]->element_ptr(I0o.offset(), (j2-nclosed_)+(j3-nclosed_)*nact_ + 2*i*nact_*nact_), - I0o.size(), out.get()+I0o.size()*k); - copy_n(shalf_[iext]->element_ptr(I0o.offset(), (j2-nclosed_)+(j3-nclosed_)*nact_ + (2*i+1)*nact_*nact_), - I0o.size(), out.get()+I0o.size()*(k+I2.size()*I3.size())); - } + for (int j1 = I1.offset(); j1 != I1.offset()+I1.size(); ++j1) + for (int j0 = I0.offset(); j0 != I0.offset()+I0.size(); ++j0, ++k) + copy_n(shalf.element_ptr(I0o.offset(),j0-nclosed_+nact_*(j1-nclosed_+nact_*(j3-nclosed_))), + I0o.size(), out.get()+I0o.size()*k); return move(out); }; - for (auto& i0o : interm_[iext]) { - unique_ptr transp = create_transp(ist, i2, i3, i0o); - for (auto& i1 : virt_) - for (auto& i0 : closed_) { - if (!tensor->is_local(i0, i1, i2, i3)) continue; - const size_t blocksize = tensor->get_size(i0, i1, i2, i3); - unique_ptr interm = dtensor->get_block(i0o, i0, i1); - const size_t interm_size = dtensor->get_size(i0o, i0, i1); - if (imag_) { - const unique_ptr denom = denom_[istate]->at(iext)->get_block(i0o, i0, i1); - for (size_t i = 0; i != interm_size; ++i) { - interm[i] *= denom[i]; - } - } - unique_ptr interm2(new double[dtensor->get_size(i0o, i0, i1)]); - sort_indices<1,2,0,0,1,1,1>(interm.get(), interm2.get(), i0o.size(), i0.size(), i1.size()); - unique_ptr data0(new double[blocksize*2]); - btas::gemm_impl::call(CblasColMajor, CblasNoTrans, CblasNoTrans, i0.size()*i1.size(), i2.size()*i3.size()*2, i0o.size(), - 1.0, interm2.get(), i0.size()*i1.size(), transp.get(), i0o.size(), 0.0, data0.get(), i0.size()*i1.size()); - unique_ptr data1(new double[blocksize]); - unique_ptr data2(new double[blocksize]); - copy_n(data0.get(), blocksize, data1.get()); - sort_indices<2,1,0,3,0,1,1,1>(data0.get()+blocksize, data2.get(), i0.size(), i1.size(), i2.size(), i3.size()); - tensor->add_block(data1, i0, i1, i2, i3); - tensor->add_block(data2, i2, i1, i0, i3); - } - } - } - break; - case Excitations::arst: - for (auto& i3 : active_) - for (auto& i2 : active_) - for (auto& i0 : active_) { - auto create_transp = [&iext, this](const int i, const Index& I0, const Index& I2, const Index& I3, const Index& I0o) { - unique_ptr out(new double[I0.size()*I2.size()*I3.size()*I0o.size()]); - for (int j3 = I3.offset(), k = 0; j3 != I3.offset()+I3.size(); ++j3) - for (int j2 = I2.offset(); j2 != I2.offset()+I2.size(); ++j2) - for (int j0 = I0.offset(); j0 != I0.offset()+I0.size(); ++j0, ++k) - copy_n(shalf_[iext]->element_ptr(I0o.offset(),j0-nclosed_+nact_*(j2-nclosed_+nact_*(j3-nclosed_)) + i*nact_*nact_*nact_), - I0o.size(), out.get()+I0o.size()*k); - return move(out); - }; - for (auto& i0o : interm_[iext]) { - unique_ptr transp = create_transp(ist, i0, i2, i3, i0o); - for (auto& i1 : virt_) { - if (!tensor->is_local(i0, i1, i2, i3)) continue; - const size_t blocksize = tensor->get_size(i0, i1, i2, i3); - unique_ptr interm = dtensor->get_block(i0o, i1); - const size_t interm_size = dtensor->get_size(i0o, i1); - if (imag_) { - const unique_ptr denom = denom_[istate]->at(iext)->get_block(i0o, i1); - for (size_t i = 0; i != interm_size; ++i) { - interm[i] *= denom[i]; - } + for (auto& i0o : interm_[dataindex]) { + unique_ptr transp = create_transp(ishalf, i0, i1, i3, i0o); + for (auto& i2 : closed_) { + if (!tensor->is_local(i0, i1, i2, i3)) continue; + const size_t blocksize = tensor->get_size(i0, i1, i2, i3); + unique_ptr interm = dtensor->get_block(i0o, i2); + const size_t interm_size = dtensor->get_size(i0o, i2); + if (imag_) { + const unique_ptr denom = denom_[istate]->at(iext)->get_block(i0o, i2); + for (size_t i = 0; i != interm_size; ++i) { + interm[i] *= denom[i]; } - unique_ptr data0(new double[blocksize]); - btas::gemm_impl::call(CblasColMajor, CblasConjTrans, CblasNoTrans, i0.size()*i2.size()*i3.size(), i1.size(), i0o.size(), - 1.0, transp.get(), i0o.size(), interm.get(), i0o.size(), 0.0, data0.get(), i0.size()*i2.size()*i3.size()); - unique_ptr data1(new double[blocksize]); - sort_indices<0,3,1,2,0,1,1,1>(data0.get(), data1.get(), i0.size(), i2.size(), i3.size(), i1.size()); - tensor->add_block(data1, i0, i1, i2, i3); } + unique_ptr data0(new double[blocksize]); + btas::gemm_impl::call(CblasColMajor, CblasConjTrans, CblasNoTrans, i0.size()*i1.size()*i3.size(), i2.size(), i0o.size(), + 1.0, transp.get(), i0o.size(), interm.get(), i0o.size(), 0.0, data0.get(), i0.size()*i1.size()*i3.size()); + unique_ptr data1(new double[blocksize]); + sort_indices<0,1,3,2,0,1,1,1>(data0.get(), data1.get(), i0.size(), i1.size(), i3.size(), i2.size()); + tensor->add_block(data1, i0, i1, i2, i3); } } - break; - case Excitations::rist: - for (auto& i3 : active_) - for (auto& i1 : active_) - for (auto& i0 : active_) { - auto create_transp = [&iext, this](const int i, const Index& I0, const Index& I1, const Index& I3, const Index& I0o) { - unique_ptr out(new double[I0.size()*I1.size()*I3.size()*I0o.size()]); - for (int j3 = I3.offset(), k = 0; j3 != I3.offset()+I3.size(); ++j3) - for (int j1 = I1.offset(); j1 != I1.offset()+I1.size(); ++j1) - for (int j0 = I0.offset(); j0 != I0.offset()+I0.size(); ++j0, ++k) - copy_n(shalf_[iext]->element_ptr(I0o.offset(),j0-nclosed_+nact_*(j1-nclosed_+nact_*(j3-nclosed_)) + i*nact_*nact_*nact_), - I0o.size(), out.get()+I0o.size()*k); - return move(out); - }; - for (auto& i0o : interm_[iext]) { - unique_ptr transp = create_transp(ist, i0, i1, i3, i0o); - for (auto& i2 : closed_) { - if (!tensor->is_local(i0, i1, i2, i3)) continue; - const size_t blocksize = tensor->get_size(i0, i1, i2, i3); - unique_ptr interm = dtensor->get_block(i0o, i2); - const size_t interm_size = dtensor->get_size(i0o, i2); - if (imag_) { - const unique_ptr denom = denom_[istate]->at(iext)->get_block(i0o, i2); - for (size_t i = 0; i != interm_size; ++i) { - interm[i] *= denom[i]; - } - } - unique_ptr data0(new double[blocksize]); - btas::gemm_impl::call(CblasColMajor, CblasConjTrans, CblasNoTrans, i0.size()*i1.size()*i3.size(), i2.size(), i0o.size(), - 1.0, transp.get(), i0o.size(), interm.get(), i0o.size(), 0.0, data0.get(), i0.size()*i1.size()*i3.size()); - unique_ptr data1(new double[blocksize]); - sort_indices<0,1,3,2,0,1,1,1>(data0.get(), data1.get(), i0.size(), i1.size(), i3.size(), i2.size()); - tensor->add_block(data1, i0, i1, i2, i3); + } + break; + case Excitations::aibj: + const int pos = sssr_ ? iext : iext + ist; + for (auto& i3 : virt_) + for (auto& i2 : closed_) + for (auto& i1 : virt_) + for (auto& i0 : closed_) { + if (!tensor->is_local(i0, i1, i2, i3)) continue; + unique_ptr data0 = data_[istate]->at(pos)->get_block(i0, i1, i2, i3); + if (imag_) { + const unique_ptr denom = denom_[istate]->at(pos)->get_block(i0, i1, i2, i3); + const size_t blocksize = data_[istate]->at(pos)->get_size(i0, i1, i2, i3); + for (size_t i = 0; i != blocksize; ++i) { + data0[i] *= denom[i]; } } + out->at(ist)->add_block(data0, i0, i1, i2, i3); } - break; - case Excitations::aibj: - const int pos = iext + (sssr_ ? 0 : ist); - for (auto& i3 : virt_) - for (auto& i2 : closed_) - for (auto& i1 : virt_) - for (auto& i0 : closed_) { - if (!tensor->is_local(i0, i1, i2, i3)) continue; - unique_ptr data0 = data_[istate]->at(pos)->get_block(i0, i1, i2, i3); - if (imag_) { - const unique_ptr denom = denom_[istate]->at(pos)->get_block(i0,i1, i2, i3); - const size_t blocksize = data_[istate]->at(pos)->get_size(i0, i1, i2, i3); - for (size_t i = 0; i != blocksize; ++i) { - data0[i] *= denom[i]; - } - } - out->at(ist)->add_block(data0, i0, i1, i2, i3); - } - break; - } + break; } } } @@ -1109,11 +1121,12 @@ for (int iext = Excitations::arbs; iext != Excitations::total; ++iext) { const shared_ptr> rtensor = r->data(istate)->at(iext); const shared_ptr> dtensor = denom_[istate]->at(iext); + const int dataindex = sssr_ ? iext + istate * Excitations::total : iext; switch(iext) { case Excitations::arbs: for (auto& i3 : virt_) for (auto& i1 : virt_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!dtensor->is_local(i0o, i1, i3)) continue; unique_ptr residual = rtensor->get_block(i0o, i1, i3); unique_ptr denom = dtensor->get_block(i0o, i1, i3); @@ -1134,7 +1147,7 @@ for (auto& i3 : virt_) for (auto& i2 : closed_) for (auto& i1 : virt_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!dtensor->is_local(i0o, i1, i2, i3)) continue; unique_ptr residual = rtensor->get_block(i0o, i1, i2, i3); unique_ptr denom = dtensor->get_block(i0o, i1, i2, i3); @@ -1155,7 +1168,7 @@ for (auto& i2 : closed_) for (auto& i1 : virt_) for (auto& i0 : closed_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!dtensor->is_local(i0o, i0, i1, i2)) continue; unique_ptr residual = rtensor->get_block(i0o, i0, i1, i2); unique_ptr denom = dtensor->get_block(i0o, i0, i1, i2); @@ -1175,7 +1188,7 @@ case Excitations::risj: for (auto& i2 : closed_) for (auto& i0 : closed_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!dtensor->is_local(i0o, i0, i2)) continue; unique_ptr residual = rtensor->get_block(i0o, i0, i2); unique_ptr denom = dtensor->get_block(i0o, i0, i2); @@ -1195,7 +1208,7 @@ case Excitations::airs: for (auto& i1 : virt_) for (auto& i0 : closed_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!dtensor->is_local(i0o, i0, i1)) continue; unique_ptr residual = rtensor->get_block(i0o, i0, i1); unique_ptr denom = dtensor->get_block(i0o, i0, i1); @@ -1214,7 +1227,7 @@ break; case Excitations::arst: for (auto& i1 : virt_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!dtensor->is_local(i0o, i1)) continue; unique_ptr residual = rtensor->get_block(i0o, i1); unique_ptr denom = dtensor->get_block(i0o, i1); @@ -1233,7 +1246,7 @@ break; case Excitations::rist: for (auto& i0 : closed_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!dtensor->is_local(i0o, i0)) continue; unique_ptr residual = rtensor->get_block(i0o, i0); unique_ptr denom = dtensor->get_block(i0o, i0); diff -Nru bagel-1.2.0/src/smith/orthogonal.h bagel-1.2.2/src/smith/orthogonal.h --- bagel-1.2.0/src/smith/orthogonal.h 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/src/smith/orthogonal.h 2018-12-29 22:08:28.000000000 +0000 @@ -44,7 +44,9 @@ enum Excitations { arbs, arbi, airj, risj, airs, arst, rist, aibj, total }; class Orthogonal_Basis { +// TODO need fixes protected: + std::map to_denom_; IndexRange closed_; IndexRange active_; @@ -74,12 +76,11 @@ double e0_; Basis_Type basis_type_; - std::vector> shalf_; - std::vector phi_; + std::shared_ptr> d_; std::vector>> data_; std::vector>> denom_; - std::shared_ptr> init_data(const int iext); + std::shared_ptr> init_data(const int iext, const int istate); std::shared_ptr> weight_by_denom(const int istate, std::shared_ptr> original) const; void set_shalf(std::shared_ptr> d); void set_denom(std::shared_ptr> d); @@ -97,7 +98,7 @@ IndexRange& virt() { return virt_; } IndexRange& closed() { return closed_; } - IndexRange& interm(const int iext) { return interm_[iext]; } + IndexRange& interm(const int dataindex) { return interm_[dataindex]; } // transform to orthogonal void transform_to_orthogonal(std::shared_ptr> t, const int istate); @@ -115,8 +116,9 @@ std::shared_ptr> data(const size_t i) const { return data_[i]; } std::shared_ptr> denom(const size_t i) const { return denom_[i]; } std::shared_ptr> get_contravariant(const int istate, const bool weight = false) const; - std::shared_ptr shalf(const int type) const { return shalf_[type]; } - double phi(const int type, const size_t i) const { return phi_[type][i]; } + + const MatView shalf(const int iext, const int ist) const { return d_->shalf(to_denom_.at(iext), ist); } + double phi(const int iext, const int ist, const size_t i) const { return d_->denom(to_denom_.at(iext), ist, i); } bool is_residual() const { return (basis_type_ == Basis_Type::residual); } bool is_amplitude() const { return (basis_type_ == Basis_Type::amplitude); } diff -Nru bagel-1.2.0/src/smith/orthogonal_shift.cc bagel-1.2.2/src/smith/orthogonal_shift.cc --- bagel-1.2.0/src/smith/orthogonal_shift.cc 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/src/smith/orthogonal_shift.cc 2018-12-29 22:08:28.000000000 +0000 @@ -39,11 +39,12 @@ for (int iext = Excitations::arbs; iext != Excitations::total; ++iext) { const shared_ptr> ttensor = t->data(istate)->at(iext); + const int dataindex = sssr_ ? iext + istate * Excitations::total : iext; switch(iext) { case Excitations::arbs: for (auto& i3 : virt_) for (auto& i1 : virt_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!ttensor->is_local(i0o, i1, i3)) continue; unique_ptr amplitude = ttensor->get_block(i0o, i1, i3); const size_t blocksize = ttensor->get_size(i0o, i1, i3); @@ -63,7 +64,7 @@ for (auto& i3 : virt_) for (auto& i2 : closed_) for (auto& i1 : virt_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!ttensor->is_local(i0o, i1, i2, i3)) continue; unique_ptr amplitude = ttensor->get_block(i0o, i1, i2, i3); const size_t blocksize = ttensor->get_size(i0o, i1, i2, i3); @@ -83,7 +84,7 @@ for (auto& i2 : closed_) for (auto& i1 : virt_) for (auto& i0 : closed_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!ttensor->is_local(i0o, i0, i1, i2)) continue; unique_ptr amplitude = ttensor->get_block(i0o, i0, i1, i2); const size_t blocksize = ttensor->get_size(i0o, i0, i1, i2); @@ -102,7 +103,7 @@ case Excitations::risj: for (auto& i2 : closed_) for (auto& i0 : closed_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!ttensor->is_local(i0o, i0, i2)) continue; unique_ptr amplitude = ttensor->get_block(i0o, i0, i2); const size_t blocksize = ttensor->get_size(i0o, i0, i2); @@ -121,7 +122,7 @@ case Excitations::airs: for (auto& i1 : virt_) for (auto& i0 : closed_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!ttensor->is_local(i0o, i0, i1)) continue; unique_ptr amplitude = ttensor->get_block(i0o, i0, i1); const size_t blocksize = ttensor->get_size(i0o, i0, i1); @@ -139,7 +140,7 @@ break; case Excitations::arst: for (auto& i1 : virt_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!ttensor->is_local(i0o, i1)) continue; unique_ptr amplitude = ttensor->get_block(i0o, i1); const size_t blocksize = ttensor->get_size(i0o, i1); @@ -157,7 +158,7 @@ break; case Excitations::rist: for (auto& i0 : closed_) - for (auto& i0o : interm_[iext]) { + for (auto& i0o : interm_[dataindex]) { if (!ttensor->is_local(i0o, i0)) continue; unique_ptr amplitude = ttensor->get_block(i0o, i0); const size_t blocksize = ttensor->get_size(i0o, i0); diff -Nru bagel-1.2.0/src/smith/spinfreebase.cc bagel-1.2.2/src/smith/spinfreebase.cc --- bagel-1.2.0/src/smith/spinfreebase.cc 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/src/smith/spinfreebase.cc 2018-12-29 22:08:28.000000000 +0000 @@ -282,7 +282,11 @@ } assert(fockact_); - auto denom = make_shared>(fockact_, nstates, info_->thresh_overlap()); + shared_ptr> denom; + if (info_->sssr()) + denom = make_shared>(fockact_, nstates, info_->thresh_overlap()); + else + denom = make_shared>(fockact_, nstates, info_->thresh_overlap()); // TODO this can be reduced to half by bra-ket symmetry for (int ist = 0; ist != nstates; ++ist) { @@ -354,7 +358,11 @@ } assert(fockact_); - auto denom = make_shared>>(fockact_, nstates, info_->thresh_overlap()); + shared_ptr>> denom; + if (info_->sssr()) + denom = make_shared>>(fockact_, nstates, info_->thresh_overlap()); + else + denom = make_shared>>(fockact_, nstates, info_->thresh_overlap()); // TODO this can be reduced to half by bra-ket symmetry for (int ist = 0; ist != nstates; ++ist) { diff -Nru bagel-1.2.0/src/smith/spinfreebase.h bagel-1.2.2/src/smith/spinfreebase.h --- bagel-1.2.0/src/smith/spinfreebase.h 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/src/smith/spinfreebase.h 2018-12-29 22:08:28.000000000 +0000 @@ -42,6 +42,7 @@ template class SpinFreeMethod { protected: + using ViewType = typename std::conditional::value,MatView,ZMatView>::type; using MatType = typename std::conditional::value,Matrix,ZMatrix>::type; using VecType = typename std::conditional::value, VectorB, ZVectorB>::type; using CIWfnT = typename std::conditional::value,CIWfn,RelCIWfn>::type; diff -Nru bagel-1.2.0/src/smith/spinfreebase_update.cpp bagel-1.2.2/src/smith/spinfreebase_update.cpp --- bagel-1.2.0/src/smith/spinfreebase_update.cpp 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/src/smith/spinfreebase_update.cpp 2018-12-29 22:08:28.000000000 +0000 @@ -84,26 +84,27 @@ for (int jst = 0; jst != nst; ++jst) { if (!t->at(jst) || !r->at(ist)) continue; + { + const ViewType ishalf = denom_->shalf("xx", ist); + const ViewType jshalf = denom_->shalf("xx", jst); for (auto& i2 : active_) { for (auto& i0 : active_) { // trans is the transformation matrix - assert(denom_->shalf_xx()); - const size_t interm_size = denom_->shalf_xx()->ndim(); + const size_t interm_size = ishalf.ndim(); const int nact = info_->nact() * fac2; const int nclo = info_->nclosed() * fac2; - auto create_transp = [&nclo,&nact,&interm_size, this](const int i, const Index& I0, const Index& I2) { + auto create_transp = [&nclo,&nact,&interm_size, this](const ViewType shalf, const Index& I0, const Index& I2) { unique_ptr out(new DataType[I0.size()*I2.size()*interm_size]); for (int j2 = I2.offset(), k = 0; j2 != I2.offset()+I2.size(); ++j2) for (int j0 = I0.offset(); j0 != I0.offset()+I0.size(); ++j0, ++k) - copy_n(denom_->shalf_xx()->element_ptr(0,(j0-nclo)+(j2-nclo)*nact + i*nact*nact), - interm_size, out.get()+interm_size*k); + copy_n(shalf.element_ptr(0, (j0-nclo)+(j2-nclo)*nact), interm_size, out.get()+interm_size*k); return move(out); }; - unique_ptr transp = create_transp(ist, i0, i2); + unique_ptr transp = create_transp(ishalf, i0, i2); for (auto& i2t : active_) { for (auto& i0t : active_) { - unique_ptr transp2 = create_transp(jst, i0t, i2t); + unique_ptr transp2 = create_transp(jshalf, i0t, i2t); for (auto& i3 : virt_) { for (auto& i1 : virt_) { @@ -128,7 +129,7 @@ for (int j3 = i3.offset(); j3 != i3.offset()+i3.size(); ++j3) for (int j1 = i1.offset(); j1 != i1.offset()+i1.size(); ++j1) for (int j02 = 0; j02 != interm_size; ++j02, ++iall) - interm[iall] /= min(-0.1, e0_ - (denom_->denom_xx(j02) + eig_[j3] + eig_[j1])); + interm[iall] /= min(-0.1, e0_ - (denom_->denom("xx", ist, j02) + eig_[j3] + eig_[j1])); // move back to non-orthogonal basis // factor of 0.5 due to the factor in the overlap @@ -146,23 +147,26 @@ } } } + } + { + const ViewType ishalf = denom_->shalf("x", ist); + const ViewType jshalf = denom_->shalf("x", jst); for (auto& i0 : active_) { // trans is the transformation matrix - assert(denom_->shalf_x()); - const size_t interm_size = denom_->shalf_x()->ndim(); + const size_t interm_size = ishalf.ndim(); const int nact = info_->nact() * fac2; const int nclo = info_->nclosed() * fac2; - auto create_transp = [&nclo,&nact,&interm_size, this](const int i, const Index& I0) { + auto create_transp = [&nclo,&nact,&interm_size, this](const ViewType shalf, const Index& I0) { unique_ptr out(new DataType[I0.size()*interm_size]); for (int j0 = I0.offset(), k = 0; j0 != I0.offset()+I0.size(); ++j0, ++k) - copy_n(denom_->shalf_x()->element_ptr(0,j0-nclo + i*nact), interm_size, out.get()+interm_size*k); + copy_n(shalf.element_ptr(0,j0-nclo), interm_size, out.get()+interm_size*k); return move(out); }; - unique_ptr transp = create_transp(ist, i0); + unique_ptr transp = create_transp(ishalf, i0); for (auto& i0t : active_) { - unique_ptr transp2 = create_transp(jst, i0t); + unique_ptr transp2 = create_transp(jshalf, i0t); for (auto& i3 : virt_) { for (auto& i2 : closed_) { @@ -193,7 +197,7 @@ for (int j2 = i2.offset(); j2 != i2.offset()+i2.size(); ++j2) for (int j1 = i1.offset(); j1 != i1.offset()+i1.size(); ++j1) for (int j0 = 0; j0 != interm_size; ++j0, ++iall) - interm[iall] /= min(-0.1, e0_ - (denom_->denom_x(j0) + eig_[j3] - eig_[j2] + eig_[j1])); + interm[iall] /= min(-0.1, e0_ - (denom_->denom("x", ist, j0) + eig_[j3] - eig_[j2] + eig_[j1])); // move back to non-orthogonal basis unique_ptr data3(new DataType[blocksizet]); @@ -206,23 +210,26 @@ } } } + } + { + const ViewType ishalf = denom_->shalf("h", ist); + const ViewType jshalf = denom_->shalf("h", jst); for (auto& i3 : active_) { // trans is the transformation matrix - assert(denom_->shalf_h()); - const size_t interm_size = denom_->shalf_x()->ndim(); + const size_t interm_size = ishalf.ndim(); const int nact = info_->nact() * fac2; const int nclo = info_->nclosed() * fac2; - auto create_transp = [&nclo,&nact,&interm_size, this](const int i, const Index& I3) { + auto create_transp = [&nclo,&nact,&interm_size, this](const ViewType shalf, const Index& I3) { unique_ptr out(new DataType[I3.size()*interm_size]); for (int j3 = I3.offset(), k = 0; j3 != I3.offset()+I3.size(); ++j3, ++k) - copy_n(denom_->shalf_h()->element_ptr(0,j3-nclo + i*nact), interm_size, out.get()+interm_size*k); + copy_n(shalf.element_ptr(0,j3-nclo), interm_size, out.get()+interm_size*k); return move(out); }; - unique_ptr transp = create_transp(ist, i3); + unique_ptr transp = create_transp(ishalf, i3); for (auto& i3t : active_) { - unique_ptr transp2 = create_transp(jst, i3t); + unique_ptr transp2 = create_transp(jshalf, i3t); blas::conj_n(transp2.get(), i3t.size()*interm_size); for (auto& i2 : closed_) { @@ -254,7 +261,7 @@ for (int j2 = i2.offset(); j2 != i2.offset()+i2.size(); ++j2) for (int j1 = i1.offset(); j1 != i1.offset()+i1.size(); ++j1) for (int j0 = i0.offset(); j0 != i0.offset()+i0.size(); ++j0, ++iall) - interm[iall] /= min(-0.1, e0_ - (denom_->denom_h(j3) - eig_[j2] + eig_[j1] - eig_[j0])); + interm[iall] /= min(-0.1, e0_ - (denom_->denom("h", ist, j3) - eig_[j2] + eig_[j1] - eig_[j0])); // move back to non-orthogonal basis unique_ptr data3(new DataType[blocksizet]); @@ -267,26 +274,28 @@ } } } + } + { + const ViewType ishalf = denom_->shalf("hh", ist); + const ViewType jshalf = denom_->shalf("hh", jst); for (auto& i3 : active_) { for (auto& i1 : active_) { - assert(denom_->shalf_hh()); - const size_t interm_size = denom_->shalf_hh()->ndim(); + const size_t interm_size = ishalf.ndim(); const int nact = info_->nact() * fac2; const int nclo = info_->nclosed() * fac2; - auto create_transp = [&nclo,&nact,&interm_size, this](const int i, const Index& I1, const Index& I3) { + auto create_transp = [&nclo,&nact,&interm_size, this](const ViewType shalf, const Index& I1, const Index& I3) { unique_ptr out(new DataType[I1.size()*I3.size()*interm_size]); for (int j3 = I3.offset(), k = 0; j3 != I3.offset()+I3.size(); ++j3) for (int j1 = I1.offset(); j1 != I1.offset()+I1.size(); ++j1, ++k) - copy_n(denom_->shalf_hh()->element_ptr(0,(j1-nclo)+(j3-nclo)*nact + i*nact*nact), - interm_size, out.get()+interm_size*k); + copy_n(shalf.element_ptr(0,(j1-nclo)+(j3-nclo)*nact), interm_size, out.get()+interm_size*k); return move(out); }; - unique_ptr transp = create_transp(ist, i1, i3); + unique_ptr transp = create_transp(ishalf, i1, i3); for (auto& i3t : active_) { for (auto& i1t : active_) { - unique_ptr transp2 = create_transp(jst, i1t, i3t); + unique_ptr transp2 = create_transp(jshalf, i1t, i3t); blas::conj_n(transp2.get(), i1t.size()*i3t.size()*interm_size); for (auto& i2 : closed_) { @@ -312,7 +321,7 @@ for (int j13 = 0; j13 != interm_size; ++j13) for (int j2 = i2.offset(); j2 != i2.offset()+i2.size(); ++j2) for (int j0 = i0.offset(); j0 != i0.offset()+i0.size(); ++j0, ++iall) - interm[iall] /= min(-0.1, e0_ - (denom_->denom_hh(j13) - eig_[j2] - eig_[j0])); + interm[iall] /= min(-0.1, e0_ - (denom_->denom("hh", ist, j13) - eig_[j2] - eig_[j0])); // move back to non-orthogonal basis // factor of 0.5 due to the factor in the overlap @@ -329,30 +338,31 @@ } } } + } + { + const ViewType ishalf = denom_->shalf("xh", ist); + const ViewType jshalf = denom_->shalf("xh", jst); for (auto& i3 : active_) { for (auto& i2 : active_) { if (is_same::value) { - assert(denom_->shalf_xh()); - const size_t interm_size = denom_->shalf_xh()->ndim(); + const size_t interm_size = ishalf.ndim(); const int nact = info_->nact() * fac2; const int nclo = info_->nclosed() * fac2; - auto create_transp = [&nclo,&nact,&interm_size, this](const int i, const Index& I2, const Index& I3) { + auto create_transp = [&nclo,&nact,&interm_size, this](const ViewType shalf, const Index& I2, const Index& I3) { unique_ptr out(new DataType[I2.size()*I3.size()*interm_size*2]); for (int j3 = I3.offset(), k = 0; j3 != I3.offset()+I3.size(); ++j3) for (int j2 = I2.offset(); j2 != I2.offset()+I2.size(); ++j2, ++k) { - copy_n(denom_->shalf_xh()->element_ptr(0, (j2-nclo)+(j3-nclo)*nact + 2*i*nact*nact), - interm_size, out.get()+interm_size*k); - copy_n(denom_->shalf_xh()->element_ptr(0, (j2-nclo)+(j3-nclo)*nact + (2*i+1)*nact*nact), - interm_size, out.get()+interm_size*(k+I2.size()*I3.size())); + copy_n(shalf.element_ptr(0, (j2-nclo)+(j3-nclo)*nact), interm_size, out.get()+interm_size*k); + copy_n(shalf.element_ptr(0, (j2-nclo)+(j3-nclo)*nact + nact*nact), interm_size, out.get()+interm_size*(k+I2.size()*I3.size())); } return move(out); }; - unique_ptr transp = create_transp(ist, i2, i3); + unique_ptr transp = create_transp(ishalf, i2, i3); for (auto& i3t : active_) { for (auto& i2t : active_) { - unique_ptr transp2 = create_transp(jst, i2t, i3t); + unique_ptr transp2 = create_transp(jshalf, i2t, i3t); blas::conj_n(transp2.get(), i2t.size()*i3t.size()*interm_size*2); for (auto& i1 : virt_) { @@ -381,7 +391,7 @@ for (int j23 = 0; j23 != interm_size; ++j23) for (int j1 = i1.offset(); j1 != i1.offset()+i1.size(); ++j1) for (int j0 = i0.offset(); j0 != i0.offset()+i0.size(); ++j0, ++iall) - interm[iall] /= min(-0.1, e0_ - (denom_->denom_xh(j23) + eig_[j1] - eig_[j0])); + interm[iall] /= min(-0.1, e0_ - (denom_->denom("xh", ist, j23) + eig_[j1] - eig_[j0])); // move back to non-orthogonal basis btas::gemm_impl::call(CblasColMajor, CblasNoTrans, CblasNoTrans, i0.size()*i1.size(), i2t.size()*i3t.size()*2, interm_size, @@ -399,23 +409,21 @@ } } } else { - assert(denom_->shalf_xh()); - const size_t interm_size = denom_->shalf_xh()->ndim(); + const size_t interm_size = ishalf.ndim(); const int nact = info_->nact() * fac2; const int nclo = info_->nclosed() * fac2; - auto create_transp = [&,this](const int i, const Index& I2, const Index& I3) { + auto create_transp = [&,this](const ViewType shalf, const Index& I2, const Index& I3) { unique_ptr out(new DataType[I2.size()*I3.size()*interm_size]); for (int j3 = I3.offset(), k = 0; j3 != I3.offset()+I3.size(); ++j3) for (int j2 = I2.offset(); j2 != I2.offset()+I2.size(); ++j2, ++k) - copy_n(denom_->shalf_xh()->element_ptr(0, (j2-nclo)+(j3-nclo)*nact + i*nact*nact), - interm_size, out.get()+interm_size*k); + copy_n(shalf.element_ptr(0, (j2-nclo)+(j3-nclo)*nact), interm_size, out.get()+interm_size*k); return move(out); }; - unique_ptr transp = create_transp(ist, i2, i3); + unique_ptr transp = create_transp(ishalf, i2, i3); for (auto& i3t : active_) { for (auto& i2t : active_) { - unique_ptr transp2 = create_transp(jst, i2t, i3t); + unique_ptr transp2 = create_transp(jshalf, i2t, i3t); blas::conj_n(transp2.get(), i2t.size()*i3t.size()*interm_size); for (auto& i1 : virt_) { @@ -441,7 +449,7 @@ for (int j23 = 0; j23 != interm_size; ++j23) for (int j1 = i1.offset(); j1 != i1.offset()+i1.size(); ++j1) for (int j0 = i0.offset(); j0 != i0.offset()+i0.size(); ++j0, ++iall) - interm[iall] /= min(-0.1, e0_ - (denom_->denom_xh(j23) + eig_[j1] - eig_[j0])); + interm[iall] /= min(-0.1, e0_ - (denom_->denom("xh", ist, j23) + eig_[j1] - eig_[j0])); // move back to non-orthogonal basis btas::gemm_impl::call(CblasColMajor, CblasNoTrans, CblasNoTrans, i0.size()*i1.size(), i2t.size()*i3t.size(), interm_size, @@ -458,29 +466,31 @@ } } } + } + { + const ViewType ishalf = denom_->shalf("xxh", ist); + const ViewType jshalf = denom_->shalf("xxh", jst); for (auto& i3 : active_) { for (auto& i2 : active_) { for (auto& i0 : active_) { - assert(denom_->shalf_xxh()); - const size_t interm_size = denom_->shalf_xxh()->ndim(); + const size_t interm_size = ishalf.ndim(); const int nact = info_->nact() * fac2; const int nclo = info_->nclosed() * fac2; - auto create_transp = [&nclo,&nact,&interm_size, this](const int i, const Index& I0, const Index& I2, const Index& I3) { + auto create_transp = [&nclo,&nact,&interm_size, this](const ViewType shalf, const Index& I0, const Index& I2, const Index& I3) { unique_ptr out(new DataType[I0.size()*I2.size()*I3.size()*interm_size]); for (int j3 = I3.offset(), k = 0; j3 != I3.offset()+I3.size(); ++j3) for (int j2 = I2.offset(); j2 != I2.offset()+I2.size(); ++j2) for (int j0 = I0.offset(); j0 != I0.offset()+I0.size(); ++j0, ++k) - copy_n(denom_->shalf_xxh()->element_ptr(0,j0-nclo+nact*(j2-nclo+nact*(j3-nclo)) + i*nact*nact*nact), - interm_size, out.get()+interm_size*k); + copy_n(shalf.element_ptr(0,j0-nclo+nact*(j2-nclo+nact*(j3-nclo))), interm_size, out.get()+interm_size*k); return move(out); }; - unique_ptr transp = create_transp(ist, i0, i2, i3); + unique_ptr transp = create_transp(ishalf, i0, i2, i3); for (auto& i3t : active_) { for (auto& i2t : active_) { for (auto& i0t : active_) { - unique_ptr transp2 = create_transp(jst, i0t, i2t, i3t); + unique_ptr transp2 = create_transp(jshalf, i0t, i2t, i3t); blas::conj_n(transp2.get(), i0t.size()*i2t.size()*i3t.size()*interm_size); for (auto& i1 : virt_) { @@ -504,7 +514,7 @@ size_t iall = 0; for (int j123 = 0; j123 != interm_size; ++j123) for (int j1 = i1.offset(); j1 != i1.offset()+i1.size(); ++j1, ++iall) - interm[iall] /= min(-0.1, e0_ - (denom_->denom_xxh(j123) + eig_[j1])); + interm[iall] /= min(-0.1, e0_ - (denom_->denom("xxh", ist, j123) + eig_[j1])); // move back to non-orthogonal basis btas::gemm_impl::call(CblasColMajor, CblasNoTrans, CblasNoTrans, i1.size(), i0t.size()*i2t.size()*i3t.size(), interm_size, @@ -521,29 +531,31 @@ } } } + } + { + const ViewType ishalf = denom_->shalf("xhh", ist); + const ViewType jshalf = denom_->shalf("xhh", jst); for (auto& i3 : active_) { for (auto& i1 : active_) { for (auto& i0 : active_) { - assert(denom_->shalf_xhh()); - const size_t interm_size = denom_->shalf_xhh()->ndim(); + const size_t interm_size = ishalf.ndim(); const int nact = info_->nact() * fac2; const int nclo = info_->nclosed() * fac2; - auto create_transp = [&nclo,&nact,&interm_size, this](const int i, const Index& I0, const Index& I1, const Index& I3) { + auto create_transp = [&nclo,&nact,&interm_size, this](const ViewType shalf, const Index& I0, const Index& I1, const Index& I3) { unique_ptr out(new DataType[I0.size()*I1.size()*I3.size()*interm_size]); for (int j3 = I3.offset(), k = 0; j3 != I3.offset()+I3.size(); ++j3) for (int j1 = I1.offset(); j1 != I1.offset()+I1.size(); ++j1) for (int j0 = I0.offset(); j0 != I0.offset()+I0.size(); ++j0, ++k) - copy_n(denom_->shalf_xhh()->element_ptr(0,j0-nclo+nact*(j1-nclo+nact*(j3-nclo)) + i*nact*nact*nact), - interm_size, out.get()+interm_size*k); + copy_n(shalf.element_ptr(0,j0-nclo+nact*(j1-nclo+nact*(j3-nclo))), interm_size, out.get()+interm_size*k); return move(out); }; - unique_ptr transp = create_transp(ist, i0, i1, i3); + unique_ptr transp = create_transp(ishalf, i0, i1, i3); for (auto& i3t : active_) { for (auto& i1t : active_) { for (auto& i0t : active_) { - unique_ptr transp2 = create_transp(jst, i0t, i1t, i3t); + unique_ptr transp2 = create_transp(jshalf, i0t, i1t, i3t); blas::conj_n(transp2.get(), i0t.size()*i1t.size()*i3t.size()*interm_size); for (auto& i2 : closed_) { @@ -567,7 +579,7 @@ size_t iall = 0; for (int j013 = 0; j013 != interm_size; ++j013) for (int j2 = i2.offset(); j2 != i2.offset()+i2.size(); ++j2, ++iall) - interm[iall] /= min(-0.1, e0_ - (denom_->denom_xhh(j013) - eig_[j2])); + interm[iall] /= min(-0.1, e0_ - (denom_->denom("xhh", ist, j013) - eig_[j2])); // move back to non-orthogonal basis btas::gemm_impl::call(CblasColMajor, CblasNoTrans, CblasNoTrans, i2.size(), i0t.size()*i1t.size()*i3t.size(), interm_size, @@ -584,6 +596,7 @@ } } } + } } // jst loop } // ist loop diff -Nru bagel-1.2.0/src/testimpl/test_molden.cc bagel-1.2.2/src/testimpl/test_molden.cc --- bagel-1.2.0/src/testimpl/test_molden.cc 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/src/testimpl/test_molden.cc 2018-12-29 22:08:28.000000000 +0000 @@ -74,11 +74,13 @@ auto geom = std::make_shared(mol); auto coeff = std::make_shared(geom); + auto tmp = std::make_shared(geom->nbasis()); + auto tmp2 = std::make_shared(geom->nbasis()); std::string filename = inp1 + ".molden"; MoldenIn mfs(filename, geom->spherical()); mfs.read(); - mfs >> tie(coeff, geom); + mfs >> tie(coeff, geom, tmp, tmp2); std::shared_ptr ao_density = coeff->form_density_rhf(geom->nele()/2); auto hcore = std::make_shared(geom); diff -Nru bagel-1.2.0/src/util/io/moldenin.cc bagel-1.2.2/src/util/io/moldenin.cc --- bagel-1.2.0/src/util/io/moldenin.cc 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/src/util/io/moldenin.cc 2018-12-29 22:08:28.000000000 +0000 @@ -54,20 +54,29 @@ } -MoldenIn& MoldenIn::operator>> (tuple, shared_ptr> inp) { +MoldenIn& MoldenIn::operator>> (tuple, shared_ptr, shared_ptr, shared_ptr> inp) { shared_ptr coeff = get<0>(inp); shared_ptr geom = get<1>(inp); + shared_ptr eig = get<2>(inp); + shared_ptr occup = get<3>(inp); assert(has_mo()); vector atom_offsets; for (auto& ioff : geom->offsets()) - atom_offsets.push_back(ioff.front()); + atom_offsets.push_back(!ioff.empty() ? ioff.front(): 0); + + for (int i = 0; i != mo_eig_.size(); ++i) + (*eig)[i] = mo_eig_[i]; + + for (int i = 0; i != mo_occup_.size(); ++i) + (*occup)[i] = mo_occup_[i]; double *idata = coeff->data(); for (auto& imo : mo_coefficients_) { auto icoeff = imo.begin(); int ii = 0; for (auto iatom = shell_orders_.begin(); iatom != shell_orders_.end(); ++iatom, ++ii) { + if (iatom->empty()) continue; double* tmp_idata = idata + atom_offsets[gto_order_[ii]-1]; for (auto& ishell : *iatom) { if (cartesian_) { @@ -109,6 +118,8 @@ vector> positions; /* Atom names */ vector names; + /* Atom charges */ + vector charges; /* Map atom number to basis info */ map, vector>>> basis_info; @@ -116,7 +127,7 @@ * Set up "global" regular expressions * ************************************************************/ regex gto_re("\\[GTO\\]"); - regex atoms_re("\\[Atoms\\]"); + regex atoms_re("\\[[Aa][Tt][Oo][Mm][Ss]\\]"); regex mo_re("\\[MO\\]"); regex other_re("\\[\\w+\\]"); @@ -141,7 +152,7 @@ { cartesian_ = true; ifstream sph_input(filename_); - if (!sph_input.is_open()){ + if (!sph_input.is_open()) { throw runtime_error("Molden input file not found"); } else { regex _5d_re("\\[5[Dd]\\]"); @@ -165,10 +176,10 @@ getline(ifs, line); - while (!ifs.eof()){ + while (!ifs.eof()) { if (regex_search(line,atoms_re)) { regex ang_re("Angs"); - regex atoms_line("(\\w{1,2})\\s+\\d+\\s+\\d+\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)"); + regex atoms_line("([a-zA-Z]{1,2})[0-9]*\\s+\\d+\\s+([+-]?[0-9]*[.]?[0-9]+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)"); scale = regex_search(line, ang_re) ? (1.0/au2angstrom__) : 1.0; @@ -180,33 +191,34 @@ const string nm(matches[1].first, matches[1].second); names.push_back(nm); - const string x_str(matches[2].first, matches[2].second); - const string y_str(matches[3].first, matches[3].second); - const string z_str(matches[4].first, matches[4].second); + const string charge_str(matches[2].first, matches[2].second); + const string x_str(matches[3].first, matches[3].second); + const string y_str(matches[4].first, matches[4].second); + const string z_str(matches[5].first, matches[5].second); array pos; - pos[0] = lexical_cast(x_str)*scale; pos[1] = lexical_cast(y_str)*scale; pos[2] = lexical_cast(z_str)*scale; - positions.push_back(pos); + charges.push_back(lexical_cast(charge_str)); + getline(ifs, line); } else { getline(ifs, line); } } found_atoms = true; - } else if (regex_search(line,gto_re)){ + } else if (regex_search(line,gto_re)) { getline(ifs, line); regex atom_line("(\\d+)\\s*\\S*"); - regex shell_line("([spdfg])\\s+(\\d+)\\s*\\S*"); + regex shell_line("([spdfghij])\\s+(\\d+)\\s*\\S*"); regex exp_line("(\\S+)\\s+(\\S+)"); regex Dd("[Dd]"); - while (!regex_search(line, other_re) && !ifs.eof()){ + while (!regex_search(line, other_re) && !ifs.eof()) { /* This line should be a new atom */ if (!regex_search(line.c_str(), matches, atom_line)) { getline(ifs, line); continue; @@ -272,29 +284,46 @@ } /* Not used at the moment. Maybe later. regex sym_re("Sym=\\s+(\\S+)"); + regex spin_re("Spin=\\s+(\\w+)"); */ regex ene_re("Ene=\\s+(\\S+)"); - regex spin_re("Spin=\\s+(\\w+)"); - regex occup_re("Occup=\\s+(\\S+)"); */ + regex occup_re("Occup=\\s+(\\S+)"); regex coeff_re("\\d+\\s+(\\S+)"); getline(ifs, line); while (!regex_search(line, other_re) && !ifs.eof()) { + if (regex_search(line.c_str(), matches, ene_re)) { + string estring(matches[1].first, matches[1].second); + mo_eig_.push_back(lexical_cast(estring)); + } + if (regex_search(line.c_str(), matches, occup_re)) { + string estring(matches[1].first, matches[1].second); + mo_occup_.push_back(lexical_cast(estring)); + } getline(ifs, line); if (ifs.eof()) break; while (!regex_search(line.c_str(), coeff_re)) { - /* For now, throwing away excess data until we get to MO coefficients */ + if (regex_search(line.c_str(), matches, ene_re)) { + string estring(matches[1].first, matches[1].second); + mo_eig_.push_back(lexical_cast(estring)); + } + if (regex_search(line.c_str(), matches, occup_re)) { + string estring(matches[1].first, matches[1].second); + mo_occup_.push_back(lexical_cast(estring)); + } getline(ifs, line); } vector movec; - while (regex_search(line.c_str(), matches, coeff_re)){ + while (regex_search(line.c_str(), matches, coeff_re)) { string mo_string(matches[1].first, matches[1].second); movec.push_back(lexical_cast(mo_string)); getline(ifs, line); } mo_coefficients_.push_back(movec); } + if (mo_eig_.size() != mo_coefficients_.size()) + throw logic_error("Eigenvalues and eigenvectors are not consistent"); } else { getline(ifs, line); } @@ -304,26 +333,35 @@ * Check to make sure all the necessary information was * * found. * ************************************************************/ - if (!(found_atoms && found_gto)){ + if (!(found_atoms && found_gto)) { string message("Section not found in Molden file: "); - if (!found_atoms){ message += "atoms "; } - if (!found_gto) { message += "GTO"; } + if (!found_atoms) { message += "atoms "; } + if (!found_gto) { message += "GTO"; } throw runtime_error(message); } vector> all_atoms; /* Assuming the names and positions vectors are in the right order */ - vector::iterator iname = names.begin(); - vector>::iterator piter = positions.begin(); - for (int i = 0; i < num_atoms; ++i, ++iname, ++piter){ + auto iname = names.begin(); + auto piter = positions.begin(); + auto citer = charges.begin(); + for (int i = 0; i < num_atoms; ++i, ++iname, ++piter, ++citer) { vector, vector>> binfo = basis_info.find(i+1)->second; - if (i == num_atoms) { + if (i == num_atoms) throw runtime_error("It appears an atom was missing in the GTO section. Check your file"); - } /* For each atom, I need to make an atom object and stick it into a vector */ - all_atoms.push_back(make_shared(is_spherical_, to_lower(*iname), *piter, binfo, "molden")); + const string lname = to_lower(*iname); + shared_ptr at; + if (lname != "q") { + at = make_shared(is_spherical_, lname, *piter, binfo, "molden"); + if (fabs(at->atom_charge() - *citer) > 1.0e-16) + throw runtime_error("MoldenIn failed - inconsistent atom charge"); + } else { + at = make_shared(is_spherical_, lname, *piter, *citer); + } + all_atoms.push_back(at); } atoms_ = all_atoms; diff -Nru bagel-1.2.0/src/util/io/moldenin.h bagel-1.2.2/src/util/io/moldenin.h --- bagel-1.2.0/src/util/io/moldenin.h 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/src/util/io/moldenin.h 2018-12-29 22:08:28.000000000 +0000 @@ -36,6 +36,8 @@ std::vector> atoms_; + std::vector mo_eig_; + std::vector mo_occup_; std::vector> mo_coefficients_; std::vector>>> lmtuv_; @@ -51,7 +53,7 @@ void read(); MoldenIn& operator>> (std::vector>& atoms_); - MoldenIn& operator>> (std::tuple, std::shared_ptr>); + MoldenIn& operator>> (std::tuple, std::shared_ptr, std::shared_ptr, std::shared_ptr>); bool has_mo() const { return !mo_coefficients_.empty(); } }; diff -Nru bagel-1.2.0/src/util/io/moldenio.cc bagel-1.2.2/src/util/io/moldenio.cc --- bagel-1.2.0/src/util/io/moldenio.cc 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/src/util/io/moldenio.cc 2018-12-29 22:08:28.000000000 +0000 @@ -68,8 +68,11 @@ vector sph_d_order = { 3, 4, 1, 2, 0 }; vector sph_f_order = { 5, 6, 3, 4, 1, 2, 0 }; vector sph_g_order = { 7, 8, 5, 6, 3, 4, 1, 2, 0 }; + vector sph_h_order = { 9,10, 7, 8, 5, 6, 3, 4, 1, 2, 0 }; + vector sph_i_order = {11,12, 9,10, 7, 8, 5, 6, 3, 4, 1, 2, 0 }; + vector sph_j_order = {13,14,11,12, 9,10, 7, 8, 5, 6, 3, 4, 1, 2, 0 }; - m2b_sph_ = vector>{sph_s_order, sph_p_order, sph_d_order, sph_f_order, sph_g_order}; + m2b_sph_ = vector>{sph_s_order, sph_p_order, sph_d_order, sph_f_order, sph_g_order, sph_h_order, sph_i_order, sph_j_order}; } /************************************************************ @@ -89,8 +92,11 @@ vector sph_d_order = { 4, 2, 3, 0, 1 }; vector sph_f_order = { 6, 4, 5, 2, 3, 0, 1 }; vector sph_g_order = { 8, 6, 7, 4, 5, 2, 3, 0, 1}; + vector sph_h_order = {10, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1}; + vector sph_i_order = {12,10,11, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1}; + vector sph_j_order = {14,12,13,10,11, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1}; - b2m_sph_ = vector>{sph_s_order, sph_p_order, sph_d_order, sph_f_order, sph_g_order}; + b2m_sph_ = vector>{sph_s_order, sph_p_order, sph_d_order, sph_f_order, sph_g_order, sph_h_order, sph_i_order, sph_j_order}; } } diff -Nru bagel-1.2.0/src/util/io/moldenout.cc bagel-1.2.2/src/util/io/moldenout.cc --- bagel-1.2.0/src/util/io/moldenout.cc 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/src/util/io/moldenout.cc 2018-12-29 22:08:28.000000000 +0000 @@ -38,6 +38,7 @@ MoldenOut& MoldenOut::operator<< (shared_ptr mol) { mol_ = mol; write_geom(); + write_aos(); return *this; } @@ -60,24 +61,28 @@ ofs_ << "[Atoms] Angs" << endl; for (int i = 0; i < num_atoms; ++i) { - shared_ptr cur_atom = mol_->atoms(i); + shared_ptr cur_atom = mol_->atoms(i); - const string cur_name = cur_atom->name(); - const int cur_number = cur_atom->atom_number(); - const array cur_pos = cur_atom->position(); - - ofs_ << setw(2) << cur_name << setw(8) << i+1 - << setw(8) << cur_number << setiosflags(ios_base::scientific) - << setw(20) << setprecision(12) << cur_pos[0]*au2angstrom__ - << setw(20) << setprecision(12) << cur_pos[1]*au2angstrom__ - << setw(20) << setprecision(12) << cur_pos[2]*au2angstrom__ << endl; + const string cur_name = cur_atom->name(); + ofs_ << setw(2) << cur_name << setw(8) << i+1; + + if (to_lower(cur_name) != "q") + ofs_ << fixed << " " << setw(20) << cur_atom->atom_number(); + else + ofs_ << fixed << " " << setw(20) << setprecision(12) << cur_atom->atom_charge(); + ofs_ << scientific; + + const array cur_pos = cur_atom->position(); + + ofs_ << setw(20) << setprecision(12) << cur_pos[0]*au2angstrom__ + << setw(20) << setprecision(12) << cur_pos[1]*au2angstrom__ + << setw(20) << setprecision(12) << cur_pos[2]*au2angstrom__ << endl; } } -void MoldenOut::write_mos() { - vector> atoms = mol_->atoms(); - const bool is_spherical = mol_->spherical(); +void MoldenOut::write_aos() { + vector> atoms = mol_->atoms(); const int num_atoms = mol_->natom(); /************************************************************ @@ -111,29 +116,29 @@ ofs_ << endl; } ofs_ << endl; +} + + +void MoldenOut::write_mos() { + vector> atoms = mol_->atoms(); + const bool is_spherical = mol_->spherical(); + if (is_spherical) ofs_ << "[5D]" << endl << "[7F]" << endl << "[9G]" << endl; ofs_ << "[MO]" << endl; - const int num_mos = ref_->coeff()->mdim(); - int nocc = ref_->nclosed(); + const int num_mos = ref_->coeff()->mdim(); const double* modata = ref_->coeff()->data(); + const VectorB eig = ref_->eig(); + const VectorB occup = ref_->occup(); - VectorB eigvec = ref_->eig(); - if (eigvec.empty()) - eigvec = VectorB(num_mos); - assert(eigvec.size() == num_mos); + for (int i = 0; i != num_mos; ++i) { - for (auto& ieig : eigvec) { + ofs_ << " Ene=" << setw(12) << setprecision(6) << fixed << (eig.empty() ? 0.0 : eig[i]) << endl; - ofs_ << " Ene=" << setw(12) << setprecision(6) << fixed << ieig << endl; - - /* At the moment only thinking about RHF, so assume spin is Alpha */ + // TODO this has to change ofs_ << " Spin=" << " Alpha" << endl; - - /* At the moment, assuming occupation can be 2 or 0. Should be fine for RHF */ - const string occ_string = nocc-- > 0 ? " 2.000" : " 0.000"; - ofs_ << " Occup=" << occ_string << endl; + ofs_ << " Occup=" << setw(12) << occup[i] << endl; int j = 0; for (auto& iatom : atoms) { @@ -142,7 +147,7 @@ vector corder = (is_spherical ? b2m_sph_.at(ishell->angular_number()) : b2m_cart_.at(ishell->angular_number())); vector scales = (is_spherical ? vector(corder.size(), 1.0) : scaling_.at(ishell->angular_number())); for (auto& iorder : corder) { - ofs_ << fixed << setw(4) << ++j << setw(22) << setprecision(16) << modata[iorder] / scales.at(iorder) << endl; + ofs_ << fixed << setw(4) << ++j << setw(22) << setprecision(16) << modata[iorder] / scales.at(iorder) << endl; } modata += corder.size(); } @@ -166,15 +171,15 @@ ofs_ << "[FR-COORD]" << endl; for (int i = 0; i < num_atoms; ++i) { - shared_ptr cur_atom = ref_->geom()->atoms(i); + shared_ptr cur_atom = ref_->geom()->atoms(i); - const string cur_name = cur_atom->name(); - const array cur_pos = cur_atom->position(); + const string cur_name = cur_atom->name(); + const array cur_pos = cur_atom->position(); - // molden format specifies that this section is in Bohr - ofs_ << setw(2) << cur_name << setw(20) << setprecision(12) << cur_pos[0] - << setw(20) << setprecision(12) << cur_pos[1] - << setw(20) << setprecision(12) << cur_pos[2] << endl; + // molden format specifies that this section is in Bohr + ofs_ << setw(2) << cur_name << setw(20) << setprecision(12) << cur_pos[0] + << setw(20) << setprecision(12) << cur_pos[1] + << setw(20) << setprecision(12) << cur_pos[2] << endl; } ofs_ << "[FR-NORM-COORD]" << endl; diff -Nru bagel-1.2.0/src/util/io/moldenout.h bagel-1.2.2/src/util/io/moldenout.h --- bagel-1.2.0/src/util/io/moldenout.h 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/src/util/io/moldenout.h 2018-12-29 22:08:28.000000000 +0000 @@ -34,6 +34,7 @@ std::ofstream ofs_; void write_geom(); + void write_aos(); void write_mos(); void write_freq(); diff -Nru bagel-1.2.0/src/wfn/reference.cc bagel-1.2.2/src/wfn/reference.cc --- bagel-1.2.0/src/wfn/reference.cc 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/src/wfn/reference.cc 2018-12-29 22:08:28.000000000 +0000 @@ -58,6 +58,9 @@ if (rdm2_av_) mpi__->broadcast(const_cast(rdm2_av_->data()), rdm2_av_->size(), 0); + occup_ = VectorB(nclosed_+nact_+nvirt_); + fill_n(occup_.data(), nclosed_, 2.0); + //if (nact_ && rdm1_.empty()) // throw logic_error("If nact != 0, Reference::Reference wants to have RDMs."); @@ -73,8 +76,12 @@ mfs.read(); if (mfs.has_mo()) { auto c = make_shared(geom_); - mfs >> tie(c, g); + auto e = make_shared(c->mdim()); + auto o = make_shared(c->mdim()); + mfs >> tie(c, g, e, o); coeff_ = c; + eig_ = *e; + occup_ = *o; } } @@ -237,6 +244,18 @@ } +void Reference::set_eigB(const VectorB& eigB) { + eigB_ = eigB; + mpi__->broadcast(eigB_.data(), eigB_.size(), 0); +} + + +void Reference::set_occup(const VectorB& occup) { + occup_ = occup; + mpi__->broadcast(occup_.data(), occup_.size(), 0); +} + + void Reference::set_coeff_AB(const shared_ptr a, const shared_ptr b) { mpi__->broadcast(const_pointer_cast(a)->data(), a->size(), 0); mpi__->broadcast(const_pointer_cast(b)->data(), b->size(), 0); diff -Nru bagel-1.2.0/src/wfn/reference.h bagel-1.2.2/src/wfn/reference.h --- bagel-1.2.0/src/wfn/reference.h 2018-10-26 04:06:41.000000000 +0000 +++ bagel-1.2.2/src/wfn/reference.h 2018-12-29 22:08:28.000000000 +0000 @@ -59,6 +59,8 @@ std::shared_ptr hcore_; VectorB eig_; + VectorB eigB_; + VectorB occup_; int nclosed_; int nact_; @@ -79,7 +81,7 @@ template void serialize(Archive& ar, const unsigned int) { ar & geom_ & coeff_ & coeffA_ & coeffB_ & noccA_ & noccB_ & energy_ & prop_freq_ & prop_ir_ & prop_eig_ - & hcore_ & eig_ & nclosed_ & nact_ & nvirt_ & nstate_ & ciwfn_ & rdm1_ & rdm2_ & rdm1_av_ & rdm2_av_; + & hcore_ & eig_ & eigB_ & occup_ & nclosed_ & nact_ & nvirt_ & nstate_ & ciwfn_ & rdm1_ & rdm2_ & rdm1_av_ & rdm2_av_; } public: @@ -111,7 +113,11 @@ void set_nocc(const int a, const int b) { noccA_ = a; noccB_ = b; } void set_eig(const VectorB& eig); + void set_eigB(const VectorB& eig); + void set_occup(const VectorB& occup); const VectorB& eig() const { return eig_; } + const VectorB& eigB() const { return eigB_; } + const VectorB& occup() const { return occup_; } int nclosed() const { return nclosed_; } int nact() const { return nact_; }