Package: tnsp-bridge
TNSP-bridge is a tool used to facilitate the conversion of tensor data from the format ofthe old TNSPtoTATformat.
It's important to note that different versions of TNSP may have variations in their data structures,
but this specific subproject focuses on compatibility with TNSP version 4.
And we support the conversion of non-symmetry tensors and boson/fermion (Z(2)) / (U(1)) symmetry tensors of various scalar types.InstallPlease either copy or create a soft link for the directory in thesite-packagesdirectory.
Alternatively, users can utilize pip to install the TNSP-bridge package by running the commandpip install tnsp_bridge.DocumentsThe only function isbridge, which accepts a function that extracts the old version tensor data line by line and returns the tensor in the new version.
For example, here is the old version of the data:T T T T
 readable_data T
           2           8           3           0
           1           4           8
           3           7           8
   1.00000000       2.00000000       3.00000000      -1.00000000      -2.00000000      -3.00000000      -4.00000000       0.00000000
 End_data
 readable_data T
           1           8           3           0
           1           4           8
           3           7           8
           3           2           1           1           2           2           1           1
 End_data
 readable_data T
           1           6           2           0
           1           4
           3           6
           3           4           1          -1          -1           1
 End_data
 A1_1.D  A1_1.R  A1_1.n
 readable_data T
           3           9          12           0
           1       22049           0           0           4   538976288   538976288   538976288           8   538976288   538976288   538976288
           3           0           0           0           7           0           0           0           9           0           0           0
 0.23446911431164341       0.13002435022579403       -3.1842370052190448E-002  0.45356268067516309       -1.4087785231172337E-002  -9.0396315774136524E-002  -2.0732171027595565E-002 -0.35235299284206140       -1.2456779139446277E-002
 End_data
EOFThe code below converts the aforementioned data,
stored in the string variable namedexample_data, to the new version format:from bridge import bridge

data_line_by_line = example_data.split("\n")
data_line_by_line.reverse()
print(bridge(data_line_by_line.pop, compat=True, parity=False))

{names:[A1_1.n,A1_1.R,A1_1.D],edges:[{arrow:0,segment:{0:1}},{arrow:1,segment:{-1:1,-2:2,-3:2,-4:1}},{arrow:1,segment:{1:3,2:2,3:1}}],blocks:{[0,-1,1]:[0.234469,0.130024,-0.0318424],[0,-2,2]:[0.453563,-0.0140878,-0.0903963,-0.0207322],[0,-3,3]:[-0.352353,-0.0124568]}}The functionbridgehas two optional arguments.
The first one isparity, used to distinguish the symmetry group of a symmetry tensor.
Whenparityis set toFalse(default), it should be a fermion or boson (U(1)) symmetry tensor.
If set toTrue, a fermion or boson (Z(1)) symmetry tensor is considered.
The second argument iscompat, which distinguishes the version in the old TNSP.
Within old TNSP, there are two data formats: the older one is processed whencompatis set toTrue, and the newer one if set toFalse(default).