-
Notifications
You must be signed in to change notification settings - Fork 12
/
set_stackspinblock_components.C
657 lines (587 loc) · 24.7 KB
/
set_stackspinblock_components.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
/*
Developed by Sandeep Sharma and Garnet K.-L. Chan, 2012
Copyright (c) 2012, Garnet K.-L. Chan
This program is integrated in Molpro with the permission of
Sandeep Sharma and Garnet K.-L. Chan
*/
#include "Stackspinblock.h"
namespace SpinAdapted{
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
void StackSpinBlock::setstoragetype(Storagetype st)
{
if (st == LOCAL_STORAGE)
{
localstorage = true;
if (has(CRE))
set_op_array(CRE)->set_local() = true;
if (has(DES))
set_op_array(DES)->set_local() = true;
if (has(CRE_DES))
set_op_array(CRE_DES)->set_local() = true;
if (has(DES_CRE))
set_op_array(DES_CRE)->set_local() = true;
if (has(CRE_CRE))
set_op_array(CRE_CRE)->set_local() = true;
if (has(DES_DES))
set_op_array(DES_DES)->set_local() = true;
if (has(DES_DESCOMP))
set_op_array(DES_DESCOMP)->set_local() = true;
if (has(CRE_CRECOMP))
set_op_array(CRE_CRECOMP)->set_local() = true;
if (has(CRE_DESCOMP))
set_op_array(CRE_DESCOMP)->set_local() = true;
if (has(DES_CRECOMP))
set_op_array(DES_CRECOMP)->set_local() = true;
if (has(CRE_CRE_DESCOMP))
set_op_array(CRE_CRE_DESCOMP)->set_local() = true;
if (has(CRE_DES_DESCOMP))
set_op_array(CRE_DES_DESCOMP)->set_local() = true;
if (has(RI_3INDEX))
set_op_array(RI_3INDEX)->set_local() = true;
if (has(RI_4INDEX))
set_op_array(RI_4INDEX)->set_local() = true;
if (has(CRE_CRE_DES))
set_op_array(CRE_CRE_DES)->set_local() = true;
if (has(CRE_DES_DES))
set_op_array(CRE_DES_DES)->set_local() = true;
if (has(CRE_DES_CRE))
set_op_array(CRE_DES_CRE)->set_local() = true;
if (has(CRE_CRE_CRE))
set_op_array(CRE_CRE_CRE)->set_local() = true;
if (has(DES_CRE_DES))
set_op_array(DES_CRE_DES)->set_local() = true;
if (has(DES_DES_CRE))
set_op_array(DES_DES_CRE)->set_local() = true;
if (has(DES_CRE_CRE))
set_op_array(DES_CRE_CRE)->set_local() = true;
if (has(DES_DES_DES))
set_op_array(DES_DES_DES)->set_local() = true;
//mps_nevpt2
if (has(CDD_CRE_DESCOMP))
set_op_array(CDD_CRE_DESCOMP)->set_local() = true;
if (has(CDD_DES_DESCOMP))
set_op_array(CDD_DES_DESCOMP)->set_local() = true;
if (has(CCD_CRE_DESCOMP))
set_op_array(CCD_CRE_DESCOMP)->set_local() = true;
if (has(CCD_CRE_CRECOMP))
set_op_array(CCD_CRE_CRECOMP)->set_local() = true;
}
else if (st == DISTRIBUTED_STORAGE)
{
localstorage = false;
//ONLY CRE IS LOCAL
if (has(CRE))
set_op_array(CRE)->set_local() = false;
if (has(DES))
set_op_array(DES)->set_local() = false;
if (has(CRE_DES))
set_op_array(CRE_DES)->set_local() = false;
if (has(DES_CRE))
set_op_array(DES_CRE)->set_local() = false;
if (has(CRE_CRE))
set_op_array(CRE_CRE)->set_local() = false;
if (has(DES_DES))
set_op_array(DES_DES)->set_local() = false;
if (has(DES_DESCOMP))
set_op_array(DES_DESCOMP)->set_local() = false;
if (has(CRE_CRECOMP))
set_op_array(CRE_CRECOMP)->set_local() = false;
if (has(CRE_DESCOMP))
set_op_array(CRE_DESCOMP)->set_local() = false;
if (has(DES_CRECOMP))
set_op_array(DES_CRECOMP)->set_local() = false;
if (has(CRE_CRE_DESCOMP))
set_op_array(CRE_CRE_DESCOMP)->set_local() = false;
if (has(CRE_DES_DESCOMP))
set_op_array(CRE_DES_DESCOMP)->set_local() = false;
if (has(RI_3INDEX))
set_op_array(RI_3INDEX)->set_local() = false;
if (has(RI_4INDEX))
set_op_array(RI_4INDEX)->set_local() = false;
if (has(CRE_CRE_DES))
set_op_array(CRE_CRE_DES)->set_local() = false;
if (has(CRE_DES_DES))
set_op_array(CRE_DES_DES)->set_local() = false;
if (has(CRE_DES_CRE))
set_op_array(CRE_DES_CRE)->set_local() = false;
if (has(CRE_CRE_CRE))
set_op_array(CRE_CRE_CRE)->set_local() = false;
if (has(DES_CRE_DES))
set_op_array(DES_CRE_DES)->set_local() = false;
if (has(DES_DES_CRE))
set_op_array(DES_DES_CRE)->set_local() = false;
if (has(DES_CRE_CRE))
set_op_array(DES_CRE_CRE)->set_local() = false;
if (has(DES_DES_DES))
set_op_array(DES_DES_DES)->set_local() = false;
//mps_nevpt2
if (has(CDD_CRE_DESCOMP))
set_op_array(CDD_CRE_DESCOMP)->set_local() = false;
if (has(CDD_DES_DESCOMP))
set_op_array(CDD_DES_DESCOMP)->set_local() = false;
if (has(CCD_CRE_DESCOMP))
set_op_array(CCD_CRE_DESCOMP)->set_local() = false;
if (has(CCD_CRE_CRECOMP))
set_op_array(CCD_CRE_CRECOMP)->set_local() = false;
}
//this is needed for onepdm generation, the system block all the cre are local
//and on the environment block all the cre are distributed, this way in multiple
//processor runs, we can generate all O_{ij} elements of onepdm where i is on
//the system and j is on the environment
else if (st == DISTRIBUTED_STORAGE_FOR_ONEPDM)
{
if ( dmrginp.new_npdm_code() && !dmrginp.nevpt2() ) assert(false);
localstorage = false;
if (has(CRE))
set_op_array(CRE)->set_local() = true;
if (has(DES))
set_op_array(DES)->set_local() = true;
if (has(CRE_DES))
set_op_array(CRE_DES)->set_local() = false;
if (has(CRE_CRE))
set_op_array(CRE_CRE)->set_local() = false;
if (has(DES_DESCOMP))
set_op_array(DES_DESCOMP)->set_local() = false;
if (has(CRE_DESCOMP))
set_op_array(CRE_DESCOMP)->set_local() = false;
if (has(CRE_CRE_DESCOMP))
set_op_array(CRE_CRE_DESCOMP)->set_local() = false;
}
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
boost::shared_ptr<StackOp_component_base> make_new_stackop(const opTypes &optype, const bool &is_core)
{
boost::shared_ptr<StackOp_component_base> ret;
switch(optype)
{
case CRE:
ret = boost::shared_ptr<StackOp_component<StackCre> >(new StackOp_component<StackCre>(is_core));
break;
case DES:
ret = boost::shared_ptr<StackOp_component<StackDes> >(new StackOp_component<StackDes>(is_core));
break;
case CRE_DES:
ret = boost::shared_ptr<StackOp_component<StackCreDes> >(new StackOp_component<StackCreDes>(is_core));
break;
case DES_CRE:
ret = boost::shared_ptr<StackOp_component<StackDesCre> >(new StackOp_component<StackDesCre>(is_core));
break;
case CRE_CRE:
ret = boost::shared_ptr<StackOp_component<StackCreCre> >(new StackOp_component<StackCreCre>(is_core));
break;
case DES_DES:
ret = boost::shared_ptr<StackOp_component<StackDesDes> >(new StackOp_component<StackDesDes>(is_core));
break;
case CRE_DESCOMP:
ret = boost::shared_ptr<StackOp_component<StackCreDesComp> >(new StackOp_component<StackCreDesComp>(is_core));
break;
case DES_CRECOMP:
ret = boost::shared_ptr<StackOp_component<StackDesCreComp> >(new StackOp_component<StackDesCreComp>(is_core));
break;
case DES_DESCOMP:
ret = boost::shared_ptr<StackOp_component<StackDesDesComp> >(new StackOp_component<StackDesDesComp>(is_core));
break;
case CRE_CRECOMP:
ret = boost::shared_ptr<StackOp_component<StackCreCreComp> >(new StackOp_component<StackCreCreComp>(is_core));
break;
case CRE_CRE_DESCOMP:
ret = boost::shared_ptr<StackOp_component<StackCreCreDesComp> >(new StackOp_component<StackCreCreDesComp>(is_core));
break;
case CRE_DES_DESCOMP:
ret = boost::shared_ptr<StackOp_component<StackCreDesDesComp> >(new StackOp_component<StackCreDesDesComp>(is_core));
break;
case HAM:
ret = boost::shared_ptr<StackOp_component<StackHam> >(new StackOp_component<StackHam>(is_core));
break;
case OVERLAP:
ret = boost::shared_ptr<StackOp_component<StackOverlap> >(new StackOp_component<StackOverlap>(is_core));
break;
case RI_3INDEX:
ret = boost::shared_ptr<StackOp_component<RI3index> >(new StackOp_component<RI3index>(is_core));
break;
case RI_4INDEX:
ret = boost::shared_ptr<StackOp_component<RI4index> >(new StackOp_component<RI4index>(is_core));
break;
case CRE_CRE_DES:
ret = boost::shared_ptr<StackOp_component<StackCreCreDes> >(new StackOp_component<StackCreCreDes>(is_core));
break;
case CRE_DES_DES:
ret = boost::shared_ptr<StackOp_component<StackCreDesDes> >(new StackOp_component<StackCreDesDes>(is_core));
break;
case CRE_DES_CRE:
ret = boost::shared_ptr<StackOp_component<StackCreDesCre> >(new StackOp_component<StackCreDesCre>(is_core));
break;
case CRE_CRE_CRE:
ret = boost::shared_ptr<StackOp_component<StackCreCreCre> >(new StackOp_component<StackCreCreCre>(is_core));
break;
// 4PDM and tran_4PDM
case DES_CRE_DES:
ret = boost::shared_ptr<StackOp_component<StackDesCreDes> >(new StackOp_component<StackDesCreDes>(is_core));
break;
case DES_DES_CRE:
ret = boost::shared_ptr<StackOp_component<StackDesDesCre> >(new StackOp_component<StackDesDesCre>(is_core));
break;
case DES_CRE_CRE:
ret = boost::shared_ptr<StackOp_component<StackDesCreCre> >(new StackOp_component<StackDesCreCre>(is_core));
break;
case DES_DES_DES:
ret = boost::shared_ptr<StackOp_component<StackDesDesDes> >(new StackOp_component<StackDesDesDes>(is_core));
break;
// 4PDM and tran_4PDM
/*
case CRE_DES_CRE_DES:
ret = boost::shared_ptr<StackOp_component<StackCreDesCreDes> >(new StackOp_component<StackCreDesCreDes>(is_core));
break;
case CRE_DES_DES_CRE:
ret = boost::shared_ptr<StackOp_component<StackCreDesDesCre> >(new StackOp_component<StackCreDesDesCre>(is_core));
break;
case CRE_CRE_DES_DES:
ret = boost::shared_ptr<StackOp_component<StackCreCreDesDes> >(new StackOp_component<StackCreCreDesDes>(is_core));
break;
*/
case CDD_SUM:
ret = boost::shared_ptr<StackOp_component<StackCDD_sum> >(new StackOp_component<StackCDD_sum>(is_core));
break;
case CDD_CRE_DESCOMP:
ret = boost::shared_ptr<StackOp_component<StackCDD_CreDesComp> >(new StackOp_component<StackCDD_CreDesComp>(is_core));
break;
case CDD_DES_DESCOMP:
ret = boost::shared_ptr<StackOp_component<StackCDD_DesDesComp> >(new StackOp_component<StackCDD_DesDesComp>(is_core));
break;
case CCD_SUM:
ret = boost::shared_ptr<StackOp_component<StackCCD_sum> >(new StackOp_component<StackCCD_sum>(is_core));
break;
case CCD_CRE_DESCOMP:
ret = boost::shared_ptr<StackOp_component<StackCCD_CreDesComp> >(new StackOp_component<StackCCD_CreDesComp>(is_core));
break;
case CCD_CRE_CRECOMP:
ret = boost::shared_ptr<StackOp_component<StackCCD_CreCreComp> >(new StackOp_component<StackCCD_CreCreComp>(is_core));
break;
default:
assert(false);
break;
}
return ret;
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
//this is used for the dot block
void StackSpinBlock::default_op_components(bool complementary_, bool implicitTranspose)
{
// New version of NPDM code not yet working with implicit transposes
if ( dmrginp.new_npdm_code() ) implicitTranspose = false;
if ( !dmrginp.doimplicitTranspose() ) implicitTranspose = false; //this is usually used for testing
//************
//implicitTranspose = false;
//*******
complementary = complementary_;
normal = !complementary_;
this->direct = false;
this->loopblock = true;
if(dmrginp.calc_type() == MPS_NEVPT)
{
ops[CRE] = make_new_stackop(CRE, true);
ops[DES] = make_new_stackop(DES, true);
ops[OVERLAP] = make_new_stackop(OVERLAP, true);
if(this->nonactive_orb()[0] >= (dmrginp.spinAdapted()? dmrginp.core_size()+dmrginp.act_size(): (dmrginp.core_size()+dmrginp.act_size())*2)){
ops[CDD_CRE_DESCOMP] = make_new_stackop(CDD_CRE_DESCOMP, true);
ops[CDD_DES_DESCOMP] = make_new_stackop(CDD_DES_DESCOMP, true);
ops[CDD_SUM] = make_new_stackop(CDD_SUM, true);
}
else{
ops[CCD_CRE_DESCOMP] = make_new_stackop(CCD_CRE_DESCOMP, true);
ops[CCD_CRE_CRECOMP] = make_new_stackop(CCD_CRE_CRECOMP, true);
ops[CCD_SUM] = make_new_stackop(CCD_SUM, true);
}
return;
}
//for a dot operator generate all possible operators
//they are not rigorously needed in all possible scenarios, e.g. not needed
//for hubbard model. But they are so cheap that there is no need to have special
//cases
ops[CRE] = make_new_stackop(CRE, true);
if (!dmrginp.do_npdm_ops()) {
ops[CRE_CRE_DESCOMP] = make_new_stackop(CRE_CRE_DESCOMP, true);
ops[HAM] = make_new_stackop(HAM, true);
}
if (!implicitTranspose ) {
ops[DES] = make_new_stackop(DES, true);
ops[DES_CRE] = make_new_stackop(DES_CRE, true);
ops[DES_DES] = make_new_stackop(DES_DES, true);
if (!dmrginp.do_npdm_ops()) {
ops[CRE_DES_DESCOMP] = make_new_stackop(CRE_DES_DESCOMP, true);
ops[DES_CRECOMP] = make_new_stackop(DES_CRECOMP, true);
ops[CRE_CRECOMP] = make_new_stackop(CRE_CRECOMP, true);
}
}
ops[OVERLAP] = make_new_stackop(OVERLAP, true);
ops[CRE_DES] = make_new_stackop(CRE_DES, true);
ops[CRE_CRE] = make_new_stackop(CRE_CRE, true);
if (!dmrginp.do_npdm_ops()) {
ops[CRE_DESCOMP] = make_new_stackop(CRE_DESCOMP, true);
ops[DES_DESCOMP] = make_new_stackop(DES_DESCOMP, true);
}
if (dmrginp.do_npdm_ops()) {
ops[RI_3INDEX] = make_new_stackop(RI_3INDEX, true);
ops[RI_4INDEX] = make_new_stackop(RI_4INDEX, true);
if (!dmrginp.set_fullrestart()) {
if ( (dmrginp.calc_type() == THREEPDM) ||
(dmrginp.calc_type() == RESTART_THREEPDM) ||
(dmrginp.calc_type() == TRANSITION_THREEPDM) ||
(dmrginp.calc_type() == RESTART_T_THREEPDM)
){
ops[CRE_CRE_CRE] = make_new_stackop(CRE_CRE_CRE, true);
ops[CRE_DES_DES] = make_new_stackop(CRE_DES_DES, true);
ops[CRE_CRE_DES] = make_new_stackop(CRE_CRE_DES, true);
ops[CRE_DES_CRE] = make_new_stackop(CRE_DES_CRE, true);
if ( !dmrginp.doimplicitTranspose())
{
ops[DES_CRE_DES] = make_new_stackop(DES_CRE_DES, true);
ops[DES_DES_CRE] = make_new_stackop(DES_DES_CRE, true);
ops[DES_CRE_CRE] = make_new_stackop(DES_CRE_CRE, true);
ops[DES_DES_DES] = make_new_stackop(DES_DES_DES, true);
}
}
}
}
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
void StackSpinBlock::set_big_components()
{
setstoragetype(DISTRIBUTED_STORAGE);
if(dmrginp.calc_type() == MPS_NEVPT)
{
if(this->nonactive_orb()[0] >= (dmrginp.spinAdapted()? dmrginp.core_size()+dmrginp.act_size(): (dmrginp.core_size()+dmrginp.act_size())*2)){
ops[CDD_SUM] = make_new_stackop(CDD_SUM, false);
}
else{
ops[CCD_SUM] = make_new_stackop(CCD_SUM, false);
}
return;
}
else
ops[HAM] = make_new_stackop(HAM, false);
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
void StackSpinBlock::default_op_components(bool direct, bool haveNormops, bool haveCompops, bool implicitTranspose)
{
// New version of NPDM code not yet working with implicit transposes
if ( dmrginp.new_npdm_code() ) implicitTranspose = false;
if ( !dmrginp.doimplicitTranspose() ) implicitTranspose = false; //this is usually used for testing
this->direct = direct;
//************
//implicitTranspose = false;
//*******
if (haveNormops)
this->loopblock = true;
else
this->loopblock = false;
// Not direct
//------------------
if (!is_direct()) {
if(dmrginp.calc_type() == MPS_NEVPT)
{
ops[CRE] = make_new_stackop(CRE, true);
ops[DES] = make_new_stackop(DES, true);
ops[OVERLAP] = make_new_stackop(OVERLAP, true);
if(this->nonactive_orb()[0] >= (dmrginp.spinAdapted()? dmrginp.core_size()+dmrginp.act_size(): (dmrginp.core_size()+dmrginp.act_size())*2)){
ops[CDD_CRE_DESCOMP] = make_new_stackop(CDD_CRE_DESCOMP, true);
ops[CDD_DES_DESCOMP] = make_new_stackop(CDD_DES_DESCOMP, true);
ops[CDD_SUM] = make_new_stackop(CDD_SUM, true);
}
else{
ops[CCD_CRE_DESCOMP] = make_new_stackop(CCD_CRE_DESCOMP, true);
ops[CCD_CRE_CRECOMP] = make_new_stackop(CCD_CRE_CRECOMP, true);
ops[CCD_SUM] = make_new_stackop(CCD_SUM, true);
}
return;
}
if ( dmrginp.new_npdm_code() && sites.size() > 1) assert(false);
ops[CRE] = make_new_stackop(CRE, true);
if (!dmrginp.do_npdm_ops()) {
ops[CRE_CRE_DESCOMP] = make_new_stackop(CRE_CRE_DESCOMP, true);
ops[HAM] = make_new_stackop(HAM, true);
}
ops[OVERLAP] = make_new_stackop(OVERLAP, true);
//this option is used when bra and ket states are different
if (!implicitTranspose ) {
ops[DES] = make_new_stackop(DES, true);
if (!dmrginp.do_npdm_ops())
ops[CRE_DES_DESCOMP] = make_new_stackop(CRE_DES_DESCOMP, true);
}
if(dmrginp.do_npdm_ops() && (dmrginp.calc_type() == RESTART_ONEPDM || dmrginp.calc_type() == ONEPDM))
return;
//for hubbard model if we want to calculate twopdm we still need cd operators
if (dmrginp.hamiltonian() != HUBBARD || dmrginp.do_npdm_ops()) {
if (haveNormops || dmrginp.do_npdm_ops()) {
ops[CRE_DES] = make_new_stackop(CRE_DES, true);
ops[CRE_CRE] = make_new_stackop(CRE_CRE, true);
if (!implicitTranspose) {
ops[DES_CRE] = make_new_stackop(DES_CRE, true);
ops[DES_DES] = make_new_stackop(DES_DES, true);
}
}
if (haveCompops && !dmrginp.do_npdm_ops()) {
ops[CRE_DESCOMP] = make_new_stackop(CRE_DESCOMP, true);
ops[DES_DESCOMP] = make_new_stackop(DES_DESCOMP, true);
if (!implicitTranspose) {
ops[DES_CRECOMP] = make_new_stackop(DES_CRECOMP, true);
ops[CRE_CRECOMP] = make_new_stackop(CRE_CRECOMP, true);
}
}
if (dmrginp.do_npdm_ops()) {
ops[RI_3INDEX] = make_new_stackop(RI_3INDEX, true);
ops[RI_4INDEX] = make_new_stackop(RI_4INDEX, true);
if (!dmrginp.set_fullrestart()) {
if ( (dmrginp.calc_type() == THREEPDM) ||
(dmrginp.calc_type() == RESTART_THREEPDM) ||
(dmrginp.calc_type() == TRANSITION_THREEPDM) ||
(dmrginp.calc_type() == RESTART_T_THREEPDM)
){
ops[CRE_CRE_CRE] = make_new_stackop(CRE_CRE_CRE, true);
ops[CRE_DES_DES] = make_new_stackop(CRE_DES_DES, true);
ops[CRE_CRE_DES] = make_new_stackop(CRE_CRE_DES, true);
ops[CRE_DES_CRE] = make_new_stackop(CRE_DES_CRE, true);
if (!dmrginp.doimplicitTranspose()) {
ops[DES_CRE_DES] = make_new_stackop(DES_CRE_DES, true);
ops[DES_DES_CRE] = make_new_stackop(DES_DES_CRE, true);
ops[DES_CRE_CRE] = make_new_stackop(DES_CRE_CRE, true);
ops[DES_DES_DES] = make_new_stackop(DES_DES_DES, true);
}
}
}
}
}
if (haveNormops)
this->loopblock = true;
else
this->loopblock = false;
}
// Is direct
//------------------
else {
if(dmrginp.calc_type() == MPS_NEVPT)
{
ops[CRE] = make_new_stackop(CRE, false);
ops[DES] = make_new_stackop(DES, false);
ops[OVERLAP] = make_new_stackop(OVERLAP, false);
if(this->nonactive_orb()[0] >= (dmrginp.spinAdapted()? dmrginp.core_size()+dmrginp.act_size(): (dmrginp.core_size()+dmrginp.act_size())*2)){
ops[CDD_CRE_DESCOMP] = make_new_stackop(CDD_CRE_DESCOMP, false);
ops[CDD_DES_DESCOMP] = make_new_stackop(CDD_DES_DESCOMP, false);
ops[CDD_SUM] = make_new_stackop(CDD_SUM, false);
}
else{
ops[CCD_CRE_DESCOMP] = make_new_stackop(CCD_CRE_DESCOMP, false);
ops[CCD_CRE_CRECOMP] = make_new_stackop(CCD_CRE_CRECOMP, false);
ops[CCD_SUM] = make_new_stackop(CCD_SUM, false);
}
return;
}
//we need CCDcomp to be on core, the rest of them can be generated very quickly
//and dont really required incore storage
ops[CRE] = make_new_stackop(CRE, false);
if (!dmrginp.do_npdm_ops()) {
ops[CRE_CRE_DESCOMP] = make_new_stackop(CRE_CRE_DESCOMP, false);
ops[HAM] = make_new_stackop(HAM, false);
}
ops[OVERLAP] = make_new_stackop(OVERLAP, false);
//this option is used when bra and ket states are different
if (!implicitTranspose) {
ops[DES] = make_new_stackop(DES, false);
if (!dmrginp.do_npdm_ops())
ops[CRE_DES_DESCOMP] = make_new_stackop(CRE_DES_DESCOMP, false);
}
//Only need one index operators for one pdm calculation except for single dot.
if(dmrginp.do_npdm_ops() && (dmrginp.calc_type() == RESTART_ONEPDM || dmrginp.calc_type() == ONEPDM))
return;
//for hubbard model if we want to calculate twopdm we still need cd operators
if (dmrginp.hamiltonian() != HUBBARD || dmrginp.do_npdm_ops()) {
if (haveNormops || dmrginp.do_npdm_ops()) {
ops[CRE_DES] = make_new_stackop(CRE_DES, false);
ops[CRE_CRE] = make_new_stackop(CRE_CRE, false);
if (!implicitTranspose ) {
ops[DES_CRE] = make_new_stackop(DES_CRE, false);
ops[DES_DES] = make_new_stackop(DES_DES, false);
}
}
if (haveCompops && !dmrginp.do_npdm_ops()) {
ops[CRE_DESCOMP] = make_new_stackop(CRE_DESCOMP, false);
ops[DES_DESCOMP] = make_new_stackop(DES_DESCOMP, false);
if (!implicitTranspose) {
ops[DES_CRECOMP] = make_new_stackop(DES_CRECOMP, false);
ops[CRE_CRECOMP] = make_new_stackop(CRE_CRECOMP, false);
}
}
if (dmrginp.do_npdm_ops()) {
ops[RI_3INDEX] = make_new_stackop(RI_3INDEX, false);
ops[RI_4INDEX] = make_new_stackop(RI_4INDEX, false);
if (!dmrginp.set_fullrestart()) {
if ( (dmrginp.calc_type() == THREEPDM) ||
(dmrginp.calc_type() == RESTART_THREEPDM) ||
(dmrginp.calc_type() == TRANSITION_THREEPDM) ||
(dmrginp.calc_type() == RESTART_T_THREEPDM)
){
ops[CRE_CRE_CRE] = make_new_stackop(CRE_CRE_CRE, false);
ops[CRE_DES_DES] = make_new_stackop(CRE_DES_DES, false);
ops[CRE_CRE_DES] = make_new_stackop(CRE_CRE_DES, false);
ops[CRE_DES_CRE] = make_new_stackop(CRE_DES_CRE, false);
if (!dmrginp.doimplicitTranspose()) {
ops[DES_CRE_DES] = make_new_stackop(DES_CRE_DES, false);
ops[DES_DES_CRE] = make_new_stackop(DES_DES_CRE, false);
ops[DES_CRE_CRE] = make_new_stackop(DES_CRE_CRE, false);
ops[DES_DES_DES] = make_new_stackop(DES_DES_DES, false);
}
}
}
}
}
if (haveNormops)
this->loopblock = true;
else
this->loopblock = false;
}
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
void StackSpinBlock::nevpt_op_components(bool direct, StackSpinBlock& lBlock, StackSpinBlock& rBlock, const perturber& pb)
{
this->direct = direct;
if (lBlock.is_complementary() || rBlock.is_complementary()) {
this->complementary = true;
this->normal = false;
} else {
this->complementary = false;
this->normal = true;
}
if (is_direct()) {
ops[CRE] = make_new_stackop(CRE, false);
ops[DES] = make_new_stackop(DES, false);
ops[OVERLAP] = make_new_stackop(OVERLAP, false);
if(pb.type() == Va){
ops[CDD_CRE_DESCOMP] = make_new_stackop(CDD_CRE_DESCOMP, false);
ops[CDD_DES_DESCOMP] = make_new_stackop(CDD_DES_DESCOMP, false);
ops[CDD_SUM] = make_new_stackop(CDD_SUM, false);
}
else if(pb.type() == TwoPerturbType::Vi){
ops[CCD_CRE_DESCOMP] = make_new_stackop(CCD_CRE_DESCOMP, false);
ops[CCD_CRE_CRECOMP] = make_new_stackop(CCD_CRE_CRECOMP, false);
ops[CCD_SUM] = make_new_stackop(CCD_SUM, false);
}
}
else
{
ops[CRE] = make_new_stackop(CRE, true);
ops[DES] = make_new_stackop(DES, true);
ops[OVERLAP] = make_new_stackop(OVERLAP, true);
if(pb.type() == TwoPerturbType::Va){
ops[CDD_CRE_DESCOMP] = make_new_stackop(CDD_CRE_DESCOMP, true);
ops[CDD_DES_DESCOMP] = make_new_stackop(CDD_DES_DESCOMP, true);
ops[CDD_SUM] = make_new_stackop(CDD_SUM, true);
}
else if(pb.type() == TwoPerturbType::Vi){
ops[CCD_CRE_DESCOMP] = make_new_stackop(CCD_CRE_DESCOMP, true);
ops[CCD_CRE_CRECOMP] = make_new_stackop(CCD_CRE_CRECOMP, true);
ops[CCD_SUM] = make_new_stackop(CCD_SUM, true);
}
}
}
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
}