Tensor Network Theory Library  Beta release 1.2.1
A library of routines for performing TNT-based operations
 All Data Structures Functions Variables Groups Pages
tntMpsCreateProductMpo.c
1 /*
2  A uthors: Sarah Al-Assam, St*ephen Clark and Dieter Jaksch
3  $LastChangedDate$
4  (c) University of Oxford 2014
5  */
6 /* Include the internal header for the TNT library */
7 #include "tntMpsInternal.h"
8 
9 
37 tntNetwork tntMpsCreateProductMpo(unsigned L,
38  tntNodeArray *op,
39  tntIntArray *sitenum)
40 {
41  tntNetwork pmpo; /* The network to return */
42  tntNode A; /* Total operator for the current site, and the current node */
43  tntIntArray qnums_phys, qnums_int; /* Quantum numbers for the physical legs and the internal legs */
44  unsigned j; /* For looping over sites */
45  int fixqn = 0; /* Flag to say whether quantum numbers need to be determined for the internal legs */
46 
48 
49  /* Check that there is a parameter for each of the onsite operators */
50  if (op->sz != sitenum->sz) {
51  tntErrorPrint("Cannot create a matrix product operator|The number of sitenumbers does not equal the number of operators."); /* NO_COVERAGE */
52  } /* NO_COVERAGE */
53 
54  /* Make a network of identity nodes - these will have the same quantum numbers as the basis operator */
55  pmpo = tntMpsCreateEyeMpo(L,NULL);
56 
57  /* Apply the operators to the network. Note although this function is for applying a pmpo to an MPS, the additional upwards facing leg of the pmpo will not affect the way this function operates */
58  /* If the operators are not quantum number conserving, then quantum numbers will be stripped */
59  tntMpsPmpoProduct(pmpo,op,sitenum);
60 
61  /* Check whether quantum numbers need to be fixed. This will if there is a global symmetry, but any of the operators were not quantum number conserving */
62  if (tntSymmTypeGet()) {
63  for (j = 0; j < op->sz; j++) {
64  if (!tntNodeIsCovariant(op->vals[j])) {
65  fixqn = 1;
66  break;
67  }
68  }
69  }
70  /* Now go through network, and deal with quantum numbers if they are being applied. */
71  if (fixqn) {
72 
73  /* Get the quantum numbers for the physical leg */
74  qnums_phys = tntNodeGetQN(tntSysBasisOpGet(), "D");
75 
76  /* Allocate array of the correct size for the internal leg quantum numbers - all the values will be initialised to zero */
77  qnums_int = tntIntArrayAlloc(tntSymmNumGet());
78 
79  /* Get the first node in the network*/
80  A = tntNodeFindFirst(pmpo);
81 
82  /* Loop through the sites, making each node invariant as you come accross it. */
83  for (j = 0; j < L; j++) {
84 
85  /* Clear current quantum numbers if they already exist as they will be incorrect */
86  tntNodeClearQN(A);
87 
88  /* match QNs on the incoming leg to be the same as those on the outgoing leg of the previous node (or zero if this is the first node) */
89  tntNodeSetQN(A,"L",&qnums_int,TNT_QN_IN);
90 
91  /* assign quantum numbers to the physical legs */
92  tntNodeSetQN(A,"D",&qnums_phys,TNT_QN_IN);
93  tntNodeSetQN(A,"U",&qnums_phys,TNT_QN_OUT);
94 
95  /* make the node invariant, this will set QNs on the right internal leg (the only remaining leg that does not have QNs set) as an outgoing leg */
97 
98  /* Get the quantum numbers on the leg (freeing previous values first) */
99  tntIntArrayFree(&qnums_int);
100  qnums_int = tntNodeGetQN(A, "R");
101 
102  /* go to the next node */
103  A = tntNodeFindConn(A, "R");
104  }
105 
106  /* free the arrays containing the quantum numbers */
107  tntIntArrayFree(&qnums_int);
108  tntIntArrayFree(&qnums_phys);
109 
110  }
111 
113 
114  /* return the network */
115  return pmpo;
116 }
void tntNodeSetQN(tntNode A, tntLegLabel legA, tntIntArray *qvals, int legdir)
Definition: tntNodeQN.c:37
void tntNodeMakeCovariantQN(tntNode A)
Definition: tntNodeQN.c:204
unsigned tntSymmNumGet(void)
Definition: tntSys.c:512
unsigned tntNodeIsCovariant(tntNode A)
Definition: tntNodeInfo.c:535
tntIntArray tntNodeGetQN(tntNode A, tntLegLabel legA)
Definition: tntNodeQN.c:155
void tntIntArrayFree(tntIntArray *arr)
Definition: tntArray.c:620
tntIntArray tntIntArrayAlloc(unsigned numrows, unsigned numcols)
Definition: tntArray.c:29
tntNode tntNodeFindConn(tntNode A, tntLegLabel legA)
Definition: tntNodeInfo.c:29
tntNode tntSysBasisOpGet(void)
Definition: tntSys.c:407
void tntNodeClearQN(tntNode A)
Definition: tntNodeQN.c:182
tntNode tntNodeFindFirst(tntNetwork nw)
Definition: tntNodeInfo.c:50
int tntSymmTypeGet(void)
Definition: tntSys.c:498
void tntSysQNClearWarnOn(void)
Definition: tntUtil.c:17
void tntMpsPmpoProduct(tntNetwork mps, tntNodeArray *op, tntIntArray *sitenum)
Definition: tntMpsPmpo.c:35
tntNetwork tntMpsCreateProductMpo(unsigned L, tntNodeArray *op, tntIntArray *sitenum)
tntNetwork tntMpsCreateEyeMpo(unsigned L, tntNode basisOp)
void tntSysQNClearWarnOff(void)
Definition: tntUtil.c:35