13 #include "tntMpsInternal.h"
18 #define TNT_SH_NUM_TERMS 12
19 #define TNT_SH_NUM_NN_TERMS 9
21 #define TNT_BS_NUM_TERMS 7
22 #define TNT_BS_NUM_NN_TERMS 3
218 static struct option all_long_options[] = {
219 {
"dt", required_argument, 0, 1},
220 {
"idt", required_argument, 0, 2},
221 {
"rand-state", required_argument, 0, 3},
222 {
"qnum-rand-state", required_argument, 0, 4},
223 {
"config-state", required_argument, 0, 5},
224 {
"qnum-config-state", required_argument, 0, 6},
225 {
"length", required_argument, 0, 7},
226 {
"system", required_argument, 0, 8},
227 {
"qnum-eye-state", no_argument, 0, 9},
228 {
"eye-state", no_argument, 0, 10},
231 static struct option sh_long_options[] = {
232 {
"Jxx", required_argument, 0, 1},
233 {
"Jyy", required_argument, 0, 2},
234 {
"Jzz", required_argument, 0, 3},
235 {
"Jxy", required_argument, 0, 4},
236 {
"Jyx", required_argument, 0, 5},
237 {
"Jyz", required_argument, 0, 6},
238 {
"Jzy", required_argument, 0, 7},
239 {
"Jzx", required_argument, 0, 8},
240 {
"Jxz", required_argument, 0, 9},
241 {
"Bx", required_argument, 0, 10},
242 {
"By", required_argument, 0, 11},
243 {
"Bz", required_argument, 0, 12},
244 {
"2S", required_argument, 0, 13},
247 static struct option bs_long_options[] = {
248 {
"Jb", required_argument, 0, 1},
249 {
"Vb", required_argument, 0, 2},
250 {
"param-driv", required_argument, 0, 3},
251 {
"Ub", required_argument, 0, 4},
252 {
"mub", required_argument, 0, 5},
253 {
"E-harm", required_argument, 0, 6},
254 {
"coher-driv", required_argument, 0, 7},
255 {
"jc-harm", required_argument, 0, 8},
256 {
"n-max", required_argument, 0, 9},
264 unsigned no_operators = 0;
265 double dt = 0.0, idt = 0.0;
267 unsigned MPStype = 0;
268 char config[TNT_STRLEN];
272 tntNodeArray nnL, nnR, os;
273 tntComplexArray nnparam, osparam;
283 argv_cp = (
char **) malloc(argc*
sizeof(
char *));
284 for (c = 0; c<argc; c++) {
285 argv_cp[c] = argv[c];
289 if ((NULL == prop) && (NULL == mpo)) {
293 tntPrintf(
"----------------------------------------------------------\n");
294 tntPrintf(
"Creating MPS system with the following parameters: \n");
295 tntPrintf(
"----------------------------------------------------------\n");
298 while ((c = getopt_long(argc, argv_cp,
"", all_long_options, &option_index)) != -1) {
302 tntWarningPrint(
"The input parameter dt is being ignored as U is NULL|");
310 tntWarningPrint(
"The input parameter idt is being ignored as U is NULL|");
318 tntWarningPrint(
"The input parameter rand-state is being ignored as argument mps is NULL|");
319 }
else if (MPStype) {
320 tntWarningPrint(
"The input parameter rand-state is being ignored as the MPS type has already been set|");
323 D = abs(atoi(optarg));
324 tntPrintf(
"Random MPS being creating with starting internal dimension: <<<%d>>>\n",D);
329 tntWarningPrint(
"The input parameter qnum-eye-state is being ignored as argument mps is NULL|");
330 }
else if (MPStype) {
331 tntWarningPrint(
"The input parameter qnum-eye-state is being ignored as the MPS type has already been set|");
338 tntPrintf(
"Creating MPS with initial quantum number: <<<%d>>>\n",Q);
343 tntWarningPrint(
"The input parameter config-state is being ignored as argument mps is NULL|");
344 }
else if (MPStype) {
345 tntWarningPrint(
"The input parameter config-state is being ignored as the MPS type has already been set|");
348 strcpy(config, optarg);
349 tntPrintf(
"Creating MPS with configuration: <<<%s>>>\n",config);
354 tntWarningPrint(
"The input parameter qnum-state is being ignored as argument mps is NULL|");
355 }
else if (MPStype) {
356 tntWarningPrint(
"The input parameter qnum-state is being ignored as the MPS type has already been set|");
359 strcpy(config, optarg);
360 tntPrintf(
"Creating number conserving MPS with configuration: <<<%s>>>\n",config);
366 L = abs(atoi(optarg));
371 tntWarningPrint(
"The input parameter system is being ignored as the system type has already been set|");
372 }
else if (!strcmp(optarg,
"spin")) {
375 }
else if (!strcmp(optarg,
"boson")) {
379 tntErrorPrint(
"System type %s is not known",optarg);
384 tntWarningPrint(
"The input parameter qnum-eye-state is being ignored as argument mps is NULL|");
385 }
else if (MPStype) {
386 tntWarningPrint(
"The input parameter qnum-eye-state is being ignored as the start-state type has already been set|");
389 tntPrintf(
"Creating identity density matrix as start state, with quantum number conservation turned on\n");
394 tntWarningPrint(
"The input parameter qnum-eye-state is being ignored as argument mps is NULL|");
395 }
else if (MPStype) {
396 tntWarningPrint(
"The input parameter qnum-eye-state is being ignored as the start-state type has already been set|");
399 tntPrintf(
"Creating identity density matrix as start state\n");
407 tntErrorPrint(
"The system cannot be initialised as the length has not been set");
410 if ((0 == MPStype)&&(mps != NULL)) {
411 tntErrorPrint(
"The wave function cannot be created as the starting state has not been set");
418 unsigned sh_param_present[TNT_SH_NUM_TERMS] = {0,0,0,0,0,0,0,0,0,0,0,0};
419 char sh_param_strs[TNT_SH_NUM_TERMS][4] = {
"Jxx",
"Jyy",
"Jzz",
"Jxy",
"Jyx",
"Jyz",
"Jzy",
"Jzx",
"Jxz",
"Bx",
"By",
"Bz"};
422 for (c = 0; c<argc; c++) {
423 argv_cp[c] = argv[c];
429 tntPrintf(
"----------------------------------------------------------\n");
430 tntPrintf(
"Creating spin system with the following parameters: \n");
431 tntPrintf(
"----------------------------------------------------------\n");
434 while ((c = getopt_long(argc, argv_cp,
"", sh_long_options, &option_index)) != -1) {
435 if (c <= TNT_SH_NUM_TERMS) {
437 sh_params[c-1] =
tntAtoC(optarg);
438 sh_param_present[c-1] = 1;
439 if (fabs(sh_params[c-1].re) > DBL_EPSILON && fabs(sh_params[c-1].im) > DBL_EPSILON) {
440 tntPrintf(
"%s : <<<%g%+gi>>>\n", sh_param_strs[c-1], sh_params[c-1].re, sh_params[c-1].im);
441 }
else if (fabs(sh_params[c-1].re) > DBL_EPSILON) {
442 tntPrintf(
"%s : <<<%g>>>\n", sh_param_strs[c-1], sh_params[c-1].re);
443 }
else if (fabs(sh_params[c-1].im) > DBL_EPSILON) {
444 tntPrintf(
"%s : <<<%gi>>>\n", sh_param_strs[c-1], sh_params[c-1].im);
446 tntPrintf(
"%s : <<<0>>>\n", sh_param_strs[c-1]);
448 if (c <= TNT_SH_NUM_NN_TERMS) {
453 }
else if (13 == c) {
454 TwoS = abs(atoi(optarg));
459 tntNode Sx, Sy, Sz, Sp, Sm, eye;
470 if (0 == numnn && 0 == numos) {
471 tntErrorPrint(
"Cannot create operators as all the parameters are zero");
481 if (sh_param_present[5] || sh_param_present[6] || sh_param_present[7] || sh_param_present[8] || sh_param_present[9] || sh_param_present[10]) {
482 char full_msg[TNT_STRLEN];
483 strcpy(full_msg,
"Your Hamiltonian is not invariant under the symmetry type chosen|");
484 for (loop = 5; loop < 11; loop++) {
485 if (sh_param_present[loop]) {
486 strcat(full_msg, sh_param_strs[loop]);
487 strcat(full_msg,
" ");
488 sh_param_present[loop] = 0;
489 if (loop < TNT_SH_NUM_NN_TERMS) {
496 strcat(full_msg,
"being set to zero|");
497 tntWarningPrint(full_msg);
509 nnparam.numrows = nnparam.numcols = 0;
516 osparam.numrows = osparam.numcols = 0;
527 if (sh_param_present[0] || sh_param_present[1]) {
528 if (fabs(sh_params[0].re-sh_params[1].re) + fabs(sh_params[0].im-sh_params[1].im) > DBL_EPSILON) {
529 tntWarningPrint(
"Your Hamiltonian is not invariant under the symmetry type chosen| Only Jxx=Jyy allowed - values being changed to average of Jxx and Jyy");
534 nnparam.vals[numnn].re = 0.25*(sh_params[0].
re + sh_params[1].
re);
535 nnparam.vals[numnn].im = 0.25*(sh_params[0].
im + sh_params[1].
im);
539 nnparam.vals[numnn].re = 0.25*(sh_params[0].
re + sh_params[1].
re);
540 nnparam.vals[numnn].im = 0.25*(sh_params[0].
im + sh_params[1].
im);
543 sh_param_present[0] = sh_param_present[1] = 0;
546 if (sh_param_present[3] || sh_param_present[4]) {
547 if (fabs(sh_params[3].re + sh_params[4].re) + fabs(sh_params[3].im + sh_params[4].im) > DBL_EPSILON) {
548 tntWarningPrint(
"Your Hamiltonian is not invariant under the symmetry type chosen|Only Jxy=-Jyx allowed - values being changed to Jxy_new = -Jyx_new = (Jxy - Jyx)/2");
553 nnparam.vals[numnn].im = 0.25*(sh_params[3].
re - sh_params[4].
re);
554 nnparam.vals[numnn].re = -0.25*(sh_params[3].
im - sh_params[4].
im);
558 nnparam.vals[numnn].im = 0.25*(sh_params[4].
re - sh_params[3].
re);
559 nnparam.vals[numnn].re = -0.25*(sh_params[4].
im - sh_params[3].
im);
562 sh_param_present[3] = sh_param_present[4] = 0;
568 for (loop = 0; loop < TNT_SH_NUM_TERMS; loop++) {
569 if (sh_param_present[loop]) {
575 nnparam.vals[numnn] = sh_params[loop];
582 nnparam.vals[numnn] = sh_params[loop];
589 nnparam.vals[numnn] = sh_params[loop];
596 nnparam.vals[numnn] = sh_params[loop];
603 nnparam.vals[numnn] = sh_params[loop];
610 nnparam.vals[numnn] = sh_params[loop];
617 nnparam.vals[numnn] = sh_params[loop];
624 nnparam.vals[numnn] = sh_params[loop];
631 nnparam.vals[numnn] = sh_params[loop];
637 osparam.vals[numos] = sh_params[loop];
643 osparam.vals[numos] = sh_params[loop];
649 osparam.vals[numos] = sh_params[loop];
668 double jc = (L-1.0)/2.0;
671 unsigned bs_param_present[TNT_BS_NUM_TERMS] = {0,0,0,0,0,0,0};
672 char bs_param_strs[TNT_BS_NUM_TERMS][12] = {
"Jb",
"Vb",
"param-driv",
"Ub",
"mub",
"E-harm",
"coher-driv"};
674 tntPrintf(
"----------------------------------------------------------\n");
675 tntPrintf(
"Creating boson system with the following parameters: \n");
676 tntPrintf(
"----------------------------------------------------------\n");
680 for (c = 0; c<argc; c++) {
681 argv_cp[c] = argv[c];
691 while ((c = getopt_long(argc, argv_cp,
"", bs_long_options, &option_index)) != -1) {
692 if (c <= TNT_BS_NUM_TERMS) {
694 bs_params[c-1] =
tntAtoC(optarg);
695 bs_param_present[c-1] = 1;
696 if (fabs(bs_params[c-1].re) > DBL_EPSILON && fabs(bs_params[c-1].im) > DBL_EPSILON) {
697 tntPrintf(
"%s : <<<%g%+gi>>>\n", bs_param_strs[c-1], bs_params[c-1].re, bs_params[c-1].im);
698 }
else if (fabs(bs_params[c-1].re) > DBL_EPSILON) {
699 tntPrintf(
"%s : <<<%g>>>\n", bs_param_strs[c-1], bs_params[c-1].re);
700 }
else if (fabs(bs_params[c-1].im) > DBL_EPSILON) {
701 tntPrintf(
"%s : <<<%gi>>>\n", bs_param_strs[c-1], bs_params[c-1].im);
703 tntPrintf(
"%s : <<<0>>>\n", bs_param_strs[c-1]);
705 if ((1 == c)||(3 == c)) {
707 }
else if (c <= TNT_BS_NUM_NN_TERMS) {
718 n_max = abs(atoi(optarg));
723 tntNode b_op, bdag_op, n_op, os_int, eye;
734 if (0 == numnn && 0 == numos) {
735 tntErrorPrint(
"Cannot create operators as all the parameters are zero");
742 if (bs_param_present[2] && bs_param_present[6]) {
743 tntWarningPrint(
"Your Hamiltonian is not invariant under the symmetry type chosen|%s and %s being set to zero|", bs_param_strs[2], bs_param_strs[6]);
744 bs_param_present[2] = bs_param_present[6] = 0;
747 }
else if (bs_param_present[2]) {
748 tntWarningPrint(
"Your Hamiltonian is not invariant under the symmetry type chosen|%s being set to zero|", bs_param_strs[2]);
749 bs_param_present[2] = 0;
751 }
else if (bs_param_present[6]) {
752 tntWarningPrint(
"Your Hamiltonian is not invariant under the symmetry type chosen|%s being set to zero|", bs_param_strs[6]);
753 bs_param_present[6] = 0;
767 nnparam.numrows = nnparam.numcols = 0;
771 if (bs_param_present[5])
777 osparam.numrows = osparam.numcols = 0;
784 for (loop = 0; loop < TNT_BS_NUM_TERMS; loop++) {
785 if (bs_param_present[loop]) {
791 nnparam.vals[numnn].re = -bs_params[loop].
re;
792 nnparam.vals[numnn].im = -bs_params[loop].
im;
795 nnparam.vals[numnn+1].re = -bs_params[loop].
re;
796 nnparam.vals[numnn+1].im = bs_params[loop].
im;
803 nnparam.vals[numnn] = bs_params[loop];
810 nnparam.vals[numnn] = bs_params[loop];
814 nnparam.vals[numnn+1].re = bs_params[loop].
re;
815 nnparam.vals[numnn+1].im = -bs_params[loop].
im;
822 if (bs_param_present[5]) {
823 for (j = 0; j < L; j++) {
824 osparam.vals[numos + j*os.sz].re = bs_params[loop].
re/2.0;
825 osparam.vals[numos + j*os.sz].im = bs_params[loop].
im/2.0;
828 osparam.vals[numos].re = bs_params[loop].
re/2.0;
829 osparam.vals[numos].im = bs_params[loop].
im/2.0;
836 if (bs_param_present[5]) {
837 for (j = 0; j < L; j++) {
838 osparam.vals[numos + j*os.sz].re = -bs_params[loop].
re;
839 osparam.vals[numos + j*os.sz].im = -bs_params[loop].
im;
842 osparam.vals[numos].re = -bs_params[loop].
re;
843 osparam.vals[numos].im = -bs_params[loop].
im;
850 for (j = 0; j < L; j++) {
852 osparam.vals[numos + j*os.sz].re = 0.5*bs_params[loop].
re*(j - jc)*(j - jc);
853 osparam.vals[numos + j*os.sz].im = 0.5*bs_params[loop].
im*(j - jc)*(j - jc);
862 if (bs_param_present[5]) {
863 for (j = 0; j < L; j++) {
864 osparam.vals[numos + j*os.sz] = bs_params[loop];
865 osparam.vals[numos + 1 + j*os.sz].
re = bs_params[loop].
re;
866 osparam.vals[numos + 1 + j*os.sz].im = -bs_params[loop].
im;
869 osparam.vals[numos] = bs_params[loop];
870 osparam.vals[numos+1].
re = bs_params[loop].
re;
871 osparam.vals[numos+1].im = -bs_params[loop].
im;
889 tntErrorPrint(
"No operators can be created as the system type has not been set");
911 }
else if (2 == MPStype) {
913 }
else if (3 == MPStype) {
915 }
else if (4 == MPStype) {
tntNode tntNodeCopy(tntNode A)
void tntNodeArrayFree(tntNodeArray *arr)
void tntMpsProcessSysOptions(int argc, char **argv, tntNetwork *mps, tntNetwork *mpo, tntNetwork *prop, tntMpsExOp *ExOp)
void tntMpsCreateSpinOp(unsigned TwoS, tntNode *Sx, tntNode *Sy, tntNode *Sz, tntNode *Sp, tntNode *Sm, tntNode *eye)
void tntMpsProcessExpecOptions(int argc, char **argv, tntMpsExOp *Op)
tntNodeArray tntNodeArrayAlloc(unsigned num_elems)
void tntSysTypeSet(int sysnum)
tntNetwork tntMpsCreateMpo(unsigned L, tntNodeArray *nnl, tntNodeArray *nnr, tntComplexArray *nnparam, tntNodeArray *os, tntComplexArray *osparam, unsigned ignoreQN)
void tntMpsCreateBosonOp(unsigned Nmax, tntNode *b, tntNode *bd, tntNode *n, tntNode *os_int, tntNode *eye)
void tntNodeFree(tntNode *A)
tntComplexArray tntComplexArrayAlloc(unsigned numrows, unsigned numcols)
tntNetwork tntMpsCreateConfig(unsigned L, const char *config)
tntNetwork tntMpsCreateRandom(unsigned L, unsigned D)
void tntSymmTypeSet(const char *symmTypeStr, unsigned num_qn)
tntComplex tntAtoC(const char *str)
void tntSysBasisOpSet(tntNode basisOp)
void tntComplexArrayFree(tntComplexArray *arr)
int tntPrintf(const char *format,...)
tntNetwork tntMpsCreateEyeMpo(unsigned L, tntNode basisOp)
tntNetwork tntMpsCreatePropST2sc(unsigned L, tntComplex dtc, tntNodeArray *nnL, tntNodeArray *nnR, tntComplexArray *nnparam, tntNodeArray *os, tntComplexArray *osparam)
tntNetwork tntMpsCreateSymmRandom(unsigned L, int *qn)