Dear All,
My question is related to the calculated results of the below code.
This entails MPS implantation to reach energy gap of a Heisenberg chain in
the presence of a magnetic field.
We wrote:
%%%%%%%%%%%%%%% Start %%%%%%%%%%%%%%%%%%%%%%%
import pyalps
import numpy as np
import matplotlib.pyplot as plt
import pyalps.plot
parms = []
for hz in [0.0, 0.2, 0.4, 0.6, 0.8, 1.0]:
parms.append(
{
'LATTICE' : "open chain lattice",
'MODEL' : "spin",
'CONSERVED_QUANTUMNUMBERS' : 'N,Sz',
'Sz_total' : 0,
'J' : 1,
'h' : hz,
'SWEEPS' : 4,
'L' : 32,
'MAXSTATES' : 100,
'NUMBER_EIGENVALUES' : 2
}
)
input_file = pyalps.writeInputFiles('parm_spin_one_half_gap',parms)
res = pyalps.runApplication('mps_optim',input_file,writexml=True)
data =
pyalps.loadEigenstateMeasurements(pyalps.getResultFiles(prefix='parm_spin_one_half_gap'))
energies = np.empty(0)
for s in data[0]:
if s.props['observable'] == 'Energy':
energies = s.y
else:
print(s.props['observable'], ':', s.y[0])
energies.sort()
print('Energies:', end=' ')
for e in energies:
print(e, end=' ')
print('\nGap:', abs(energies[1]-energies[0]))
%%%%%%%%%%%%%%% END %%%%%%%%%%%%%%%%%%%%%%%
Although, in the file "parm_spin_one_half_gap.in.xml" there are expensive
information such as energies for any "hz", we need to collect all results
in a *.dat or *.txt file.
For instance, a "file.txt" as:
hz gap
0.0 0.11
0.2 0.12
0.4 0.14
0.6 0.15
How can we generate such a file?!